Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Lending

Lending helps you make smarter credit decisions on small businesses by enabling you to pull your customers' latest data from the operating systems they are already using. You can use that data for automating decisioning and surfacing new insights on the customer, all via one API.

Summary

Lending API: Our Lending API helps you make smarter credit decisions on small businesses by enabling you to pull your customers' latest data from accounting, banking, and commerce software they are already using. It also includes features to help providers verify the accuracy of data and process it more efficiently.

The Lending API is built on top of the latest accounting, commerce, and banking data, providing you with the most important data points you need to get a full picture of SMB creditworthiness and make a comprehensive assessment of your customers.

Explore product | See OpenAPI spec

Endpoints

Endpoints Description
Companies Create and manage your SMB users' companies.
Connections Create new and manage existing data connections for a company.
Bank statements Retrieve banking data from linked bank accounts.
Sales Retrieve standardized sales data from a linked commerce software.
Financial statements Financial data and reports from a linked accounting software.
Liabilities Debt and other liabilities.
Accounts payable Data from a linked accounting software representing money the business owes money to its suppliers.
Accounts receivable Data from a linked accounting software representing money owed to the business for sold goods or services.
Transactions Data from a linked accounting software representing transactions.
Company info View company information fetched from the source platform.
Data integrity Match mutable accounting data with immutable banking data to increase confidence in financial data.
Excel reports Download reports in Excel format.
Manage data Control how data is retrieved from an integration.
File upload Endpoints to manage uploaded files.
Loan writeback Implement the loan writeback procedure in your lending process to maintain an accurate position of a loan during the entire lending cycle.

Table of Contents

SDK Installation

To add the SDK as a dependency to your project:

go get github.com/codatio/client-sdk-go/lending

Example Usage

SDK Example Usage

Example

package main

import (
	"context"
	lending "github.com/codatio/client-sdk-go/lending/v8"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
	"log"
)

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

	s := lending.New()

	res, err := s.AccountCategoriesUpdated(ctx, &shared.AccountCategoriesUpdatedWebhook{
		AlertID:    lending.String("a9367074-b5c3-42c4-9be4-be129f43577e"),
		ClientID:   lending.String("bae71d36-ff47-420a-b4a6-f8c9ddf41140"),
		ClientName: lending.String("Bank of Dave"),
		CompanyID:  lending.String("8a210b68-6988-11ed-a1eb-0242ac120002"),
		Data: &shared.AccountCategoriesUpdatedWebhookData{
			ModifiedDate: lending.String("2022-10-23"),
		},
		DataConnectionID: lending.String("2e9d2c44-f675-40ba-8049-353bfcb5e171"),
		Message:          lending.String("Account categories updated for company f1c35bdc-1546-41b9-baf4-3f31135af968."),
		RuleID:           lending.String("70af3071-65d9-4ec3-b3cb-5283e8d55dac"),
		RuleType:         lending.String("Account Categories Updated"),
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Available Resources and Operations

Available methods
  • Get - Get bank account
  • List - List bank accounts
  • Get - Get bill credit note
  • List - List bill credit notes
  • Get - Get bill payment
  • List - List bill payments
  • Get - Get credit note
  • List - List credit notes
  • Get - Get payment
  • List - List payments
  • List - List account balances
  • Get - Get account
  • List - List accounts
  • Get - Get categorized bank statement
  • Get - Get transaction category
  • List - List transaction categories
  • Get - Get bank transaction
  • List - List transactions
  • Create - Create connection
  • Delete - Delete connection
  • Get - Get connection
  • List - List connections
  • Unlink - Unlink connection
  • Details - List data integrity details
  • Status - Get data integrity status
  • Summaries - Get data integrity summaries
  • Download - Download all files for a company
  • ListUploaded - List all files uploaded by a company
  • Upload - Upload files for a company
  • Get - Get account
  • List - List accounts
  • Get - Get cash flow statement
  • Create - Create bank account transactions
  • GetCreateModel - Get create bank account transactions model
  • Get - Get create operation
  • List - List create operations
  • Get - Get pull operation
  • List - List pull operations
  • Get - Get customer
  • List - List customers
  • Get - Get dispute
  • List - List disputes
  • Get - Get location
  • List - List locations
  • Get - Get order
  • List - List orders
  • Get - Get payment method
  • List - List payment methods
  • Get - Get payment
  • List - List payments
  • Get - Get product category
  • List - List product categories
  • Get - Get product
  • List - List products
  • Get - Get transaction
  • List - List transactions
  • Get - Get account transaction
  • List - List account transactions
  • Get - Get journal entry
  • List - List journal entries
  • Get - Get journal
  • List - List journals
  • Get - Get transfer
  • List - List transfers

Special Types

This SDK defines the following custom types to assist with marshalling and unmarshalling data.

Date

types.Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02".

Usage

d1 := types.NewDate(time.Now()) // returns *types.Date

d2 := types.DateFromTime(time.Now()) // returns types.Date

d3, err := types.NewDateFromString("2019-01-01") // returns *types.Date, error

d4, err := types.DateFromString("2019-01-01") // returns types.Date, error

d5 := types.MustNewDateFromString("2019-01-01") // returns *types.Date and panics on error

d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on error

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retry.Config object to the call by using the WithRetries option:

package main

import (
	"context"
	lending "github.com/codatio/client-sdk-go/lending/v8"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/retry"
	"log"
	"pkg/models/operations"
)

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

	s := lending.New(
		lending.WithSecurity(shared.Security{
			AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
		}),
	)

	res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
		Description: lending.String("Requested early access to the new financing scheme."),
		Name:        "Technicalium",
	}, operations.WithRetries(
		retry.Config{
			Strategy: "backoff",
			Backoff: &retry.BackoffStrategy{
				InitialInterval: 1,
				MaxInterval:     50,
				Exponent:        1.1,
				MaxElapsedTime:  100,
			},
			RetryConnectionErrors: false,
		}))
	if err != nil {
		log.Fatal(err)
	}
	if res.Company != nil {
		// handle response
	}
}

If you'd like to override the default retry strategy for all operations that support retries, you can use the WithRetryConfig option at SDK initialization:

package main

import (
	"context"
	lending "github.com/codatio/client-sdk-go/lending/v8"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/retry"
	"log"
)

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

	s := lending.New(
		lending.WithRetryConfig(
			retry.Config{
				Strategy: "backoff",
				Backoff: &retry.BackoffStrategy{
					InitialInterval: 1,
					MaxInterval:     50,
					Exponent:        1.1,
					MaxElapsedTime:  100,
				},
				RetryConnectionErrors: false,
			}),
		lending.WithSecurity(shared.Security{
			AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
		}),
	)

	res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
		Description: lending.String("Requested early access to the new financing scheme."),
		Name:        "Technicalium",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.Company != nil {
		// handle response
	}
}

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both.

By Default, an API error will return sdkerrors.SDKError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation.

For example, the Create function may return the following errors:

Error Type Status Code Content Type
sdkerrors.ErrorMessage 400, 401, 402, 403, 429, 500, 503 application/json
sdkerrors.SDKError 4XX, 5XX */*

Example

package main

import (
	"context"
	"errors"
	lending "github.com/codatio/client-sdk-go/lending/v8"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/models/sdkerrors"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
	"log"
)

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

	s := lending.New(
		lending.WithSecurity(shared.Security{
			AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
		}),
	)

	res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
		Description: lending.String("Requested early access to the new financing scheme."),
		Name:        "Technicalium",
	})
	if err != nil {

		var e *sdkerrors.ErrorMessage
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}

		var e *sdkerrors.SDKError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}
	}
}

Server Selection

Override Server URL Per-Client

The default server can also be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:

package main

import (
	"context"
	lending "github.com/codatio/client-sdk-go/lending/v8"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
	"log"
)

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

	s := lending.New(
		lending.WithServerURL("https://api.codat.io"),
		lending.WithSecurity(shared.Security{
			AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
		}),
	)

	res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
		Description: lending.String("Requested early access to the new financing scheme."),
		Name:        "Technicalium",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.Company != nil {
		// handle response
	}
}

Custom HTTP Client

The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.

import (
	"net/http"
	"time"
	"github.com/myorg/your-go-sdk"
)

var (
	httpClient = &http.Client{Timeout: 30 * time.Second}
	sdkClient  = sdk.New(sdk.WithClient(httpClient))
)

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
AuthHeader apiKey API key

You can configure it using the WithSecurity option when initializing the SDK client instance. For example:

package main

import (
	"context"
	lending "github.com/codatio/client-sdk-go/lending/v8"
	"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
	"log"
)

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

	s := lending.New(
		lending.WithSecurity(shared.Security{
			AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
		}),
	)

	res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
		Description: lending.String("Requested early access to the new financing scheme."),
		Name:        "Technicalium",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.Company != nil {
		// handle response
	}
}

Support

If you encounter any challenges while utilizing our SDKs, please don't hesitate to reach out for assistance. You can raise any issues by contacting your dedicated Codat representative or reaching out to our support team. We're here to help ensure a smooth experience for you.

Library generated by Speakeasy