Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpscout client: Various fixes for scripting #676

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading