UNPKG

@spree/storefront-api-v2-sdk

Version:

Node module to easily integrate your JavaScript or TypeScript application with Spree API V2. You can create an entirely custom Storefront in JS/TS with this package including one page checkout, Single Page Apps, PWAs and so on

15 lines (13 loc) 711 B
import { authParams, refreshParams } from '../helpers/auth' import Http from '../Http' import { AuthTokenAttr, RefreshTokenAttr } from '../interfaces/Authentication' import { IOAuthTokenResult } from '../interfaces/Token' import { Routes } from '../routes' export default class Authentication extends Http { public async getToken(params: AuthTokenAttr): Promise<IOAuthTokenResult> { return await this.spreeResponse('post', Routes.oauthTokenPath(), {}, authParams(params)) as IOAuthTokenResult } public async refreshToken(params: RefreshTokenAttr): Promise<IOAuthTokenResult> { return await this.spreeResponse('post', Routes.oauthTokenPath(), {}, refreshParams(params)) as IOAuthTokenResult } }