/* * 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("Expenses Accounting Expenses All", async () => { const testHttpClient = createTestHTTPClient("accounting.expensesAll"); 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.expenses.list({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getExpensesResponse).toBeDefined(); expect(result.getExpensesResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "Expenses", operation: "all", data: [ { id: "12345", number: "OIT00546", transactionDate: new Date("2021-05-01T12:00:00.000Z"), accountId: "123456", supplierId: "12345", companyId: "12345", departmentId: "12345", paymentType: "cash", currency: "USD", currencyRate: 0.69, type: "expense", memo: "For travel expenses incurred on 2024-05-15", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, totalAmount: 275, lineItems: [ { id: "12345", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, description: "Travel US.", totalAmount: 275, }, { id: "12345", trackingCategories: [ { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, description: "Travel US.", totalAmount: 275, }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), 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", }, }, }, ], }, ], }, { id: "12345", number: "OIT00546", transactionDate: new Date("2021-05-01T12:00:00.000Z"), accountId: "123456", supplierId: "12345", companyId: "12345", departmentId: "12345", paymentType: "cash", currency: "USD", currencyRate: 0.69, type: "expense", memo: "For travel expenses incurred on 2024-05-15", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, totalAmount: 275, lineItems: [ { id: "12345", trackingCategories: [ { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, description: "Travel US.", totalAmount: 275, }, { id: "12345", trackingCategories: [ { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, description: "Travel US.", totalAmount: 275, }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), 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", }, }, }, ], }, ], }, { id: "12345", number: "OIT00546", transactionDate: new Date("2021-05-01T12:00:00.000Z"), accountId: "123456", supplierId: "12345", companyId: "12345", departmentId: "12345", paymentType: "cash", currency: "USD", currencyRate: 0.69, type: "expense", memo: "For travel expenses incurred on 2024-05-15", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, totalAmount: 275, lineItems: [ { id: "12345", trackingCategories: [ { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, description: "Travel US.", totalAmount: 275, }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, }, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), 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", }, }, }, { 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("Expenses Accounting Expenses Add", async () => { const testHttpClient = createTestHTTPClient("accounting.expensesAdd"); 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.expenses.create({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", expense: { number: "OIT00546", transactionDate: new Date("2021-05-01T12:00:00.000Z"), accountId: "123456", supplierId: "12345", companyId: "12345", departmentId: "12345", paymentType: "cash", currency: "USD", currencyRate: 0.69, type: "expense", memo: "For travel expenses incurred on 2024-05-15", taxRate: { id: "123456", rate: 10, }, totalAmount: 275, lineItems: [ { trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", rate: 10, }, description: "Travel US.", totalAmount: 275, }, ], 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", 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.createExpenseResponse).toBeDefined(); expect(result.createExpenseResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "Expenses", operation: "add", data: { id: "12345", }, }); }); test("Expenses Accounting Expenses One", async () => { const testHttpClient = createTestHTTPClient("accounting.expensesOne"); 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.expenses.get({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getExpenseResponse).toBeDefined(); expect(result.getExpenseResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "Expenses", operation: "one", data: { id: "12345", number: "OIT00546", transactionDate: new Date("2021-05-01T12:00:00.000Z"), accountId: "123456", supplierId: "12345", companyId: "12345", departmentId: "12345", paymentType: "cash", currency: "USD", currencyRate: 0.69, type: "expense", memo: "For travel expenses incurred on 2024-05-15", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, totalAmount: 275, lineItems: [ { id: "12345", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, description: "Travel US.", totalAmount: 275, }, { id: "12345", trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, description: "Travel US.", totalAmount: 275, }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, }, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, ], updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), rowVersion: "1-12345", passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); }); test("Expenses Accounting Expenses Update", async () => { const testHttpClient = createTestHTTPClient("accounting.expensesUpdate"); 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.expenses.update({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", expenseUpdateInput: { number: "OIT00546", transactionDate: new Date("2021-05-01T12:00:00.000Z"), accountId: "123456", supplierId: "12345", companyId: "12345", departmentId: "12345", paymentType: "cash", currency: "USD", currencyRate: 0.69, type: "expense", memo: "For travel expenses incurred on 2024-05-15", taxRate: { id: "123456", rate: 10, }, totalAmount: 275, lineItems: [ { trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", rate: 10, }, description: "Travel US.", totalAmount: 275, }, { trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", rate: 10, }, description: "Travel US.", totalAmount: 275, }, { trackingCategories: [ { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, { id: "123456", name: "New York", }, ], accountId: "123456", customerId: "12345", departmentId: "12345", locationId: "12345", taxRate: { id: "123456", rate: 10, }, description: "Travel US.", totalAmount: 275, }, ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, ], 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", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.updateExpenseResponse).toBeDefined(); expect(result.updateExpenseResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "Expenses", operation: "update", data: { id: "12345", }, }); }); test("Expenses Accounting Expenses Delete", async () => { const testHttpClient = createTestHTTPClient("accounting.expensesDelete"); 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.expenses.delete({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.deleteExpenseResponse).toBeDefined(); expect(result.deleteExpenseResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "Expenses", operation: "delete", data: { id: "12345", }, }); });