/* * 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("Connectionsettings Vault Connection Settings All", async () => { const testHttpClient = createTestHTTPClient("vault.connectionSettingsAll"); 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.vault.connectionSettings.list({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", unifiedApi: "crm", serviceId: "pipedrive", resource: "leads", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getConnectionResponse).toBeDefined(); expect(result.getConnectionResponse).toEqual({ statusCode: 200, status: "OK", data: { id: "crm+salesforce", serviceId: "salesforce", name: "Salesforce", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", unifiedApi: "crm", state: "authorized", integrationState: "configured", authType: "oauth2", oauthGrantType: "authorization_code", enabled: true, website: "https://www.salesforce.com", icon: "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png", logo: "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg", authorizeUrl: "https://unify.apideck.com/vault/authorize/salesforce/?state=", revokeUrl: "https://unify.apideck.com/vault/revoke/salesforce/?state=", settings: { "instance_url": "https://eu28.salesforce.com", "api_key": "12345xxxxxx", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, formFields: [ { id: "instance_url", label: "Instance url", placeholder: "", type: "text", required: true, customField: false, allowCustomValues: false, disabled: false, sensitive: false, }, { id: "api_key", label: "API Key", placeholder: "", type: "text", required: true, customField: false, allowCustomValues: false, disabled: false, sensitive: true, }, ], configuration: [ { resource: "leads", defaults: [ { target: "custom_fields", id: "ProductInterest", options: [ { label: "General Channel", value: 123, optionType: "simple", }, { label: "General Channel", value: true, optionType: "simple", }, { id: "1234", label: "General Channel", options: [], optionType: "group", }, ], value: true, }, { target: "custom_fields", id: "ProductInterest", options: [ { label: "General Channel", value: true, optionType: "simple", }, ], value: 10.5, }, ], }, { resource: "leads", defaults: [ { target: "custom_fields", id: "ProductInterest", options: [ { label: "General Channel", value: 123, optionType: "simple", }, ], value: 10.5, }, { target: "custom_fields", id: "ProductInterest", options: [ { id: "1234", label: "General Channel", options: [ { label: "General Channel", value: [ "team", "general", ], optionType: "simple", }, { label: "General Channel", value: 12.5, optionType: "simple", }, ], optionType: "group", }, ], value: "GC5000 series", }, ], }, { resource: "leads", defaults: [ { target: "custom_fields", id: "ProductInterest", options: [ { label: "General Channel", value: [ "team", "general", ], optionType: "simple", }, { label: "General Channel", value: [ "team", "general", ], optionType: "simple", }, { label: "General Channel", value: "general", optionType: "simple", }, ], value: [], }, ], }, ], configurableResources: [ "opportunities", "companies", "contacts", "leads", ], resourceSchemaSupport: [ "leads", ], resourceSettingsSupport: [ "leads", ], settingsRequiredForAuthorization: [ "client_id", "client_secret", ], subscriptions: [ { downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f", unifyEventTypes: [ "crm.contact.created", ], downstreamEventTypes: [ "contacts.CREATED", ], executeUrl: "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}", createdAt: "2020-10-01T12:00:00.000Z", }, { downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f", unifyEventTypes: [ "crm.contact.created", ], downstreamEventTypes: [ "contacts.CREATED", ], executeUrl: "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}", createdAt: "2020-10-01T12:00:00.000Z", }, ], hasGuide: true, customMappings: [ { id: "hris+employees+first_aid_training", label: "First Aid Training", description: "First Aid Training completed after 2019-01-01", value: "$.root.training.first_aid", key: "first_aid_training", required: false, customField: true, consumerId: "test_user_id", example: "Some value", }, { id: "hris+employees+first_aid_training", label: "First Aid Training", description: "First Aid Training completed after 2019-01-01", value: "$.root.training.first_aid", key: "first_aid_training", required: false, customField: true, consumerId: "test_user_id", example: "Some value", }, ], createdAt: 1615563533390, updatedAt: 1616662325753, }, }); }); test("Connectionsettings Vault Connection Settings Update", async () => { const testHttpClient = createTestHTTPClient("vault.connectionSettingsUpdate"); 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.vault.connectionSettings.update({ consumerId: "test-consumer", appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", serviceId: "pipedrive", unifiedApi: "crm", resource: "leads", connection: { enabled: true, settings: { "api_key": "12345xxxxxx", "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "id": "c01458a5-7276-41ce-bc19-639906b0450a", "name": "My Company", }, "plan": "enterprise", }, }, configuration: [ { resource: "leads", defaults: [ { id: "ProductInterest", options: [ { id: "1234", label: "General Channel", options: [ { label: "General Channel", value: 12.5, optionType: "simple", }, { label: "General Channel", value: [ "team", "general", ], optionType: "simple", }, ], optionType: "group", }, { label: "General Channel", value: [ "team", "general", ], optionType: "simple", }, ], value: 10.5, }, { id: "ProductInterest", options: [ { label: "General Channel", value: "general", optionType: "simple", }, ], value: true, }, ], }, { resource: "leads", defaults: [ { id: "ProductInterest", options: [ { label: "General Channel", value: true, optionType: "simple", }, ], value: true, }, { id: "ProductInterest", options: [ { label: "General Channel", value: true, optionType: "simple", }, { id: "1234", label: "General Channel", options: [ { label: "General Channel", value: 12.5, optionType: "simple", }, ], optionType: "group", }, ], value: "GC5000 series", }, { id: "ProductInterest", options: [ { label: "General Channel", value: [ "team", "general", ], optionType: "simple", }, ], value: [ 10.5, 10, "GC6000 series", ], }, ], }, { resource: "leads", defaults: [ { id: "ProductInterest", options: [ { id: "1234", label: "General Channel", options: [ { label: "General Channel", value: "general", optionType: "simple", }, { label: "General Channel", value: "general", optionType: "simple", }, { label: "General Channel", value: 123, optionType: "simple", }, ], optionType: "group", }, { id: "1234", label: "General Channel", options: [], optionType: "group", }, ], value: true, }, { id: "ProductInterest", options: [ { label: "General Channel", value: "general", optionType: "simple", }, ], value: true, }, ], }, ], customMappings: [ { value: "$.root.training.first_aid", }, { value: "$.root.training.first_aid", }, ], }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.updateConnectionResponse).toBeDefined(); expect(result.updateConnectionResponse).toEqual({ statusCode: 200, status: "OK", data: { id: "crm+salesforce", serviceId: "salesforce", name: "Salesforce", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", unifiedApi: "crm", state: "authorized", integrationState: "configured", authType: "oauth2", oauthGrantType: "authorization_code", enabled: true, website: "https://www.salesforce.com", icon: "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png", logo: "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg", authorizeUrl: "https://unify.apideck.com/vault/authorize/salesforce/?state=", revokeUrl: "https://unify.apideck.com/vault/revoke/salesforce/?state=", settings: { "instance_url": "https://eu28.salesforce.com", "api_key": "12345xxxxxx", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, formFields: [ { id: "instance_url", label: "Instance url", placeholder: "", type: "text", required: true, customField: false, allowCustomValues: false, disabled: false, sensitive: false, }, { id: "api_key", label: "API Key", placeholder: "", type: "text", required: true, customField: false, allowCustomValues: false, disabled: false, sensitive: true, }, ], configuration: [ { resource: "leads", defaults: [ { target: "custom_fields", id: "ProductInterest", options: [ { id: "1234", label: "General Channel", options: [ { label: "General Channel", value: 12.5, optionType: "simple", }, { label: "General Channel", value: 123, optionType: "simple", }, { label: "General Channel", value: 123, optionType: "simple", }, ], optionType: "group", }, ], value: 10.5, }, { target: "custom_fields", id: "ProductInterest", options: [ { id: "1234", label: "General Channel", options: [ { label: "General Channel", value: true, optionType: "simple", }, { label: "General Channel", value: 123, optionType: "simple", }, { label: "General Channel", value: true, optionType: "simple", }, ], optionType: "group", }, { label: "General Channel", value: 123, optionType: "simple", }, { label: "General Channel", value: 123, optionType: "simple", }, ], value: true, }, ], }, { resource: "leads", defaults: [ { target: "custom_fields", id: "ProductInterest", options: [ { label: "General Channel", value: "general", optionType: "simple", }, ], value: 10.5, }, ], }, ], configurableResources: [ "opportunities", "companies", "contacts", "leads", ], resourceSchemaSupport: [ "leads", ], resourceSettingsSupport: [ "leads", ], settingsRequiredForAuthorization: [ "client_id", "client_secret", ], subscriptions: [ { downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f", unifyEventTypes: [ "crm.contact.created", ], downstreamEventTypes: [ "contacts.CREATED", ], executeUrl: "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}", createdAt: "2020-10-01T12:00:00.000Z", }, ], hasGuide: true, customMappings: [ { id: "hris+employees+first_aid_training", label: "First Aid Training", description: "First Aid Training completed after 2019-01-01", value: "$.root.training.first_aid", key: "first_aid_training", required: false, customField: true, consumerId: "test_user_id", example: "Some value", }, { id: "hris+employees+first_aid_training", label: "First Aid Training", description: "First Aid Training completed after 2019-01-01", value: "$.root.training.first_aid", key: "first_aid_training", required: false, customField: true, consumerId: "test_user_id", example: "Some value", }, ], createdAt: 1615563533390, updatedAt: 1616662325753, }, }); });