Skip to content

Commit

Permalink
[People] People API Improvements for Developers
Browse files Browse the repository at this point in the history
  • Loading branch information
onairmarc committed Nov 28, 2024
1 parent a0c3b91 commit d7821ce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Objects/People/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function get(): ClientResponse
public function forPerson(): ClientResponse
{
$http = $this->client()
->get($this->hostname() . Person::PEOPLE_ENDPOINT . "/" . $this->attributes->personId . "/emails");
->get($this->hostname() . Person::PEOPLE_ENDPOINT . "/{$this->attributes->personId}/emails");

$clientResponse = new ClientResponse($http);

Expand All @@ -58,7 +58,7 @@ public function forPerson(): ClientResponse
public function update(): ClientResponse
{
$http = $this->client()
->patch($this->hostname() . self::EMAIL_ENDPOINT . "/" . $this->attributes->emailAddressId, $this->mapToPco());
->patch($this->hostname() . self::EMAIL_ENDPOINT . "/{$this->attributes->emailAddressId}", $this->mapToPco());

return $this->processResponse($http);
}
Expand Down
13 changes: 10 additions & 3 deletions src/Objects/People/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public static function make(?string $clientId = null, ?string $clientSecret = nu
return $person;
}

public function forPersonId(string $personId): static
{
$this->attributes->personId = $personId;

return $this;
}

public function all(?array $query = null): ClientResponse
{
$http = $this->client()
Expand All @@ -51,7 +58,7 @@ public function all(?array $query = null): ClientResponse
public function get(?array $query = null): ClientResponse
{
$http = $this->client()
->get($this->hostname() . self::PEOPLE_ENDPOINT . "/" . $this->attributes->personId, $query);
->get($this->hostname() . self::PEOPLE_ENDPOINT . "/{$this->attributes->personId}", $query);

return $this->processResponse($http);
}
Expand All @@ -67,15 +74,15 @@ public function create(): ClientResponse
public function update(): ClientResponse
{
$http = $this->client()
->patch($this->hostname() . self::PEOPLE_ENDPOINT . "/" . $this->attributes->personId, $this->mapToPco());
->patch($this->hostname() . self::PEOPLE_ENDPOINT . "/{$this->attributes->personId}", $this->mapToPco());

return $this->processResponse($http);
}

public function delete(): ClientResponse
{
$http = $this->client()
->delete($this->hostname() . self::PEOPLE_ENDPOINT . "/" . $this->attributes->personId);
->delete($this->hostname() . self::PEOPLE_ENDPOINT . "/{$this->attributes->personId}");

return $this->processResponse($http);
}
Expand Down
9 changes: 8 additions & 1 deletion src/Objects/People/PersonMerger/PersonMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ public static function make(string $clientId, string $clientSecret): PersonMerge
return $personMerger;
}

public function forPersonId(string $personId): static
{
$this->attributes->personMergerId = $personId;

return $this;
}

public function get(?array $query = []): ClientResponse
{
$http = $this->client()
->get($this->hostname() . self::PERSON_MERGER_ENDPOINT . "/" . $this->attributes->personMergerId, $query);
->get($this->hostname() . self::PERSON_MERGER_ENDPOINT . "/{$this->attributes->personMergerId}", $query);

return $this->processResponse($http);
}
Expand Down

0 comments on commit d7821ce

Please sign in to comment.