Skip to content

Latest commit

 

History

History
1585 lines (1244 loc) · 87 KB

README.md

File metadata and controls

1585 lines (1244 loc) · 87 KB

V2

(Ledger.V2)

Overview

Available Operations

AddMetadataOnTransaction

Set the metadata of a transaction by its ID

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.AddMetadataOnTransaction(ctx, operations.V2AddMetadataOnTransactionRequest{
        RequestBody: map[string]string{
            "admin": "true",
        },
        DryRun: formancesdkgo.Bool(true),
        ID: big.NewInt(1234),
        Ledger: "ledger001",
    })
    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.V2AddMetadataOnTransactionRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2AddMetadataOnTransactionResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

AddMetadataToAccount

Add metadata to an account

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.AddMetadataToAccount(ctx, operations.V2AddMetadataToAccountRequest{
        RequestBody: map[string]string{
            "admin": "true",
        },
        Address: "users:001",
        DryRun: formancesdkgo.Bool(true),
        Ledger: "ledger001",
    })
    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.V2AddMetadataToAccountRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2AddMetadataToAccountResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

CountAccounts

Count the accounts from a ledger

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.CountAccounts(ctx, operations.V2CountAccountsRequest{
        Ledger: "ledger001",
    })
    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.V2CountAccountsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2CountAccountsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

CountTransactions

Count the transactions from a ledger

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.CountTransactions(ctx, operations.V2CountTransactionsRequest{
        Ledger: "ledger001",
    })
    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.V2CountTransactionsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2CountTransactionsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

CreateBulk

Bulk request

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.CreateBulk(ctx, operations.V2CreateBulkRequest{
        RequestBody: []shared.V2BulkElement{
            shared.CreateV2BulkElementV2BulkElementAddMetadata(
                shared.V2BulkElementAddMetadata{
                    Action: "<value>",
                },
            ),
        },
        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.
opts []operations.Option The options for this request.

Response

*operations.V2CreateBulkResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

CreateLedger

Create a ledger

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{
        V2CreateLedgerRequest: &shared.V2CreateLedgerRequest{
            Metadata: map[string]string{
                "admin": "true",
            },
        },
        Ledger: "ledger001",
    })
    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.V2CreateLedgerRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2CreateLedgerResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

CreateTransaction

Create a new transaction to a ledger

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.CreateTransaction(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: formancesdkgo.String("ref:001"),
            Script: &shared.V2PostTransactionScript{
                Plain: "vars {\n" +
                "account $user\n" +
                "}\n" +
                "send [COIN 10] (\n" +
                "	source = @world\n" +
                "	destination = $user\n" +
                ")\n" +
                "",
                Vars: map[string]any{
                    "user": "users:042",
                },
            },
        },
        DryRun: formancesdkgo.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.
opts []operations.Option The options for this request.

Response

*operations.V2CreateTransactionResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

DeleteAccountMetadata

Delete metadata by key

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.DeleteAccountMetadata(ctx, operations.V2DeleteAccountMetadataRequest{
        Address: "96609 Cummings Canyon",
        Key: "foo",
        Ledger: "ledger001",
    })
    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.V2DeleteAccountMetadataRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2DeleteAccountMetadataResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

DeleteLedgerMetadata

Delete ledger metadata by key

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.DeleteLedgerMetadata(ctx, operations.V2DeleteLedgerMetadataRequest{
        Key: "foo",
        Ledger: "ledger001",
    })
    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.V2DeleteLedgerMetadataRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2DeleteLedgerMetadataResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

DeleteTransactionMetadata

Delete metadata by key

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.DeleteTransactionMetadata(ctx, operations.V2DeleteTransactionMetadataRequest{
        ID: big.NewInt(1234),
        Key: "foo",
        Ledger: "ledger001",
    })
    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.V2DeleteTransactionMetadataRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2DeleteTransactionMetadataResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

ExportLogs

Export logs

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.ExportLogs(ctx, operations.V2ExportLogsRequest{
        Ledger: "ledger001",
    })
    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.V2ExportLogsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2ExportLogsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.SDKError 4XX, 5XX */*

GetAccount

Get account by its address

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.GetAccount(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.
opts []operations.Option The options for this request.

Response

*operations.V2GetAccountResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

GetBalancesAggregated

Get the aggregated balances from selected accounts

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.GetBalancesAggregated(ctx, operations.V2GetBalancesAggregatedRequest{
        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.
opts []operations.Option The options for this request.

Response

*operations.V2GetBalancesAggregatedResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

GetInfo

Show server information

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.GetInfo(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.
opts []operations.Option The options for this request.

Response

*operations.V2GetInfoResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

GetLedger

Get a ledger

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.GetLedger(ctx, operations.V2GetLedgerRequest{
        Ledger: "ledger001",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.V2GetLedgerResponse != 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.
opts []operations.Option The options for this request.

Response

*operations.V2GetLedgerResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

GetLedgerInfo

Get information about a ledger

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.GetLedgerInfo(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.
opts []operations.Option The options for this request.

Response

*operations.V2GetLedgerInfoResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

GetTransaction

Get transaction from a ledger by its ID

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.GetTransaction(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.
opts []operations.Option The options for this request.

Response

*operations.V2GetTransactionResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

GetVolumesWithBalances

Get list of volumes with balances for (account/asset)

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.GetVolumesWithBalances(ctx, operations.V2GetVolumesWithBalancesRequest{
        Cursor: formancesdkgo.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        GroupBy: formancesdkgo.Int64(3),
        Ledger: "ledger001",
        PageSize: formancesdkgo.Int64(100),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.V2VolumesWithBalanceCursorResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.V2GetVolumesWithBalancesResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

ImportLogs

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.ImportLogs(ctx, operations.V2ImportLogsRequest{
        Ledger: "ledger001",
    })
    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.V2ImportLogsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2ImportLogsResponse, error

Errors

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.ListAccounts(ctx, operations.V2ListAccountsRequest{
        Cursor: formancesdkgo.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
        PageSize: formancesdkgo.Int64(100),
    })
    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.
opts []operations.Option The options for this request.

Response

*operations.V2ListAccountsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

ListLedgers

List ledgers

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{
        Cursor: formancesdkgo.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        PageSize: formancesdkgo.Int64(100),
    })
    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.
opts []operations.Option The options for this request.

Response

*operations.V2ListLedgersResponse, error

Errors

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.ListLogs(ctx, operations.V2ListLogsRequest{
        Cursor: formancesdkgo.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
        PageSize: formancesdkgo.Int64(100),
    })
    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.
opts []operations.Option The options for this request.

Response

*operations.V2ListLogsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

ListTransactions

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

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{
        Cursor: formancesdkgo.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="),
        Ledger: "ledger001",
        PageSize: formancesdkgo.Int64(100),
    })
    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.
opts []operations.Option The options for this request.

Response

*operations.V2ListTransactionsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
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/v3/pkg/models/shared"
	formancesdkgo "github.com/formancehq/formance-sdk-go/v3"
	"context"
	"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.ReadStats(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.
opts []operations.Option The options for this request.

Response

*operations.V2ReadStatsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

RevertTransaction

Revert a ledger transaction by its ID

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.RevertTransaction(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.
opts []operations.Option The options for this request.

Response

*operations.V2RevertTransactionResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*

UpdateLedgerMetadata

Update ledger metadata

Example Usage

package main

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

func main() {
    s := formancesdkgo.New(
        formancesdkgo.WithSecurity(shared.Security{
            ClientID: formancesdkgo.String("<YOUR_CLIENT_ID_HERE>"),
            ClientSecret: formancesdkgo.String("<YOUR_CLIENT_SECRET_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Ledger.V2.UpdateLedgerMetadata(ctx, operations.V2UpdateLedgerMetadataRequest{
        RequestBody: map[string]string{
            "admin": "true",
        },
        Ledger: "ledger001",
    })
    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.V2UpdateLedgerMetadataRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.V2UpdateLedgerMetadataResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.V2ErrorResponse default application/json
sdkerrors.SDKError 4XX, 5XX */*