Skip to content

Latest commit

 

History

History
918 lines (773 loc) · 49.1 KB

README.md

File metadata and controls

918 lines (773 loc) · 49.1 KB

Connections

(vault.connections)

Overview

Available Operations

  • list - Get all connections
  • get - Get connection
  • update - Update connection
  • delete - Deletes a connection
  • imports - Import connection
  • token - Authorize Access Token

list

This endpoint includes all the configured integrations and contains the required assets to build an integrations page where your users can install integrations. OAuth2 supported integrations will contain authorize and revoke links to handle the authentication flows.

Example Usage

import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const result = await apideck.vault.connections.list({
    api: "crm",
    configured: true,
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ApideckCore } from "@apideck/unify/core.js";
import { vaultConnectionsList } from "@apideck/unify/funcs/vaultConnectionsList.js";

// Use `ApideckCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const apideck = new ApideckCore({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const res = await vaultConnectionsList(apideck, {
    api: "crm",
    configured: true,
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.VaultConnectionsAllRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.VaultConnectionsAllResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponse 400 application/json
errors.UnauthorizedResponse 401 application/json
errors.PaymentRequiredResponse 402 application/json
errors.NotFoundResponse 404 application/json
errors.UnprocessableResponse 422 application/json
errors.APIError 4XX, 5XX */*

get

Get a connection

Example Usage

import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const result = await apideck.vault.connections.get({
    serviceId: "pipedrive",
    unifiedApi: "crm",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ApideckCore } from "@apideck/unify/core.js";
import { vaultConnectionsGet } from "@apideck/unify/funcs/vaultConnectionsGet.js";

// Use `ApideckCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const apideck = new ApideckCore({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const res = await vaultConnectionsGet(apideck, {
    serviceId: "pipedrive",
    unifiedApi: "crm",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.VaultConnectionsOneRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.VaultConnectionsOneResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponse 400 application/json
errors.UnauthorizedResponse 401 application/json
errors.PaymentRequiredResponse 402 application/json
errors.NotFoundResponse 404 application/json
errors.UnprocessableResponse 422 application/json
errors.APIError 4XX, 5XX */*

update

Update a connection

Example Usage

import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const result = await apideck.vault.connections.update({
    serviceId: "pipedrive",
    unifiedApi: "crm",
    connection: {
      enabled: true,
      settings: {
        "instance_url": "https://eu28.salesforce.com",
        "api_key": "12345xxxxxx",
      },
      metadata: {
        "account": {
          "name": "My Company",
          "id": "c01458a5-7276-41ce-bc19-639906b0450a",
        },
        "plan": "enterprise",
      },
      configuration: [
        {
          resource: "leads",
          defaults: [
            {
              id: "ProductInterest",
              options: [
                {
                  id: "1234",
                  label: "General Channel",
                  options: [
                    {
                      label: "General Channel",
                      value: 12.5,
                    },
                  ],
                },
              ],
              value: 10.5,
            },
            {
              id: "ProductInterest",
              options: [
                {
                  id: "1234",
                  label: "General Channel",
                  options: [
                    {
                      label: "General Channel",
                      value: 12.5,
                    },
                    {
                      label: "General Channel",
                      value: [
                        "team",
                        "general",
                      ],
                    },
                    {
                      label: "General Channel",
                      value: true,
                    },
                  ],
                },
                {
                  label: "General Channel",
                  value: 12.5,
                },
              ],
              value: true,
            },
          ],
        },
        {
          resource: "leads",
          defaults: [
            {
              id: "ProductInterest",
              options: [
                {
                  id: "1234",
                  label: "General Channel",
                  options: [
                    {
                      label: "General Channel",
                      value: [
                        "team",
                        "general",
                      ],
                    },
                    {
                      label: "General Channel",
                      value: true,
                    },
                  ],
                },
              ],
              value: "GC5000 series",
            },
            {
              id: "ProductInterest",
              options: [
                {
                  label: "General Channel",
                  value: 12.5,
                },
              ],
              value: 10,
            },
          ],
        },
        {
          resource: "leads",
          defaults: [
            {
              id: "ProductInterest",
              options: [
                {
                  label: "General Channel",
                  value: [
                    "team",
                    "general",
                  ],
                },
              ],
              value: true,
            },
            {
              id: "ProductInterest",
              options: [
                {
                  id: "1234",
                  label: "General Channel",
                  options: [
                    {
                      label: "General Channel",
                      value: "general",
                    },
                    {
                      label: "General Channel",
                      value: "general",
                    },
                  ],
                },
                {
                  label: "General Channel",
                  value: [
                    "team",
                    "general",
                  ],
                },
              ],
              value: "GC5000 series",
            },
            {
              id: "ProductInterest",
              options: [
                {
                  label: "General Channel",
                  value: "general",
                },
                {
                  label: "General Channel",
                  value: "general",
                },
              ],
              value: 10.5,
            },
          ],
        },
      ],
      customMappings: [
        {
          value: "$.root.training.first_aid",
        },
        {
          value: "$.root.training.first_aid",
        },
      ],
    },
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ApideckCore } from "@apideck/unify/core.js";
import { vaultConnectionsUpdate } from "@apideck/unify/funcs/vaultConnectionsUpdate.js";

// Use `ApideckCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const apideck = new ApideckCore({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const res = await vaultConnectionsUpdate(apideck, {
    serviceId: "pipedrive",
    unifiedApi: "crm",
    connection: {
      enabled: true,
      settings: {
        "instance_url": "https://eu28.salesforce.com",
        "api_key": "12345xxxxxx",
      },
      metadata: {
        "account": {
          "name": "My Company",
          "id": "c01458a5-7276-41ce-bc19-639906b0450a",
        },
        "plan": "enterprise",
      },
      configuration: [
        {
          resource: "leads",
          defaults: [
            {
              id: "ProductInterest",
              options: [
                {
                  id: "1234",
                  label: "General Channel",
                  options: [
                    {
                      label: "General Channel",
                      value: 12.5,
                    },
                  ],
                },
              ],
              value: 10.5,
            },
            {
              id: "ProductInterest",
              options: [
                {
                  id: "1234",
                  label: "General Channel",
                  options: [
                    {
                      label: "General Channel",
                      value: 12.5,
                    },
                    {
                      label: "General Channel",
                      value: [
                        "team",
                        "general",
                      ],
                    },
                    {
                      label: "General Channel",
                      value: true,
                    },
                  ],
                },
                {
                  label: "General Channel",
                  value: 12.5,
                },
              ],
              value: true,
            },
          ],
        },
        {
          resource: "leads",
          defaults: [
            {
              id: "ProductInterest",
              options: [
                {
                  id: "1234",
                  label: "General Channel",
                  options: [
                    {
                      label: "General Channel",
                      value: [
                        "team",
                        "general",
                      ],
                    },
                    {
                      label: "General Channel",
                      value: true,
                    },
                  ],
                },
              ],
              value: "GC5000 series",
            },
            {
              id: "ProductInterest",
              options: [
                {
                  label: "General Channel",
                  value: 12.5,
                },
              ],
              value: 10,
            },
          ],
        },
        {
          resource: "leads",
          defaults: [
            {
              id: "ProductInterest",
              options: [
                {
                  label: "General Channel",
                  value: 123,
                },
              ],
              value: true,
            },
            {
              id: "ProductInterest",
              options: [
                {
                  id: "1234",
                  label: "General Channel",
                  options: [
                    {
                      label: "General Channel",
                      value: "general",
                    },
                    {
                      label: "General Channel",
                      value: "general",
                    },
                  ],
                },
                {
                  label: "General Channel",
                  value: [
                    "team",
                    "general",
                  ],
                },
              ],
              value: "GC5000 series",
            },
            {
              id: "ProductInterest",
              options: [
                {
                  label: "General Channel",
                  value: "general",
                },
                {
                  label: "General Channel",
                  value: "general",
                },
              ],
              value: 10.5,
            },
          ],
        },
      ],
      customMappings: [
        {
          value: "$.root.training.first_aid",
        },
        {
          value: "$.root.training.first_aid",
        },
      ],
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.VaultConnectionsUpdateRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.VaultConnectionsUpdateResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponse 400 application/json
errors.UnauthorizedResponse 401 application/json
errors.PaymentRequiredResponse 402 application/json
errors.NotFoundResponse 404 application/json
errors.UnprocessableResponse 422 application/json
errors.APIError 4XX, 5XX */*

delete

Deletes a connection

Example Usage

import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const result = await apideck.vault.connections.delete({
    serviceId: "pipedrive",
    unifiedApi: "crm",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ApideckCore } from "@apideck/unify/core.js";
import { vaultConnectionsDelete } from "@apideck/unify/funcs/vaultConnectionsDelete.js";

// Use `ApideckCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const apideck = new ApideckCore({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const res = await vaultConnectionsDelete(apideck, {
    serviceId: "pipedrive",
    unifiedApi: "crm",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.VaultConnectionsDeleteRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.VaultConnectionsDeleteResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponse 400 application/json
errors.UnauthorizedResponse 401 application/json
errors.PaymentRequiredResponse 402 application/json
errors.NotFoundResponse 404 application/json
errors.UnprocessableResponse 422 application/json
errors.APIError 4XX, 5XX */*

imports

Import an authorized connection.

Example Usage

import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const result = await apideck.vault.connections.imports({
    serviceId: "pipedrive",
    unifiedApi: "crm",
    connectionImportData: {
      credentials: {
        refreshToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.cThIIoDvwdueQB468K5xDc5633seEFoqwxjF_xSJyQQ",
        accessToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
        issuedAt: new Date("2020-01-01T00:00:00Z"),
        expiresIn: 3600,
      },
      metadata: {
        "account": {
          "name": "My Company",
          "id": "c01458a5-7276-41ce-bc19-639906b0450a",
        },
        "plan": "enterprise",
      },
    },
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ApideckCore } from "@apideck/unify/core.js";
import { vaultConnectionsImports } from "@apideck/unify/funcs/vaultConnectionsImports.js";

// Use `ApideckCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const apideck = new ApideckCore({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const res = await vaultConnectionsImports(apideck, {
    serviceId: "pipedrive",
    unifiedApi: "crm",
    connectionImportData: {
      credentials: {
        refreshToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.cThIIoDvwdueQB468K5xDc5633seEFoqwxjF_xSJyQQ",
        accessToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
        issuedAt: new Date("2020-01-01T00:00:00Z"),
        expiresIn: 3600,
      },
      metadata: {
        "account": {
          "name": "My Company",
          "id": "c01458a5-7276-41ce-bc19-639906b0450a",
        },
        "plan": "enterprise",
      },
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.VaultConnectionsImportRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.VaultConnectionsImportResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponse 400 application/json
errors.UnauthorizedResponse 401 application/json
errors.PaymentRequiredResponse 402 application/json
errors.NotFoundResponse 404 application/json
errors.UnprocessableResponse 422 application/json
errors.APIError 4XX, 5XX */*

token

Triggers exchanging persisted connection credentials for an access token and store it in Vault. Currently supported for connections with the client_credentials or password OAuth grant type.

Note:

  • Do not include any credentials in the request body. This operation does not persist changes, but only triggers the exchange of persisted connection credentials for an access token.
  • The access token will not be returned in the response. A 200 response code indicates the authorization was successful and that a valid access token was stored on the connection.
  • The access token will be used for subsequent API requests.

Example Usage

import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const result = await apideck.vault.connections.token({
    serviceId: "pipedrive",
    unifiedApi: "crm",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ApideckCore } from "@apideck/unify/core.js";
import { vaultConnectionsToken } from "@apideck/unify/funcs/vaultConnectionsToken.js";

// Use `ApideckCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const apideck = new ApideckCore({
  apiKey: process.env["APIDECK_API_KEY"] ?? "",
  consumerId: "test-consumer",
  appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});

async function run() {
  const res = await vaultConnectionsToken(apideck, {
    serviceId: "pipedrive",
    unifiedApi: "crm",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.VaultConnectionsTokenRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.VaultConnectionsTokenResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponse 400 application/json
errors.UnauthorizedResponse 401 application/json
errors.PaymentRequiredResponse 402 application/json
errors.NotFoundResponse 404 application/json
errors.UnprocessableResponse 422 application/json
errors.APIError 4XX, 5XX */*