UNPKG

modem-pay

Version:

A TypeScript SDK for integrating with the Modem Pay payment gateway, enabling seamless payment processing and financial services in your applications.

88 lines (87 loc) 3.61 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const base_1 = __importDefault(require("./base")); class CustomersResource extends base_1.default { constructor(apiKey, maxRetries, timeout) { super(apiKey, maxRetries, timeout); } /** Creates a new customer. */ create(params, options = { distinct: false }) { return __awaiter(this, void 0, void 0, function* () { return this.request({ method: "post", url: `${this.apiURL}/v1/customers`, headers: this.getHeaders(), data: Object.assign(Object.assign({}, params), { config: Object.assign({}, options) }), }); }); } /** Retrieves a Customer's data. */ retrieve(id) { return __awaiter(this, void 0, void 0, function* () { return this.request({ method: "get", url: `${this.apiURL}/v1/customers/${id}`, headers: this.getHeaders(), }); }); } /** Returns a list of customers. */ list(options = { limit: 10 }) { var _a; return __awaiter(this, void 0, void 0, function* () { const data = yield this.request({ method: "get", url: `${this.apiURL}/v1/customers?term=${(_a = options.search) !== null && _a !== void 0 ? _a : ""}`, headers: this.getHeaders(), params: Object.assign({ offset: 0 }, options), }); return data; }); } /** Updates the specified customer. */ update(id, params) { return __awaiter(this, void 0, void 0, function* () { return this.request({ method: "put", url: `${this.apiURL}/v1/customers/${id}`, headers: this.getHeaders(), data: { data: Object.assign({}, params) }, }); }); } /** Permanently deletes a customer. */ delete(id) { return __awaiter(this, void 0, void 0, function* () { yield this.request({ method: "delete", url: `${this.apiURL}/v1/customers/${id}`, headers: this.getHeaders(), }); }); } /** Returns a list of payment methods associated with a specific customer. */ listPaymentMethods(id, options = { limit: 10 }) { return __awaiter(this, void 0, void 0, function* () { return this.request({ method: "get", url: `${this.apiURL}/v1/customers/${id}/payment-methods`, headers: this.getHeaders(), params: Object.assign({ offset: 0 }, options), }); }); } } exports.default = CustomersResource;