Skip to content

Commit 0a17af6

Browse files
committed
Support 204 response from PUT /call in addition to 200
This is related to a voice API bug. The endpoint may revert to returning data in future with a 200 response, so we need to support both HTTP codes simultaneously
1 parent b859cbf commit 0a17af6

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/Call/Call.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ public function put($payload)
113113
$request->getBody()->write(json_encode($payload));
114114
$response = $this->client->send($request);
115115

116-
if($response->getStatusCode() != '200'){
116+
$responseCode = $response->getStatusCode();
117+
if($responseCode != '200' && $responseCode != '204'){
117118
throw $this->getException($response);
118119
}
119120

test/Call/CallTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testGetMakesRequest()
9191
* @param $payload
9292
* @dataProvider putCall
9393
*/
94-
public function testPutMakesRequest($payload)
94+
public function testPutMakesRequest($payload, $expectedHttpCode, $expectedResponse)
9595
{
9696
$id = $this->id;
9797
$expected = json_decode(json_encode($payload), true);
@@ -106,7 +106,7 @@ public function testPutMakesRequest($payload)
106106
$this->assertEquals($expected, $body);
107107

108108
return true;
109-
}))->willReturn($this->getResponse('updated'));
109+
}))->willReturn($this->getResponse($expectedResponse, $expectedHttpCode));
110110

111111
$this->entity->put($payload);
112112
}
@@ -126,8 +126,9 @@ public function putCall()
126126
];
127127

128128
return [
129-
[$transfer],
130-
[new Transfer('http://example.com')]
129+
[$transfer, 200, 'updated'],
130+
[new Transfer('http://example.com'), 200, 'updated'],
131+
[new Transfer('http://example.com'), 204, 'empty']
131132
];
132133
}
133134

test/Call/responses/empty.json

Whitespace-only changes.

0 commit comments

Comments
 (0)