From f25af8a1e1794ebdfe4c223b982562eb193dbfe1 Mon Sep 17 00:00:00 2001 From: Manuel Thomsen Date: Mon, 10 Jul 2017 11:09:44 +0200 Subject: [PATCH] Make it possible to create notes without creating a deal first --- src/PipedriveChannel.php | 5 +++++ tests/ChannelTest.php | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/PipedriveChannel.php b/src/PipedriveChannel.php index 82dbaf3..b4218d6 100644 --- a/src/PipedriveChannel.php +++ b/src/PipedriveChannel.php @@ -35,6 +35,11 @@ private function savePipedriveResources(PipedriveMessage $message) $activity->setClient($this->client, $this->token); $activity->save(); } + + foreach ($message->notes as $note) { + $note->setClient($this->client, $this->token); + $note->save(); + } } private function validate($notification) diff --git a/tests/ChannelTest.php b/tests/ChannelTest.php index 64eac65..a29f275 100644 --- a/tests/ChannelTest.php +++ b/tests/ChannelTest.php @@ -84,6 +84,17 @@ public function it_can_create_and_update_deals_and_activities() ]) ->andReturn($response); + $client->shouldReceive('request') + ->once() + ->with('POST', 'https://api.pipedrive.com/v1/notes?api_token=PipedriveToken', + [ + 'form_params' => [ + 'deal_id' => 1, + 'content' => 'Customer bought milk', + ], + ]) + ->andReturn($response); + $channel = new PipedriveChannel($client); $channel->send(new TestNotifiable(), new CreateDealWithActivitiesNotification()); } @@ -165,6 +176,10 @@ public function toPipedrive($notifiable) $activity->subject('Buy milk') ->type('shopping') ->due('2017-12-18'); + }) + ->note(function ($note) { + $note->deal(1) + ->content('Customer bought milk'); }); } }