@sahabaplus/moyasar
Version:
A comprehensive TypeScript SDK for integrating with the Moyasar payment gateway
28 lines • 818 B
JavaScript
export class MockApiClient {
constructor() {
this.mockResponses = new Map();
this.requestHistory = [];
}
setMockResponse(key, response) {
this.mockResponses.set(key, response);
}
async request(config) {
this.requestHistory.push(config);
const key = `${config.method}:${config.url}`;
const response = this.mockResponses.get(key);
if (response instanceof Error) {
throw response;
}
if (response === undefined) {
throw new Error(`No mock response for ${key}`);
}
return response;
}
clearHistory() {
this.requestHistory = [];
}
getLastRequest() {
return this.requestHistory[this.requestHistory.length - 1];
}
}
//# sourceMappingURL=mock_api_client.js.map