-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from close-dev-team/feature/CL-8956-add-new-pa…
…rtner-api-methods Feature/cl 8956 add new partner api methods
- Loading branch information
Showing
18 changed files
with
837 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuites> | ||
<testsuite name="ClosePartnerSdk\Tests\Endpoint\SendCardMessageToUserInAllChatsTest" file="/Users/chriscalalang/Sites/partner-sdk-php/tests/Endpoint/SendCardMessageToUserInAllChatsTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.015574"> | ||
<testcase name="it_can_send_card_message_to_a_user_in_all_chats" class="ClosePartnerSdk\Tests\Endpoint\SendCardMessageToUserInAllChatsTest" classname="ClosePartnerSdk.Tests.Endpoint.SendCardMessageToUserInAllChatsTest" file="/Users/chriscalalang/Sites/partner-sdk-php/tests/Endpoint/SendCardMessageToUserInAllChatsTest.php" line="16" assertions="1" time="0.015574"/> | ||
</testsuite> | ||
</testsuites> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Sending a message to all users in all chats for one event. | ||
Do you want to send a message to all users going to a specific event? Then you can use the sendToAllChatsForEvent() operation. | ||
|
||
|
||
##### example: | ||
```php | ||
<?php | ||
use ClosePartnerSdk\CloseSdk; | ||
use ClosePartnerSdk\Dto\EventId; | ||
use ClosePartnerSdk\Exception\CloseSdkException; | ||
|
||
try { | ||
// Define DTO structure | ||
$eventId = new EventId('CLEV3BX47D58YCMERC6CGJ2L7xxx'); | ||
$request = [ | ||
"title" => "Special offer!", | ||
"image_id" => "CLIM05D3FA6NOOUFJUPC5B5Y7V0NS6", | ||
"text" => "First paragraph for {user.nickname}", | ||
"link" => "https =>//thecloseapp.com/", | ||
"push_notification_message" => "Click to see our special offers for you.", | ||
"button_text" => "O P E N", | ||
"open_link_in_app" => false, | ||
"detail_view_description_1" => "extra paragraph 1\nevent", | ||
"detail_view_title_2" => "Heading 2", | ||
"detail_view_description_2" => "extra paragraph 2" | ||
]; | ||
|
||
$sdk | ||
->cardMessage() | ||
->sendToAllChatsForEvent($eventId, $request) | ||
} catch (CloseSdkException $e) { | ||
echo "The card has not been sent.\n"; | ||
// We recommend to retry after a couple of seconds. | ||
} | ||
``` | ||
##### DTOs explained: | ||
| DTO | info | | ||
|---------|----------------------------------------------------------| | ||
| EventId | Identifies one specific event. Always starts with "CLEV" | | ||
| Request | An array of card details that you'd like to send. | | ||
|
||
[Back to User Guide](/USERGUIDE.md#cardmessage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Sending a message to all users in one specific chat. | ||
Do you want to send a message to everyone in one specific chat? Then you can use the sendToAllUsersForChat() operation. | ||
|
||
|
||
##### example: | ||
```php | ||
<?php | ||
use ClosePartnerSdk\CloseSdk; | ||
use ClosePartnerSdk\Dto\EventId; | ||
use ClosePartnerSdk\Dto\ChatId; | ||
use ClosePartnerSdk\Exception\CloseSdkException; | ||
|
||
try { | ||
// Define DTO structure | ||
$eventId = new EventId('CLEV3BX47D58YCMERC6CGJ2L7xxx'); | ||
$chatId = new ChatId('CLECxxxxx'); | ||
$request = [ | ||
"title" => "Special offer!", | ||
"image_id" => "CLIM05D3FA6NOOUFJUPC5B5Y7V0NS6", | ||
"text" => "First paragraph for {user.nickname}", | ||
"link" => "https =>//thecloseapp.com/", | ||
"push_notification_message" => "Click to see our special offers for you.", | ||
"button_text" => "O P E N", | ||
"open_link_in_app" => false, | ||
"detail_view_description_1" => "extra paragraph 1\nevent", | ||
"detail_view_title_2" => "Heading 2", | ||
"detail_view_description_2" => "extra paragraph 2" | ||
]; | ||
|
||
$sdk | ||
->cardMessage() | ||
->sendToAllUsersForChat($eventId, $chatId, $request); | ||
} catch (CloseSdkException $e) { | ||
echo "The card has not been sent.\n"; | ||
// We recommend to retry after a couple of seconds. | ||
} | ||
``` | ||
##### DTOs explained: | ||
| DTO | info | | ||
|---------| ----------- | | ||
| EventId | Identifies one specific event. Always starts with "CLEV"| | ||
| ChatId | Identifies one specific chat. Always starts with "CLEC"| | ||
| Request | An array of card details that you'd like to send.| | ||
|
||
[Back to User Guide](/USERGUIDE.md#cardmessage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Sending a message to one specific user in all chats for one event. | ||
Sometimes one user can be a part of multiple chats for one event. In case you want to send a message to this user in all chats of which this user is a member for one specific event you can use the sendToUserInAllChats() operation. | ||
|
||
##### example: | ||
```php | ||
<?php | ||
use ClosePartnerSdk\CloseSdk; | ||
use ClosePartnerSdk\Dto\EventId; | ||
use ClosePartnerSdk\Dto\UserId; | ||
use ClosePartnerSdk\Exception\CloseSdkException; | ||
|
||
try { | ||
// Define DTO structure | ||
$eventId = new EventId('CLEV3BX47D58YCMERC6CGJ2L7xxx'); | ||
$userId = new UserId('CLUSxxxxxxxxx'); | ||
$request = [ | ||
"title" => "Special offer!", | ||
"image_id" => "CLIM05D3FA6NOOUFJUPC5B5Y7V0NS6", | ||
"text" => "First paragraph for {user.nickname}", | ||
"link" => "https =>//thecloseapp.com/", | ||
"push_notification_message" => "Click to see our special offers for you.", | ||
"button_text" => "O P E N", | ||
"open_link_in_app" => false, | ||
"detail_view_description_1" => "extra paragraph 1\nevent", | ||
"detail_view_title_2" => "Heading 2", | ||
"detail_view_description_2" => "extra paragraph 2" | ||
]; | ||
|
||
$sdk | ||
->cardMessage() | ||
->sendToUserInAllChats($eventId, $userId, $request); | ||
} catch (CloseSdkException $e) { | ||
echo "The text has not been sent.\n"; | ||
// We recommend to retry after a couple of seconds. | ||
} | ||
``` | ||
##### DTOs explained: | ||
| DTO | info | | ||
|---------| ----------- | | ||
| EventId | Identifies one specific event. Always starts with "CLEV"| | ||
| UserId | Identifies one specific user. Always starts with "CLUS"| | ||
| Request | An array of card details that you'd like to send.| | ||
|
||
[Back to User Guide](/USERGUIDE.md#cardmessage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Sending a message to one specific user in one specific chat for an event. | ||
If you want to send a message to one specific user in one specific chat for an event you can use the sendToUserInChat() operation. | ||
|
||
##### example: | ||
```php | ||
<?php | ||
use ClosePartnerSdk\CloseSdk; | ||
use ClosePartnerSdk\Dto\EventId; | ||
use ClosePartnerSdk\Dto\ChatId; | ||
use ClosePartnerSdk\Dto\UserId; | ||
use ClosePartnerSdk\Exception\CloseSdkException; | ||
|
||
try { | ||
// Define DTO structure | ||
$eventId = new EventId('CLEV3BX47D58YCMERC6CGJ2L7xxx'); | ||
$chatId = new ChatId('CLECxxxxx'); | ||
$userId = new UserId('CLUSxxxxxxxxx'); | ||
$request = [ | ||
"title" => "Special offer!", | ||
"image_id" => "CLIM05D3FA6NOOUFJUPC5B5Y7V0NS6", | ||
"text" => "First paragraph for {user.nickname}", | ||
"link" => "https =>//thecloseapp.com/", | ||
"push_notification_message" => "Click to see our special offers for you.", | ||
"button_text" => "O P E N", | ||
"open_link_in_app" => false, | ||
"detail_view_description_1" => "extra paragraph 1\nevent", | ||
"detail_view_title_2" => "Heading 2", | ||
"detail_view_description_2" => "extra paragraph 2" | ||
]; | ||
|
||
$sdk | ||
->cardMessage() | ||
->sendToUserInChat($eventId, $chatId, $userId, $request); | ||
} catch (CloseSdkException $e) { | ||
echo "The card has not been sent.\n"; | ||
// We recommend to retry after a couple of seconds. | ||
} | ||
``` | ||
##### DTOs explained: | ||
| DTO | info | | ||
|---------|----------------------------------------------------------| | ||
| EventId | Identifies one specific event. Always starts with "CLEV" | | ||
| ChatId | Identifies one specific chat. Always starts with "CLEC" | | ||
| UserId | Identifies one specific user. Always starts with "CLUS" | | ||
| Request | An array of card details that you'd like to send. | | ||
|
||
[Back to User Guide](/USERGUIDE.md#cardmessage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Creating a carousel for an event. | ||
Do you want to create a carousel for a specific event? Then you can use the createCarousel() operation. | ||
|
||
|
||
##### example: | ||
```php | ||
<?php | ||
use ClosePartnerSdk\CloseSdk; | ||
use ClosePartnerSdk\Dto\EventId; | ||
use ClosePartnerSdk\Exception\CloseSdkException; | ||
|
||
try { | ||
// Define DTO structure | ||
$eventId = new EventId('CLEV3BX47D58YCMERC6CGJ2L7xxx'); | ||
$name = 'Awesome Carousel'; | ||
|
||
$sdk | ||
->event() | ||
->createCarousel($eventId, $name) | ||
} catch (CloseSdkException $e) { | ||
// error | ||
} | ||
``` | ||
##### DTOs explained: | ||
| DTO | info | | ||
|---------|----------------------------------------------------------| | ||
| EventId | Identifies one specific event. Always starts with "CLEV" | | ||
| Name | Name of the carousel. Must be unique per event. | | ||
|
||
[Back to User Guide](/USERGUIDE.md#carousel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Looking up a carousel in an event. | ||
Do you want to look up a carousel name? Then you can use the lookupCarousel() operation. | ||
|
||
|
||
##### example: | ||
```php | ||
<?php | ||
use ClosePartnerSdk\CloseSdk; | ||
use ClosePartnerSdk\Dto\EventId; | ||
use ClosePartnerSdk\Exception\CloseSdkException; | ||
|
||
try { | ||
// Define DTO structure | ||
$eventId = new EventId('CLEV3BX47D58YCMERC6CGJ2L7xxx'); | ||
$name = 'Awesome Carousel'; | ||
|
||
$sdk | ||
->event() | ||
->lookupCarousel($eventId, $name) | ||
} catch (CloseSdkException $e) { | ||
// error | ||
} | ||
``` | ||
##### DTOs explained: | ||
| DTO | info | | ||
|---------|----------------------------------------------------------| | ||
| EventId | Identifies one specific event. Always starts with "CLEV" | | ||
| Name | Name of the carousel. | | ||
|
||
[Back to User Guide](/USERGUIDE.md#carousel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace ClosePartnerSdk\Dto; | ||
|
||
class Carousel | ||
{ | ||
protected string $name; | ||
protected string $public_id; | ||
|
||
/** | ||
* @param string $name | ||
* @param string $public_id | ||
*/ | ||
public function __construct(string $name, string $public_id) | ||
{ | ||
$this->name = $name; | ||
$this->public_id = $public_id; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public static function buildFromResponseObject(\StdClass $obj): self | ||
{ | ||
return new self( | ||
$obj->name, | ||
$obj->id, | ||
); | ||
} | ||
} |
Oops, something went wrong.