/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { expect, test } from "vitest"; import { Apideck } from "../index.js"; import { createTestHTTPClient } from "./testclient.js"; test("Payments Accounting Payments All", async () => { const testHttpClient = createTestHTTPClient("accounting.paymentsAll"); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.payments.list({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", filter: { updatedSince: new Date("2020-09-30T07:43:32.000Z"), }, sort: { by: "updated_at", direction: "desc", }, passThrough: { "search": "San Francisco", }, fields: "id,updated_at", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getPaymentsResponse).toBeDefined(); expect(result.getPaymentsResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "payments", operation: "all", data: [ { id: "12345", downstreamId: "12345", currency: "USD", currencyRate: 0.69, totalAmount: 49.99, reference: "123456", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, transactionDate: new Date("2021-05-01T12:00:00.000Z"), customer: { id: "12345", displayId: "CUST00101", displayName: "Windsurf Shop", companyName: "The boring company", email: "boring@boring.com", }, companyId: "12345", reconciled: true, status: "authorised", type: "accounts_receivable", allocations: [ { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, ], note: "Some notes about this transaction", number: "123456", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, ], rowVersion: "1-12345", displayId: "123456", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, { id: "12345", downstreamId: "12345", currency: "USD", currencyRate: 0.69, totalAmount: 49.99, reference: "123456", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, transactionDate: new Date("2021-05-01T12:00:00.000Z"), customer: { id: "12345", displayId: "CUST00101", displayName: "Windsurf Shop", companyName: "The boring company", email: "boring@boring.com", }, companyId: "12345", reconciled: true, status: "authorised", type: "accounts_receivable", allocations: [ { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, ], note: "Some notes about this transaction", number: "123456", trackingCategories: [ { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": "", "1": "", }, }, ], rowVersion: "1-12345", displayId: "123456", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, { id: "12345", downstreamId: "12345", currency: "USD", currencyRate: 0.69, totalAmount: 49.99, reference: "123456", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, transactionDate: new Date("2021-05-01T12:00:00.000Z"), customer: { id: "12345", displayId: "CUST00101", displayName: "Windsurf Shop", companyName: "The boring company", email: "boring@boring.com", }, companyId: "12345", reconciled: true, status: "authorised", type: "accounts_receivable", allocations: [ { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, ], note: "Some notes about this transaction", number: "123456", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, "1": {}, }, }, ], rowVersion: "1-12345", displayId: "123456", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, ], meta: { itemsOnPage: 50, cursors: { previous: "em9oby1jcm06OnBhZ2U6OjE=", current: "em9oby1jcm06OnBhZ2U6OjI=", next: "em9oby1jcm06OnBhZ2U6OjM=", }, }, links: { previous: "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjE%3D", current: "https://unify.apideck.com/crm/companies", next: "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjM", }, }); }); test("Payments Accounting Payments Add", async () => { const testHttpClient = createTestHTTPClient("accounting.paymentsAdd"); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.payments.create({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", payment: { currency: "USD", currencyRate: 0.69, totalAmount: 49.99, reference: "123456", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", nominalCode: "N091", code: "453", }, transactionDate: new Date("2021-05-01T12:00:00.000Z"), customer: { id: "12345", displayName: "Windsurf Shop", email: "boring@boring.com", }, companyId: "12345", reconciled: true, status: "authorised", type: "accounts_receivable", allocations: [ { id: "123456", amount: 49.99, allocationId: "123456", }, { id: "123456", amount: 49.99, allocationId: "123456", }, ], note: "Some notes about this transaction", number: "123456", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", displayId: "123456", passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(201); expect(result.createPaymentResponse).toBeDefined(); expect(result.createPaymentResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "payments", operation: "add", data: { id: "12345", }, }); }); test("Payments Accounting Payments One", async () => { const testHttpClient = createTestHTTPClient("accounting.paymentsOne"); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.payments.get({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", fields: "id,updated_at", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getPaymentResponse).toBeDefined(); expect(result.getPaymentResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "payments", operation: "one", data: { id: "12345", downstreamId: "12345", currency: "USD", currencyRate: 0.69, totalAmount: 49.99, reference: "123456", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, transactionDate: new Date("2021-05-01T12:00:00.000Z"), customer: { id: "12345", displayId: "CUST00101", displayName: "Windsurf Shop", companyName: "The boring company", email: "boring@boring.com", }, companyId: "12345", reconciled: true, status: "authorised", type: "accounts_receivable", allocations: [ { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, ], note: "Some notes about this transaction", number: "123456", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, }, }, ], rowVersion: "1-12345", displayId: "123456", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); }); test("Payments Accounting Payments Update", async () => { const testHttpClient = createTestHTTPClient("accounting.paymentsUpdate"); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.payments.update({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", paymentUpdateInput: { currency: "USD", currencyRate: 0.69, totalAmount: 49.99, reference: "123456", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", nominalCode: "N091", code: "453", }, transactionDate: new Date("2021-05-01T12:00:00.000Z"), customer: { id: "12345", displayName: "Windsurf Shop", email: "boring@boring.com", }, companyId: "12345", reconciled: true, status: "authorised", type: "accounts_receivable", allocations: [ { id: "123456", amount: 49.99, allocationId: "123456", }, { id: "123456", amount: 49.99, allocationId: "123456", }, { id: "123456", amount: 49.99, allocationId: "123456", }, ], note: "Some notes about this transaction", number: "123456", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, "1": {}, }, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, ], rowVersion: "1-12345", displayId: "123456", passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.updatePaymentResponse).toBeDefined(); expect(result.updatePaymentResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "payments", operation: "update", data: { id: "12345", }, }); }); test("Payments Accounting Payments Delete", async () => { const testHttpClient = createTestHTTPClient("accounting.paymentsDelete"); const apideck = new Apideck({ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080", httpClient: testHttpClient, apiKey: process.env["APIDECK_API_KEY"] ?? "value", }); const result = await apideck.accounting.payments.delete({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.deletePaymentResponse).toBeDefined(); expect(result.deletePaymentResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "payments", operation: "delete", data: { id: "12345", }, }); });