UNPKG

paypal-rest-api

Version:

A typescript module for integrating with PayPal REST APIs.

95 lines (94 loc) 3.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const api_1 = require("../abstracts/api"); const schemas_1 = require("./schemas"); class InvoiceApi extends api_1.Api { constructor(client) { super(client, InvoiceApi.schemas, InvoiceApi.paths); } send(id, options = {}) { if (InvoiceApi.schemas.id) { id = this.schemaValidate(id, InvoiceApi.schemas.id); } options.uri = this.parsePath(InvoiceApi.paths.send, { id }); options = this.schemaValidate(options, InvoiceApi.schemas.send); return this.client.request(options); } remind(id, options = {}) { if (InvoiceApi.schemas.id) { id = this.schemaValidate(id, InvoiceApi.schemas.id); } options.uri = this.parsePath(InvoiceApi.paths.remind, { id }); options = this.schemaValidate(options, InvoiceApi.schemas.remind); return this.client.request(options); } cancel(id, options = {}) { if (InvoiceApi.schemas.id) { id = this.schemaValidate(id, InvoiceApi.schemas.id); } options.uri = this.parsePath(InvoiceApi.paths.cancel, { id }); options = this.schemaValidate(options, InvoiceApi.schemas.cancel); return this.client.request(options); } recordPayment(id, options = {}) { if (InvoiceApi.schemas.id) { id = this.schemaValidate(id, InvoiceApi.schemas.id); } options.uri = this.parsePath(InvoiceApi.paths.recordPayment, { id }); options = this.schemaValidate(options, InvoiceApi.schemas.recordPayment); return this.client.request(options); } recordRefund(id, options = {}) { if (InvoiceApi.schemas.id) { id = this.schemaValidate(id, InvoiceApi.schemas.id); } options.uri = this.parsePath(InvoiceApi.paths.recordRefund, { id }); options = this.schemaValidate(options, InvoiceApi.schemas.recordRefund); return this.client.request(options); } qr(id, options = {}) { if (InvoiceApi.schemas.id) { id = this.schemaValidate(id, InvoiceApi.schemas.id); } options.uri = this.parsePath(InvoiceApi.paths.qr, { id }); options = this.schemaValidate(options, InvoiceApi.schemas.qr); return this.client.request(options); } generateNumber(options = {}) { options.uri = InvoiceApi.paths.qr; options = this.schemaValidate(options, InvoiceApi.schemas.generateNumber); return this.client.request(options); } } InvoiceApi.paths = { cancel: `/v1/invoicing/invoices/{id}/cancel`, create: `/v1/invoicing/invoices`, delete: `/v1/invoicing/invoices/{id}`, generateNumber: `/v1/invoicing/invoices/next-invoice-number`, get: `/v1/invoicing/invoices/{id}`, list: `/v1/invoicing/invoices`, qr: `/v1/invoicing/invoices/{id}/qr-code`, recordPayment: `/v1/invoicing/invoices/{id}/record-payment`, recordRefund: `/v1/invoicing/invoices/{id}/record-refund`, remind: `/v1/invoicing/invoices/{id}/remind`, search: `/v1/invoicing/search`, send: `/v1/invoicing/invoices/{id}/send`, update: `/v1/invoicing/invoices/{id}`, }; InvoiceApi.schemas = { cancel: schemas_1.invoiceCancelRequestSchema, create: schemas_1.invoiceCreateRequestSchema, delete: schemas_1.invoiceDeleteRequestSchema, generateNumber: schemas_1.invoiceGenerateNumberRequestSchema, get: schemas_1.invoiceGetRequestSchema, id: schemas_1.invoiceIdSchema, list: schemas_1.invoiceListRequestSchema, qr: schemas_1.invoiceQrRequestSchema, recordPayment: schemas_1.invoiceRecordPaymentRequestSchema, recordRefund: schemas_1.invoiceRecordRefundRequestSchema, remind: schemas_1.invoiceRemindRequestSchema, search: schemas_1.invoiceSearchRequestSchema, send: schemas_1.invoiceSendRequestSchema, update: schemas_1.invoiceUpdateRequestSchema, }; exports.InvoiceApi = InvoiceApi;