Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from botamp/whitelist-for-messenger
Browse files Browse the repository at this point in the history
Add method to whitelist a specific domain for Facebook messenger feat…
  • Loading branch information
ousmanedev committed Nov 14, 2016
2 parents 994e8ba + 0ddf114 commit 308fb5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Botamp/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ public function getPageAttributes()
return ApiResponse::getContent($this->getHttpClient()->get($url));
}

public function whitelistForMessenger($domain)
{
$url = $this->getApiBase().'/'.$this->getApiVersion().'/me?domain='.$domain;
return ApiResponse::getContent($this->getHttpClient()->get($url));
}

private function setHttpClient(HttpClient $httpClient, MessageFactory $messageFactory)
{
$plugins = [
Expand Down
20 changes: 20 additions & 0 deletions tests/Botamp/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ public function testShouldGetPageAttributes()
$this->assertEquals($attributes, $client->getPageAttributes());
}

public function testShouldwhitelistForMessenger(){
$domain = 'http://example.com';
$url = 'https://app.botamp.com/api/v1/me?domain='.$domain;
$response = ['status' =>'200', 'body'=> 'Successfully updated whitelisted domains'];

$httpClient = $this->getHttpMethodsMock(array('get'));
$httpClient
->expects($this->any())
->method('get')
->with($url, array())
->will($this->returnValue($this->getPSR7Response($response)));

$client = $this->getMock('Botamp\Client', array('getHttpClient'), array('123456789'));
$client->expects($this->any())
->method('getHttpClient')
->willReturn($httpClient);

$this->assertEquals($response, $client->whitelistForMessenger($domain));
}

/**
* @expectedException Botamp\Exceptions\Base
* @expectedExceptionMessage No valid api version provided.
Expand Down

0 comments on commit 308fb5c

Please sign in to comment.