Skip to content

Commit 6829d4a

Browse files
author
ppaulis
committed
Merge branch 'release/1.4.2'
2 parents 2350bf9 + 6011953 commit 6829d4a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Service/Resource.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ protected function request($url, $method = 'GET', $body = null)
227227
);
228228
}
229229

230+
if (array_key_exists('timeout_milliseconds', $zohoConfig) &&
231+
!empty($zohoConfig['timeout_milliseconds']))
232+
{
233+
curl_setopt(
234+
$this->curl, CURLOPT_TIMEOUT_MS,
235+
$this->getServiceLocator()->get('config')['zoho']['timeout_milliseconds']
236+
);
237+
}
238+
230239
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
231240
curl_setopt($this->curl, CURLOPT_HTTPHEADER, [
232241
'Authorization: Zoho-authtoken ' . $this->getAuthToken(),
@@ -261,10 +270,12 @@ protected function request($url, $method = 'GET', $body = null)
261270
if ($this->getLastResponseHttpCode() == 429) {
262271
throw new Exception(Exception::TYPE_TOO_MANY_REQUESTS, 'Too many Requests', 'Zoho Subscriptions is currently not available because of too many requests.');
263272
} else if ($this->getLastResponseHttpCode() == 404 ||
264-
($this->getLastResponseHttpCode() == 400 && array_key_exists('code', $result) &&
265-
$result['code'] == 3004))
273+
($this->getLastResponseHttpCode() == 400 && array_key_exists('code', $result) &&
274+
$result['code'] == 3004))
266275
{
267276
throw new Exception(Exception::TYPE_RESOURCE_NOT_FOUND, 'Not found', 'Resource not found.');
277+
} else if ($this->getLastResponseHttpCode() == 522) {
278+
throw new Exception(Exception::TYPE_GATEWAY_TIMEOUT, 'Zoho Timeout', 'Zoho Subscriptions is currently not available.');
268279
}
269280

270281
curl_close($this->curl);

0 commit comments

Comments
 (0)