| Conditions | 1 |
| Paths | 1 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function __construct($token, $maxRetries = self::MAX_RETRIES) |
||
| 24 | { |
||
| 25 | $handler = new GuzzleClient([ |
||
| 26 | 'base_url' => self::BASE_URL, |
||
| 27 | 'defaults' => [ |
||
| 28 | 'headers' => [ |
||
| 29 | 'Content-Type' => 'application/json', |
||
| 30 | 'Accept' => 'application/json', |
||
| 31 | 'Authorization' => sprintf('Bearer %s', $token), |
||
| 32 | ], |
||
| 33 | ], |
||
| 34 | ]); |
||
| 35 | |||
| 36 | $retry = new RetrySubscriber([ |
||
| 37 | 'filter' => RetrySubscriber::createChainFilter([ |
||
| 38 | RetrySubscriber::createCurlFilter([CURLE_PARTIAL_FILE]), |
||
| 39 | RetrySubscriber::createStatusFilter([500, 502, 503, 504]), |
||
| 40 | ]), |
||
| 41 | 'max' => $maxRetries, |
||
| 42 | ]); |
||
| 43 | |||
| 44 | $handler->getEmitter()->attach($retry); |
||
| 45 | |||
| 46 | $this->client = new Client($handler); |
||
| 47 | } |
||
| 48 | |||
| 57 |