From cebd888f25064461150c4e4e88ec4dec5324025a Mon Sep 17 00:00:00 2001 From: Stefano Arlandini Date: Fri, 1 Mar 2019 14:06:13 +0100 Subject: [PATCH] Fix CR issues --- src/Api/CallActivityApi.php | 2 +- src/Api/ContactApi.php | 4 ++-- src/Api/CustomFieldApi.php | 4 ++-- src/Api/EmailActivityApi.php | 4 ++-- src/Api/LeadApi.php | 6 +++--- src/Api/LeadStatusApi.php | 4 ++-- src/Api/NoteActivityApi.php | 4 ++-- src/Api/OpportunityApi.php | 4 ++-- src/Api/OpportunityStatusApi.php | 4 ++-- src/Api/SmsActivityApi.php | 4 ++-- src/Api/TaskApi.php | 4 ++-- tests/ClientTest.php | 10 ++++++---- 12 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/Api/CallActivityApi.php b/src/Api/CallActivityApi.php index d559516..4478397 100644 --- a/src/Api/CallActivityApi.php +++ b/src/Api/CallActivityApi.php @@ -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); diff --git a/src/Api/ContactApi.php b/src/Api/ContactApi.php index 6588f94..c776fcd 100644 --- a/src/Api/ContactApi.php +++ b/src/Api/ContactApi.php @@ -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); @@ -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); diff --git a/src/Api/CustomFieldApi.php b/src/Api/CustomFieldApi.php index 858b9f6..792b0d2 100644 --- a/src/Api/CustomFieldApi.php +++ b/src/Api/CustomFieldApi.php @@ -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); @@ -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); diff --git a/src/Api/EmailActivityApi.php b/src/Api/EmailActivityApi.php index bd2d34f..9f5f623 100644 --- a/src/Api/EmailActivityApi.php +++ b/src/Api/EmailActivityApi.php @@ -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); @@ -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); diff --git a/src/Api/LeadApi.php b/src/Api/LeadApi.php index 882ed7e..297137c 100644 --- a/src/Api/LeadApi.php +++ b/src/Api/LeadApi.php @@ -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); @@ -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); @@ -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(), ]); diff --git a/src/Api/LeadStatusApi.php b/src/Api/LeadStatusApi.php index 33bd065..585b2d8 100644 --- a/src/Api/LeadStatusApi.php +++ b/src/Api/LeadStatusApi.php @@ -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); @@ -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); diff --git a/src/Api/NoteActivityApi.php b/src/Api/NoteActivityApi.php index cd16348..d8e1d81 100644 --- a/src/Api/NoteActivityApi.php +++ b/src/Api/NoteActivityApi.php @@ -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); @@ -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); diff --git a/src/Api/OpportunityApi.php b/src/Api/OpportunityApi.php index 520f856..f7723c5 100644 --- a/src/Api/OpportunityApi.php +++ b/src/Api/OpportunityApi.php @@ -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); @@ -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); diff --git a/src/Api/OpportunityStatusApi.php b/src/Api/OpportunityStatusApi.php index 905cb45..92e3192 100644 --- a/src/Api/OpportunityStatusApi.php +++ b/src/Api/OpportunityStatusApi.php @@ -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); @@ -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); diff --git a/src/Api/SmsActivityApi.php b/src/Api/SmsActivityApi.php index 236ed7f..444b4dd 100644 --- a/src/Api/SmsActivityApi.php +++ b/src/Api/SmsActivityApi.php @@ -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); @@ -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); diff --git a/src/Api/TaskApi.php b/src/Api/TaskApi.php index d76d2bc..3bcf269 100644 --- a/src/Api/TaskApi.php +++ b/src/Api/TaskApi.php @@ -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); @@ -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); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 69bb15a..470c3ea 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -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