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

Add token exchange endpoint #841

Merged
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
47 changes: 47 additions & 0 deletions src/API/TokenExchangeV3ToV5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Pinterest API Token exchnge class.
*
* @class TokenExchangeV3ToV5
* @version x.x.x
* @package Pinterest_For_WordPress/Classes/
*/

namespace Automattic\WooCommerce\Pinterest\API;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* V3 to V5 token exchange class.
* Contains the methods API methods and the update procedure.
*
* @since x.x.x
*/
class TokenExchangeV3ToV5 extends APIV5 {

const API_DOMAIN = 'https://api.pinterest.com/v3';

/**
* Pull ads supported countries information from the API.
*
* @since x.x.x
*
* @return array $data {
* Contains token details.
*
* @type string $access_token The access token for authentication.
* @type string $refresh_token The refresh token for acquiring a new access token.
* @type string $token_type Type of the token, usually "bearer".
* @type int $expires_in Time in seconds when the access token expires.
* @type int $refresh_token_expires_in Time in seconds when the refresh token expires.
* @type string $scope The scope for which the access token has permission.
* }
*/
public static function exchange_token() {
$request_url = 'oauth/commerce_integrations/token/exchange/';
return self::make_request( $request_url );
}

}
Loading