Skip to content

Commit

Permalink
Merge 1978312 into 0a76a33
Browse files Browse the repository at this point in the history
  • Loading branch information
gigorok committed Nov 5, 2019
2 parents 0a76a33 + 1978312 commit 98fbe17
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Item/Did.php
Expand Up @@ -19,12 +19,12 @@ public function getDedicatedChannelsCount(): int
return $this->attributes['dedicated_channels_count'];
}

public function getTerminated(): boolean
public function getTerminated(): bool
{
return $this->attributes['terminated'];
}

public function setTerminated(boolean $terminated)
public function setTerminated(bool $terminated)
{
$this->attributes['terminated'] = $terminated;
}
Expand All @@ -39,12 +39,12 @@ public function getDescription(): string
return $this->attributes['description'];
}

public function setPendingRemoval(boolean $pendingRemoval)
public function setPendingRemoval(bool $pendingRemoval)
{
$this->attributes['pending_removal'] = $pendingRemoval;
}

public function getPendingRemoval(): boolean
public function getPendingRemoval(): bool
{
return $this->attributes['pending_removal'];
}
Expand All @@ -59,17 +59,17 @@ public function getCapacityLimit(): int
return $this->attributes['capacity_limit'];
}

public function getBlocked(): boolean
public function getBlocked(): bool
{
return $this->attributes['blocked'];
}

public function getAwaitingRegistration(): boolean
public function getAwaitingRegistration(): bool
{
return $this->attributes['awaiting_registration'];
}

public function getNumber(): boolean
public function getNumber(): string
{
return $this->attributes['number'];
}
Expand Down
36 changes: 36 additions & 0 deletions tests/DidTest.php
Expand Up @@ -121,4 +121,40 @@ public function testApplySharedCapacityGroup()

$this->stopVCR();
}

public function testBooleans()
{
$this->startVCR('dids.yml');

$didDocument = \Didww\Item\Did::find('9df99644-f1a5-4a3c-99a4-559d758eb96b');
$did = $didDocument->getData();
$this->assertEquals($did->getPendingRemoval(), false);
$this->assertEquals($did->getTerminated(), false);
$this->assertEquals($did->getNumber(), '16091609123456797');
$this->assertEquals($did->getBlocked(), false);
$this->assertEquals($did->getAwaitingRegistration(), false);

$did->setPendingRemoval(true);
$did->setTerminated(true);
$didDocument = $did->save();

$this->assertEquals($did->toJsonApiArray(), [
'id' => $did->getId(),
'type' => 'dids',
'attributes' => [
'capacity_limit' => $did->getCapacityLimit(),
'description' => $did->getDescription(),
'terminated' => true,
'pending_removal' => true,
'dedicated_channels_count' => $did->getDedicatedChannelsCount(),
],
]);

$did = $didDocument->getData();

$this->assertEquals($did->getPendingRemoval(), true);
$this->assertEquals($did->getTerminated(), true);

$this->stopVCR();
}
}
76 changes: 76 additions & 0 deletions tests/fixtures/dids.yml
Expand Up @@ -232,3 +232,79 @@
Access-Control-Allow-Methods: 'GET, POST, DELETE, PUT, PATCH, OPTIONS'
Access-Control-Allow-Credentials: 'true'
body: '{"data":{"id":"9df99644-f1a5-4a3c-99a4-559d758eb96b","type":"dids","attributes":{"blocked":false,"capacity_limit":2,"description":"something","terminated":false,"awaiting_registration":false,"created_at":"2018-12-27T09:59:55.015Z","number":"16091609123456797","expires_at":"2019-01-27T10:00:04.755Z","channels_included_count":0,"pending_removal":false,"dedicated_channels_count":0},"relationships":{"did_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/did_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/did_group"}},"order":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/order","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/order"}},"trunk":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/trunk","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/trunk"}},"trunk_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/trunk_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/trunk_group"}},"capacity_pool":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/capacity_pool","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/capacity_pool"}},"shared_capacity_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/shared_capacity_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/shared_capacity_group"}}}}}'
-
request:
method: GET
url: 'https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b'
headers:
Host: sandbox-api.didww.com
Accept-Encoding: null
User-Agent: 'GuzzleHttp/6.3.3 curl/7.65.0 PHP/7.1.29'
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
api-key: PLACEYOURAPIKEYHERE
response:
status:
http_version: '1.1'
code: '200'
message: OK
headers:
Server: nginx
Date: 'Tue, 05 Nov 2019 11:16:04 GMT'
Content-Type: application/vnd.api+json
Transfer-Encoding: chunked
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: '1; mode=block'
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
ETag: 'W/"88223029fb07584f264562fd8ee45462"'
Cache-Control: 'max-age=0, private, must-revalidate'
X-Request-Id: 9d3239ec-b550-45aa-b7d1-c4ec71db1da5
X-Runtime: '0.046822'
Access-Control-Allow-Origin: '*'
Access-Control-Allow-Headers: 'Origin, X-Requested-With, Content-Type, Accept, x-api-key, api-key, x-api-token, Cache-Control'
Access-Control-Allow-Methods: 'GET, POST, DELETE, PUT, PATCH, OPTIONS'
Access-Control-Allow-Credentials: 'true'
body: '{"data":{"id":"9df99644-f1a5-4a3c-99a4-559d758eb96b","type":"dids","attributes":{"blocked":false,"capacity_limit":2,"description":"something","terminated":false,"awaiting_registration":false,"created_at":"2018-12-27T09:59:55.015Z","number":"16091609123456797","expires_at":"2019-11-27T10:00:04.755Z","channels_included_count":0,"pending_removal":false,"dedicated_channels_count":0},"relationships":{"did_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/did_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/did_group"}},"order":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/order","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/order"}},"trunk":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/trunk","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/trunk"}},"trunk_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/trunk_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/trunk_group"}},"capacity_pool":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/capacity_pool","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/capacity_pool"}},"shared_capacity_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/shared_capacity_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/shared_capacity_group"}}}}}'
-
request:
method: PATCH
url: 'https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b'
headers:
Host: sandbox-api.didww.com
Expect: null
Accept-Encoding: null
User-Agent: 'GuzzleHttp/6.3.3 curl/7.65.0 PHP/7.1.29'
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
api-key: PLACEYOURAPIKEYHERE
body: '{"data":{"type":"dids","id":"9df99644-f1a5-4a3c-99a4-559d758eb96b","attributes":{"capacity_limit":2,"description":"something","terminated":true,"pending_removal":true,"dedicated_channels_count":0}}}'
response:
status:
http_version: '1.1'
code: '200'
message: OK
headers:
Server: nginx
Date: 'Tue, 05 Nov 2019 11:16:07 GMT'
Content-Type: application/vnd.api+json
Transfer-Encoding: chunked
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: '1; mode=block'
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
ETag: 'W/"9a9183a45a861229f5f5e8935582eec5"'
Cache-Control: 'max-age=0, private, must-revalidate'
X-Request-Id: 05a5f9c8-ca9f-4d79-9a60-ce07c75feac8
X-Runtime: '0.127103'
Access-Control-Allow-Origin: '*'
Access-Control-Allow-Headers: 'Origin, X-Requested-With, Content-Type, Accept, x-api-key, api-key, x-api-token, Cache-Control'
Access-Control-Allow-Methods: 'GET, POST, DELETE, PUT, PATCH, OPTIONS'
Access-Control-Allow-Credentials: 'true'
body: '{"data":{"id":"9df99644-f1a5-4a3c-99a4-559d758eb96b","type":"dids","attributes":{"blocked":true,"capacity_limit":2,"description":"something","terminated":true,"awaiting_registration":false,"created_at":"2018-12-27T09:59:55.015Z","number":"16091609123456797","expires_at":"2019-11-27T10:00:04.755Z","channels_included_count":0,"pending_removal":true,"dedicated_channels_count":0},"relationships":{"did_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/did_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/did_group"}},"order":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/order","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/order"}},"trunk":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/trunk","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/trunk"}},"trunk_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/trunk_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/trunk_group"}},"capacity_pool":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/capacity_pool","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/capacity_pool"}},"shared_capacity_group":{"links":{"self":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/relationships/shared_capacity_group","related":"https://sandbox-api.didww.com/v3/dids/9df99644-f1a5-4a3c-99a4-559d758eb96b/shared_capacity_group"}}}}}'

0 comments on commit 98fbe17

Please sign in to comment.