Skip to content

Latest commit

 

History

History
436 lines (360 loc) · 25.8 KB

File metadata and controls

436 lines (360 loc) · 25.8 KB

Accounting.BankAccounts

Overview

Available Operations

  • List - List Bank Accounts
  • Create - Create Bank Account
  • Get - Get Bank Account
  • Update - Update Bank Account
  • Delete - Delete Bank Account

List

List Bank Accounts

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/apideck-libraries/sdk-go"
	"github.com/apideck-libraries/sdk-go/models/components"
	"github.com/apideck-libraries/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
    )

    res, err := s.Accounting.BankAccounts.List(ctx, operations.AccountingBankAccountsAllRequest{
        ServiceID: sdkgo.Pointer("salesforce"),
        CompanyID: sdkgo.Pointer("12345"),
        Filter: &components.BankAccountsFilter{
            Name: sdkgo.Pointer("Main Operating"),
            AccountType: components.BankAccountsFilterAccountTypeChecking.ToPointer(),
            Status: components.BankAccountsFilterStatusActive.ToPointer(),
        },
        Sort: &components.BankAccountsSort{},
        PassThrough: map[string]any{
            "search": "San Francisco",
        },
        Fields: sdkgo.Pointer("id,updated_at"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetBankAccountsResponse != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.AccountingBankAccountsAllRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.AccountingBankAccountsAllResponse, error

Errors

Error Type Status Code Content Type
apierrors.BadRequestResponse 400 application/json
apierrors.UnauthorizedResponse 401 application/json
apierrors.PaymentRequiredResponse 402 application/json
apierrors.NotFoundResponse 404 application/json
apierrors.UnprocessableResponse 422 application/json
apierrors.APIError 4XX, 5XX */*

Create

Create Bank Account

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/apideck-libraries/sdk-go"
	"github.com/apideck-libraries/sdk-go/models/components"
	"github.com/apideck-libraries/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
    )

    res, err := s.Accounting.BankAccounts.Create(ctx, operations.AccountingBankAccountsAddRequest{
        ServiceID: sdkgo.Pointer("salesforce"),
        AccountingBankAccount: components.AccountingBankAccountInput{
            DisplayID: sdkgo.Pointer("BA-001"),
            Name: sdkgo.Pointer("Main Operating Account"),
            AccountNumber: sdkgo.Pointer("123465"),
            AccountType: components.AccountingBankAccountAccountTypeChecking.ToPointer(),
            LedgerAccount: &components.LinkedLedgerAccount{
                ID: sdkgo.Pointer("123456"),
                Name: sdkgo.Pointer("Bank account"),
                NominalCode: sdkgo.Pointer("N091"),
                Code: sdkgo.Pointer("453"),
                ParentID: sdkgo.Pointer("123456"),
                DisplayID: sdkgo.Pointer("123456"),
            },
            BankName: sdkgo.Pointer("Chase Bank"),
            Currency: components.CurrencyUsd.ToPointer(),
            Balance: sdkgo.Pointer[float64](25000.0),
            AvailableBalance: sdkgo.Pointer[float64](24500.0),
            OverdraftLimit: sdkgo.Pointer[float64](5000.0),
            RoutingNumber: sdkgo.Pointer("021000021"),
            Iban: sdkgo.Pointer("GB33BUKB20201555555555"),
            Bic: sdkgo.Pointer("CHASUS33"),
            BsbNumber: sdkgo.Pointer("062-001"),
            BranchIdentifier: sdkgo.Pointer("001"),
            BankCode: sdkgo.Pointer("BNH"),
            Country: sdkgo.Pointer("US"),
            Status: components.AccountingBankAccountStatusActive.ToPointer(),
            Description: sdkgo.Pointer("Primary operating account for daily transactions"),
            CustomFields: []components.CustomField{
                components.CreateCustomFieldCustomField1(
                    components.CustomField1{
                        ID: sdkgo.Pointer("2389328923893298"),
                        Name: sdkgo.Pointer("employee_level"),
                        Description: sdkgo.Pointer("Employee Level"),
                        Value: sdkgo.Pointer(components.CreateCustomField1ValueStr(
                            "Uses Salesforce and Marketo",
                        )),
                    },
                ),
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.CreateBankAccountResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.AccountingBankAccountsAddRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.AccountingBankAccountsAddResponse, error

Errors

Error Type Status Code Content Type
apierrors.BadRequestResponse 400 application/json
apierrors.UnauthorizedResponse 401 application/json
apierrors.PaymentRequiredResponse 402 application/json
apierrors.NotFoundResponse 404 application/json
apierrors.UnprocessableResponse 422 application/json
apierrors.APIError 4XX, 5XX */*

Get

Get Bank Account

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/apideck-libraries/sdk-go"
	"github.com/apideck-libraries/sdk-go/models/components"
	"github.com/apideck-libraries/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
    )

    res, err := s.Accounting.BankAccounts.Get(ctx, operations.AccountingBankAccountsOneRequest{
        ID: "<id>",
        Filter: &components.BankAccountFilter{
            AccountType: components.BankAccountFilterAccountTypeChecking.ToPointer(),
        },
        ServiceID: sdkgo.Pointer("salesforce"),
        CompanyID: sdkgo.Pointer("12345"),
        Fields: sdkgo.Pointer("id,updated_at"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetBankAccountResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.AccountingBankAccountsOneRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.AccountingBankAccountsOneResponse, error

Errors

Error Type Status Code Content Type
apierrors.BadRequestResponse 400 application/json
apierrors.UnauthorizedResponse 401 application/json
apierrors.PaymentRequiredResponse 402 application/json
apierrors.NotFoundResponse 404 application/json
apierrors.UnprocessableResponse 422 application/json
apierrors.APIError 4XX, 5XX */*

Update

Update Bank Account

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/apideck-libraries/sdk-go"
	"github.com/apideck-libraries/sdk-go/models/components"
	"github.com/apideck-libraries/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
    )

    res, err := s.Accounting.BankAccounts.Update(ctx, operations.AccountingBankAccountsUpdateRequest{
        ID: "<id>",
        ServiceID: sdkgo.Pointer("salesforce"),
        AccountingBankAccount: components.AccountingBankAccountInput{
            DisplayID: sdkgo.Pointer("BA-001"),
            Name: sdkgo.Pointer("Main Operating Account"),
            AccountNumber: sdkgo.Pointer("123465"),
            AccountType: components.AccountingBankAccountAccountTypeChecking.ToPointer(),
            LedgerAccount: &components.LinkedLedgerAccount{
                ID: sdkgo.Pointer("123456"),
                Name: sdkgo.Pointer("Bank account"),
                NominalCode: sdkgo.Pointer("N091"),
                Code: sdkgo.Pointer("453"),
                ParentID: sdkgo.Pointer("123456"),
                DisplayID: sdkgo.Pointer("123456"),
            },
            BankName: sdkgo.Pointer("Chase Bank"),
            Currency: components.CurrencyUsd.ToPointer(),
            Balance: sdkgo.Pointer[float64](25000.0),
            AvailableBalance: sdkgo.Pointer[float64](24500.0),
            OverdraftLimit: sdkgo.Pointer[float64](5000.0),
            RoutingNumber: sdkgo.Pointer("021000021"),
            Iban: sdkgo.Pointer("GB33BUKB20201555555555"),
            Bic: sdkgo.Pointer("CHASUS33"),
            BsbNumber: sdkgo.Pointer("062-001"),
            BranchIdentifier: sdkgo.Pointer("001"),
            BankCode: sdkgo.Pointer("BNH"),
            Country: sdkgo.Pointer("US"),
            Status: components.AccountingBankAccountStatusActive.ToPointer(),
            Description: sdkgo.Pointer("Primary operating account for daily transactions"),
            CustomFields: []components.CustomField{
                components.CreateCustomFieldCustomField1(
                    components.CustomField1{
                        ID: sdkgo.Pointer("2389328923893298"),
                        Name: sdkgo.Pointer("employee_level"),
                        Description: sdkgo.Pointer("Employee Level"),
                        Value: sdkgo.Pointer(components.CreateCustomField1ValueStr(
                            "Uses Salesforce and Marketo",
                        )),
                    },
                ),
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.UpdateBankAccountResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.AccountingBankAccountsUpdateRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.AccountingBankAccountsUpdateResponse, error

Errors

Error Type Status Code Content Type
apierrors.BadRequestResponse 400 application/json
apierrors.UnauthorizedResponse 401 application/json
apierrors.PaymentRequiredResponse 402 application/json
apierrors.NotFoundResponse 404 application/json
apierrors.UnprocessableResponse 422 application/json
apierrors.APIError 4XX, 5XX */*

Delete

Delete Bank Account

Example Usage

package main

import(
	"context"
	"os"
	sdkgo "github.com/apideck-libraries/sdk-go"
	"github.com/apideck-libraries/sdk-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := sdkgo.New(
        sdkgo.WithConsumerID("test-consumer"),
        sdkgo.WithAppID("dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"),
        sdkgo.WithSecurity(os.Getenv("APIDECK_API_KEY")),
    )

    res, err := s.Accounting.BankAccounts.Delete(ctx, operations.AccountingBankAccountsDeleteRequest{
        ID: "<id>",
        ServiceID: sdkgo.Pointer("salesforce"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.DeleteBankAccountResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.AccountingBankAccountsDeleteRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.AccountingBankAccountsDeleteResponse, error

Errors

Error Type Status Code Content Type
apierrors.BadRequestResponse 400 application/json
apierrors.UnauthorizedResponse 401 application/json
apierrors.PaymentRequiredResponse 402 application/json
apierrors.NotFoundResponse 404 application/json
apierrors.UnprocessableResponse 422 application/json
apierrors.APIError 4XX, 5XX */*