UNPKG

@johntad/m-pesa

Version:

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

38 lines (37 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RegisterUrlResponse = void 0; /** * Represents the response object from the Register URL API. */ class RegisterUrlResponse { constructor(responseCode, responseMessage, customerMessage, timestamp) { this.responseCode = responseCode; this.responseMessage = responseMessage; this.customerMessage = customerMessage; this.timestamp = timestamp; } /** * Factory method to create an instance from API response data. * @param data - The raw response data from the API. * @returns An instance of RegisterUrlResponse. */ static fromApiResponse(data) { return new RegisterUrlResponse(data.responseCode, data.responseMessage, data.customerMessage, data.timestamp); } /** * Determines if the response indicates success. * @returns True if the response was successful, false otherwise. */ isSuccess() { return this.responseCode === '200'; } /** * Returns a formatted string summarizing the response. * @returns A formatted string. */ toString() { return `Register URL Response: ${this.responseMessage} (Code: ${this.responseCode})`; } } exports.RegisterUrlResponse = RegisterUrlResponse;