/* * 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("Invoiceitems Accounting Invoice Items All", async () => { const testHttpClient = createTestHTTPClient("accounting.invoiceItemsAll"); 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.invoiceItems.list({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", filter: { name: "Widgets Large", type: "service", }, sort: { by: "updated_at", direction: "desc", }, passThrough: { "search": "San Francisco", }, fields: "id,updated_at", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getInvoiceItemsResponse).toBeDefined(); expect(result.getInvoiceItemsResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "invoice-items", operation: "all", data: [ { id: "123456", name: "Model Y", description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", code: "120-C", sold: true, purchased: true, tracked: true, taxable: true, inventoryDate: new Date("2020-10-30"), type: "inventory", salesDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, }, purchaseDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, }, quantity: 1, unitPrice: 27500.5, assetAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, incomeAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, expenseAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], active: true, departmentId: "12345", locationId: "12345", subsidiaryId: "12345", taxScheduleId: "123456", rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: 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", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, { id: "123456", name: "Model Y", description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", code: "120-C", sold: true, purchased: true, tracked: true, taxable: true, inventoryDate: new Date("2020-10-30"), type: "inventory", salesDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, }, purchaseDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, }, quantity: 1, unitPrice: 27500.5, assetAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, incomeAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, expenseAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], active: true, departmentId: "12345", locationId: "12345", subsidiaryId: "12345", taxScheduleId: "123456", rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: 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", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, { id: "123456", name: "Model Y", description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", code: "120-C", sold: true, purchased: true, tracked: true, taxable: true, inventoryDate: new Date("2020-10-30"), type: "inventory", salesDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, }, purchaseDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, }, quantity: 1, unitPrice: 27500.5, assetAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, incomeAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, expenseAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, trackingCategories: [ { id: "123456", name: "New York", }, ], active: true, departmentId: "12345", locationId: "12345", subsidiaryId: "12345", taxScheduleId: "123456", rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: 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", }, }, }, { 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("Invoiceitems Accounting Invoice Items Add", async () => { const testHttpClient = createTestHTTPClient("accounting.invoiceItemsAdd"); 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.invoiceItems.create({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", invoiceItem: { name: "Model Y", description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", code: "120-C", sold: true, purchased: true, tracked: true, taxable: true, inventoryDate: new Date("2020-10-30"), type: "inventory", salesDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", rate: 10, }, }, purchaseDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", rate: 10, }, }, quantity: 1, unitPrice: 27500.5, assetAccount: { id: "123456", nominalCode: "N091", code: "453", }, incomeAccount: { id: "123456", nominalCode: "N091", code: "453", }, expenseAccount: { id: "123456", nominalCode: "N091", code: "453", }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], active: true, departmentId: "12345", locationId: "12345", subsidiaryId: "12345", taxScheduleId: "123456", rowVersion: "1-12345", 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", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(201); expect(result.createInvoiceItemResponse).toBeDefined(); expect(result.createInvoiceItemResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "invoice-items", operation: "add", data: { id: "12345", }, }); }); test("Invoiceitems Accounting Invoice Items One", async () => { const testHttpClient = createTestHTTPClient("accounting.invoiceItemsOne"); 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.invoiceItems.get({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", fields: "id,updated_at", filter: { type: "service", }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.getInvoiceItemResponse).toBeDefined(); expect(result.getInvoiceItemResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "invoice-items", operation: "one", data: { id: "123456", name: "Model Y", description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", code: "120-C", sold: true, purchased: true, tracked: true, taxable: true, inventoryDate: new Date("2020-10-30"), type: "inventory", salesDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, }, purchaseDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, }, quantity: 1, unitPrice: 27500.5, assetAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, incomeAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, expenseAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], active: true, departmentId: "12345", locationId: "12345", subsidiaryId: "12345", taxScheduleId: "123456", rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: 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", }, }, }, { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); }); test("Invoiceitems Accounting Invoice Items Update", async () => { const testHttpClient = createTestHTTPClient("accounting.invoiceItemsUpdate"); 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.invoiceItems.update({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", invoiceItem: { name: "Model Y", description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", code: "120-C", sold: true, purchased: true, tracked: true, taxable: true, inventoryDate: new Date("2020-10-30"), type: "inventory", salesDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", rate: 10, }, }, purchaseDetails: { unitPrice: 27500.5, unitOfMeasure: "pc.", taxInclusive: true, taxRate: { id: "123456", rate: 10, }, }, quantity: 1, unitPrice: 27500.5, assetAccount: { id: "123456", nominalCode: "N091", code: "453", }, incomeAccount: { id: "123456", nominalCode: "N091", code: "453", }, expenseAccount: { id: "123456", nominalCode: "N091", code: "453", }, trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], active: true, departmentId: "12345", locationId: "12345", subsidiaryId: "12345", taxScheduleId: "123456", rowVersion: "1-12345", 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", }, }, }, { 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.updateInvoiceItemsResponse).toBeDefined(); expect(result.updateInvoiceItemsResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "invoice-items", operation: "update", data: { id: "12345", }, }); }); test("Invoiceitems Accounting Invoice Items Delete", async () => { const testHttpClient = createTestHTTPClient("accounting.invoiceItemsDelete"); 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.invoiceItems.delete({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.deleteTaxRateResponse).toBeDefined(); expect(result.deleteTaxRateResponse).toEqual({ statusCode: 200, status: "OK", service: "xero", resource: "tax-rates", operation: "delete", data: { id: "12345", }, }); });