Skip to content

Commit

Permalink
Return the resource ID when creating a new resource (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidstanley01 authored Feb 18, 2019
1 parent eec3191 commit 7f7ec1b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 20 deletions.
6 changes: 4 additions & 2 deletions src/Conversations/ConversationsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ public function delete(int $conversationId): void

/**
* @param Conversation $conversation
*
* @return int|null
*/
public function create(Conversation $conversation): void
public function create(Conversation $conversation): ?int
{
$this->restClient->createResource($conversation, sprintf('/v2/conversations'));
return $this->restClient->createResource($conversation, sprintf('/v2/conversations'));
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Conversations/Threads/Attachments/AttachmentsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ public function get(int $conversationId, int $attachmentId): Attachment
* @param int $conversationId
* @param int $threadId
* @param Attachment $attachment
*
* @return int|null
*/
public function create(int $conversationId, int $threadId, Attachment $attachment): void
public function create(int $conversationId, int $threadId, Attachment $attachment): ?int
{
$this->restClient->createResource(
return $this->restClient->createResource(
$attachment,
sprintf('/v2/conversations/%d/threads/%d/attachments', $conversationId, $threadId)
);
Expand Down
9 changes: 7 additions & 2 deletions src/Conversations/Threads/ThreadsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ public function list(int $conversationId): PagedCollection
/**
* @param int $conversationId
* @param Thread $thread
*
* @return int|null
*/
public function create(int $conversationId, Thread $thread): void
public function create(int $conversationId, Thread $thread): ?int
{
$this->restClient->createResource($thread, $thread::resourceUrl($conversationId));
return $this->restClient->createResource(
$thread,
$thread::resourceUrl($conversationId)
);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Customers/CustomersEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class CustomersEndpoint extends Endpoint
{
/**
* @param Customer $customer
*
* @return int|null
*/
public function create(Customer $customer): void
public function create(Customer $customer): ?int
{
$this->restClient->createResource(
return $this->restClient->createResource(
$customer,
'/v2/customers'
);
Expand Down
36 changes: 24 additions & 12 deletions src/Customers/Entry/CustomerEntryEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ class CustomerEntryEndpoint extends Endpoint
/**
* @param int $customerId
* @param Address $address
*
* @return int|null
*/
public function createAddress(int $customerId, Address $address): void
public function createAddress(int $customerId, Address $address): ?int
{
$this->restClient->createResource(
return $this->restClient->createResource(
$address,
sprintf(self::CUSTOMER_ADDRESS, $customerId)
);
Expand Down Expand Up @@ -56,10 +58,12 @@ public function deleteAddress(int $customerId): void
/**
* @param int $customerId
* @param Chat $chat
*
* @return int|null
*/
public function createChat(int $customerId, Chat $chat): void
public function createChat(int $customerId, Chat $chat): ?int
{
$this->restClient->createResource(
return $this->restClient->createResource(
$chat,
sprintf(self::CREATE_CUSTOMER_CHAT, $customerId)
);
Expand Down Expand Up @@ -91,10 +95,12 @@ public function deleteChat(int $customerId, int $chatId): void
/**
* @param int $customerId
* @param Email $email
*
* @return int|null
*/
public function createEmail(int $customerId, Email $email): void
public function createEmail(int $customerId, Email $email): ?int
{
$this->restClient->createResource(
return $this->restClient->createResource(
$email,
sprintf(self::CREATE_CUSTOMER_EMAIL, $customerId)
);
Expand Down Expand Up @@ -126,10 +132,12 @@ public function deleteEmail(int $customerId, int $emailId): void
/**
* @param int $customerId
* @param Phone $phone
*
* @return int|null
*/
public function createPhone(int $customerId, Phone $phone): void
public function createPhone(int $customerId, Phone $phone): ?int
{
$this->restClient->createResource(
return $this->restClient->createResource(
$phone,
sprintf(self::CREATE_CUSTOMER_PHONE, $customerId)
);
Expand Down Expand Up @@ -161,10 +169,12 @@ public function deletePhone(int $customerId, int $phoneId): void
/**
* @param int $customerId
* @param SocialProfile $socialProfile
*
* @return int|null
*/
public function createSocialProfile(int $customerId, SocialProfile $socialProfile): void
public function createSocialProfile(int $customerId, SocialProfile $socialProfile): ?int
{
$this->restClient->createResource(
return $this->restClient->createResource(
$socialProfile,
sprintf(self::CREATE_CUSTOMER_SOCIAL, $customerId)
);
Expand Down Expand Up @@ -196,10 +206,12 @@ public function deleteSocialProfile(int $customerId, int $socialProfileId): void
/**
* @param int $customerId
* @param Website $website
*
* @return int|null
*/
public function createWebsite(int $customerId, Website $website): void
public function createWebsite(int $customerId, Website $website): ?int
{
$this->restClient->createResource(
return $this->restClient->createResource(
$website,
sprintf(self::CREATE_CUSTOMER_WEBSITE, $customerId)
);
Expand Down

0 comments on commit 7f7ec1b

Please sign in to comment.