Skip to content

Latest commit

 

History

History
540 lines (411 loc) · 38.5 KB

File metadata and controls

540 lines (411 loc) · 38.5 KB

Proxy

Overview

Available Operations

get

Proxies a downstream GET request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization. Note: Vault will proxy all data to the downstream URL and method/verb in the headers.

Example Usage

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

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

async function run() {
  const result = await apideck.proxy.get({
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await proxyGet(apideck, {
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("proxyGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ProxyGetProxyRequest ✔️ 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.ProxyGetProxyResponse>

Errors

Error Type Status Code Content Type
errors.Unauthorized 401 application/json
errors.APIError 4XX, 5XX */*

options

Proxies a downstream OPTION request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization. Note: Vault will proxy all data to the downstream URL and method/verb in the headers.

Example Usage

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

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

async function run() {
  const result = await apideck.proxy.options({
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await proxyOptions(apideck, {
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("proxyOptions failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ProxyOptionsProxyRequest ✔️ 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.ProxyOptionsProxyResponse>

Errors

Error Type Status Code Content Type
errors.Unauthorized 401 application/json
errors.APIError 4XX, 5XX */*

post

Proxies a downstream POST request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization. Note: Vault will proxy all data to the downstream URL and method/verb in the headers.

Example Usage

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

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

async function run() {
  const result = await apideck.proxy.post({
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await proxyPost(apideck, {
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("proxyPost failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ProxyPostProxyRequest ✔️ 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.ProxyPostProxyResponse>

Errors

Error Type Status Code Content Type
errors.Unauthorized 401 application/json
errors.APIError 4XX, 5XX */*

put

Proxies a downstream PUT request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization. Note: Vault will proxy all data to the downstream URL and method/verb in the headers.

Example Usage

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

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

async function run() {
  const result = await apideck.proxy.put({
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await proxyPut(apideck, {
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("proxyPut failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ProxyPutProxyRequest ✔️ 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.ProxyPutProxyResponse>

Errors

Error Type Status Code Content Type
errors.Unauthorized 401 application/json
errors.APIError 4XX, 5XX */*

patch

Proxies a downstream PATCH request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization. Note: Vault will proxy all data to the downstream URL and method/verb in the headers.

Example Usage

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

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

async function run() {
  const result = await apideck.proxy.patch({
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await proxyPatch(apideck, {
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("proxyPatch failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ProxyPatchProxyRequest ✔️ 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.ProxyPatchProxyResponse>

Errors

Error Type Status Code Content Type
errors.Unauthorized 401 application/json
errors.APIError 4XX, 5XX */*

delete

Proxies a downstream DELETE request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization. Note: Vault will proxy all data to the downstream URL and method/verb in the headers.

Example Usage

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

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

async function run() {
  const result = await apideck.proxy.delete({
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await proxyDelete(apideck, {
    serviceId: "close",
    unifiedApi: "hris",
    downstreamUrl: "https://api.close.com/api/v1/lead",
    downstreamAuthorization: "Bearer <token>",
    timeout: 30000,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("proxyDelete failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ProxyDeleteProxyRequest ✔️ 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.ProxyDeleteProxyResponse>

Errors

Error Type Status Code Content Type
errors.Unauthorized 401 application/json
errors.APIError 4XX, 5XX */*