mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-25 14:26:04 +03:00
Add mapping for assignable_to_pools property of ips index response
This commit is contained in:
parent
a91f5f6185
commit
90028dc6a1
@ -28,6 +28,11 @@ final class IndexResponse implements ApiResponse
|
||||
*/
|
||||
private $totalCount;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $assignableToPools;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
@ -37,6 +42,7 @@ final class IndexResponse implements ApiResponse
|
||||
$model = new self();
|
||||
$model->items = $data['items'];
|
||||
$model->totalCount = $data['total_count'] ?? 0;
|
||||
$model->assignableToPools = $data['assignable_to_pools'];
|
||||
|
||||
return $model;
|
||||
}
|
||||
@ -49,6 +55,14 @@ final class IndexResponse implements ApiResponse
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAssignableToPools(): array
|
||||
{
|
||||
return $this->assignableToPools;
|
||||
}
|
||||
|
||||
public function getTotalCount(): int
|
||||
{
|
||||
return $this->totalCount;
|
||||
|
@ -28,6 +28,7 @@ class IpTest extends TestCase
|
||||
$this->setRequestUri('/v3/ips');
|
||||
$this->setHttpResponse(new Response(200, ['Content-Type' => 'application/json'], <<<'JSON'
|
||||
{
|
||||
"assignable_to_pools": ["192.168.0.1"],
|
||||
"items": ["192.161.0.1", "192.168.0.2"],
|
||||
"total_count": 2
|
||||
}
|
||||
@ -41,6 +42,7 @@ JSON
|
||||
$this->assertEquals(2, $response->getTotalCount());
|
||||
$this->assertEquals('192.161.0.1', $response->getItems()[0]);
|
||||
$this->assertEquals('192.168.0.2', $response->getItems()[1]);
|
||||
$this->assertEquals('192.168.0.1', $response->getAssignableToPools()[0]);
|
||||
}
|
||||
|
||||
public function testIndexOnlyDedicated()
|
||||
@ -49,6 +51,7 @@ JSON
|
||||
$this->setRequestUri('/v3/ips?dedicated=1');
|
||||
$this->setHttpResponse(new Response(200, ['Content-Type' => 'application/json'], <<<'JSON'
|
||||
{
|
||||
"assignable_to_pools": ["192.168.0.1"],
|
||||
"items": ["192.161.0.1"],
|
||||
"total_count": 1
|
||||
}
|
||||
@ -61,6 +64,7 @@ JSON
|
||||
$this->assertInstanceOf(IndexResponse::class, $response);
|
||||
$this->assertEquals(1, $response->getTotalCount());
|
||||
$this->assertEquals('192.161.0.1', $response->getItems()[0]);
|
||||
$this->assertEquals('192.168.0.1', $response->getAssignableToPools()[0]);
|
||||
}
|
||||
|
||||
public function testIndexOnlyShared()
|
||||
@ -69,6 +73,7 @@ JSON
|
||||
$this->setRequestUri('/v3/ips?dedicated=0');
|
||||
$this->setHttpResponse(new Response(200, ['Content-Type' => 'application/json'], <<<'JSON'
|
||||
{
|
||||
"assignable_to_pools": ["192.168.0.1"],
|
||||
"items": ["192.168.0.2"],
|
||||
"total_count": 1
|
||||
}
|
||||
@ -81,5 +86,6 @@ JSON
|
||||
$this->assertInstanceOf(IndexResponse::class, $response);
|
||||
$this->assertEquals(1, $response->getTotalCount());
|
||||
$this->assertEquals('192.168.0.2', $response->getItems()[0]);
|
||||
$this->assertEquals('192.168.0.1', $response->getAssignableToPools()[0]);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class IndexResponseTest extends BaseModelTest
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"assignable_to_pools": ["192.161.0.1"],
|
||||
"items": ["192.161.0.1", "192.168.0.2"],
|
||||
"total_count": 2
|
||||
}
|
||||
@ -31,4 +32,20 @@ JSON;
|
||||
$this->assertCount(2, $items);
|
||||
$this->assertEquals('192.161.0.1', $items[0]);
|
||||
}
|
||||
|
||||
public function testCreateWithAssignableToPools()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"assignable_to_pools": ["192.161.0.1"],
|
||||
"items": ["192.161.0.1", "192.168.0.2"],
|
||||
"total_count": 2
|
||||
}
|
||||
JSON;
|
||||
$model = IndexResponse::create(json_decode($json, true));
|
||||
$assignableToPools = $model->getAssignableToPools();
|
||||
$this->assertCount(1, $assignableToPools);
|
||||
$this->assertEquals('192.161.0.1', $assignableToPools[0]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user