Skip to content

Latest commit

 

History

History
357 lines (255 loc) · 21 KB

File metadata and controls

357 lines (255 loc) · 21 KB

SourceAccounts

(sourceAccounts)

Overview

Source accounts act as a bridge to bank accounts in accounting software.

Available Operations

create

The Create Source Account endpoint allows you to create a representation of a bank account within Codat's domain. The company can then map the source account to an existing or new target account in their accounting software.

Account mapping variability

The method of mapping the source account to the target account varies depending on the accounting package your company uses.

Mapping options:

  1. API Mapping: Integrate the mapping journey directly into your application for a seamless user experience.
  2. Codat UI Mapping: If you prefer a quicker setup, you can utilize Codat's provided user interface for mapping.
  3. Accounting Platform Mapping: For some accounting software, the mapping process must be conducted within the software itself.

Integration-specific behaviour

Bank Feed Integration API Mapping Codat UI Mapping Accounting Platform Mapping
Xero
FreeAgent
Oracle NetSuite
Exact Online (NL)
QuickBooks Online
Sage

Example Usage

import { CodatBankFeeds } from "@codat/bank-feeds";

async function run() {
  const sdk = new CodatBankFeeds({
    security: {
      authHeader: "Basic BASE_64_ENCODED(API_KEY)",
    },
  });

  const res = await sdk.sourceAccounts.create({
    sourceAccount: {
      accountName: "account-081",
      accountNumber: "12345670",
      accountType: "Credit",
      balance: 99.99,
      currency: "GBP",
      feedStartDate: "2022-10-23T00:00:00Z",
      id: "acc-002",
      modifiedDate: "2023-01-09T14:14:14.1057478Z",
      sortCode: "123456",
      status: "pending",
    },
    companyId: "8a210b68-6988-11ed-a1eb-0242ac120002",
    connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CreateSourceAccountRequest ✔️ The request object to use for the request.
retries utils.RetryConfig Configuration to override the default retry behavior of the client.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.CreateSourceAccountResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

delete

The Delete source account endpoint enables you to remove a source account.

Removing a source account will also remove any mapping between the source bank feed bank accounts and the target bankfeed bank account.

Example Usage

import { CodatBankFeeds } from "@codat/bank-feeds";

async function run() {
  const sdk = new CodatBankFeeds({
    security: {
      authHeader: "Basic BASE_64_ENCODED(API_KEY)",
    },
  });

  const res = await sdk.sourceAccounts.delete({
    accountId: "7110701885",
    companyId: "8a210b68-6988-11ed-a1eb-0242ac120002",
    connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteSourceAccountRequest ✔️ The request object to use for the request.
retries utils.RetryConfig Configuration to override the default retry behavior of the client.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.DeleteSourceAccountResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

deleteCredentials

The Delete Bank Account Credentials endpoint serves as a comprehensive mechanism for revoking all existing authorization credentials that a company employs to establish its Bank Feed connection.

In cases where multiple credential sets have been generated, a single API call to this endpoint revokes all of them.

Example Usage

import { CodatBankFeeds } from "@codat/bank-feeds";

async function run() {
  const sdk = new CodatBankFeeds({
    security: {
      authHeader: "Basic BASE_64_ENCODED(API_KEY)",
    },
  });

  const res = await sdk.sourceAccounts.deleteCredentials({
    companyId: "8a210b68-6988-11ed-a1eb-0242ac120002",
    connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteBankFeedCredentialsRequest ✔️ The request object to use for the request.
retries utils.RetryConfig Configuration to override the default retry behavior of the client.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.DeleteBankFeedCredentialsResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

generateCredentials

The Generate Bank Account Credentials endpoint can be used to generate credentials for QuickBooks Online to use for authentication of the Bank Feed in their portal, each time this is used a new set of credentials will be generated.

The old credentials will still be valid until the revoke credentials endpoint is used, which will revoke all credentials associated to the data connection.

Example Usage

import { CodatBankFeeds } from "@codat/bank-feeds";

async function run() {
  const sdk = new CodatBankFeeds({
    security: {
      authHeader: "Basic BASE_64_ENCODED(API_KEY)",
    },
  });

  const res = await sdk.sourceAccounts.generateCredentials({
    requestBody: new TextEncoder().encode("0xeDCfFBde9E"),
    companyId: "8a210b68-6988-11ed-a1eb-0242ac120002",
    connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GenerateCredentialsRequest ✔️ The request object to use for the request.
retries utils.RetryConfig Configuration to override the default retry behavior of the client.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.GenerateCredentialsResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

list

The List source accounts endpoint returns a list of source accounts for a given company's connection.

source accounts are the bank's bank account within Codat's domain from which transactions are synced into the accounting platform.

Example Usage

import { CodatBankFeeds } from "@codat/bank-feeds";

async function run() {
  const sdk = new CodatBankFeeds({
    security: {
      authHeader: "Basic BASE_64_ENCODED(API_KEY)",
    },
  });

  const res = await sdk.sourceAccounts.list({
    companyId: "8a210b68-6988-11ed-a1eb-0242ac120002",
    connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListSourceAccountsRequest ✔️ The request object to use for the request.
retries utils.RetryConfig Configuration to override the default retry behavior of the client.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.ListSourceAccountsResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

update

The Update source account endpoint updates a single source account for a single data connection connected to a single company.

Example Usage

import { CodatBankFeeds } from "@codat/bank-feeds";

async function run() {
  const sdk = new CodatBankFeeds({
    security: {
      authHeader: "Basic BASE_64_ENCODED(API_KEY)",
    },
  });

  const res = await sdk.sourceAccounts.update({
    sourceAccount: {
      accountName: "account-095",
      accountNumber: "12345671",
      accountType: "Credit",
      balance: 0,
      currency: "USD",
      feedStartDate: "2022-10-23T00:00:00Z",
      id: "acc-003",
      modifiedDate: "2023-01-09T14:14:14.1057478Z",
      sortCode: "123456",
      status: "pending",
    },
    accountId: "7110701885",
    companyId: "8a210b68-6988-11ed-a1eb-0242ac120002",
    connectionId: "2e9d2c44-f675-40ba-8049-353bfcb5e171",
  });

  if (res.statusCode == 200) {
    // handle response
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateSourceAccountRequest ✔️ The request object to use for the request.
retries utils.RetryConfig Configuration to override the default retry behavior of the client.
config AxiosRequestConfig Available config options for making requests.

Response

Promise<operations.UpdateSourceAccountResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /