@lorenstuff/amazon-selling-partner-api
Version:
A package for interacting with the Amazon Selling Partner API.
88 lines • 3.56 kB
TypeScript
/** An access token possessed by the client. */
export interface AmazonSellingPartnerAPIClientAccessToken {
/** The access token. */
accessToken: string;
/** A unix timestamp representing when the access token expires. */
expiresTimestamp: number;
}
/** A response from Amazon's OAuth2 endpoint. */
export interface AmazonSellingPartnerAPIClientAccessTokenResponse {
/** The access token. */
access_token: string;
/** The refresh token. */
refresh_token: string;
/** The token type. */
token_type: string;
/** The amount of time, in seconds, the access token is valid for. */
expires_in: number;
}
/** Options passed to the Client constructor. */
export interface AmazonSellingPartnerAPIClientOptions {
/** A refresh token from an Amazon Seller Central app. */
refreshToken: string;
/** A client identifier from an Amazon Seller Central app. */
clientIdentifier: string;
/** A client secret from an Amazon Seller Central app. */
clientSecret: string;
/** @deprecated No longer used. */
iamUserAccessKey: string;
/** @deprecated No longer used. */
iamUserSecretAccessKey: string;
/**
* An Amazon Seller Partner API Endpoint to use.
*
* @see https://developer-docs.amazon.com/sp-api/docs/sp-api-endpoints
*/
apiEndpoint: string;
/**
* The AWS region to use. This should correspond to the region of the API endpoint.
*
* @see https://developer-docs.amazon.com/sp-api/docs/sp-api-endpoints
*/
awsRegion: string;
}
/** Options passed to a Client's connect method. */
export interface AmazonSellingPartnerAPIClientRequestOptions {
/** The HTTP method to use. */
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
/** The path to the API you want to call. */
path: string;
/** The query parameters to use, if any. */
searchParams?: URLSearchParams;
/** The body of the request, if any. */
body?: string;
}
/** The core client that handles actually connecting to the Selling Partner API. */
export declare class AmazonSellingPartnerAPIClient {
/** The refresh token from an Amazon Seller Central app. */
refreshToken: string;
/** The client identifier from an Amazon Seller Central app. */
clientIdentifier: string;
/** The client secret from an Amazon Seller Central app. */
clientSecret: string;
/** The Amazon Seller Partner API Endpoint to use. */
apiEndpoint: string;
/** The AWS region to use. */
awsRegion: string;
/** The current access tokens this client has. */
accessTokens: AmazonSellingPartnerAPIClientAccessToken[];
/** Constructs a new client. */
constructor(options: AmazonSellingPartnerAPIClientOptions);
/**
* Adds an access token to the client.
*
* This is intended to be used to add a restricted data token.
*/
addAccessToken(accessToken: AmazonSellingPartnerAPIClientAccessToken): AmazonSellingPartnerAPIClientAccessToken;
/** Removes an access token from the client, if it is still present. */
removeAccessToken(accessToken: AmazonSellingPartnerAPIClientAccessToken): void;
/**
* Fetches a fresh access token.
*
* @returns A promise that resolves to the access token.
*/
getCurrentAccessToken(): Promise<AmazonSellingPartnerAPIClientAccessToken>;
/** Performs a request to the Selling Partner API. */
request(options: AmazonSellingPartnerAPIClientRequestOptions): Promise<Response>;
}
//# sourceMappingURL=AmazonSellingPartnerAPIClient.d.ts.map