UNPKG

paypal-rest-api

Version:

A typescript module for integrating with PayPal REST APIs.

58 lines (57 loc) 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const joi = require("joi"); const client_1 = require("../client"); const invoice_1 = require("../invoice"); const payment_1 = require("../payment"); const sale_1 = require("../sale"); const webhook_1 = require("../webhook"); const webhookEvent_1 = require("../webhookEvent"); const schemas_1 = require("./schemas"); class PayPalRestApi { constructor(config) { this.config = config; this.client = new client_1.Client(this.config); webhook_1.default.init(this.client); webhookEvent_1.default.init(this.client); invoice_1.default.init(this.client); payment_1.default.init(this.client); sale_1.default.init(this.client); } get config() { return this._config; } set config(config) { const validateConfig = joi.validate(config, schemas_1.configurationSchema, { allowUnknown: true }); if (validateConfig.error) { throw validateConfig.error; } config = validateConfig.value; if (config.mode === "sandbox") { config.requestOptions.baseUrl = "https://api.sandbox.paypal.com"; } this._config = config; } get client() { return this._client; } set client(client) { this._client = client; } get invoice() { return invoice_1.default; } get webhook() { return webhook_1.default; } get webhookEvent() { return webhookEvent_1.default; } get payment() { return payment_1.default; } get sale() { return sale_1.default; } } exports.PayPalRestApi = PayPalRestApi;