/* * 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("Consumers Vault Consumers Add", async () => { const testHttpClient = createTestHTTPClient("vault.consumersAdd"); 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.consumers.create({ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", createConsumerRequest: { consumerId: "test_consumer_id", metadata: { accountName: "SpaceX", userName: "Elon Musk", email: "elon@musk.com", image: "https://www.spacex.com/static/images/share.jpg", }, }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.createConsumerResponse).toBeDefined(); expect(result.createConsumerResponse).toEqual({ statusCode: 200, status: "OK", data: { consumerId: "test_consumer_id", applicationId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", metadata: { accountName: "SpaceX", userName: "Elon Musk", email: "elon@musk.com", image: "https://www.spacex.com/static/images/share.jpg", }, connections: [ { id: "1111+test_user_id", name: "Salesforce", 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", website: "https://www.salesforce.com", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", serviceId: "teamleader", unifiedApi: "crm", consumerId: "test_user_id", authType: "oauth2", enabled: true, settings: { "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, createdAt: "2020-09-19T12:18:37.071Z", updatedAt: "2020-09-19T12:18:37.071Z", state: "authorized", }, { id: "1111+test_user_id", name: "Salesforce", 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", website: "https://www.salesforce.com", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", serviceId: "teamleader", unifiedApi: "crm", consumerId: "test_user_id", authType: "oauth2", enabled: true, settings: { "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, createdAt: "2020-09-19T12:18:37.071Z", updatedAt: "2020-09-19T12:18:37.071Z", state: "authorized", }, ], services: [ "salesforce", "stripe", ], aggregatedRequestCount: 101, requestCounts: { unify: 100, proxy: 10, vault: 21, }, created: "2021-05-07T12:55:42.242Z", modified: "2021-05-07T12:55:42.242Z", requestCountUpdated: "2021-05-07T12:55:42.242Z", }, }); }); test("Consumers Vault Consumers All", async () => { const testHttpClient = createTestHTTPClient("vault.consumersAll"); 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.consumers.list({ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getConsumersResponse).toBeDefined(); expect(result.getConsumersResponse).toEqual({ statusCode: 200, status: "OK", data: [ { consumerId: "test_consumer_id", applicationId: "1111", metadata: { accountName: "SpaceX", userName: "Elon Musk", email: "elon@musk.com", image: "https://www.spacex.com/static/images/share.jpg", }, aggregatedRequestCount: 101, requestCounts: { unify: 100, proxy: 10, vault: 21, }, created: "2021-05-07T12:55:42.242Z", modified: "2021-05-07T12:55:42.242Z", requestCountUpdated: "2021-05-07T12:55:42.242Z", services: [ "salesforce", "stripe", ], }, { consumerId: "test_consumer_id", applicationId: "1111", metadata: { accountName: "SpaceX", userName: "Elon Musk", email: "elon@musk.com", image: "https://www.spacex.com/static/images/share.jpg", }, aggregatedRequestCount: 101, requestCounts: { unify: 100, proxy: 10, vault: 21, }, created: "2021-05-07T12:55:42.242Z", modified: "2021-05-07T12:55:42.242Z", requestCountUpdated: "2021-05-07T12:55:42.242Z", services: [ "salesforce", "stripe", ], }, { consumerId: "test_consumer_id", applicationId: "1111", metadata: { accountName: "SpaceX", userName: "Elon Musk", email: "elon@musk.com", image: "https://www.spacex.com/static/images/share.jpg", }, aggregatedRequestCount: 101, requestCounts: { unify: 100, proxy: 10, vault: 21, }, created: "2021-05-07T12:55:42.242Z", modified: "2021-05-07T12:55:42.242Z", requestCountUpdated: "2021-05-07T12:55:42.242Z", services: [ "salesforce", "stripe", ], }, ], 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("Consumers Vault Consumers One", async () => { const testHttpClient = createTestHTTPClient("vault.consumersOne"); 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.consumers.get({ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", consumerId: "test_user_id", }); expect(result.httpMeta.response.status).toBe(200); expect(result.getConsumerResponse).toBeDefined(); expect(result.getConsumerResponse).toEqual({ statusCode: 200, status: "OK", data: { consumerId: "test_consumer_id", applicationId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", metadata: { accountName: "SpaceX", userName: "Elon Musk", email: "elon@musk.com", image: "https://www.spacex.com/static/images/share.jpg", }, connections: [ { id: "1111+test_user_id", name: "Salesforce", 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", website: "https://www.salesforce.com", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", serviceId: "teamleader", unifiedApi: "crm", consumerId: "test_user_id", authType: "oauth2", enabled: true, settings: { "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, createdAt: "2020-09-19T12:18:37.071Z", updatedAt: "2020-09-19T12:18:37.071Z", state: "authorized", }, { id: "1111+test_user_id", name: "Salesforce", 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", website: "https://www.salesforce.com", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", serviceId: "teamleader", unifiedApi: "crm", consumerId: "test_user_id", authType: "oauth2", enabled: true, settings: { "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, createdAt: "2020-09-19T12:18:37.071Z", updatedAt: "2020-09-19T12:18:37.071Z", state: "authorized", }, { id: "1111+test_user_id", name: "Salesforce", 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", website: "https://www.salesforce.com", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", serviceId: "teamleader", unifiedApi: "crm", consumerId: "test_user_id", authType: "oauth2", enabled: true, settings: { "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, createdAt: "2020-09-19T12:18:37.071Z", updatedAt: "2020-09-19T12:18:37.071Z", state: "authorized", }, ], services: [ "salesforce", "stripe", ], aggregatedRequestCount: 101, requestCounts: { unify: 100, proxy: 10, vault: 21, }, created: "2021-05-07T12:55:42.242Z", modified: "2021-05-07T12:55:42.242Z", requestCountUpdated: "2021-05-07T12:55:42.242Z", }, }); }); test("Consumers Vault Consumers Update", async () => { const testHttpClient = createTestHTTPClient("vault.consumersUpdate"); 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.consumers.update({ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", consumerId: "test_user_id", updateConsumerRequest: { metadata: { accountName: "SpaceX", userName: "Elon Musk", email: "elon@musk.com", image: "https://www.spacex.com/static/images/share.jpg", }, }, }); expect(result.httpMeta.response.status).toBe(200); expect(result.updateConsumerResponse).toBeDefined(); expect(result.updateConsumerResponse).toEqual({ statusCode: 200, status: "OK", data: { consumerId: "test_consumer_id", applicationId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", metadata: { accountName: "SpaceX", userName: "Elon Musk", email: "elon@musk.com", image: "https://www.spacex.com/static/images/share.jpg", }, connections: [ { id: "1111+test_user_id", name: "Salesforce", 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", website: "https://www.salesforce.com", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", serviceId: "teamleader", unifiedApi: "crm", consumerId: "test_user_id", authType: "oauth2", enabled: true, settings: { "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, createdAt: "2020-09-19T12:18:37.071Z", updatedAt: "2020-09-19T12:18:37.071Z", state: "authorized", }, { id: "1111+test_user_id", name: "Salesforce", 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", website: "https://www.salesforce.com", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", serviceId: "teamleader", unifiedApi: "crm", consumerId: "test_user_id", authType: "oauth2", enabled: true, settings: { "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, createdAt: "2020-09-19T12:18:37.071Z", updatedAt: "2020-09-19T12:18:37.071Z", state: "authorized", }, { id: "1111+test_user_id", name: "Salesforce", 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", website: "https://www.salesforce.com", tagLine: "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.", serviceId: "teamleader", unifiedApi: "crm", consumerId: "test_user_id", authType: "oauth2", enabled: true, settings: { "instance_url": "https://eu28.salesforce.com", }, metadata: { additionalProperties: { "account": { "name": "My Company", "id": "c01458a5-7276-41ce-bc19-639906b0450a", }, "plan": "enterprise", }, }, createdAt: "2020-09-19T12:18:37.071Z", updatedAt: "2020-09-19T12:18:37.071Z", state: "authorized", }, ], services: [ "salesforce", "stripe", ], aggregatedRequestCount: 101, requestCounts: { unify: 100, proxy: 10, vault: 21, }, created: "2021-05-07T12:55:42.242Z", modified: "2021-05-07T12:55:42.242Z", requestCountUpdated: "2021-05-07T12:55:42.242Z", }, }); }); test("Consumers Vault Consumers Delete", async () => { const testHttpClient = createTestHTTPClient("vault.consumersDelete"); 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.consumers.delete({ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX", consumerId: "test_user_id", }); expect(result.httpMeta.response.status).toBe(200); expect(result.deleteConsumerResponse).toBeDefined(); expect(result.deleteConsumerResponse).toEqual({ statusCode: 200, status: "OK", data: { consumerId: "test_consumer_id", }, }); });