diff --git a/CHANGELOG.md b/CHANGELOG.md index be77195..b12d354 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## v2.0.0-alpha.2 - 2023-02-21 + +### Added + +- Add timeout. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. + ## v2.0.0-alpha - 2023-02-17 ### Added diff --git a/src/PaymayaClient.php b/src/PaymayaClient.php index efff76d..4263d12 100644 --- a/src/PaymayaClient.php +++ b/src/PaymayaClient.php @@ -20,6 +20,8 @@ class PaymayaClient private string $base_url; + private int $timeout = 3; + private ?HandlerStack $handler_stack = null; /** @throws ErrorException */ @@ -44,6 +46,7 @@ private function client(array $header): Client 'Accept' => 'application/json', 'Content-Type' => 'application/json', ], + 'timeout' => $this->timeout, ]; if ($this->handler_stack != null) { @@ -71,7 +74,7 @@ public function secretClient(array $header = []): Client ); } - public function setHandlerStack(HandlerStack $handlerStack, array &$historyContainer = []): self + public function setHandlerStack(HandlerStack $handlerStack, array &$historyContainer = []): static { $handlerStack->push(Middleware::history($historyContainer)); @@ -79,4 +82,11 @@ public function setHandlerStack(HandlerStack $handlerStack, array &$historyConta return $this; } + + public function setTimeout(int $timeout): static + { + $this->timeout = $timeout; + + return $this; + } }