Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Fix CR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ste93cry committed Mar 1, 2019
1 parent 1653662 commit cebd888
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Api/CallActivityApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function get(string $id, array $fields = []): CallActivity
*/
public function create(CallActivity $activity): CallActivity
{
$response = $this->client->post($this->prepareUrlForKey('add-call'), $activity->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-call'), [], $activity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new CallActivity($responseData);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/ContactApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function get(string $id, array $fields = []): Contact
*/
public function create(Contact $contact): Contact
{
$response = $this->client->post($this->prepareUrlForKey('add-contact'), $contact->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-contact'), [], $contact->jsonSerialize());
$responseData = $response->getDecodedBody();

return new Contact($responseData);
Expand All @@ -108,7 +108,7 @@ public function update(Contact $contact): Contact

$contact->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-contact', ['id' => $id]), $contact->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-contact', ['id' => $id]), [], $contact->jsonSerialize());
$responseData = $response->getDecodedBody();

return new Contact($responseData);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/CustomFieldApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function get(string $id, array $fields = []): CustomField
*/
public function create(CustomField $customField): CustomField
{
$response = $this->client->post($this->prepareUrlForKey('create-custom-field'), $customField->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('create-custom-field'), [], $customField->jsonSerialize());
$responseData = $response->getDecodedBody();

return new CustomField($responseData);
Expand All @@ -106,7 +106,7 @@ public function update(CustomField $customField): CustomField

$customField->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-custom-field', ['id' => $id]), $customField->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-custom-field', ['id' => $id]), [], $customField->jsonSerialize());
$responseData = $response->getDecodedBody();

return new CustomField($responseData);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/EmailActivityApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function get(string $id, array $fields = []): EmailActivity
*/
public function create(EmailActivity $activity): EmailActivity
{
$response = $this->client->post($this->prepareUrlForKey('add-email'), $activity->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-email'), [], $activity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new EmailActivity($responseData);
Expand All @@ -111,7 +111,7 @@ public function update(EmailActivity $activity): EmailActivity

$activity->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-email', ['id' => $id]), $activity->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-email', ['id' => $id]), [], $activity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new EmailActivity($responseData);
Expand Down
6 changes: 3 additions & 3 deletions src/Api/LeadApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function create(Lead $lead): Lead
{
$this->validateLeadForPost($lead);

$response = $this->client->post($this->prepareUrlForKey('add-lead'), $lead->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-lead'), [], $lead->jsonSerialize());
$responseData = $response->getDecodedBody();

return new Lead($responseData);
Expand All @@ -116,7 +116,7 @@ public function update(Lead $lead): Lead

$lead->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-lead', ['id' => $id]), $lead->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-lead', ['id' => $id]), [], $lead->jsonSerialize());
$responseData = $response->getDecodedBody();

return new Lead($responseData);
Expand Down Expand Up @@ -150,7 +150,7 @@ public function merge(Lead $source, Lead $destination): void
throw new InvalidParamException('You need to specify two already existing leads in order to merge them');
}

$this->client->post($this->prepareUrlForKey('merge-leads'), [
$this->client->post($this->prepareUrlForKey('merge-leads'), [], [
'destination' => $destination->getId(),
'source' => $source->getId(),
]);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/LeadStatusApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function get(string $id, array $fields = []): LeadStatus
*/
public function create(LeadStatus $leadStatus): LeadStatus
{
$response = $this->client->post($this->prepareUrlForKey('add-status'), $leadStatus->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-status'), [], $leadStatus->jsonSerialize());
$responseData = $response->getDecodedBody();

return new LeadStatus($responseData);
Expand All @@ -109,7 +109,7 @@ public function update(LeadStatus $leadStatus): LeadStatus

$leadStatus->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-status', ['id' => $id]), $leadStatus->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-status', ['id' => $id]), [], $leadStatus->jsonSerialize());
$responseData = $response->getDecodedBody();

return new LeadStatus($responseData);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/NoteActivityApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function get(string $id, array $fields = []): NoteActivity
*/
public function create(NoteActivity $activity): NoteActivity
{
$response = $this->client->post($this->prepareUrlForKey('add-note'), $activity->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-note'), [], $activity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new NoteActivity($responseData);
Expand All @@ -110,7 +110,7 @@ public function update(NoteActivity $activity): NoteActivity

$activity->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-note', ['id' => $id]), $activity->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-note', ['id' => $id]), [], $activity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new NoteActivity($responseData);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/OpportunityApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function get(string $id, array $fields = []): Opportunity
*/
public function create(Opportunity $opportunity): Opportunity
{
$response = $this->client->post($this->prepareUrlForKey('add-opportunity'), $opportunity->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-opportunity'), [], $opportunity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new Opportunity($responseData);
Expand All @@ -116,7 +116,7 @@ public function update(Opportunity $opportunity): Opportunity

$opportunity->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-opportunity', ['id' => $id]), $opportunity->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-opportunity', ['id' => $id]), [], $opportunity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new Opportunity($responseData);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/OpportunityStatusApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function get(string $id, array $fields = []): OpportunityStatus
*/
public function create(OpportunityStatus $opportunityStatus): OpportunityStatus
{
$response = $this->client->post($this->prepareUrlForKey('add-status'), $opportunityStatus->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-status'), [], $opportunityStatus->jsonSerialize());
$responseData = $response->getDecodedBody();

return new OpportunityStatus($responseData);
Expand All @@ -110,7 +110,7 @@ public function update(OpportunityStatus $opportunityStatus): OpportunityStatus

$opportunityStatus->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-status', ['id' => $id]), $opportunityStatus->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-status', ['id' => $id]), [], $opportunityStatus->jsonSerialize());
$responseData = $response->getDecodedBody();

return new OpportunityStatus($responseData);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/SmsActivityApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function get(string $id, array $fields = []): SmsActivity
*/
public function create(SmsActivity $activity): SmsActivity
{
$response = $this->client->post($this->prepareUrlForKey('add-sms'), $activity->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-sms'), [], $activity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new SmsActivity($responseData);
Expand All @@ -110,7 +110,7 @@ public function update(SmsActivity $activity): SmsActivity

$activity->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-sms', ['id' => $id]), $activity->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-sms', ['id' => $id]), [], $activity->jsonSerialize());
$responseData = $response->getDecodedBody();

return new SmsActivity($responseData);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/TaskApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function get(string $id, array $fields = []): Task
*/
public function create(Task $task): Task
{
$response = $this->client->post($this->prepareUrlForKey('add-task'), $task->jsonSerialize());
$response = $this->client->post($this->prepareUrlForKey('add-task'), [], $task->jsonSerialize());
$responseData = $response->getDecodedBody();

return new Task($responseData);
Expand All @@ -108,7 +108,7 @@ public function update(Task $task): Task

$task->setId(null);

$response = $this->client->put($this->prepareUrlForKey('update-task', ['id' => $id]), $task->jsonSerialize());
$response = $this->client->put($this->prepareUrlForKey('update-task', ['id' => $id]), [], $task->jsonSerialize());
$responseData = $response->getDecodedBody();

return new Task($responseData);
Expand Down
10 changes: 6 additions & 4 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,28 @@ public function testPost(): void
{
$this->httpClient->addResponse(MessageFactoryDiscovery::find()->createResponse(StatusCodeInterface::STATUS_OK, null, [], '{}'));

$this->client->post('/foo/', ['foo' => 'bar', 'bar' => 'foo']);
$this->client->post('/foo/', ['foo' => 'bar'], ['bar' => 'foo']);

$lastRequest = $this->httpClient->getLastRequest();

$this->assertInstanceOf(RequestInterface::class, $lastRequest);
$this->assertEquals('https://app.close.io/api/v1/foo/?foo=bar&bar=foo', (string) $lastRequest->getUri());
$this->assertEquals('https://app.close.io/api/v1/foo/?foo=bar', (string) $lastRequest->getUri());
$this->assertEquals('POST', $lastRequest->getMethod());
$this->assertEquals('{"bar":"foo"}', (string) $lastRequest->getBody());
}

public function testPut(): void
{
$this->httpClient->addResponse(MessageFactoryDiscovery::find()->createResponse(StatusCodeInterface::STATUS_OK, null, [], '{}'));

$this->client->put('/foo/', ['foo' => 'bar', 'bar' => 'foo']);
$this->client->put('/foo/', ['foo' => 'bar'], ['bar' => 'foo']);

$lastRequest = $this->httpClient->getLastRequest();

$this->assertInstanceOf(RequestInterface::class, $lastRequest);
$this->assertEquals('https://app.close.io/api/v1/foo/?foo=bar&bar=foo', (string) $lastRequest->getUri());
$this->assertEquals('https://app.close.io/api/v1/foo/?foo=bar', (string) $lastRequest->getUri());
$this->assertEquals('PUT', $lastRequest->getMethod());
$this->assertEquals('{"bar":"foo"}', (string) $lastRequest->getBody());
}

public function testDelete(): void
Expand Down

0 comments on commit cebd888

Please sign in to comment.