Skip to content

Commit

Permalink
Helpscout Client: Various fixes for scripting (#676)
Browse files Browse the repository at this point in the history
* Helpscout client: Store the last API request in an accessible field.

* Helpscout client: Remove Foundation support, no longer exists.

* Bump the timeout to 30s, as some endpoints are slow.
  • Loading branch information
dd32 authored Dec 17, 2024
1 parent 613141f commit 127a982
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions mu-plugins/utilities/class-helpscout.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class HelpScout {
*
* @var int
*/
public $timeout = 15;
public $timeout = 30;

public $name = '';
protected $app_id = '';
protected $app_secret = '';
protected $webhook_secret = '';

public $last_api_request = false;

/**
* Fetch an instance of the HelpScout API.
*/
Expand All @@ -42,11 +44,6 @@ protected function __construct( $app_id, $secret = false, $webhook_secret = fals
$app_id = HELPSCOUT_APP_ID;
$secret = HELPSCOUT_APP_SECRET;
$webhook_secret = HELPSCOUT_WEBHOOK_SECRET_KEY;
} elseif ( 'foundation' === $app_id && defined( 'HELPSCOUT_FOUNDATION_APP_ID' ) ) {
$name = 'foundation';
$app_id = HELPSCOUT_FOUNDATION_APP_ID;
$secret = HELPSCOUT_FOUNDATION_APP_SECRET;
$webhook_secret = HELPSCOUT_FOUNDATION_WEBHOOK_SECRET_KEY;
}

$this->name = $name;
Expand Down Expand Up @@ -178,7 +175,7 @@ public function api( $url, $args = null, $method = 'GET' ) {
$body = wp_json_encode( $args );
}

$request = wp_remote_request(
$this->last_api_request = wp_remote_request(
$url,
array(
'method' => $method,
Expand All @@ -188,7 +185,7 @@ public function api( $url, $args = null, $method = 'GET' ) {
)
);

return json_decode( wp_remote_retrieve_body( $request ) );
return json_decode( wp_remote_retrieve_body( $this->last_api_request ) );
}

/**
Expand Down

0 comments on commit 127a982

Please sign in to comment.