/* * 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("Refunds Accounting Refunds All", async () => { const testHttpClient = createTestHTTPClient("accounting.refundsAll"); 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.refunds.list({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", filter: { updatedSince: new Date("2020-09-30T07:43:32.000Z"), customerId: "123abc", }, sort: { by: "updated_at", direction: "desc", }, passThrough: { "search": "San Francisco", }, fields: "id,updated_at", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getRefundsResponse).toBeDefined(); expect(result.getRefundsResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "refunds", operation: "all", data: [], 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("Refunds Accounting Refunds Add", async () => { const testHttpClient = createTestHTTPClient("accounting.refundsAdd"); 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.refunds.create({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", refund: { number: "RF-00001", customer: null, companyId: "12345", currency: "USD", currencyRate: 0.69, taxInclusive: true, subTotal: 250, totalAmount: 49.99, totalTax: 25, refundDate: new Date("2021-05-01T12:00:00.000Z"), status: "paid", type: "refund_receipt", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, serviceDate: new Date("2024-01-15"), categoryId: "12345", locationId: "12345", departmentId: "12345", subsidiaryId: "12345", shippingId: "12345", memo: "Some memo", prepaid: true, item: { id: "12344", code: "120-C", name: "Model Y", }, taxApplicableOn: "Domestic_Purchase_of_Goods_and_Services", taxRecoverability: "Fully_Recoverable", taxMethod: "Due_to_Supplier", worktags: [ { id: "123456", value: "New York", }, ], taxRate: { id: "123456", code: "N-T", rate: 10, }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", }, ], allocations: [ { id: "123456", amount: 49.99, allocationId: "123456", }, ], taxCode: "1234", discountPercentage: 5.5, discountAmount: 25, note: "Refund for returned items", customerMemo: "Thank you for your business and have a great day!", reference: "REF-123456", billingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", line5: "Attention: Finance Dept", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", line5: "Attention: Finance Dept", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, department: { displayId: "123456", name: "Acme Inc.", }, location: { id: "123456", displayId: "123456", name: "New York Office", }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], 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.createRefundResponse).toBeDefined(); expect(result.createRefundResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "refunds", operation: "add", data: { id: "12345", }, }); }); test("Refunds Accounting Refunds One", async () => { const testHttpClient = createTestHTTPClient("accounting.refundsOne"); 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.refunds.get({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", fields: "id,updated_at", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getRefundResponse).toBeDefined(); expect(result.getRefundResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "refunds", operation: "one", data: { id: "123456", number: "RF-00001", customer: { id: "12345", displayId: "CUST00101", displayName: "Windsurf Shop", companyName: "The boring company", email: "boring@boring.com", }, companyId: "12345", currency: "USD", currencyRate: 0.69, taxInclusive: true, subTotal: 250, totalAmount: 49.99, totalTax: 25, refundDate: new Date("2021-05-01T12:00:00.000Z"), status: "paid", type: "refund_receipt", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, serviceDate: new Date("2024-01-15"), categoryId: "12345", locationId: "12345", departmentId: "12345", subsidiaryId: "12345", shippingId: "12345", memo: "Some memo", prepaid: true, item: { id: "12344", code: "120-C", name: "Model Y", }, taxApplicableOn: "Domestic_Purchase_of_Goods_and_Services", taxRecoverability: "Fully_Recoverable", taxMethod: "Due_to_Supplier", worktags: [ { id: "123456", value: "New York", }, ], taxRate: { id: "123456", code: "N-T", name: "GST on Purchases", rate: 10, }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", updatedBy: "12345", createdBy: "12345", createdAt: new Date("2020-09-30T07:43:32.000Z"), updatedAt: new Date("2020-09-30T07:43:32.000Z"), }, ], allocations: [ { id: "123456", code: "N091", amount: 49.99, allocationId: "123456", }, ], taxCode: "1234", discountPercentage: 5.5, discountAmount: 25, note: "Refund for returned items", customerMemo: "Thank you for your business and have a great day!", reference: "REF-123456", billingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", line5: "Attention: Finance Dept", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", line5: "Attention: Finance Dept", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, 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", }, ], 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("Refunds Accounting Refunds Update", async () => { const testHttpClient = createTestHTTPClient("accounting.refundsUpdate"); 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.refunds.update({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", refundUpdateInput: { number: "RF-00001", customer: { id: "12345", displayName: "Windsurf Shop", email: "boring@boring.com", }, companyId: "12345", currency: "USD", currencyRate: 0.69, taxInclusive: true, subTotal: 250, totalAmount: 49.99, totalTax: 25, refundDate: new Date("2021-05-01T12:00:00.000Z"), status: "paid", type: "refund_receipt", paymentMethod: "cash", paymentMethodReference: "123456", paymentMethodId: "12345", account: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, lineItems: [ { id: "12345", rowId: "12345", code: "120-C", lineNumber: 1, description: "Model Y is a fully electric, mid-size SUV, with seating for up to seven, dual motor AWD and unparalleled protection.", type: "sales_item", taxAmount: 27500, totalAmount: 27500, quantity: 1, unitPrice: 27500.5, unitOfMeasure: "pc.", discountPercentage: 0.01, discountAmount: 19.99, serviceDate: new Date("2024-01-15"), categoryId: "12345", locationId: "12345", departmentId: "12345", subsidiaryId: "12345", shippingId: "12345", memo: "Some memo", prepaid: true, item: { id: "12344", code: "120-C", name: "Model Y", }, taxApplicableOn: "Domestic_Purchase_of_Goods_and_Services", taxRecoverability: "Fully_Recoverable", taxMethod: "Due_to_Supplier", worktags: [ { id: "123456", value: "New York", }, ], taxRate: { id: "123456", code: "N-T", rate: 10, }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], ledgerAccount: { id: "123456", name: "Bank account", nominalCode: "N091", code: "453", parentId: "123456", displayId: "123456", }, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], rowVersion: "1-12345", }, ], allocations: [ { id: "123456", amount: 49.99, allocationId: "123456", }, ], taxCode: "1234", discountPercentage: 5.5, discountAmount: 25, note: "Refund for returned items", customerMemo: "Thank you for your business and have a great day!", reference: "REF-123456", billingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", line5: "Attention: Finance Dept", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, shippingAddress: { id: "123", type: "primary", string: "25 Spring Street, Blackburn, VIC 3130", name: "HQ US", line1: "Main street", line2: "apt #", line3: "Suite #", line4: "delivery instructions", line5: "Attention: Finance Dept", streetNumber: "25", city: "San Francisco", state: "CA", postalCode: "94104", country: "US", latitude: "40.759211", longitude: "-73.984638", county: "Santa Clara", contactName: "Elon Musk", salutation: "Mr", phoneNumber: "111-111-1111", fax: "122-111-1111", email: "elon@musk.com", website: "https://elonmusk.com", notes: "Address notes or delivery instructions.", rowVersion: "1-12345", }, department: { displayId: "123456", name: "Acme Inc.", }, location: { id: "123456", displayId: "123456", name: "New York Office", }, trackingCategories: [ { id: "123456", code: "100", name: "New York", parentId: "123456", parentName: "New York", }, ], 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.updateRefundResponse).toBeDefined(); expect(result.updateRefundResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "refunds", operation: "update", data: { id: "12345", }, }); }); test("Refunds Accounting Refunds Delete", async () => { const testHttpClient = createTestHTTPClient("accounting.refundsDelete"); 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.refunds.delete({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.deleteRefundResponse).toBeDefined(); expect(result.deleteRefundResponse).toEqual({ statusCode: 200, status: "OK", service: "quickbooks", resource: "refunds", operation: "delete", data: { id: "12345", }, }); });