Skip to content

Commit

Permalink
Merge pull request #25 from justbetter/feature/guid
Browse files Browse the repository at this point in the history
Support GUID
  • Loading branch information
VincentBean authored Jul 18, 2024
2 parents e4e13f9 + f285dfe commit 567e1da
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Client/ClientHttpProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function send(HttpRequestMessage $request): ResponseInterface
/** @var DynamicsException $dynamicsException */
$dynamicsException = new $mapping($message, $code, $exception);

throw $dynamicsException->setRequest($request);
throw $dynamicsException
->setRequest($request)
->setResponse($exception->response);
}
}
}
2 changes: 1 addition & 1 deletion src/Concerns/HasCasts.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getCastType(string $key): ?string
public function cast(string $key, mixed $value): string
{
return match ($this->getCastType($key)) {
'int', 'date', 'decimal' => (string) $value,
'int', 'date', 'decimal', 'guid' => (string) $value,
default => '\''.$value.'\'',
};
}
Expand Down
10 changes: 10 additions & 0 deletions src/Exceptions/DynamicsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
namespace JustBetter\DynamicsClient\Exceptions;

use Exception;
use Illuminate\Http\Client\Response;
use SaintSystems\OData\HttpRequestMessage;

class DynamicsException extends Exception
{
public ?HttpRequestMessage $request = null;

public ?Response $response = null;

public function setRequest(HttpRequestMessage $request): static
{
$this->request = $request;

return $this;
}

public function setResponse(Response $response): static
{
$this->response = $response;

return $this;
}
}
4 changes: 3 additions & 1 deletion src/Exceptions/ModifiedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace JustBetter\DynamicsClient\Exceptions;

class ModifiedException extends DynamicsException {}
class ModifiedException extends DynamicsException
{
}
4 changes: 3 additions & 1 deletion src/Exceptions/NotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace JustBetter\DynamicsClient\Exceptions;

class NotFoundException extends DynamicsException {}
class NotFoundException extends DynamicsException
{
}
4 changes: 3 additions & 1 deletion src/Exceptions/UnreachableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

namespace JustBetter\DynamicsClient\Exceptions;

class UnreachableException extends DynamicsException {}
class UnreachableException extends DynamicsException
{
}
1 change: 1 addition & 0 deletions src/OData/BaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function create(array $data): static

public function update(array $data, bool $force = false): ?static
{

$this
->client($this->etag($force))
->patch($this->getResourceUrl(), $data);
Expand Down
2 changes: 2 additions & 0 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public function find(mixed ...$values): ?BaseResource
foreach ($combined as $key => $value) {
if ($baseResource->getCastType($key) === 'date') {
$this->builder->whereDate($key, '=', $value);
} elseif ($baseResource->getCastType($key) === 'guid') {
$this->builder->whereRaw("$key eq $value");
} else {
$this->builder->where($key, '=', $value);
}
Expand Down

0 comments on commit 567e1da

Please sign in to comment.