Skip to content

Commit

Permalink
Stretching the expected response time from the DK API (#167)
Browse files Browse the repository at this point in the history
It seems like during peak periods that DK is not responding to invoice generation requests in time. This stretches the timeout to 10 seconds for GET requests and 15 seconds for POST requests, with is 2x and 3x the default of 5 seconds.
  • Loading branch information
aldavigdis authored Jul 18, 2024
1 parent 2591453 commit 6f1dcf3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Service/DKApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
* Handles the low-level HTTP requests to the DK JSON API.
*/
class DKApiRequest {
const DK_API_URL = 'https://api.dkplus.is/api/v1';
const DK_API_URL = 'https://api.dkplus.is/api/v1';
const GET_TIMEOUT = 10.0;
const POST_TIMEOUT = 15.0;

/**
* The DK API key
Expand Down Expand Up @@ -83,6 +85,7 @@ public function get_result( string $path ): WP_Error|stdClass {
array(
'httpversion' => '1.1',
'headers' => $this->get_headers,
'timeout' => self::GET_TIMEOUT,
),
);

Expand Down Expand Up @@ -117,6 +120,7 @@ public function get_table_result(
array(
'httpversion' => '1.1',
'headers' => $this->get_headers,
'timeout' => self::GET_TIMEOUT,
),
);

Expand Down Expand Up @@ -155,6 +159,7 @@ public function request_result(
'httpversion' => '1.1',
'headers' => $this->post_headers,
'body' => $body,
'timeout' => self::POST_TIMEOUT,
),
);

Expand Down

0 comments on commit 6f1dcf3

Please sign in to comment.