Skip to content

Commit

Permalink
Add timeout.
Browse files Browse the repository at this point in the history
Signed-off-by: Lloric Mayuga Garcia <lloricode@gmail.com>
  • Loading branch information
lloricode committed Feb 21, 2023
1 parent a58bbbf commit ee91b31
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/PaymayaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class PaymayaClient

private string $base_url;

private int $timeout = 3;

private ?HandlerStack $handler_stack = null;

/** @throws ErrorException */
Expand All @@ -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) {
Expand Down Expand Up @@ -71,12 +74,19 @@ 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));

$this->handler_stack = $handlerStack;

return $this;
}

public function setTimeout(int $timeout): static
{
$this->timeout = $timeout;

return $this;
}
}

0 comments on commit ee91b31

Please sign in to comment.