diff --git a/spec/MessengerSpec.php b/spec/MessengerSpec.php index a693f7f..87e6e28 100644 --- a/spec/MessengerSpec.php +++ b/spec/MessengerSpec.php @@ -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); + } } diff --git a/src/Messenger.php b/src/Messenger.php index 377daf7..71809f8 100644 --- a/src/Messenger.php +++ b/src/Messenger.php @@ -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 *