Skip to content

Commit

Permalink
Merge pull request #13 from Jxckaroo/master
Browse files Browse the repository at this point in the history
Fix an issue with URI paths.
  • Loading branch information
JustSteveKing authored Jun 23, 2022
2 parents be54fe4 + ca1a26f commit fcab5ec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Resources/AbstractResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
*/
abstract class AbstractResource
{
protected string $path = '';

public function __construct(
private SDK $sdk,
private null|string $path = null,
protected string $authHeader = 'Bearer',
private array $with = [],
protected array $relations = [],
Expand Down Expand Up @@ -151,7 +152,7 @@ public function get(): ResponseInterface
*/
public function find(string|int $identifier): ResponseInterface
{
$this->sdk()->uri()->addPath(
$this->loadPath()->sdk()->uri()->addPath(
path: "{$this->sdk()->uri()->path()}/{$identifier}",
);

Expand Down Expand Up @@ -182,6 +183,8 @@ public function find(string|int $identifier): ResponseInterface
*/
public function create(array $data): ResponseInterface
{
$this->loadPath();

if (! is_null($this->with)) {
$this->sdk()->uri()->addPath(
path: "{$this->sdk()->uri()->path()}/" . implode("/", $this->with),
Expand All @@ -205,7 +208,7 @@ public function create(array $data): ResponseInterface
*/
public function update($identifier, array $data, string $method = 'patch'): ResponseInterface
{
$this->sdk()->uri()->addPath(
$this->loadPath()->sdk()->uri()->addPath(
path: "{$this->sdk()->uri()->path()}/{$identifier}",
);

Expand All @@ -232,7 +235,7 @@ public function update($identifier, array $data, string $method = 'patch'): Resp
*/
public function delete(string|int $identifier): ResponseInterface
{
$this->sdk()->uri()->addPath(
$this->loadPath()->sdk()->uri()->addPath(
path: "{$this->sdk()->uri()->path()}/{$identifier}"
);

Expand Down

0 comments on commit fcab5ec

Please sign in to comment.