/* * 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("Opportunities Crm Opportunities All", async () => { const testHttpClient = createTestHTTPClient("crm.opportunitiesAll"); 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.crm.opportunities.list({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", filter: { status: "Completed", monetaryAmount: 75000, }, sort: { by: "created_at", direction: "desc", }, passThrough: { "search": "San Francisco", }, fields: "id,updated_at", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getOpportunitiesResponse).toBeDefined(); expect(result.getOpportunitiesResponse).toEqual({ statusCode: 200, status: "OK", service: "zoho-crm", resource: "opportunities", operation: "all", data: [ { id: "12345", title: "New Rocket", primaryContactId: "12345", description: "Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines.", type: "Existing Customer - Upgrade", monetaryAmount: 75000, currency: "USD", winProbability: 40, expectedRevenue: 75000, closeDate: new Date("2020-10-30"), lossReasonId: "12345", lossReason: "No budget", wonReasonId: "12345", wonReason: "Best pitch", pipelineId: "12345", pipelineStageId: "12345", sourceId: "12345", leadId: "12345", leadSource: "Website", contactId: "12345", contactIds: [ "12345", ], companyId: "12345", companyName: "Copper", ownerId: "12345", priority: "None", status: "Open", statusId: "12345", tags: [ "New", ], interactionCount: 0, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: 10, }, ], stageLastChangedAt: new Date("2020-09-30T07:43:32.000Z"), lastActivityAt: "2020-09-30T07:43:32.000Z", deleted: false, dateStageChanged: new Date("2020-09-30T00:00:00.000Z"), dateLastContacted: new Date("2020-09-30T00:00:00.000Z"), dateLeadCreated: new Date("2020-09-30T00:00:00.000Z"), 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", }, }, }, ], }, ], }, { id: "12345", title: "New Rocket", primaryContactId: "12345", description: "Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines.", type: "Existing Customer - Upgrade", monetaryAmount: 75000, currency: "USD", winProbability: 40, expectedRevenue: 75000, closeDate: new Date("2020-10-30"), lossReasonId: "12345", lossReason: "No budget", wonReasonId: "12345", wonReason: "Best pitch", pipelineId: "12345", pipelineStageId: "12345", sourceId: "12345", leadId: "12345", leadSource: "Website", contactId: "12345", contactIds: [ "12345", ], companyId: "12345", companyName: "Copper", ownerId: "12345", priority: "None", status: "Open", statusId: "12345", tags: [ "New", ], interactionCount: 0, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, ], stageLastChangedAt: new Date("2020-09-30T07:43:32.000Z"), lastActivityAt: "2020-09-30T07:43:32.000Z", deleted: false, dateStageChanged: new Date("2020-09-30T00:00:00.000Z"), dateLastContacted: new Date("2020-09-30T00:00:00.000Z"), dateLeadCreated: new Date("2020-09-30T00:00:00.000Z"), 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", }, }, }, ], }, ], }, { id: "12345", title: "New Rocket", primaryContactId: "12345", description: "Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines.", type: "Existing Customer - Upgrade", monetaryAmount: 75000, currency: "USD", winProbability: 40, expectedRevenue: 75000, closeDate: new Date("2020-10-30"), lossReasonId: "12345", lossReason: "No budget", wonReasonId: "12345", wonReason: "Best pitch", pipelineId: "12345", pipelineStageId: "12345", sourceId: "12345", leadId: "12345", leadSource: "Website", contactId: "12345", contactIds: [ "12345", ], companyId: "12345", companyName: "Copper", ownerId: "12345", priority: "None", status: "Open", statusId: "12345", tags: [ "New", ], interactionCount: 0, customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: "Uses Salesforce and Marketo", }, ], stageLastChangedAt: new Date("2020-09-30T07:43:32.000Z"), lastActivityAt: "2020-09-30T07:43:32.000Z", deleted: false, dateStageChanged: new Date("2020-09-30T00:00:00.000Z"), dateLastContacted: new Date("2020-09-30T00:00:00.000Z"), dateLeadCreated: new Date("2020-09-30T00:00:00.000Z"), 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", }, }, }, ], }, ], }, ], 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("Opportunities Crm Opportunities Add", async () => { const testHttpClient = createTestHTTPClient("crm.opportunitiesAdd"); 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.crm.opportunities.create({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", opportunity: { title: "New Rocket", primaryContactId: "12345", description: "Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines.", type: "Existing Customer - Upgrade", monetaryAmount: 75000, currency: "USD", winProbability: 40, closeDate: new Date("2020-10-30"), lossReasonId: "12345", lossReason: "No budget", wonReasonId: "12345", wonReason: "Best pitch", pipelineId: "12345", pipelineStageId: "12345", sourceId: "12345", leadId: "12345", leadSource: "Website", contactId: "12345", contactIds: [ "12345", ], companyId: "12345", companyName: "Copper", ownerId: "12345", priority: "None", status: "Open", statusId: "12345", tags: [ "New", ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, ], stageLastChangedAt: new Date("2020-09-30T07:43:32.000Z"), passThrough: [ { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(201); expect(result.createOpportunityResponse).toBeDefined(); expect(result.createOpportunityResponse).toEqual({ statusCode: 200, status: "OK", service: "zoho-crm", resource: "opportunities", operation: "add", data: { id: "12345", }, }); }); test("Opportunities Crm Opportunities One", async () => { const testHttpClient = createTestHTTPClient("crm.opportunitiesOne"); 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.crm.opportunities.get({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", fields: "id,updated_at", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getOpportunityResponse).toBeDefined(); expect(result.getOpportunityResponse).toEqual({ statusCode: 200, status: "OK", service: "zoho-crm", resource: "opportunities", operation: "one", data: { id: "12345", title: "New Rocket", primaryContactId: "12345", description: "Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines.", type: "Existing Customer - Upgrade", monetaryAmount: 75000, currency: "USD", winProbability: 40, expectedRevenue: 75000, closeDate: new Date("2020-10-30"), lossReasonId: "12345", lossReason: "No budget", wonReasonId: "12345", wonReason: "Best pitch", pipelineId: "12345", pipelineStageId: "12345", sourceId: "12345", leadId: "12345", leadSource: "Website", contactId: "12345", contactIds: [ "12345", ], companyId: "12345", companyName: "Copper", ownerId: "12345", priority: "None", status: "Open", statusId: "12345", tags: [ "New", ], interactionCount: 0, 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: {}, }, ], stageLastChangedAt: new Date("2020-09-30T07:43:32.000Z"), lastActivityAt: "2020-09-30T07:43:32.000Z", deleted: false, dateStageChanged: new Date("2020-09-30T00:00:00.000Z"), dateLastContacted: new Date("2020-09-30T00:00:00.000Z"), dateLeadCreated: new Date("2020-09-30T00:00:00.000Z"), 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", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); }); test("Opportunities Crm Opportunities Update", async () => { const testHttpClient = createTestHTTPClient("crm.opportunitiesUpdate"); 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.crm.opportunities.update({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", opportunity: { title: "New Rocket", primaryContactId: "12345", description: "Opportunities are created for People and Companies that are interested in buying your products or services. Create Opportunities for People and Companies to move them through one of your Pipelines.", type: "Existing Customer - Upgrade", monetaryAmount: 75000, currency: "USD", winProbability: 40, closeDate: new Date("2020-10-30"), lossReasonId: "12345", lossReason: "No budget", wonReasonId: "12345", wonReason: "Best pitch", pipelineId: "12345", pipelineStageId: "12345", sourceId: "12345", leadId: "12345", leadSource: "Website", contactId: "12345", contactIds: [ "12345", ], companyId: "12345", companyName: "Copper", ownerId: "12345", priority: "None", status: "Open", statusId: "12345", tags: [ "New", ], customFields: [ { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: {}, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: true, }, { id: "2389328923893298", name: "employee_level", description: "Employee Level", value: { "0": {}, "1": {}, }, }, ], stageLastChangedAt: 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", }, }, }, ], }, { serviceId: "", extendPaths: [ { path: "$.nested.property", value: { "TaxClassificationRef": { "value": "EUC-99990201-V1-00020000", }, }, }, ], }, ], }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.updateOpportunityResponse).toBeDefined(); expect(result.updateOpportunityResponse).toEqual({ statusCode: 200, status: "OK", service: "zoho-crm", resource: "companies", operation: "update", data: { id: "12345", }, }); }); test("Opportunities Crm Opportunities Delete", async () => { const testHttpClient = createTestHTTPClient("crm.opportunitiesDelete"); 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.crm.opportunities.delete({ id: "", consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "salesforce", }); expect(result.httpMeta.response.status).toBe(200); expect(result.deleteOpportunityResponse).toBeDefined(); expect(result.deleteOpportunityResponse).toEqual({ statusCode: 200, status: "OK", service: "zoho-crm", resource: "companies", operation: "delete", data: { id: "12345", }, }); });