-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/cl 8956 add new partner api methods #19
Merged
chrisangelocloseapp
merged 11 commits into
main
from
feature/CL-8956-add-new-partner-api-methods
Jul 5, 2023
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
75b404b
add get and create carousel methods
d090b55
create test
7cef2e0
fix api call
a13b02f
fix queries
f3b7cbb
fix tests
81df95d
rename getCarousel to lookupCarousel method
11b6790
specify specific phpunit version
7b3a641
set phpunit version to 9
3bc0442
a
db4d271
add send card message
15bf1c5
fix carousel descriptions
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,30 @@ | ||
# 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'); | ||
$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 @@ | ||
# 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'); | ||
$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
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, | ||
); | ||
} | ||
} |
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,92 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace ClosePartnerSdk\Tests\Endpoint; | ||
|
||
use ClosePartnerSdk\Dto\EventId; | ||
use ClosePartnerSdk\Dto\Mapper\CancelTicketMapper; | ||
use ClosePartnerSdk\Dto\Mapper\SendMessageMapper; | ||
use ClosePartnerSdk\Exception\Auth\InvalidCredentialsException; | ||
use ClosePartnerSdk\Exception\InvalidRequestJsonFormat; | ||
use ClosePartnerSdk\Tests\Factory\Dto\TicketCancelFactory; | ||
use Http\Client\Common\Exception\ClientErrorException; | ||
use Http\Message\RequestMatcher\RequestMatcher; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class CreateCarouselForEventTest extends EndpointTestCase | ||
{ | ||
/** @test */ | ||
public function it_does_not_have_the_required_field() | ||
{ | ||
$token = 'ey8393930dkdkdk'; | ||
$this->mockClient | ||
->on( | ||
new RequestMatcher('oauth/token'), | ||
fn() => $this->mockResponse([ | ||
"token_type" => "Bearer", | ||
"expires_in" => 1113, | ||
"access_token" => $token, | ||
]) | ||
); | ||
$eventId = new EventId('1234'); | ||
$this->mockClient | ||
->on( | ||
new RequestMatcher('events/'.$eventId.'/carousels'), | ||
function (RequestInterface $request) { | ||
$response = $this->mockResponse([]); | ||
$response | ||
->method('getStatusCode') | ||
->willReturn(422); | ||
|
||
self::assertEquals( | ||
422, | ||
$response->getStatusCode() | ||
); | ||
}); | ||
|
||
$this->expectException(\Throwable::class); | ||
|
||
$this->givenSdk()->event()->createCarousel( | ||
$eventId, | ||
'', | ||
); | ||
} | ||
|
||
/** @test */ | ||
public function it_creates_a_new_carousel_for_the_event() | ||
{ | ||
$token = 'ey8393930dkdkdk'; | ||
$this->mockClient | ||
->on( | ||
new RequestMatcher('oauth/token'), | ||
fn() => $this->mockResponse([ | ||
"token_type" => "Bearer", | ||
"expires_in" => 1113, | ||
"access_token" => $token, | ||
]) | ||
); | ||
|
||
$eventId = new EventId('1234'); | ||
|
||
$this->mockClient | ||
->on( | ||
new RequestMatcher('events/'.$eventId.'/carousels'), | ||
function (RequestInterface $request) { | ||
$response = json_decode($request->getBody()->getContents(), true); | ||
$response['id'] = 'CLOC1234567890'; | ||
self::assertEquals( | ||
'Carousel 1', | ||
$response['name'] | ||
); | ||
return $this->mockResponse($response); | ||
}); | ||
|
||
|
||
$this->givenSdk()->event()->createCarousel( | ||
$eventId, | ||
'Carousel 1', | ||
); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this text should change? It is about creating the carousel, not sending a message. The one below (the lookup one) should also change.