Files
2024-01-19 11:33:42 +00:00

113 KiB

Ledger

(Ledger)

Available Operations

CreateTransactions

Create a new batch of transactions to a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.CreateTransactions(ctx, operations.CreateTransactionsRequest{
        Transactions: shared.Transactions{
            Transactions: []shared.TransactionData{
                shared.TransactionData{
                    Metadata: map[string]interface{}{
                        "key": "string",
                    },
                    Postings: []shared.Posting{
                        shared.Posting{
                            Amount: big.NewInt(100),
                            Asset: "COIN",
                            Destination: "users:002",
                            Source: "users:001",
                        },
                    },
                    Reference: v2.String("ref:001"),
                },
            },
        },
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.TransactionsResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CreateTransactionsRequest ✔️ The request object to use for the request.

Response

*operations.CreateTransactionsResponse, error

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

AddMetadataOnTransaction

Set the metadata of a transaction by its ID

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.AddMetadataOnTransaction(ctx, operations.AddMetadataOnTransactionRequest{
        RequestBody: map[string]interface{}{
            "key": "string",
        },
        Ledger: "ledger001",
        Txid: big.NewInt(1234),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.AddMetadataOnTransactionRequest ✔️ The request object to use for the request.

Response

*operations.AddMetadataOnTransactionResponse, error

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

AddMetadataToAccount

Add metadata to an account

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.AddMetadataToAccount(ctx, operations.AddMetadataToAccountRequest{
        RequestBody: map[string]interface{}{
            "key": "string",
        },
        Address: "users:001",
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.AddMetadataToAccountRequest ✔️ The request object to use for the request.

Response

*operations.AddMetadataToAccountResponse, error

Error Object Status Code Content Type
sdkerrors.ErrorResponse 400,404 application/json
sdkerrors.SDKError 4xx-5xx /

CountAccounts

Count the accounts from a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.CountAccounts(ctx, operations.CountAccountsRequest{
        Address: v2.String("users:.+"),
        Ledger: "ledger001",
        Metadata: map[string]interface{}{
            "key": "string",
        },
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CountAccountsRequest ✔️ The request object to use for the request.

Response

*operations.CountAccountsResponse, error

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

CountTransactions

Count the transactions from a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.CountTransactions(ctx, operations.CountTransactionsRequest{
        Account: v2.String("users:001"),
        Destination: v2.String("users:001"),
        Ledger: "ledger001",
        Metadata: &operations.Metadata{},
        Reference: v2.String("ref:001"),
        Source: v2.String("users:001"),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // 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.

Response

*operations.CountTransactionsResponse, error

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

CreateTransaction

Create a new transaction to a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.CreateTransaction(ctx, operations.CreateTransactionRequest{
        PostTransaction: shared.PostTransaction{
            Metadata: map[string]interface{}{
                "key": "string",
            },
            Postings: []shared.Posting{
                shared.Posting{
                    Amount: big.NewInt(100),
                    Asset: "COIN",
                    Destination: "users:002",
                    Source: "users:001",
                },
            },
            Reference: v2.String("ref:001"),
            Script: &shared.PostTransactionScript{
                Plain: "vars {
            account $user
            }
            send [COIN 10] (
            	source = @world
            	destination = $user
            )
            ",
                Vars: map[string]interface{}{
                    "user": "string",
                },
            },
        },
        Ledger: "ledger001",
        Preview: v2.Bool(true),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.TransactionsResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CreateTransactionRequest ✔️ The request object to use for the request.

Response

*operations.CreateTransactionResponse, error

Error Object Status Code Content Type
sdkerrors.ErrorResponse 400 application/json
sdkerrors.SDKError 4xx-5xx /

GetAccount

Get account by its address

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.GetAccount(ctx, operations.GetAccountRequest{
        Address: "users:001",
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.AccountResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetAccountRequest ✔️ The request object to use for the request.

Response

*operations.GetAccountResponse, error

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

GetBalances

Get the balances from a ledger's account

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.GetBalances(ctx, operations.GetBalancesRequest{
        Address: v2.String("users:001"),
        After: v2.String("users:003"),
        Cursor: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
    })
    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.

Response

*operations.GetBalancesResponse, error

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

GetBalancesAggregated

Get the aggregated balances from selected accounts

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.GetBalancesAggregated(ctx, operations.GetBalancesAggregatedRequest{
        Address: v2.String("users:001"),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.AggregateBalancesResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetBalancesAggregatedRequest ✔️ The request object to use for the request.

Response

*operations.GetBalancesAggregatedResponse, error

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

GetInfo

Show server information

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.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.

Response

*operations.GetInfoResponse, error

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

GetLedgerInfo

Get information about a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.GetLedgerInfo(ctx, operations.GetLedgerInfoRequest{
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.LedgerInfoResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetLedgerInfoRequest ✔️ The request object to use for the request.

Response

*operations.GetLedgerInfoResponse, error

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

GetMapping

Get the mapping of a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.GetMapping(ctx, operations.GetMappingRequest{
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.MappingResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetMappingRequest ✔️ The request object to use for the request.

Response

*operations.GetMappingResponse, error

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

GetTransaction

Get transaction from a ledger by its ID

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.GetTransaction(ctx, operations.GetTransactionRequest{
        Ledger: "ledger001",
        Txid: big.NewInt(1234),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.TransactionResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetTransactionRequest ✔️ The request object to use for the request.

Response

*operations.GetTransactionResponse, error

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

ListAccounts

List accounts from a ledger, sorted by address in descending order.

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.ListAccounts(ctx, operations.ListAccountsRequest{
        Address: v2.String("users:.+"),
        After: v2.String("users:003"),
        Balance: v2.Int64(2400),
        Cursor: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
        Metadata: map[string]interface{}{
            "key": "string",
        },
        PaginationToken: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
    })
    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.

Response

*operations.ListAccountsResponse, error

Error Object Status Code Content Type
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/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.ListLogs(ctx, operations.ListLogsRequest{
        After: v2.String("1234"),
        Cursor: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
    })
    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.

Response

*operations.ListLogsResponse, error

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

ListTransactions

List transactions from a ledger, sorted by txid in descending order.

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.ListTransactions(ctx, operations.ListTransactionsRequest{
        Account: v2.String("users:001"),
        After: v2.String("1234"),
        Cursor: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Destination: v2.String("users:001"),
        Ledger: "ledger001",
        Metadata: map[string]interface{}{
            "key": "string",
        },
        Reference: v2.String("ref:001"),
        Source: v2.String("users:001"),
    })
    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.

Response

*operations.ListTransactionsResponse, 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/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.ReadStats(ctx, operations.ReadStatsRequest{
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatsResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.ReadStatsRequest ✔️ The request object to use for the request.

Response

*operations.ReadStatsResponse, error

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

RevertTransaction

Revert a ledger transaction by its ID

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.RevertTransaction(ctx, operations.RevertTransactionRequest{
        Ledger: "ledger001",
        Txid: big.NewInt(1234),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.TransactionResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.RevertTransactionRequest ✔️ The request object to use for the request.

Response

*operations.RevertTransactionResponse, error

Error Object Status Code Content Type
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/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.RunScript(ctx, operations.RunScriptRequest{
        Script: shared.Script{
            Metadata: map[string]interface{}{
                "key": "string",
            },
            Plain: "vars {
        account $user
        }
        send [COIN 10] (
        	source = @world
        	destination = $user
        )
        ",
            Reference: v2.String("order_1234"),
            Vars: map[string]interface{}{
                "user": "string",
            },
        },
        Ledger: "ledger001",
        Preview: v2.Bool(true),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.ScriptResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.RunScriptRequest ✔️ The request object to use for the request.

Response

*operations.RunScriptResponse, error

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

UpdateMapping

Update the mapping of a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.UpdateMapping(ctx, operations.UpdateMappingRequest{
        Mapping: &shared.Mapping{
            Contracts: []shared.Contract{
                shared.Contract{
                    Account: v2.String("users:001"),
                    Expr: shared.Expr{},
                },
            },
        },
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.MappingResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.UpdateMappingRequest ✔️ The request object to use for the request.

Response

*operations.UpdateMappingResponse, error

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

V2AddMetadataOnTransaction

Set the metadata of a transaction by its ID

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2AddMetadataOnTransaction(ctx, operations.V2AddMetadataOnTransactionRequest{
        RequestBody: map[string]string{
            "admin": "true",
        },
        DryRun: v2.Bool(true),
        ID: big.NewInt(1234),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2AddMetadataOnTransactionRequest ✔️ The request object to use for the request.

Response

*operations.V2AddMetadataOnTransactionResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 400,404 application/json
sdkerrors.SDKError 4xx-5xx /

V2AddMetadataToAccount

Add metadata to an account

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2AddMetadataToAccount(ctx, operations.V2AddMetadataToAccountRequest{
        RequestBody: map[string]string{
            "admin": "true",
        },
        Address: "users:001",
        DryRun: v2.Bool(true),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2AddMetadataToAccountRequest ✔️ The request object to use for the request.

Response

*operations.V2AddMetadataToAccountResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 400,404 application/json
sdkerrors.SDKError 4xx-5xx /

V2CountAccounts

Count the accounts from a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2CountAccounts(ctx, operations.V2CountAccountsRequest{
        RequestBody: map[string]interface{}{
            "key": "string",
        },
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2CountAccountsRequest ✔️ The request object to use for the request.

Response

*operations.V2CountAccountsResponse, error

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

V2CountTransactions

Count the transactions from a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2CountTransactions(ctx, operations.V2CountTransactionsRequest{
        RequestBody: map[string]interface{}{
            "key": "string",
        },
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2CountTransactionsRequest ✔️ The request object to use for the request.

Response

*operations.V2CountTransactionsResponse, error

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

V2CreateBulk

Bulk request

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2CreateBulk(ctx, operations.V2CreateBulkRequest{
        RequestBody: []shared.V2BulkElement{
            shared.CreateV2BulkElementV2BulkElementAddMetadata(
                shared.V2BulkElementAddMetadata{
                    Action: "string",
                    Data: &shared.V2BulkElementAddMetadataData{
                        Metadata: map[string]string{
                            "key": "string",
                        },
                        TargetID: shared.CreateV2TargetIDStr(
                        "string",
                        ),
                        TargetType: shared.V2TargetTypeAccount,
                    },
                },
            ),
        },
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2BulkResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2CreateBulkRequest ✔️ The request object to use for the request.

Response

*operations.V2CreateBulkResponse, error

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

V2CreateLedger

Create a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2CreateLedger(ctx, operations.V2CreateLedgerRequest{
        V2CreateLedgerRequest: &shared.V2CreateLedgerRequest{},
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2CreateLedgerRequest ✔️ The request object to use for the request.

Response

*operations.V2CreateLedgerResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 400 application/json
sdkerrors.SDKError 4xx-5xx /

V2CreateTransaction

Create a new transaction to a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2CreateTransaction(ctx, operations.V2CreateTransactionRequest{
        V2PostTransaction: shared.V2PostTransaction{
            Metadata: map[string]string{
                "admin": "true",
            },
            Postings: []shared.V2Posting{
                shared.V2Posting{
                    Amount: big.NewInt(100),
                    Asset: "COIN",
                    Destination: "users:002",
                    Source: "users:001",
                },
            },
            Reference: v2.String("ref:001"),
            Script: &shared.V2PostTransactionScript{
                Plain: "vars {
            account $user
            }
            send [COIN 10] (
            	source = @world
            	destination = $user
            )
            ",
                Vars: map[string]interface{}{
                    "user": "string",
                },
            },
        },
        DryRun: v2.Bool(true),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2CreateTransactionResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2CreateTransactionRequest ✔️ The request object to use for the request.

Response

*operations.V2CreateTransactionResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 400 application/json
sdkerrors.SDKError 4xx-5xx /

V2DeleteAccountMetadata

Delete metadata by key

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2DeleteAccountMetadata(ctx, operations.V2DeleteAccountMetadataRequest{
        Address: "3680 Emile Grove",
        Key: "foo",
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2DeleteAccountMetadataRequest ✔️ The request object to use for the request.

Response

*operations.V2DeleteAccountMetadataResponse, error

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

V2DeleteTransactionMetadata

Delete metadata by key

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
	"net/http"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2DeleteTransactionMetadata(ctx, operations.V2DeleteTransactionMetadataRequest{
        ID: big.NewInt(1234),
        Key: "foo",
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.StatusCode == http.StatusOK {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2DeleteTransactionMetadataRequest ✔️ The request object to use for the request.

Response

*operations.V2DeleteTransactionMetadataResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 400 application/json
sdkerrors.SDKError 4xx-5xx /

V2GetAccount

Get account by its address

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2GetAccount(ctx, operations.V2GetAccountRequest{
        Address: "users:001",
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2AccountResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2GetAccountRequest ✔️ The request object to use for the request.

Response

*operations.V2GetAccountResponse, error

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

V2GetBalancesAggregated

Get the aggregated balances from selected accounts

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2GetBalancesAggregated(ctx, operations.V2GetBalancesAggregatedRequest{
        RequestBody: map[string]interface{}{
            "key": "string",
        },
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2AggregateBalancesResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2GetBalancesAggregatedRequest ✔️ The request object to use for the request.

Response

*operations.V2GetBalancesAggregatedResponse, error

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

V2GetInfo

Show server information

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2GetInfo(ctx)
    if err != nil {
        log.Fatal(err)
    }

    if res.V2ConfigInfoResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.

Response

*operations.V2GetInfoResponse, error

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

V2GetLedger

Get a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2GetLedger(ctx, operations.V2GetLedgerRequest{
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2Ledger != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2GetLedgerRequest ✔️ The request object to use for the request.

Response

*operations.V2GetLedgerResponse, error

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

V2GetLedgerInfo

Get information about a ledger

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2GetLedgerInfo(ctx, operations.V2GetLedgerInfoRequest{
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2LedgerInfoResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2GetLedgerInfoRequest ✔️ The request object to use for the request.

Response

*operations.V2GetLedgerInfoResponse, error

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

V2GetTransaction

Get transaction from a ledger by its ID

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2GetTransaction(ctx, operations.V2GetTransactionRequest{
        ID: big.NewInt(1234),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2GetTransactionResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2GetTransactionRequest ✔️ The request object to use for the request.

Response

*operations.V2GetTransactionResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 404 application/json
sdkerrors.SDKError 4xx-5xx /

V2ListAccounts

List accounts from a ledger, sorted by address in descending order.

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2ListAccounts(ctx, operations.V2ListAccountsRequest{
        RequestBody: map[string]interface{}{
            "key": "string",
        },
        Cursor: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2AccountsCursorResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2ListAccountsRequest ✔️ The request object to use for the request.

Response

*operations.V2ListAccountsResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 400 application/json
sdkerrors.SDKError 4xx-5xx /

V2ListLedgers

List ledgers

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2ListLedgers(ctx, operations.V2ListLedgersRequest{
        Cursor: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2LedgerListResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2ListLedgersRequest ✔️ The request object to use for the request.

Response

*operations.V2ListLedgersResponse, error

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

V2ListLogs

List the logs from a ledger, sorted by ID in descending order.

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2ListLogs(ctx, operations.V2ListLogsRequest{
        RequestBody: map[string]interface{}{
            "key": "string",
        },
        Cursor: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2LogsCursorResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2ListLogsRequest ✔️ The request object to use for the request.

Response

*operations.V2ListLogsResponse, error

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

V2ListTransactions

List transactions from a ledger, sorted by id in descending order.

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2ListTransactions(ctx, operations.V2ListTransactionsRequest{
        RequestBody: map[string]interface{}{
            "key": "string",
        },
        Cursor: v2.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2TransactionsCursorResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2ListTransactionsRequest ✔️ The request object to use for the request.

Response

*operations.V2ListTransactionsResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 400,404 application/json
sdkerrors.SDKError 4xx-5xx /

V2ReadStats

Get statistics from a ledger. (aggregate metrics on accounts and transactions)

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2ReadStats(ctx, operations.V2ReadStatsRequest{
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2StatsResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2ReadStatsRequest ✔️ The request object to use for the request.

Response

*operations.V2ReadStatsResponse, error

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

V2RevertTransaction

Revert a ledger transaction by its ID

Example Usage

package main

import(
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
	"github.com/formancehq/formance-sdk-go/v2"
	"context"
	"math/big"
	"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
	"log"
)

func main() {
    s := v2.New(
        v2.WithSecurity(shared.Security{
            Authorization: "Bearer <YOUR_ACCESS_TOKEN_HERE>",
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2RevertTransaction(ctx, operations.V2RevertTransactionRequest{
        ID: big.NewInt(1234),
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.V2RevertTransactionResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.V2RevertTransactionRequest ✔️ The request object to use for the request.

Response

*operations.V2RevertTransactionResponse, error

Error Object Status Code Content Type
sdkerrors.V2ErrorResponse 400 application/json
sdkerrors.SDKError 4xx-5xx /