Skip to content

Commit

Permalink
Merge pull request #4 from tgallice/add_subscribe
Browse files Browse the repository at this point in the history
Add Messenger::subscribe() method
  • Loading branch information
tgallice committed Jun 2, 2016
2 parents 4628305 + aec33eb commit 12829d2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/MessengerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,24 @@ function it_can_delete_welcome_message($client, ResponseInterface $response)
->shouldHaveKeyWithValue('result', 'Successfully removed all new_thread\'s CTAs');

}

function it_subscribe_the_app($client, ResponseInterface $response)
{
$options = [
RequestOptions::QUERY => [
'access_token' => 'token',
],
];

$response->getBody()->willReturn('
{
"success": true
}
');

$client->request('POST', '/me/subscribed_apps', $options)
->willReturn($response);

$this->subscribe()->shouldReturn(true);
}
}
12 changes: 12 additions & 0 deletions src/Messenger.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ public function setWelcomeMessage($message, $pageId)
return $this->send('POST', sprintf('/%s/thread_settings', $pageId), $options);
}

/**
* Subscribe the app to the page
*
* @return bool
*/
public function subscribe()
{
$response = $this->send('POST', '/me/subscribed_apps');

return $response['success'];
}

/**
* @param string $pageId
*
Expand Down

0 comments on commit 12829d2

Please sign in to comment.