Changeset 13114 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/clients/class-helpscout.php
- Timestamp:
- 01/16/2024 05:05:42 AM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/clients/class-helpscout.php
r11728 r13114 15 15 const TIMEOUT = 15; 16 16 17 public static function api( $url, $args = null, $method = 'GET' ) {17 public static function api( $url, $args = null, $method = 'GET', & $response_code = null ) { 18 18 // Verify the configuration variables are available. 19 19 if ( ! defined( 'HELPSCOUT_APP_ID' ) || ! defined( 'HELPSCOUT_APP_SECRET' ) ) { … … 30 30 } 31 31 32 $body = null; 33 $headers = [ 34 'Accept' => 'application/json', 35 'Authorization' => self::get_auth_string(), 36 ]; 37 // All editable requests must have a json content-type. 38 // See https://developer.helpscout.com/mailbox-api/overview/content_type/ 39 if ( in_array( $method, [ 'POST', 'PUT', 'PATCH' ], true ) ) { 40 $headers['Content-Type'] = 'application/json'; 41 $body = json_encode( $args ); 42 } 43 32 44 $request = wp_remote_request( 33 45 $url, 34 46 array( 35 47 'method' => $method, 36 'headers' => [ 37 'Accept' => 'application/json', 38 'Authorization' => self::get_auth_string(), 39 ], 48 'headers' => $headers, 40 49 'timeout' => self::TIMEOUT, 41 'body' => ( 'POST' === $method && $args ) ? $args : null,50 'body' => $body, 42 51 ) 43 52 ); 53 54 $response_code = wp_remote_retrieve_response_code( $request ); 44 55 45 56 return json_decode( wp_remote_retrieve_body( $request ) );
Note: See TracChangeset
for help on using the changeset viewer.