Skip to content

Latest commit

 

History

History
947 lines (714 loc) · 72.2 KB

File metadata and controls

947 lines (714 loc) · 72.2 KB

Webhooks

(data.webhooks)

Overview

Available Operations

listWebhooks

Lists webhooks for the user.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.listWebhooks({
    status: "active",
  });

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksListWebhooks } from "@avalabs/avacloud-sdk/funcs/dataWebhooksListWebhooks.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksListWebhooks(avaCloudSDK, {
    status: "active",
  });

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

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

createWebhook

Create a new webhook.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.createWebhook({
    url: "https://woeful-yin.biz",
    chainId: "<id>",
    eventType: "address_activity",
    metadata: {
      addresses: [
        "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
      ],
      eventSignatures: [
        "0x61cbb2a3dee0b6064c2e681aadd61677fb4ef319f0b547508d495626f5a62f64",
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksCreateWebhook } from "@avalabs/avacloud-sdk/funcs/dataWebhooksCreateWebhook.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksCreateWebhook(avaCloudSDK, {
    url: "https://woeful-yin.biz",
    chainId: "<id>",
    eventType: "address_activity",
    metadata: {
      addresses: [
        "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
      ],
      eventSignatures: [
        "0x61cbb2a3dee0b6064c2e681aadd61677fb4ef319f0b547508d495626f5a62f64",
      ],
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request components.CreateWebhookRequest ✔️ 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<components.WebhookResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

getWebhook

Retrieves a webhook by ID.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.getWebhook({
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
  });

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

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksGetWebhook } from "@avalabs/avacloud-sdk/funcs/dataWebhooksGetWebhook.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksGetWebhook(avaCloudSDK, {
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.GetWebhookRequest ✔️ 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<components.WebhookResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

deactivateWebhook

Deactivates a webhook by ID.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.deactivateWebhook({
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
  });

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

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksDeactivateWebhook } from "@avalabs/avacloud-sdk/funcs/dataWebhooksDeactivateWebhook.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksDeactivateWebhook(avaCloudSDK, {
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.DeactivateWebhookRequest ✔️ 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<components.WebhookResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

updateWebhook

Updates an existing webhook.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.updateWebhook({
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
    updateWebhookRequest: {},
  });

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

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksUpdateWebhook } from "@avalabs/avacloud-sdk/funcs/dataWebhooksUpdateWebhook.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksUpdateWebhook(avaCloudSDK, {
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
    updateWebhookRequest: {},
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.UpdateWebhookRequest ✔️ 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<components.WebhookResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

generateOrRotateSharedSecret

Generates a new shared secret or rotate an existing one.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.generateOrRotateSharedSecret();

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

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksGenerateOrRotateSharedSecret } from "@avalabs/avacloud-sdk/funcs/dataWebhooksGenerateOrRotateSharedSecret.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksGenerateOrRotateSharedSecret(avaCloudSDK);

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
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<components.SharedSecretsResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

getSharedSecret

Get a previously generated shared secret.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.getSharedSecret();

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

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksGetSharedSecret } from "@avalabs/avacloud-sdk/funcs/dataWebhooksGetSharedSecret.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksGetSharedSecret(avaCloudSDK);

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
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<components.SharedSecretsResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

getAddressesFromWebhook

List adresses by webhook.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.getAddressesFromWebhook({
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
  });

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksGetAddressesFromWebhook } from "@avalabs/avacloud-sdk/funcs/dataWebhooksGetAddressesFromWebhook.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksGetAddressesFromWebhook(avaCloudSDK, {
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
  });

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

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

removeAddressesFromWebhook

Remove addresses from webhook.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.removeAddressesFromWebhook({
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
    addressesChangeRequest: {
      addresses: [
        "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksRemoveAddressesFromWebhook } from "@avalabs/avacloud-sdk/funcs/dataWebhooksRemoveAddressesFromWebhook.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksRemoveAddressesFromWebhook(avaCloudSDK, {
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
    addressesChangeRequest: {
      addresses: [
        "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
      ],
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.RemoveAddressesFromWebhookRequest ✔️ 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<components.WebhookResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

addAddressesToWebhook

Add addresses to webhook.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.webhooks.addAddressesToWebhook({
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
    addressesChangeRequest: {
      addresses: [
        "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
      ],
    },
  });

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

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { dataWebhooksAddAddressesToWebhook } from "@avalabs/avacloud-sdk/funcs/dataWebhooksAddAddressesToWebhook.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  serverURL: "https://api.example.com",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await dataWebhooksAddAddressesToWebhook(avaCloudSDK, {
    id: "f33de69c-d13b-4691-908f-870d6e2e6b04",
    addressesChangeRequest: {
      addresses: [
        "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
      ],
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request operations.AddAddressesToWebhookRequest ✔️ 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<components.WebhookResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*