UNPKG

@johntad/m-pesa

Version:

A TypeScript SDK for integrating M-Pesa mobile payment services into applications, enabling seamless money transfers and transactions.

39 lines (38 loc) 1.35 kB
/** * Represents the structure of an authentication response from the API. * * @property access_token - The access token used to authenticate subsequent API calls. * @property token_type - The type of token (e.g., "Bearer"). * @property expires_in - The token expiry time in seconds. */ export type AuthResponseType = { access_token: string; token_type: string; expires_in: string; }; export declare class AuthResponse { accessToken: string; tokenType: string; expiresIn: number; /** * @param accessToken - The access token used to authenticate subsequent API calls. * @param tokenType - The type of token (e.g., Bearer). * @param expiresIn - Token expiry time in seconds. */ constructor(accessToken: string, tokenType: string, expiresIn: number); /** * Factory method to create an AuthResponse object from raw API response. * @param data - The raw response body from the authentication API. * @returns An instance of `AuthResponse` instance. */ static fromApiResponse(data: { access_token: string; token_type: string; expires_in: string; }): AuthResponse; /** * Calculates the exact timestamp when the token will expire. * @returns Date object representing the token expiry time. */ getExpiryTime(): Date; }