Skip to content

Latest commit

 

History

History
207 lines (157 loc) · 15.3 KB

File metadata and controls

207 lines (157 loc) · 15.3 KB

Operations

(data.operations)

Overview

Available Operations

getOperationResult

Gets operation details for the given operation id.

Example Usage

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

const avaCloudSDK = new AvaCloudSDK({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.operations.getOperationResult({
    operationId: "aa22054a-cb7c-4a4e-9b83-59f2ede74138",
  });

  // 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 { dataOperationsGetOperationResult } from "@avalabs/avacloud-sdk/funcs/dataOperationsGetOperationResult.js";

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

async function run() {
  const res = await dataOperationsGetOperationResult(avaCloudSDK, {
    operationId: "aa22054a-cb7c-4a4e-9b83-59f2ede74138",
  });

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

  const { value: result } = res;

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

run();

Parameters

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

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 */*

postTransactionExportJob

Trigger a transaction export operation with given parameters.

The transaction export operation runs asynchronously in the background. The status of the job can be retrieved from the /v1/operations/:operationId endpoint using the operationId returned from this endpoint.

Example Usage

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

const avaCloudSDK = new AvaCloudSDK({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.operations.postTransactionExportJob({
    type: "TRANSACTION_EXPORT_PRIMARY_NETWORK_STAKING",
    firstDate: "2023-05-01",
    lastDate: "2023-05-02",
    startDate: "2023-05-01",
    endDate: "2023-05-02",
    options: {
      includeChains: [
        "p-chain",
      ],
    },
  });

  // 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 { dataOperationsPostTransactionExportJob } from "@avalabs/avacloud-sdk/funcs/dataOperationsPostTransactionExportJob.js";

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

async function run() {
  const res = await dataOperationsPostTransactionExportJob(avaCloudSDK, {
    type: "TRANSACTION_EXPORT_PRIMARY_NETWORK_STAKING",
    firstDate: "2023-05-01",
    lastDate: "2023-05-02",
    startDate: "2023-05-01",
    endDate: "2023-05-02",
    options: {
      includeChains: [
        "p-chain",
      ],
    },
  });

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

  const { value: result } = res;

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

run();

Parameters

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

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 */*