/* * 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("Expensereports Accounting Expense Reports All", async () => { const testHttpClient = createTestHTTPClient("accounting.expenseReportsAll"); 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.expenseReports.list({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", fields: "id,updated_at", filter: { updatedSince: new Date("2020-09-30T07:43:32.000Z"), status: "submitted", }, passThrough: { "search": "San Francisco", }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.getExpenseReportsResponse).toBeDefined(); expect(result.getExpenseReportsResponse).toEqual({ statusCode: 200, status: "OK", service: "netsuite", resource: "ExpenseReports", operation: "all", data: [ { id: "12345", displayId: "123456", number: "ER-001", title: "Q1 Business Travel", employee: { id: "12345", displayName: "John Doe", }, status: "submitted", transactionDate: new Date("2021-05-01T12:00:00.000Z"), postingDate: new Date("2024-06-01"), dueDate: new Date("2024-06-15"), currency: "USD", currencyRate: 0.69, subTotal: 250, totalTax: 25, totalAmount: 1250.75, reimbursableAmount: 1100, memo: "Business travel expenses for Q1 client meetings", department: { id: "12345", displayId: "123456", name: "Acme Inc.", downstreamId: "12345", }, location: { id: "123456", displayId: "123456", name: "New York Office", downstreamId: "12345", }, account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, accountingPeriod: { id: "12345", name: "Q1 2024", }, lineItems: [ { id: "12345", lineNumber: 1, expenseCategory: { id: "12345", downstreamId: "12345", displayId: "Airfare", name: "Airfare", }, account: null, description: "Flight to New York", quantity: 1, unitPrice: 27500.5, amount: 275, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, taxAmount: 27.5, totalAmount: 302.5, transactionDate: new Date("2024-05-15"), billable: true, reimbursable: true, customer: { id: "12345", displayId: "CUST00101", displayName: "Windsurf Shop", companyName: "The boring company", email: "boring@boring.com", }, department: { id: "12345", displayId: "123456", name: "Acme Inc.", downstreamId: "12345", }, location: { id: "123456", displayId: "123456", name: "New York Office", downstreamId: "12345", }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], receiptUrl: "https://example.com/receipts/123.pdf", currency: "USD", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), }, ], subsidiary: { id: "12345", displayId: "123456", name: "Acme Inc.", }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], taxInclusive: true, approvedBy: { id: "12345", displayName: "Jane Smith", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], 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", }, }, }, ], }, ], }, ], meta: { itemsOnPage: 50, cursors: { previous: "em9oby1jcm06OnBhZ2U6OjE=", current: "em9oby1jcm06OnBhZ2U6OjI=", next: "em9oby1jcm06OnBhZ2U6OjM=", }, totalCount: 1, warnings: [ { type: "downstream_request_failed", statusCode: 429, operation: "getManager", }, ], }, 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("Expensereports Accounting Expense Reports Add", async () => { const testHttpClient = createTestHTTPClient("accounting.expenseReportsAdd"); 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.expenseReports.create({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", expenseReport: { displayId: "123456", number: "ER-001", title: "Q1 Business Travel", employee: { id: "12345", displayName: "John Doe", }, status: "submitted", transactionDate: new Date("2021-05-01T12:00:00.000Z"), postingDate: new Date("2024-06-01"), dueDate: new Date("2024-06-15"), currency: "USD", currencyRate: 0.69, subTotal: 250, totalTax: 25, totalAmount: 1250.75, reimbursableAmount: 1100, memo: "Business travel expenses for Q1 client meetings", department: { displayId: "123456", name: "Acme Inc.", }, location: { id: "123456", displayId: "123456", name: "New York Office", }, account: null, accountingPeriod: { id: "12345", name: "Q1 2024", }, lineItems: [], reference: "INV-2024-001", subsidiary: { displayId: "123456", name: "Acme Inc.", }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], taxInclusive: true, approvedBy: { id: "12345", displayName: "Jane Smith", }, customFields: [ { 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", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(201); expect(result.createExpenseReportResponse).toBeDefined(); expect(result.createExpenseReportResponse).toEqual({ statusCode: 200, status: "OK", service: "netsuite", resource: "ExpenseReports", operation: "add", data: { id: "12345", }, }); }); test("Expensereports Accounting Expense Reports One", async () => { const testHttpClient = createTestHTTPClient("accounting.expenseReportsOne"); 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.expenseReports.get({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", fields: "id,updated_at", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getExpenseReportResponse).toBeDefined(); expect(result.getExpenseReportResponse).toEqual({ statusCode: 200, status: "OK", service: "netsuite", resource: "ExpenseReports", operation: "one", data: { id: "12345", displayId: "123456", number: "ER-001", title: "Q1 Business Travel", employee: { id: "12345", displayName: "John Doe", }, status: "submitted", transactionDate: new Date("2021-05-01T12:00:00.000Z"), postingDate: new Date("2024-06-01"), dueDate: new Date("2024-06-15"), currency: "USD", currencyRate: 0.69, subTotal: 250, totalTax: 25, totalAmount: 1250.75, reimbursableAmount: 1100, memo: "Business travel expenses for Q1 client meetings", department: { id: "12345", displayId: "123456", name: "Acme Inc.", downstreamId: "12345", }, location: { id: "123456", displayId: "123456", name: "New York Office", downstreamId: "12345", }, account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, accountingPeriod: { id: "12345", name: "Q1 2024", }, lineItems: [ { id: "12345", lineNumber: 1, expenseCategory: { id: "12345", downstreamId: "12345", displayId: "Airfare", name: "Airfare", }, account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, description: "Flight to New York", quantity: 1, unitPrice: 27500.5, amount: 275, taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, taxAmount: 27.5, totalAmount: 302.5, transactionDate: new Date("2024-05-15"), billable: true, reimbursable: true, customer: { id: "12345", displayId: "CUST00101", displayName: "Windsurf Shop", companyName: "The boring company", email: "boring@boring.com", }, department: { id: "12345", displayId: "123456", name: "Acme Inc.", downstreamId: "12345", }, location: null, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], receiptUrl: "https://example.com/receipts/123.pdf", currency: "USD", updatedBy: "12345", createdBy: "12345", updatedAt: new Date("2020-09-30T07:43:32.000Z"), createdAt: new Date("2020-09-30T07:43:32.000Z"), }, ], reference: "INV-2024-001", subsidiary: { id: "12345", displayId: "123456", name: "Acme Inc.", }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], taxInclusive: true, approvedBy: { id: "12345", displayName: "Jane Smith", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], 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", }, }, }, ], }, ], }, meta: { itemsOnPage: 50, cursors: { previous: "em9oby1jcm06OnBhZ2U6OjE=", current: "em9oby1jcm06OnBhZ2U6OjI=", next: "em9oby1jcm06OnBhZ2U6OjM=", }, totalCount: 1, warnings: [ { type: "downstream_request_failed", statusCode: 429, operation: "getManager", }, ], }, }); }); test("Expensereports Accounting Expense Reports Update", async () => { const testHttpClient = createTestHTTPClient( "accounting.expenseReportsUpdate", ); 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.expenseReports.update({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", expenseReportUpdateInput: { displayId: "123456", number: "ER-001", title: "Q1 Business Travel", employee: { id: "12345", displayName: "John Doe", }, status: "submitted", transactionDate: new Date("2021-05-01T12:00:00.000Z"), postingDate: new Date("2024-06-01"), dueDate: new Date("2024-06-15"), currency: "USD", currencyRate: 0.69, subTotal: 250, totalTax: 25, totalAmount: 1250.75, reimbursableAmount: 1100, memo: "Business travel expenses for Q1 client meetings", department: { displayId: "123456", name: "Acme Inc.", }, location: { id: "123456", displayId: "123456", name: "New York Office", }, account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, accountingPeriod: { id: "12345", name: "Q1 2024", }, lineItems: [], reference: "INV-2024-001", subsidiary: { displayId: "123456", name: "Acme Inc.", }, trackingCategories: null, taxInclusive: true, approvedBy: { id: "12345", displayName: "Jane Smith", }, customFields: [ { 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", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.updateExpenseReportResponse).toBeDefined(); expect(result.updateExpenseReportResponse).toEqual({ statusCode: 200, status: "OK", service: "netsuite", resource: "ExpenseReports", operation: "update", data: { id: "12345", }, }); }); test("Expensereports Accounting Expense Reports Delete", async () => { const testHttpClient = createTestHTTPClient( "accounting.expenseReportsDelete", ); 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.expenseReports.delete({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.deleteExpenseReportResponse).toBeDefined(); expect(result.deleteExpenseReportResponse).toEqual({ statusCode: 200, status: "OK", service: "netsuite", resource: "ExpenseReports", operation: "delete", data: { id: "12345", }, }); });