Skip to content

Latest commit

 

History

History
461 lines (343 loc) · 34.6 KB

README.md

File metadata and controls

461 lines (343 loc) · 34.6 KB

Destinations

(destinations)

Overview

Available Operations

  • create - Create a new destination
  • list - List destinations
  • get - Get a destination
  • update - Update a destination
  • delete - Delete a destination

create

Create a new destination

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.destinations.create({
    projectIdOrName: "<value>",
    requestBody: {
      name: "leadConvertedWebhook",
      type: "webhook",
      metadata: {
        url: "https://webhooks.mailmonkey.com/salesforce-lead-converted",
        headers: {
          "Authorization": "Bearer 1234",
        },
      },
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { destinationsCreate } from "@amp-labs/sdk-node/funcs/destinationsCreate.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await destinationsCreate(sdk, {
    projectIdOrName: "<value>",
    requestBody: {
      name: "leadConvertedWebhook",
      type: "webhook",
      metadata: {
        url: "https://webhooks.mailmonkey.com/salesforce-lead-converted",
        headers: {
          "Authorization": "Bearer 1234",
        },
      },
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.CreateDestinationRequest ✔️ 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.
options.serverURL string An optional server URL to use.

Response

Promise<operations.CreateDestinationResponse>

Errors

Error Type Status Code Content Type
errors.CreateDestinationInputValidationProblem 400 application/problem+json
errors.CreateDestinationDestinationsInputValidationProblem 422 application/problem+json
errors.APIError 4XX, 5XX */*

list

List destinations

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.destinations.list({
    projectIdOrName: "<value>",
  });

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

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { destinationsList } from "@amp-labs/sdk-node/funcs/destinationsList.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await destinationsList(sdk, {
    projectIdOrName: "<value>",
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.ListDestinationsRequest ✔️ 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.
options.serverURL string An optional server URL to use.

Response

Promise<operations.ListDestinationsResponse>

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*

get

Get a destination

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.destinations.get({
    projectIdOrName: "<value>",
    destination: "<value>",
  });

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

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { destinationsGet } from "@amp-labs/sdk-node/funcs/destinationsGet.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await destinationsGet(sdk, {
    projectIdOrName: "<value>",
    destination: "<value>",
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.GetDestinationRequest ✔️ 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.
options.serverURL string An optional server URL to use.

Response

Promise<operations.GetDestinationResponse>

Errors

Error Type Status Code Content Type
errors.GetDestinationInputValidationProblem 404 application/problem+json
errors.APIError 4XX, 5XX */*

update

Update a destination

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.destinations.update({
    projectIdOrName: "<value>",
    destination: "<value>",
    requestBody: {
      updateMask: [
        "name",
        "metadata.url",
        "metadata.headers",
      ],
      destination: {
        name: "leadConvertedWebhook",
        metadata: {
          url: "https://webhooks.mailmonkey.com/salesforce-lead-converted",
          headers: {
            "Authorization": "Bearer 1234",
          },
        },
      },
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { destinationsUpdate } from "@amp-labs/sdk-node/funcs/destinationsUpdate.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await destinationsUpdate(sdk, {
    projectIdOrName: "<value>",
    destination: "<value>",
    requestBody: {
      updateMask: [
        "name",
        "metadata.url",
        "metadata.headers",
      ],
      destination: {
        name: "leadConvertedWebhook",
        metadata: {
          url: "https://webhooks.mailmonkey.com/salesforce-lead-converted",
          headers: {
            "Authorization": "Bearer 1234",
          },
        },
      },
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.UpdateDestinationRequest ✔️ 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.
options.serverURL string An optional server URL to use.

Response

Promise<operations.UpdateDestinationResponse>

Errors

Error Type Status Code Content Type
errors.UpdateDestinationInputValidationProblem 400 application/problem+json
errors.UpdateDestinationDestinationsInputValidationProblem 404 application/problem+json
errors.UpdateDestinationDestinationsResponseInputValidationProblem 422 application/problem+json
errors.APIError 4XX, 5XX */*

delete

Delete a destination

Example Usage

import { SDK } from "@amp-labs/sdk-node";

const sdk = new SDK({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.destinations.delete({
    projectIdOrName: "<value>",
    destination: "<value>",
  });

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

run();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@amp-labs/sdk-node/core.js";
import { destinationsDelete } from "@amp-labs/sdk-node/funcs/destinationsDelete.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await destinationsDelete(sdk, {
    projectIdOrName: "<value>",
    destination: "<value>",
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.DeleteDestinationRequest ✔️ 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.
options.serverURL string An optional server URL to use.

Response

Promise<operations.DeleteDestinationAPIProblem>

Errors

Error Type Status Code Content Type
errors.APIError 4XX, 5XX */*