77 KiB
V1
(Ledger.V1)
Available Operations
- GetInfo - Show server information
- GetLedgerInfo - Get information about a ledger
- CountAccounts - Count the accounts from a ledger
- ListAccounts - List accounts from a ledger
- GetAccount - Get account by its address
- AddMetadataToAccount - Add metadata to an account
- GetMapping - Get the mapping of a ledger
- UpdateMapping - Update the mapping of a ledger
RunScript- Execute a Numscript ⚠️ Deprecated- ReadStats - Get statistics from a ledger
- CountTransactions - Count the transactions from a ledger
- ListTransactions - List transactions from a ledger
- CreateTransaction - Create a new transaction to a ledger
- GetTransaction - Get transaction from a ledger by its ID
- AddMetadataOnTransaction - Set the metadata of a transaction by its ID
- RevertTransaction - Revert a ledger transaction by its ID
- CreateTransactions - Create a new batch of transactions to a ledger
- GetBalances - Get the balances from a ledger's account
- GetBalancesAggregated - Get the aggregated balances from selected accounts
- ListLogs - List the logs from a ledger
GetInfo
Show server information
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
ctx := context.Background()
res, err := s.Ledger.V1.GetInfo(ctx)
if err != nil {
log.Fatal(err)
}
if res.ConfigInfoResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetInfoResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetLedgerInfo
Get information about a ledger
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
ctx := context.Background()
res, err := s.Ledger.V1.GetLedgerInfo(ctx, ledger)
if err != nil {
log.Fatal(err)
}
if res.LedgerInfoResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetLedgerInfoResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
CountAccounts
Count the accounts from a ledger
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
var address *string = client.String("users:.+")
var metadata map[string]any = map[string]any{
"0": "m",
"1": "e",
"2": "t",
"3": "a",
"4": "d",
"5": "a",
"6": "t",
"7": "a",
"8": "[",
"9": "k",
"10": "e",
"11": "y",
"12": "]",
"13": "=",
"14": "v",
"15": "a",
"16": "l",
"17": "u",
"18": "e",
"19": "1",
"20": "&",
"21": "m",
"22": "e",
"23": "t",
"24": "a",
"25": "d",
"26": "a",
"27": "t",
"28": "a",
"29": "[",
"30": "a",
"31": ".",
"32": "n",
"33": "e",
"34": "s",
"35": "t",
"36": "e",
"37": "d",
"38": ".",
"39": "k",
"40": "e",
"41": "y",
"42": "]",
"43": "=",
"44": "v",
"45": "a",
"46": "l",
"47": "u",
"48": "e",
"49": "2",
}
ctx := context.Background()
res, err := s.Ledger.V1.CountAccounts(ctx, ledger, address, metadata)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
address |
*string | ➖ | Filter accounts by address pattern (regular expression placed between ^ and $). | users:.+ |
metadata |
map[string]any | ➖ | Filter accounts by metadata key value pairs. The filter can be used like this metadata[key]=value1&metadata[a.nested.key]=value2 | metadata[key]=value1&metadata[a.nested.key]=value2 |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.CountAccountsResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
ListAccounts
List accounts from a ledger, sorted by address in descending order.
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"github.com/formancehq/stack/ledger/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.ListAccountsRequest{
Ledger: "ledger001",
PageSize: client.Int64(100),
After: client.String("users:003"),
Address: client.String("users:.+"),
Metadata: map[string]any{
"0": "m",
"1": "e",
"2": "t",
"3": "a",
"4": "d",
"5": "a",
"6": "t",
"7": "a",
"8": "[",
"9": "k",
"10": "e",
"11": "y",
"12": "]",
"13": "=",
"14": "v",
"15": "a",
"16": "l",
"17": "u",
"18": "e",
"19": "1",
"20": "&",
"21": "m",
"22": "e",
"23": "t",
"24": "a",
"25": "d",
"26": "a",
"27": "t",
"28": "a",
"29": "[",
"30": "a",
"31": ".",
"32": "n",
"33": "e",
"34": "s",
"35": "t",
"36": "e",
"37": "d",
"38": ".",
"39": "k",
"40": "e",
"41": "y",
"42": "]",
"43": "=",
"44": "v",
"45": "a",
"46": "l",
"47": "u",
"48": "e",
"49": "2",
},
Balance: client.Int64(2400),
Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
}
ctx := context.Background()
res, err := s.Ledger.V1.ListAccounts(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.AccountsCursorResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ListAccountsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.ListAccountsResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetAccount
Get account by its address
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
var address string = "users:001"
ctx := context.Background()
res, err := s.Ledger.V1.GetAccount(ctx, ledger, address)
if err != nil {
log.Fatal(err)
}
if res.AccountResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
address |
string | ✔️ | Exact address of the account. It must match the following regular expressions pattern:<br/>^\w+(:\w+)*$<br/> |
users:001 |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetAccountResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
AddMetadataToAccount
Add metadata to an account
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
var address string = "users:001"
var requestBody map[string]any = map[string]any{
"key": "<value>",
}
ctx := context.Background()
res, err := s.Ledger.V1.AddMetadataToAccount(ctx, ledger, address, requestBody)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
address |
string | ✔️ | Exact address of the account. It must match the following regular expressions pattern:<br/>^\w+(:\w+)*$<br/> |
users:001 |
requestBody |
map[string]any | ✔️ | metadata | |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.AddMetadataToAccountResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetMapping
Get the mapping of a ledger
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
ctx := context.Background()
res, err := s.Ledger.V1.GetMapping(ctx, ledger)
if err != nil {
log.Fatal(err)
}
if res.MappingResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetMappingResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
UpdateMapping
Update the mapping of a ledger
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
var mapping *components.Mapping = &components.Mapping{
Contracts: []components.Contract{
components.Contract{
Account: client.String("users:001"),
Expr: components.Expr{},
},
},
}
ctx := context.Background()
res, err := s.Ledger.V1.UpdateMapping(ctx, ledger, mapping)
if err != nil {
log.Fatal(err)
}
if res.MappingResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
mapping |
components.Mapping | ✔️ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.UpdateMappingResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
RunScript
This route is deprecated, and has been merged into POST /{ledger}/transactions.
⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
script := components.Script{
Plain: "vars {
account $user
}
send [COIN 10] (
source = @world
destination = $user
)
",
Vars: map[string]any{
"user": "users:042",
},
Reference: client.String("order_1234"),
}
var preview *bool = client.Bool(true)
ctx := context.Background()
res, err := s.Ledger.V1.RunScript(ctx, ledger, script, preview)
if err != nil {
log.Fatal(err)
}
if res.ScriptResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
script |
components.Script | ✔️ | N/A | |
preview |
*bool | ➖ | Set the preview mode. Preview mode doesn't add the logs to the database or publish a message to the message broker. | true |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.RunScriptResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.SDKError | 4xx-5xx | / |
ReadStats
Get statistics from a ledger. (aggregate metrics on accounts and transactions)
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
ctx := context.Background()
res, err := s.Ledger.V1.ReadStats(ctx, ledger)
if err != nil {
log.Fatal(err)
}
if res.StatsResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | name of the ledger | ledger001 |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.ReadStatsResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
CountTransactions
Count the transactions from a ledger
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"github.com/formancehq/stack/ledger/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.CountTransactionsRequest{
Ledger: "ledger001",
Reference: client.String("ref:001"),
Account: client.String("users:001"),
Source: client.String("users:001"),
Destination: client.String("users:001"),
Metadata: &operations.Metadata{},
}
ctx := context.Background()
res, err := s.Ledger.V1.CountTransactions(ctx, request)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.CountTransactionsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.CountTransactionsResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
ListTransactions
List transactions from a ledger, sorted by txid in descending order.
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"github.com/formancehq/stack/ledger/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.ListTransactionsRequest{
Ledger: "ledger001",
PageSize: client.Int64(100),
After: client.String("1234"),
Reference: client.String("ref:001"),
Account: client.String("users:001"),
Source: client.String("users:001"),
Destination: client.String("users:001"),
Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
}
ctx := context.Background()
res, err := s.Ledger.V1.ListTransactions(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.TransactionsCursorResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ListTransactionsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.ListTransactionsResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
CreateTransaction
Create a new transaction to a ledger
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"math/big"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
postTransaction := components.PostTransaction{
Postings: []components.Posting{
components.Posting{
Amount: big.NewInt(100),
Asset: "COIN",
Destination: "users:002",
Source: "users:001",
},
},
Script: &components.PostTransactionScript{
Plain: "vars {
account $user
}
send [COIN 10] (
source = @world
destination = $user
)
",
Vars: map[string]any{
"user": "users:042",
},
},
Reference: client.String("ref:001"),
}
var preview *bool = client.Bool(true)
ctx := context.Background()
res, err := s.Ledger.V1.CreateTransaction(ctx, ledger, postTransaction, preview)
if err != nil {
log.Fatal(err)
}
if res.TransactionsResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
postTransaction |
components.PostTransaction | ✔️ | The request body must contain at least one of the following objects: - postings: suitable for simple transactions- script: enabling more complex transactions with Numscript |
|
preview |
*bool | ➖ | Set the preview mode. Preview mode doesn't add the logs to the database or publish a message to the message broker. | true |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.CreateTransactionResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetTransaction
Get transaction from a ledger by its ID
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"math/big"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
var txid *big.Int = big.NewInt(1234)
ctx := context.Background()
res, err := s.Ledger.V1.GetTransaction(ctx, ledger, txid)
if err != nil {
log.Fatal(err)
}
if res.TransactionResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
txid |
*big.Int | ✔️ | Transaction ID. | 1234 |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetTransactionResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
AddMetadataOnTransaction
Set the metadata of a transaction by its ID
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"math/big"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
var txid *big.Int = big.NewInt(1234)
ctx := context.Background()
res, err := s.Ledger.V1.AddMetadataOnTransaction(ctx, ledger, txid, nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
txid |
*big.Int | ✔️ | Transaction ID. | 1234 |
requestBody |
map[string]any | ➖ | metadata | |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.AddMetadataOnTransactionResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
RevertTransaction
Revert a ledger transaction by its ID
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"math/big"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
var txid *big.Int = big.NewInt(1234)
ctx := context.Background()
res, err := s.Ledger.V1.RevertTransaction(ctx, ledger, txid, nil)
if err != nil {
log.Fatal(err)
}
if res.TransactionResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
txid |
*big.Int | ✔️ | Transaction ID. | 1234 |
disableChecks |
*bool | ➖ | Allow to disable balances checks | |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.RevertTransactionResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
CreateTransactions
Create a new batch of transactions to a ledger
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"math/big"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
transactions := components.Transactions{
Transactions: []components.TransactionData{
components.TransactionData{
Postings: []components.Posting{
components.Posting{
Amount: big.NewInt(100),
Asset: "COIN",
Destination: "users:002",
Source: "users:001",
},
},
Reference: client.String("ref:001"),
},
},
}
ctx := context.Background()
res, err := s.Ledger.V1.CreateTransactions(ctx, ledger, transactions)
if err != nil {
log.Fatal(err)
}
if res.TransactionsResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
transactions |
components.Transactions | ✔️ | N/A | |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.CreateTransactionsResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetBalances
Get the balances from a ledger's account
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"github.com/formancehq/stack/ledger/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.GetBalancesRequest{
Ledger: "ledger001",
Address: client.String("users:001"),
After: client.String("users:003"),
Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
}
ctx := context.Background()
res, err := s.Ledger.V1.GetBalances(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.BalancesCursorResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetBalancesRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetBalancesResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
GetBalancesAggregated
Get the aggregated balances from selected accounts
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
var ledger string = "ledger001"
var address *string = client.String("users:001")
ctx := context.Background()
res, err := s.Ledger.V1.GetBalancesAggregated(ctx, ledger, address, nil)
if err != nil {
log.Fatal(err)
}
if res.AggregateBalancesResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ledger |
string | ✔️ | Name of the ledger. | ledger001 |
address |
*string | ➖ | Filter balances involving given account, either as source or destination. | users:001 |
useInsertionDate |
*bool | ➖ | Use insertion date instead of effective date | |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetBalancesAggregatedResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
ListLogs
List the logs from a ledger, sorted by ID in descending order.
Example Usage
package main
import(
"github.com/formancehq/stack/ledger/client/models/components"
"github.com/formancehq/stack/ledger/client"
"github.com/formancehq/stack/ledger/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.ListLogsRequest{
Ledger: "ledger001",
PageSize: client.Int64(100),
After: client.String("1234"),
Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
}
ctx := context.Background()
res, err := s.Ledger.V1.ListLogs(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.LogsCursorResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ListLogsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.ListLogsResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |