diff --git a/Earthfile b/Earthfile index 4bac74fc0..4a629183f 100644 --- a/Earthfile +++ b/Earthfile @@ -1,6 +1,7 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.16.0 AS core +IMPORT ../../releases AS releases IMPORT ../.. AS stack IMPORT .. AS components @@ -116,7 +117,10 @@ pre-commit: BUILD --pass-args +tidy END BUILD --pass-args +lint - BUILD +openapi + WAIT + BUILD +openapi + END + BUILD +generate-client bench: FROM core+builder-image @@ -175,14 +179,15 @@ tidy: release: BUILD --pass-args stack+goreleaser --path=components/ledger -generate-sdk: +generate-client: FROM node:20-alpine - RUN apk update && apk add yq git + RUN apk update && apk add yq jq WORKDIR /src - COPY (stack+speakeasy/speakeasy) /bin/speakeasy - ARG version=v0.0.0 - COPY openapi/v2.yaml openapi.yaml + COPY (core+sources-speakeasy/speakeasy) /bin/speakeasy + COPY (+openapi/openapi.yaml) openapi.yaml + RUN cat ./openapi.yaml | yq e -o json > openapi.json + COPY (releases+sources/src/openapi-overlay.json) openapi-overlay.json + RUN jq -s '.[0] * .[1]' openapi.json openapi-overlay.json > final.json COPY --dir pkg/client client - RUN --secret SPEAKEASY_API_KEY speakeasy generate sdk -s ./openapi.yaml -o ./client -l go - + RUN --secret SPEAKEASY_API_KEY speakeasy generate sdk -s ./final.json -o ./client -l go SAVE ARTIFACT client AS LOCAL ./pkg/client diff --git a/openapi.yaml b/openapi.yaml index cc58c9072..fe21b0048 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -3706,3 +3706,11 @@ components: properties: data: $ref: '#/components/schemas/V2Ledger' + securitySchemes: + Authorization: + type: oauth2 + flows: + clientCredentials: + tokenUrl: /api/auth/oauth/token + refreshUrl: /api/auth/oauth/token + scopes: {} diff --git a/openapi/v1.yaml b/openapi/v1.yaml index 319d35c2e..ff9129b4a 100644 --- a/openapi/v1.yaml +++ b/openapi/v1.yaml @@ -1295,6 +1295,15 @@ paths: - Authorization: - ledger:read components: + securitySchemes: + Authorization: + type: oauth2 + flows: + clientCredentials: + tokenUrl: '/api/auth/oauth/token' + refreshUrl: '/api/auth/oauth/token' + scopes: { } + schemas: AccountsCursorResponse: type: object diff --git a/openapi/v2.yaml b/openapi/v2.yaml index 1ecc4a9af..e0c200b15 100644 --- a/openapi/v2.yaml +++ b/openapi/v2.yaml @@ -6,9 +6,6 @@ info: servers: - url: http://localhost:8080/ paths: - x-speakeasy-errors: - statusCodes: - - default /v2/_info: get: tags: @@ -1254,6 +1251,15 @@ paths: - Authorization: - ledger:write components: + securitySchemes: + Authorization: + type: oauth2 + flows: + clientCredentials: + tokenUrl: '/api/auth/oauth/token' + refreshUrl: '/api/auth/oauth/token' + scopes: { } + schemas: V2AccountsCursorResponse: type: object diff --git a/pkg/client/.speakeasy/gen.lock b/pkg/client/.speakeasy/gen.lock index 865f46ceb..46f840747 100644 --- a/pkg/client/.speakeasy/gen.lock +++ b/pkg/client/.speakeasy/gen.lock @@ -1,32 +1,39 @@ lockVersion: 2.0.0 id: a9ac79e1-e429-4ee3-96c4-ec973f19bec3 management: - docChecksum: 359dd8cb16193447c993d3d336785c37 + docChecksum: ca116951d61ec04bcf24308e613bf2d7 docVersion: LEDGER_VERSION - speakeasyVersion: 1.346.0 - generationVersion: 2.379.3 - releaseVersion: 0.2.0 - configChecksum: 09df02129c4cf02489fa2f86475a8a45 + speakeasyVersion: 1.351.0 + generationVersion: 2.384.1 + releaseVersion: 0.3.0 + configChecksum: c8d8f683fb8781c1d3ca28aa7371d52e features: go: additionalDependencies: 0.1.0 + constsAndDefaults: 0.1.4 core: 3.5.2 defaultEnabledRetries: 0.2.0 + deprecations: 2.81.1 devContainers: 2.90.0 downloadStreams: 0.1.1 - envVarSecurityUsage: 0.2.0 + envVarSecurityUsage: 0.2.1 errors: 2.81.9 flattening: 2.81.1 getRequestBodies: 2.81.1 + globalSecurity: 2.82.9 globalSecurityCallbacks: 0.1.0 globalServerURLs: 2.82.2 + ignores: 2.81.1 intellisenseMarkdownSupport: 0.1.0 nameOverrides: 2.81.2 + nullables: 0.1.0 + oauth2ClientCredentials: 0.1.1 responseFormat: 0.1.2 retries: 2.83.0 sdkHooks: 0.1.0 unions: 2.85.8 generatedFiles: + - v1.go - v2.go - ledger.go - formance.go @@ -48,6 +55,26 @@ generatedFiles: - internal/utils/retries.go - internal/utils/security.go - internal/utils/utils.go + - /models/operations/getinfo.go + - /models/operations/getledgerinfo.go + - /models/operations/countaccounts.go + - /models/operations/listaccounts.go + - /models/operations/getaccount.go + - /models/operations/addmetadatatoaccount.go + - /models/operations/getmapping.go + - /models/operations/updatemapping.go + - /models/operations/runscript.go + - /models/operations/readstats.go + - /models/operations/counttransactions.go + - /models/operations/listtransactions.go + - /models/operations/createtransaction.go + - /models/operations/gettransaction.go + - /models/operations/addmetadataontransaction.go + - /models/operations/reverttransaction.go + - /models/operations/createtransactions.go + - /models/operations/getbalances.go + - /models/operations/getbalancesaggregated.go + - /models/operations/listlogs.go - /models/operations/v2getinfo.go - /models/operations/v2listledgers.go - /models/operations/v2getledger.go @@ -74,10 +101,41 @@ generatedFiles: - /models/operations/v2listlogs.go - /models/operations/v2importlogs.go - /models/operations/v2exportlogs.go - - /models/sdkerrors/v2errorresponse.go + - /models/components/configinforesponse.go + - /models/components/configinfo.go + - /models/components/config.go + - /models/components/ledgerstorage.go + - /models/components/httpmetadata.go + - /models/components/errorsenum.go + - /models/components/ledgerinforesponse.go + - /models/components/ledgerinfo.go + - /models/components/migrationinfo.go + - /models/components/accountscursorresponse.go + - /models/components/account.go + - /models/components/accountresponse.go + - /models/components/accountwithvolumesandbalances.go + - /models/components/volume.go + - /models/components/mappingresponse.go + - /models/components/mapping.go + - /models/components/contract.go + - /models/components/scriptresponse.go + - /models/components/transaction.go + - /models/components/posting.go + - /models/components/script.go + - /models/components/statsresponse.go + - /models/components/stats.go + - /models/components/transactionscursorresponse.go + - /models/components/transactionsresponse.go + - /models/components/posttransaction.go + - /models/components/transactionresponse.go + - /models/components/transactions.go + - /models/components/transactiondata.go + - /models/components/balancescursorresponse.go + - /models/components/aggregatebalancesresponse.go + - /models/components/logscursorresponse.go + - /models/components/log.go - /models/components/v2errorsenum.go - /models/components/v2configinforesponse.go - - /models/components/httpmetadata.go - /models/components/v2ledgerlistresponse.go - /models/components/v2ledger.go - /models/components/v2getledgerresponse.go @@ -113,6 +171,49 @@ generatedFiles: - /models/components/v2volumeswithbalance.go - /models/components/v2logscursorresponse.go - /models/components/v2log.go + - /models/components/security.go + - /models/sdkerrors/errorresponse.go + - /models/sdkerrors/v2errorresponse.go + - docs/models/operations/getinforesponse.md + - docs/models/operations/getledgerinforequest.md + - docs/models/operations/getledgerinforesponse.md + - docs/models/operations/countaccountsrequest.md + - docs/models/operations/countaccountsresponse.md + - docs/models/operations/listaccountsrequest.md + - docs/models/operations/listaccountsresponse.md + - docs/models/operations/getaccountrequest.md + - docs/models/operations/getaccountresponse.md + - docs/models/operations/addmetadatatoaccountrequest.md + - docs/models/operations/addmetadatatoaccountresponse.md + - docs/models/operations/getmappingrequest.md + - docs/models/operations/getmappingresponse.md + - docs/models/operations/updatemappingrequest.md + - docs/models/operations/updatemappingresponse.md + - docs/models/operations/runscriptrequest.md + - docs/models/operations/runscriptresponse.md + - docs/models/operations/readstatsrequest.md + - docs/models/operations/readstatsresponse.md + - docs/models/operations/metadata.md + - docs/models/operations/counttransactionsrequest.md + - docs/models/operations/counttransactionsresponse.md + - docs/models/operations/listtransactionsrequest.md + - docs/models/operations/listtransactionsresponse.md + - docs/models/operations/createtransactionrequest.md + - docs/models/operations/createtransactionresponse.md + - docs/models/operations/gettransactionrequest.md + - docs/models/operations/gettransactionresponse.md + - docs/models/operations/addmetadataontransactionrequest.md + - docs/models/operations/addmetadataontransactionresponse.md + - docs/models/operations/reverttransactionrequest.md + - docs/models/operations/reverttransactionresponse.md + - docs/models/operations/createtransactionsrequest.md + - docs/models/operations/createtransactionsresponse.md + - docs/models/operations/getbalancesrequest.md + - docs/models/operations/getbalancesresponse.md + - docs/models/operations/getbalancesaggregatedrequest.md + - docs/models/operations/getbalancesaggregatedresponse.md + - docs/models/operations/listlogsrequest.md + - docs/models/operations/listlogsresponse.md - docs/models/operations/v2getinforesponse.md - docs/models/operations/v2listledgersrequest.md - docs/models/operations/v2listledgersresponse.md @@ -165,19 +266,59 @@ generatedFiles: - docs/models/operations/v2importlogsresponse.md - docs/models/operations/v2exportlogsrequest.md - docs/models/operations/v2exportlogsresponse.md - - docs/models/sdkerrors/v2errorresponse.md - - docs/models/components/v2errorsenum.md - - docs/models/components/v2configinforesponse.md + - docs/models/components/configinforesponse.md + - docs/models/components/configinfo.md + - docs/models/components/config.md + - docs/models/components/ledgerstorage.md - docs/models/components/httpmetadata.md + - docs/models/components/errorsenum.md + - docs/models/components/ledgerinforesponse.md + - docs/models/components/storage.md + - docs/models/components/ledgerinfo.md + - docs/models/components/state.md + - docs/models/components/migrationinfo.md - docs/models/components/cursor.md + - docs/models/components/accountscursorresponse.md + - docs/models/components/account.md + - docs/models/components/accountresponse.md + - docs/models/components/accountwithvolumesandbalances.md + - docs/models/components/volume.md + - docs/models/components/mappingresponse.md + - docs/models/components/mapping.md + - docs/models/components/expr.md + - docs/models/components/contract.md + - docs/models/components/scriptresponse.md + - docs/models/components/transaction.md + - docs/models/components/posting.md + - docs/models/components/script.md + - docs/models/components/statsresponse.md + - docs/models/components/stats.md + - docs/models/components/transactionscursorresponsecursor.md + - docs/models/components/transactionscursorresponse.md + - docs/models/components/transactionsresponse.md + - docs/models/components/posttransactionscript.md + - docs/models/components/posttransaction.md + - docs/models/components/transactionresponse.md + - docs/models/components/transactions.md + - docs/models/components/transactiondata.md + - docs/models/components/balancescursorresponsecursor.md + - docs/models/components/balancescursorresponse.md + - docs/models/components/aggregatebalancesresponse.md + - docs/models/components/logscursorresponsecursor.md + - docs/models/components/logscursorresponse.md + - docs/models/components/type.md + - docs/models/components/log.md + - docs/models/components/v2errorsenum.md + - docs/models/components/v2configinforesponse.md + - docs/models/components/v2ledgerlistresponsecursor.md - docs/models/components/v2ledgerlistresponse.md - docs/models/components/v2ledger.md - docs/models/components/v2getledgerresponse.md - docs/models/components/v2createledgerrequest.md - docs/models/components/v2ledgerinforesponse.md - - docs/models/components/storage.md + - docs/models/components/v2ledgerinfostorage.md - docs/models/components/v2ledgerinfo.md - - docs/models/components/state.md + - docs/models/components/v2migrationinfostate.md - docs/models/components/v2migrationinfo.md - docs/models/components/v2bulkresponse.md - docs/models/components/v2bulkelementresulterror.md @@ -190,7 +331,7 @@ generatedFiles: - docs/models/components/v2posting.md - docs/models/components/v2bulkelement.md - docs/models/components/v2bulkelementcreatetransaction.md - - docs/models/components/script.md + - docs/models/components/v2posttransactionscript.md - docs/models/components/v2posttransaction.md - docs/models/components/data.md - docs/models/components/v2bulkelementaddmetadata.md @@ -219,11 +360,15 @@ generatedFiles: - docs/models/components/v2volumeswithbalance.md - docs/models/components/v2logscursorresponsecursor.md - docs/models/components/v2logscursorresponse.md - - docs/models/components/type.md + - docs/models/components/v2logtype.md - docs/models/components/v2log.md + - docs/models/components/security.md + - docs/models/sdkerrors/errorresponse.md + - docs/models/sdkerrors/v2errorresponse.md - docs/sdks/formance/README.md - docs/sdks/ledger/README.md - docs/models/operations/option.md + - docs/sdks/v1/README.md - docs/sdks/v2/README.md - USAGE.md - models/operations/options.go @@ -232,4 +377,5 @@ generatedFiles: - .devcontainer/devcontainer.json - .devcontainer/setup.sh - internal/hooks/hooks.go + - internal/hooks/clientcredentials.go - CONTRIBUTING.md diff --git a/pkg/client/.speakeasy/gen.yaml b/pkg/client/.speakeasy/gen.yaml index 6d33de1c5..f8aaf5189 100644 --- a/pkg/client/.speakeasy/gen.yaml +++ b/pkg/client/.speakeasy/gen.yaml @@ -15,7 +15,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true go: - version: 0.2.0 + version: 0.3.0 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true diff --git a/pkg/client/README.md b/pkg/client/README.md index 3dbb8306a..e1fb468a5 100644 --- a/pkg/client/README.md +++ b/pkg/client/README.md @@ -56,18 +56,24 @@ package main import ( "context" "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) ctx := context.Background() - res, err := s.Ledger.V2.GetInfo(ctx) + res, err := s.Ledger.V1.GetInfo(ctx) if err != nil { log.Fatal(err) } - if res.V2ConfigInfoResponse != nil { + if res.ConfigInfoResponse != nil { // handle response } } @@ -78,6 +84,29 @@ func main() { ## Available Resources and Operations +### [Ledger.V1](docs/sdks/v1/README.md) + +* [GetInfo](docs/sdks/v1/README.md#getinfo) - Show server information +* [GetLedgerInfo](docs/sdks/v1/README.md#getledgerinfo) - Get information about a ledger +* [CountAccounts](docs/sdks/v1/README.md#countaccounts) - Count the accounts from a ledger +* [ListAccounts](docs/sdks/v1/README.md#listaccounts) - List accounts from a ledger +* [GetAccount](docs/sdks/v1/README.md#getaccount) - Get account by its address +* [AddMetadataToAccount](docs/sdks/v1/README.md#addmetadatatoaccount) - Add metadata to an account +* [GetMapping](docs/sdks/v1/README.md#getmapping) - Get the mapping of a ledger +* [UpdateMapping](docs/sdks/v1/README.md#updatemapping) - Update the mapping of a ledger +* [~~RunScript~~](docs/sdks/v1/README.md#runscript) - Execute a Numscript :warning: **Deprecated** +* [ReadStats](docs/sdks/v1/README.md#readstats) - Get statistics from a ledger +* [CountTransactions](docs/sdks/v1/README.md#counttransactions) - Count the transactions from a ledger +* [ListTransactions](docs/sdks/v1/README.md#listtransactions) - List transactions from a ledger +* [CreateTransaction](docs/sdks/v1/README.md#createtransaction) - Create a new transaction to a ledger +* [GetTransaction](docs/sdks/v1/README.md#gettransaction) - Get transaction from a ledger by its ID +* [AddMetadataOnTransaction](docs/sdks/v1/README.md#addmetadataontransaction) - Set the metadata of a transaction by its ID +* [RevertTransaction](docs/sdks/v1/README.md#reverttransaction) - Revert a ledger transaction by its ID +* [CreateTransactions](docs/sdks/v1/README.md#createtransactions) - Create a new batch of transactions to a ledger +* [GetBalances](docs/sdks/v1/README.md#getbalances) - Get the balances from a ledger's account +* [GetBalancesAggregated](docs/sdks/v1/README.md#getbalancesaggregated) - Get the aggregated balances from selected accounts +* [ListLogs](docs/sdks/v1/README.md#listlogs) - List the logs from a ledger + ### [Ledger.V2](docs/sdks/v2/README.md) * [GetInfo](docs/sdks/v2/README.md#getinfo) - Show server information @@ -120,16 +149,22 @@ package main import ( "context" "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client/retry" "log" "models/operations" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) ctx := context.Background() - res, err := s.Ledger.V2.GetInfo(ctx, operations.WithRetries( + res, err := s.Ledger.V1.GetInfo(ctx, operations.WithRetries( retry.Config{ Strategy: "backoff", Backoff: &retry.BackoffStrategy{ @@ -143,7 +178,7 @@ func main() { if err != nil { log.Fatal(err) } - if res.V2ConfigInfoResponse != nil { + if res.ConfigInfoResponse != nil { // handle response } } @@ -157,6 +192,7 @@ package main import ( "context" "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client/retry" "log" ) @@ -174,14 +210,18 @@ func main() { }, RetryConnectionErrors: false, }), + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), ) ctx := context.Background() - res, err := s.Ledger.V2.GetInfo(ctx) + res, err := s.Ledger.V1.GetInfo(ctx) if err != nil { log.Fatal(err) } - if res.V2ConfigInfoResponse != nil { + if res.ConfigInfoResponse != nil { // handle response } } @@ -194,10 +234,10 @@ func main() { Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass. -| Error Object | Status Code | Content Type | -| ------------------------- | ------------------------- | ------------------------- | -| sdkerrors.V2ErrorResponse | default | application/json | -| sdkerrors.SDKError | 4xx-5xx | */* | +| Error Object | Status Code | Content Type | +| ----------------------- | ----------------------- | ----------------------- | +| sdkerrors.ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | ### Example @@ -208,18 +248,24 @@ import ( "context" "errors" "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client/models/sdkerrors" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) ctx := context.Background() - res, err := s.Ledger.V2.GetInfo(ctx) + res, err := s.Ledger.V1.GetInfo(ctx) if err != nil { - var e *sdkerrors.V2ErrorResponse + var e *sdkerrors.ErrorResponse if errors.As(err, &e) { // handle error log.Fatal(e.Error()) @@ -255,20 +301,25 @@ package main import ( "context" "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" "log" ) func main() { s := client.New( client.WithServerIndex(0), + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), ) ctx := context.Background() - res, err := s.Ledger.V2.GetInfo(ctx) + res, err := s.Ledger.V1.GetInfo(ctx) if err != nil { log.Fatal(err) } - if res.V2ConfigInfoResponse != nil { + if res.ConfigInfoResponse != nil { // handle response } } @@ -285,20 +336,25 @@ package main import ( "context" "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" "log" ) func main() { s := client.New( client.WithServerURL("http://localhost:8080/"), + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), ) ctx := context.Background() - res, err := s.Ledger.V2.GetInfo(ctx) + res, err := s.Ledger.V1.GetInfo(ctx) if err != nil { log.Fatal(err) } - if res.V2ConfigInfoResponse != nil { + if res.ConfigInfoResponse != nil { // handle response } } @@ -341,6 +397,50 @@ This can be a convenient way to configure timeouts, cookies, proxies, custom hea + +## Authentication + +### Per-Client Security Schemes + +This SDK supports the following security schemes globally: + +| Name | Type | Scheme | +| -------------- | -------------- | -------------- | +| `ClientID` | oauth2 | OAuth2 token | +| `ClientSecret` | oauth2 | OAuth2 token | + +You can set the security parameters through the `WithSecurity` option when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example: +```go +package main + +import ( + "context" + "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" + "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 + } +} + +``` + + # Development diff --git a/pkg/client/USAGE.md b/pkg/client/USAGE.md index 8cb61e562..4dad1a404 100644 --- a/pkg/client/USAGE.md +++ b/pkg/client/USAGE.md @@ -5,18 +5,24 @@ package main import ( "context" "github.com/formancehq/stack/ledger/client" + "github.com/formancehq/stack/ledger/client/models/components" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) ctx := context.Background() - res, err := s.Ledger.V2.GetInfo(ctx) + res, err := s.Ledger.V1.GetInfo(ctx) if err != nil { log.Fatal(err) } - if res.V2ConfigInfoResponse != nil { + if res.ConfigInfoResponse != nil { // handle response } } diff --git a/pkg/client/docs/models/components/account.md b/pkg/client/docs/models/components/account.md new file mode 100644 index 000000000..50c7d2543 --- /dev/null +++ b/pkg/client/docs/models/components/account.md @@ -0,0 +1,10 @@ +# Account + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `Address` | *string* | :heavy_check_mark: | N/A | users:001 | +| `Type` | **string* | :heavy_minus_sign: | N/A | virtual | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | N/A | {
"admin": true,
"a": {
"nested": {
"key": "value"
}
}
} | \ No newline at end of file diff --git a/pkg/client/docs/models/components/accountresponse.md b/pkg/client/docs/models/components/accountresponse.md new file mode 100644 index 000000000..aa0dbb2be --- /dev/null +++ b/pkg/client/docs/models/components/accountresponse.md @@ -0,0 +1,8 @@ +# AccountResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `Data` | [components.AccountWithVolumesAndBalances](../../models/components/accountwithvolumesandbalances.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/accountscursorresponse.md b/pkg/client/docs/models/components/accountscursorresponse.md new file mode 100644 index 000000000..cb36e5259 --- /dev/null +++ b/pkg/client/docs/models/components/accountscursorresponse.md @@ -0,0 +1,8 @@ +# AccountsCursorResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `Cursor` | [components.Cursor](../../models/components/cursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/accountwithvolumesandbalances.md b/pkg/client/docs/models/components/accountwithvolumesandbalances.md new file mode 100644 index 000000000..a3f04ff46 --- /dev/null +++ b/pkg/client/docs/models/components/accountwithvolumesandbalances.md @@ -0,0 +1,12 @@ +# AccountWithVolumesAndBalances + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | +| `Address` | *string* | :heavy_check_mark: | N/A | users:001 | +| `Type` | **string* | :heavy_minus_sign: | N/A | virtual | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | N/A | {
"admin": true,
"a": {
"nested": {
"key": "value"
}
}
} | +| `Volumes` | map[string][components.Volume](../../models/components/volume.md) | :heavy_minus_sign: | N/A | {
"USD": {
"input": 100,
"output": 10,
"balance": 90
},
"EUR": {
"input": 100,
"output": 10,
"balance": 90
}
} | +| `Balances` | map[string][*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_minus_sign: | N/A | {
"COIN": 100
} | \ No newline at end of file diff --git a/pkg/client/docs/models/components/aggregatebalancesresponse.md b/pkg/client/docs/models/components/aggregatebalancesresponse.md new file mode 100644 index 000000000..2c1da4164 --- /dev/null +++ b/pkg/client/docs/models/components/aggregatebalancesresponse.md @@ -0,0 +1,8 @@ +# AggregateBalancesResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------- | ------------------------- | ------------------------- | ------------------------- | ------------------------- | +| `Data` | map[string]*int64* | :heavy_check_mark: | N/A | {
"USD": 100,
"EUR": 12
} | \ No newline at end of file diff --git a/pkg/client/docs/models/components/balancescursorresponse.md b/pkg/client/docs/models/components/balancescursorresponse.md new file mode 100644 index 000000000..8face6955 --- /dev/null +++ b/pkg/client/docs/models/components/balancescursorresponse.md @@ -0,0 +1,8 @@ +# BalancesCursorResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `Cursor` | [components.BalancesCursorResponseCursor](../../models/components/balancescursorresponsecursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/balancescursorresponsecursor.md b/pkg/client/docs/models/components/balancescursorresponsecursor.md new file mode 100644 index 000000000..8a35dbb2e --- /dev/null +++ b/pkg/client/docs/models/components/balancescursorresponsecursor.md @@ -0,0 +1,12 @@ +# BalancesCursorResponseCursor + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | []map[string]map[string]*int64* | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/config.md b/pkg/client/docs/models/components/config.md new file mode 100644 index 000000000..d73e3095a --- /dev/null +++ b/pkg/client/docs/models/components/config.md @@ -0,0 +1,8 @@ +# Config + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `Storage` | [components.LedgerStorage](../../models/components/ledgerstorage.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/configinfo.md b/pkg/client/docs/models/components/configinfo.md new file mode 100644 index 000000000..a6562985a --- /dev/null +++ b/pkg/client/docs/models/components/configinfo.md @@ -0,0 +1,10 @@ +# ConfigInfo + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `Config` | [components.Config](../../models/components/config.md) | :heavy_check_mark: | N/A | +| `Server` | *string* | :heavy_check_mark: | N/A | +| `Version` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/configinforesponse.md b/pkg/client/docs/models/components/configinforesponse.md new file mode 100644 index 000000000..40f2595c4 --- /dev/null +++ b/pkg/client/docs/models/components/configinforesponse.md @@ -0,0 +1,8 @@ +# ConfigInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `Data` | [components.ConfigInfo](../../models/components/configinfo.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/contract.md b/pkg/client/docs/models/components/contract.md new file mode 100644 index 000000000..eef8b4122 --- /dev/null +++ b/pkg/client/docs/models/components/contract.md @@ -0,0 +1,9 @@ +# Contract + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | +| `Account` | **string* | :heavy_minus_sign: | N/A | users:001 | +| `Expr` | [components.Expr](../../models/components/expr.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/cursor.md b/pkg/client/docs/models/components/cursor.md index 55ebac8e7..de83140b8 100644 --- a/pkg/client/docs/models/components/cursor.md +++ b/pkg/client/docs/models/components/cursor.md @@ -3,10 +3,10 @@ ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | -| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | -| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | -| `Next` | **string* | :heavy_minus_sign: | N/A | | -| `Data` | [][components.V2Ledger](../../models/components/v2ledger.md) | :heavy_check_mark: | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.Account](../../models/components/account.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/errorsenum.md b/pkg/client/docs/models/components/errorsenum.md new file mode 100644 index 000000000..f7cdb1cec --- /dev/null +++ b/pkg/client/docs/models/components/errorsenum.md @@ -0,0 +1,15 @@ +# ErrorsEnum + + +## Values + +| Name | Value | +| ----------------------------- | ----------------------------- | +| `ErrorsEnumInternal` | INTERNAL | +| `ErrorsEnumInsufficientFund` | INSUFFICIENT_FUND | +| `ErrorsEnumValidation` | VALIDATION | +| `ErrorsEnumConflict` | CONFLICT | +| `ErrorsEnumNoScript` | NO_SCRIPT | +| `ErrorsEnumCompilationFailed` | COMPILATION_FAILED | +| `ErrorsEnumMetadataOverride` | METADATA_OVERRIDE | +| `ErrorsEnumNotFound` | NOT_FOUND | \ No newline at end of file diff --git a/pkg/client/docs/models/components/expr.md b/pkg/client/docs/models/components/expr.md new file mode 100644 index 000000000..4cd855628 --- /dev/null +++ b/pkg/client/docs/models/components/expr.md @@ -0,0 +1,7 @@ +# Expr + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/pkg/client/docs/models/components/ledgerinfo.md b/pkg/client/docs/models/components/ledgerinfo.md new file mode 100644 index 000000000..f170e7e89 --- /dev/null +++ b/pkg/client/docs/models/components/ledgerinfo.md @@ -0,0 +1,9 @@ +# LedgerInfo + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | +| `Name` | **string* | :heavy_minus_sign: | N/A | ledger001 | +| `Storage` | [*components.Storage](../../models/components/storage.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/ledgerinforesponse.md b/pkg/client/docs/models/components/ledgerinforesponse.md new file mode 100644 index 000000000..d45e0f2c7 --- /dev/null +++ b/pkg/client/docs/models/components/ledgerinforesponse.md @@ -0,0 +1,8 @@ +# LedgerInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | +| `Data` | [*components.LedgerInfo](../../models/components/ledgerinfo.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/ledgerstorage.md b/pkg/client/docs/models/components/ledgerstorage.md new file mode 100644 index 000000000..159532bd0 --- /dev/null +++ b/pkg/client/docs/models/components/ledgerstorage.md @@ -0,0 +1,9 @@ +# LedgerStorage + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Driver` | *string* | :heavy_check_mark: | N/A | +| `Ledgers` | []*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/log.md b/pkg/client/docs/models/components/log.md new file mode 100644 index 000000000..4dd66d037 --- /dev/null +++ b/pkg/client/docs/models/components/log.md @@ -0,0 +1,12 @@ +# Log + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | +| `ID` | *int64* | :heavy_check_mark: | N/A | 1234 | +| `Type` | [components.Type](../../models/components/type.md) | :heavy_check_mark: | N/A | | +| `Data` | map[string]*any* | :heavy_check_mark: | N/A | | +| `Hash` | *string* | :heavy_check_mark: | N/A | 9ee060170400f556b7e1575cb13f9db004f150a08355c7431c62bc639166431e | +| `Date` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/logscursorresponse.md b/pkg/client/docs/models/components/logscursorresponse.md new file mode 100644 index 000000000..3503553f4 --- /dev/null +++ b/pkg/client/docs/models/components/logscursorresponse.md @@ -0,0 +1,8 @@ +# LogsCursorResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `Cursor` | [components.LogsCursorResponseCursor](../../models/components/logscursorresponsecursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/logscursorresponsecursor.md b/pkg/client/docs/models/components/logscursorresponsecursor.md new file mode 100644 index 000000000..781a3a9c8 --- /dev/null +++ b/pkg/client/docs/models/components/logscursorresponsecursor.md @@ -0,0 +1,12 @@ +# LogsCursorResponseCursor + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.Log](../../models/components/log.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/mapping.md b/pkg/client/docs/models/components/mapping.md new file mode 100644 index 000000000..1cd36db63 --- /dev/null +++ b/pkg/client/docs/models/components/mapping.md @@ -0,0 +1,8 @@ +# Mapping + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| `Contracts` | [][components.Contract](../../models/components/contract.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/mappingresponse.md b/pkg/client/docs/models/components/mappingresponse.md new file mode 100644 index 000000000..a5f448463 --- /dev/null +++ b/pkg/client/docs/models/components/mappingresponse.md @@ -0,0 +1,8 @@ +# MappingResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | +| `Data` | [*components.Mapping](../../models/components/mapping.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/migrationinfo.md b/pkg/client/docs/models/components/migrationinfo.md new file mode 100644 index 000000000..aabaecf30 --- /dev/null +++ b/pkg/client/docs/models/components/migrationinfo.md @@ -0,0 +1,11 @@ +# MigrationInfo + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | +| `Version` | **int64* | :heavy_minus_sign: | N/A | 11 | +| `Name` | **string* | :heavy_minus_sign: | N/A | migrations:001 | +| `Date` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `State` | [*components.State](../../models/components/state.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/posting.md b/pkg/client/docs/models/components/posting.md new file mode 100644 index 000000000..dc8a9ec93 --- /dev/null +++ b/pkg/client/docs/models/components/posting.md @@ -0,0 +1,11 @@ +# Posting + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Amount` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | 100 | +| `Asset` | *string* | :heavy_check_mark: | N/A | COIN | +| `Destination` | *string* | :heavy_check_mark: | N/A | users:002 | +| `Source` | *string* | :heavy_check_mark: | N/A | users:001 | \ No newline at end of file diff --git a/pkg/client/docs/models/components/posttransaction.md b/pkg/client/docs/models/components/posttransaction.md new file mode 100644 index 000000000..530732407 --- /dev/null +++ b/pkg/client/docs/models/components/posttransaction.md @@ -0,0 +1,12 @@ +# PostTransaction + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `Timestamp` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `Postings` | [][components.Posting](../../models/components/posting.md) | :heavy_minus_sign: | N/A | | +| `Script` | [*components.PostTransactionScript](../../models/components/posttransactionscript.md) | :heavy_minus_sign: | N/A | | +| `Reference` | **string* | :heavy_minus_sign: | N/A | ref:001 | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/posttransactionscript.md b/pkg/client/docs/models/components/posttransactionscript.md new file mode 100644 index 000000000..c344ba499 --- /dev/null +++ b/pkg/client/docs/models/components/posttransactionscript.md @@ -0,0 +1,9 @@ +# PostTransactionScript + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `Plain` | *string* | :heavy_check_mark: | N/A | vars {
account $user
}
send [COIN 10] (
source = @world
destination = $user
)
| +| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A | {
"user": "users:042"
} | \ No newline at end of file diff --git a/pkg/client/docs/models/components/script.md b/pkg/client/docs/models/components/script.md index cacdfe4dd..b5b4ce45b 100644 --- a/pkg/client/docs/models/components/script.md +++ b/pkg/client/docs/models/components/script.md @@ -6,4 +6,6 @@ | Field | Type | Required | Description | Example | | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | | `Plain` | *string* | :heavy_check_mark: | N/A | vars {
account $user
}
send [COIN 10] (
source = @world
destination = $user
)
| -| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A | {
"user": "users:042"
} | \ No newline at end of file +| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A | {
"user": "users:042"
} | +| `Reference` | **string* | :heavy_minus_sign: | Reference to attach to the generated transaction | order_1234 | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/scriptresponse.md b/pkg/client/docs/models/components/scriptresponse.md new file mode 100644 index 000000000..388b2fe93 --- /dev/null +++ b/pkg/client/docs/models/components/scriptresponse.md @@ -0,0 +1,11 @@ +# ScriptResponse + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ErrorCode` | [*components.ErrorsEnum](../../models/components/errorsenum.md) | :heavy_minus_sign: | N/A | INSUFFICIENT_FUND | +| `ErrorMessage` | **string* | :heavy_minus_sign: | N/A | account had insufficient funds | +| `Details` | **string* | :heavy_minus_sign: | N/A | https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9 | +| `Transaction` | [*components.Transaction](../../models/components/transaction.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/security.md b/pkg/client/docs/models/components/security.md new file mode 100644 index 000000000..051560923 --- /dev/null +++ b/pkg/client/docs/models/components/security.md @@ -0,0 +1,10 @@ +# Security + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | +| `ClientID` | *string* | :heavy_check_mark: | N/A | | +| `ClientSecret` | *string* | :heavy_check_mark: | N/A | | +| `TokenURL` | *string* | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/stats.md b/pkg/client/docs/models/components/stats.md new file mode 100644 index 000000000..c87615bc0 --- /dev/null +++ b/pkg/client/docs/models/components/stats.md @@ -0,0 +1,9 @@ +# Stats + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Accounts` | *int64* | :heavy_check_mark: | N/A | +| `Transactions` | *int64* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/statsresponse.md b/pkg/client/docs/models/components/statsresponse.md new file mode 100644 index 000000000..2b70b37ba --- /dev/null +++ b/pkg/client/docs/models/components/statsresponse.md @@ -0,0 +1,8 @@ +# StatsResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | +| `Data` | [components.Stats](../../models/components/stats.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/storage.md b/pkg/client/docs/models/components/storage.md index fe7679896..2fb03efee 100644 --- a/pkg/client/docs/models/components/storage.md +++ b/pkg/client/docs/models/components/storage.md @@ -3,6 +3,6 @@ ## Fields -| Field | Type | Required | Description | -| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| `Migrations` | [][components.V2MigrationInfo](../../models/components/v2migrationinfo.md) | :heavy_minus_sign: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `Migrations` | [][components.MigrationInfo](../../models/components/migrationinfo.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/transaction.md b/pkg/client/docs/models/components/transaction.md new file mode 100644 index 000000000..757c27e69 --- /dev/null +++ b/pkg/client/docs/models/components/transaction.md @@ -0,0 +1,14 @@ +# Transaction + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| `Timestamp` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | | +| `Postings` | [][components.Posting](../../models/components/posting.md) | :heavy_check_mark: | N/A | | +| `Reference` | **string* | :heavy_minus_sign: | N/A | ref:001 | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | N/A | | +| `Txid` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | | +| `PreCommitVolumes` | map[string]map[string][components.Volume](../../models/components/volume.md) | :heavy_minus_sign: | N/A | {
"orders:1": {
"USD": {
"input": 100,
"output": 10,
"balance": 90
}
},
"orders:2": {
"USD": {
"input": 100,
"output": 10,
"balance": 90
}
}
} | +| `PostCommitVolumes` | map[string]map[string][components.Volume](../../models/components/volume.md) | :heavy_minus_sign: | N/A | {
"orders:1": {
"USD": {
"input": 100,
"output": 10,
"balance": 90
}
},
"orders:2": {
"USD": {
"input": 100,
"output": 10,
"balance": 90
}
}
} | \ No newline at end of file diff --git a/pkg/client/docs/models/components/transactiondata.md b/pkg/client/docs/models/components/transactiondata.md new file mode 100644 index 000000000..97c958d3c --- /dev/null +++ b/pkg/client/docs/models/components/transactiondata.md @@ -0,0 +1,11 @@ +# TransactionData + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `Postings` | [][components.Posting](../../models/components/posting.md) | :heavy_check_mark: | N/A | | +| `Reference` | **string* | :heavy_minus_sign: | N/A | ref:001 | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | N/A | | +| `Timestamp` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/transactionresponse.md b/pkg/client/docs/models/components/transactionresponse.md new file mode 100644 index 000000000..345e2c536 --- /dev/null +++ b/pkg/client/docs/models/components/transactionresponse.md @@ -0,0 +1,8 @@ +# TransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | +| `Data` | [components.Transaction](../../models/components/transaction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/transactions.md b/pkg/client/docs/models/components/transactions.md new file mode 100644 index 000000000..6ca34cb05 --- /dev/null +++ b/pkg/client/docs/models/components/transactions.md @@ -0,0 +1,8 @@ +# Transactions + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `Transactions` | [][components.TransactionData](../../models/components/transactiondata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/transactionscursorresponse.md b/pkg/client/docs/models/components/transactionscursorresponse.md new file mode 100644 index 000000000..3fd945384 --- /dev/null +++ b/pkg/client/docs/models/components/transactionscursorresponse.md @@ -0,0 +1,8 @@ +# TransactionsCursorResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | +| `Cursor` | [components.TransactionsCursorResponseCursor](../../models/components/transactionscursorresponsecursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/transactionscursorresponsecursor.md b/pkg/client/docs/models/components/transactionscursorresponsecursor.md new file mode 100644 index 000000000..d3ed51be3 --- /dev/null +++ b/pkg/client/docs/models/components/transactionscursorresponsecursor.md @@ -0,0 +1,12 @@ +# TransactionsCursorResponseCursor + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.Transaction](../../models/components/transaction.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/transactionsresponse.md b/pkg/client/docs/models/components/transactionsresponse.md new file mode 100644 index 000000000..d1e0e5c88 --- /dev/null +++ b/pkg/client/docs/models/components/transactionsresponse.md @@ -0,0 +1,8 @@ +# TransactionsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `Data` | [][components.Transaction](../../models/components/transaction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/type.md b/pkg/client/docs/models/components/type.md index a039986e8..6630c645e 100644 --- a/pkg/client/docs/models/components/type.md +++ b/pkg/client/docs/models/components/type.md @@ -3,8 +3,7 @@ ## Values -| Name | Value | -| ------------------------- | ------------------------- | -| `TypeNewTransaction` | NEW_TRANSACTION | -| `TypeSetMetadata` | SET_METADATA | -| `TypeRevertedTransaction` | REVERTED_TRANSACTION | \ No newline at end of file +| Name | Value | +| -------------------- | -------------------- | +| `TypeNewTransaction` | NEW_TRANSACTION | +| `TypeSetMetadata` | SET_METADATA | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2ledgerinfo.md b/pkg/client/docs/models/components/v2ledgerinfo.md index 242a3b5a9..a83c6dcfe 100644 --- a/pkg/client/docs/models/components/v2ledgerinfo.md +++ b/pkg/client/docs/models/components/v2ledgerinfo.md @@ -3,7 +3,7 @@ ## Fields -| Field | Type | Required | Description | Example | -| --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | -| `Name` | **string* | :heavy_minus_sign: | N/A | ledger001 | -| `Storage` | [*components.Storage](../../models/components/storage.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `Name` | **string* | :heavy_minus_sign: | N/A | ledger001 | +| `Storage` | [*components.V2LedgerInfoStorage](../../models/components/v2ledgerinfostorage.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2ledgerinfostorage.md b/pkg/client/docs/models/components/v2ledgerinfostorage.md new file mode 100644 index 000000000..1eb38ab77 --- /dev/null +++ b/pkg/client/docs/models/components/v2ledgerinfostorage.md @@ -0,0 +1,8 @@ +# V2LedgerInfoStorage + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `Migrations` | [][components.V2MigrationInfo](../../models/components/v2migrationinfo.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2ledgerlistresponse.md b/pkg/client/docs/models/components/v2ledgerlistresponse.md index a7cc73e92..4e52f4b84 100644 --- a/pkg/client/docs/models/components/v2ledgerlistresponse.md +++ b/pkg/client/docs/models/components/v2ledgerlistresponse.md @@ -3,6 +3,6 @@ ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | -| `Cursor` | [components.Cursor](../../models/components/cursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `Cursor` | [components.V2LedgerListResponseCursor](../../models/components/v2ledgerlistresponsecursor.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2ledgerlistresponsecursor.md b/pkg/client/docs/models/components/v2ledgerlistresponsecursor.md new file mode 100644 index 000000000..12e998338 --- /dev/null +++ b/pkg/client/docs/models/components/v2ledgerlistresponsecursor.md @@ -0,0 +1,12 @@ +# V2LedgerListResponseCursor + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.V2Ledger](../../models/components/v2ledger.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2log.md b/pkg/client/docs/models/components/v2log.md index c1fed5c74..ae3fd7b22 100644 --- a/pkg/client/docs/models/components/v2log.md +++ b/pkg/client/docs/models/components/v2log.md @@ -6,7 +6,7 @@ | Field | Type | Required | Description | Example | | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | | `ID` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | 1234 | -| `Type` | [components.Type](../../models/components/type.md) | :heavy_check_mark: | N/A | | +| `Type` | [components.V2LogType](../../models/components/v2logtype.md) | :heavy_check_mark: | N/A | | | `Data` | map[string]*any* | :heavy_check_mark: | N/A | | | `Hash` | *string* | :heavy_check_mark: | N/A | 9ee060170400f556b7e1575cb13f9db004f150a08355c7431c62bc639166431e | | `Date` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2logtype.md b/pkg/client/docs/models/components/v2logtype.md new file mode 100644 index 000000000..28b0b930c --- /dev/null +++ b/pkg/client/docs/models/components/v2logtype.md @@ -0,0 +1,10 @@ +# V2LogType + + +## Values + +| Name | Value | +| ------------------------------ | ------------------------------ | +| `V2LogTypeNewTransaction` | NEW_TRANSACTION | +| `V2LogTypeSetMetadata` | SET_METADATA | +| `V2LogTypeRevertedTransaction` | REVERTED_TRANSACTION | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2migrationinfo.md b/pkg/client/docs/models/components/v2migrationinfo.md index e7a38da50..199094883 100644 --- a/pkg/client/docs/models/components/v2migrationinfo.md +++ b/pkg/client/docs/models/components/v2migrationinfo.md @@ -3,9 +3,9 @@ ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | -| `Version` | **int64* | :heavy_minus_sign: | N/A | 11 | -| `Name` | **string* | :heavy_minus_sign: | N/A | migrations:001 | -| `Date` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | -| `State` | [*components.State](../../models/components/state.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `Version` | **int64* | :heavy_minus_sign: | N/A | 11 | +| `Name` | **string* | :heavy_minus_sign: | N/A | migrations:001 | +| `Date` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `State` | [*components.V2MigrationInfoState](../../models/components/v2migrationinfostate.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2migrationinfostate.md b/pkg/client/docs/models/components/v2migrationinfostate.md new file mode 100644 index 000000000..1250def69 --- /dev/null +++ b/pkg/client/docs/models/components/v2migrationinfostate.md @@ -0,0 +1,9 @@ +# V2MigrationInfoState + + +## Values + +| Name | Value | +| -------------------------- | -------------------------- | +| `V2MigrationInfoStateToDo` | TO DO | +| `V2MigrationInfoStateDone` | DONE | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2posttransaction.md b/pkg/client/docs/models/components/v2posttransaction.md index 714919688..c156fcaba 100644 --- a/pkg/client/docs/models/components/v2posttransaction.md +++ b/pkg/client/docs/models/components/v2posttransaction.md @@ -3,10 +3,10 @@ ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -| `Timestamp` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | -| `Postings` | [][components.V2Posting](../../models/components/v2posting.md) | :heavy_minus_sign: | N/A | | -| `Script` | [*components.Script](../../models/components/script.md) | :heavy_minus_sign: | N/A | | -| `Reference` | **string* | :heavy_minus_sign: | N/A | ref:001 | -| `Metadata` | map[string]*string* | :heavy_check_mark: | N/A | {
"admin": "true"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `Timestamp` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | | +| `Postings` | [][components.V2Posting](../../models/components/v2posting.md) | :heavy_minus_sign: | N/A | | +| `Script` | [*components.V2PostTransactionScript](../../models/components/v2posttransactionscript.md) | :heavy_minus_sign: | N/A | | +| `Reference` | **string* | :heavy_minus_sign: | N/A | ref:001 | +| `Metadata` | map[string]*string* | :heavy_check_mark: | N/A | {
"admin": "true"
} | \ No newline at end of file diff --git a/pkg/client/docs/models/components/v2posttransactionscript.md b/pkg/client/docs/models/components/v2posttransactionscript.md new file mode 100644 index 000000000..657c7dd0e --- /dev/null +++ b/pkg/client/docs/models/components/v2posttransactionscript.md @@ -0,0 +1,9 @@ +# V2PostTransactionScript + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `Plain` | *string* | :heavy_check_mark: | N/A | vars {
account $user
}
send [COIN 10] (
source = @world
destination = $user
)
| +| `Vars` | map[string]*any* | :heavy_minus_sign: | N/A | {
"user": "users:042"
} | \ No newline at end of file diff --git a/pkg/client/docs/models/components/volume.md b/pkg/client/docs/models/components/volume.md new file mode 100644 index 000000000..5e2ea51fb --- /dev/null +++ b/pkg/client/docs/models/components/volume.md @@ -0,0 +1,10 @@ +# Volume + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Input` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | +| `Output` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | N/A | +| `Balance` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/addmetadataontransactionrequest.md b/pkg/client/docs/models/operations/addmetadataontransactionrequest.md new file mode 100644 index 000000000..1bf49cc46 --- /dev/null +++ b/pkg/client/docs/models/operations/addmetadataontransactionrequest.md @@ -0,0 +1,10 @@ +# AddMetadataOnTransactionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Txid` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `RequestBody` | map[string]*any* | :heavy_minus_sign: | metadata | | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/addmetadataontransactionresponse.md b/pkg/client/docs/models/operations/addmetadataontransactionresponse.md new file mode 100644 index 000000000..f213b79b1 --- /dev/null +++ b/pkg/client/docs/models/operations/addmetadataontransactionresponse.md @@ -0,0 +1,8 @@ +# AddMetadataOnTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/addmetadatatoaccountrequest.md b/pkg/client/docs/models/operations/addmetadatatoaccountrequest.md new file mode 100644 index 000000000..d2eabe2a8 --- /dev/null +++ b/pkg/client/docs/models/operations/addmetadatatoaccountrequest.md @@ -0,0 +1,10 @@ +# AddMetadataToAccountRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Address` | *string* | :heavy_check_mark: | Exact address of the account. It must match the following regular expressions pattern:
```
^\w+(:\w+)*$
```
| users:001 | +| `RequestBody` | map[string]*any* | :heavy_check_mark: | metadata | | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/addmetadatatoaccountresponse.md b/pkg/client/docs/models/operations/addmetadatatoaccountresponse.md new file mode 100644 index 000000000..44d783abe --- /dev/null +++ b/pkg/client/docs/models/operations/addmetadatatoaccountresponse.md @@ -0,0 +1,8 @@ +# AddMetadataToAccountResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/countaccountsrequest.md b/pkg/client/docs/models/operations/countaccountsrequest.md new file mode 100644 index 000000000..e280363ac --- /dev/null +++ b/pkg/client/docs/models/operations/countaccountsrequest.md @@ -0,0 +1,10 @@ +# CountAccountsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Address` | **string* | :heavy_minus_sign: | Filter accounts by address pattern (regular expression placed between ^ and $). | users:.+ | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | 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 | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/countaccountsresponse.md b/pkg/client/docs/models/operations/countaccountsresponse.md new file mode 100644 index 000000000..50644f143 --- /dev/null +++ b/pkg/client/docs/models/operations/countaccountsresponse.md @@ -0,0 +1,9 @@ +# CountAccountsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/counttransactionsrequest.md b/pkg/client/docs/models/operations/counttransactionsrequest.md new file mode 100644 index 000000000..400c00243 --- /dev/null +++ b/pkg/client/docs/models/operations/counttransactionsrequest.md @@ -0,0 +1,15 @@ +# CountTransactionsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Reference` | **string* | :heavy_minus_sign: | Filter transactions by reference field. | ref:001 | +| `Account` | **string* | :heavy_minus_sign: | Filter transactions with postings involving given account, either as source or destination (regular expression placed between ^ and $). | users:001 | +| `Source` | **string* | :heavy_minus_sign: | Filter transactions with postings involving given account at source (regular expression placed between ^ and $). | users:001 | +| `Destination` | **string* | :heavy_minus_sign: | Filter transactions with postings involving given account at destination (regular expression placed between ^ and $). | users:001 | +| `StartTime` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | Filter transactions that occurred after this timestamp.
The format is RFC3339 and is inclusive (for example, "2023-01-02T15:04:01Z" includes the first second of 4th minute).
| | +| `EndTime` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | Filter transactions that occurred before this timestamp.
The format is RFC3339 and is exclusive (for example, "2023-01-02T15:04:01Z" excludes the first second of 4th minute).
| | +| `Metadata` | [*operations.Metadata](../../models/operations/metadata.md) | :heavy_minus_sign: | Filter transactions by metadata key value pairs. Nested objects can be used as seen in the example below. | metadata[key]=value1&metadata[a.nested.key]=value2 | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/counttransactionsresponse.md b/pkg/client/docs/models/operations/counttransactionsresponse.md new file mode 100644 index 000000000..4c265d393 --- /dev/null +++ b/pkg/client/docs/models/operations/counttransactionsresponse.md @@ -0,0 +1,9 @@ +# CountTransactionsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/createtransactionrequest.md b/pkg/client/docs/models/operations/createtransactionrequest.md new file mode 100644 index 000000000..8419ddf60 --- /dev/null +++ b/pkg/client/docs/models/operations/createtransactionrequest.md @@ -0,0 +1,10 @@ +# CreateTransactionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Preview` | **bool* | :heavy_minus_sign: | Set the preview mode. Preview mode doesn't add the logs to the database or publish a message to the message broker. | true | +| `PostTransaction` | [components.PostTransaction](../../models/components/posttransaction.md) | :heavy_check_mark: | The request body must contain at least one of the following objects:
- `postings`: suitable for simple transactions
- `script`: enabling more complex transactions with Numscript
| | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/createtransactionresponse.md b/pkg/client/docs/models/operations/createtransactionresponse.md new file mode 100644 index 000000000..4c63523b6 --- /dev/null +++ b/pkg/client/docs/models/operations/createtransactionresponse.md @@ -0,0 +1,9 @@ +# CreateTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `TransactionsResponse` | [*components.TransactionsResponse](../../models/components/transactionsresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/createtransactionsrequest.md b/pkg/client/docs/models/operations/createtransactionsrequest.md new file mode 100644 index 000000000..319ff03d6 --- /dev/null +++ b/pkg/client/docs/models/operations/createtransactionsrequest.md @@ -0,0 +1,9 @@ +# CreateTransactionsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Transactions` | [components.Transactions](../../models/components/transactions.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/createtransactionsresponse.md b/pkg/client/docs/models/operations/createtransactionsresponse.md new file mode 100644 index 000000000..c8e70b3d8 --- /dev/null +++ b/pkg/client/docs/models/operations/createtransactionsresponse.md @@ -0,0 +1,9 @@ +# CreateTransactionsResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `TransactionsResponse` | [*components.TransactionsResponse](../../models/components/transactionsresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getaccountrequest.md b/pkg/client/docs/models/operations/getaccountrequest.md new file mode 100644 index 000000000..ef3de9390 --- /dev/null +++ b/pkg/client/docs/models/operations/getaccountrequest.md @@ -0,0 +1,9 @@ +# GetAccountRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Address` | *string* | :heavy_check_mark: | Exact address of the account. It must match the following regular expressions pattern:
```
^\w+(:\w+)*$
```
| users:001 | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getaccountresponse.md b/pkg/client/docs/models/operations/getaccountresponse.md new file mode 100644 index 000000000..6391542c3 --- /dev/null +++ b/pkg/client/docs/models/operations/getaccountresponse.md @@ -0,0 +1,9 @@ +# GetAccountResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `AccountResponse` | [*components.AccountResponse](../../models/components/accountresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getbalancesaggregatedrequest.md b/pkg/client/docs/models/operations/getbalancesaggregatedrequest.md new file mode 100644 index 000000000..316ff70bc --- /dev/null +++ b/pkg/client/docs/models/operations/getbalancesaggregatedrequest.md @@ -0,0 +1,10 @@ +# GetBalancesAggregatedRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Address` | **string* | :heavy_minus_sign: | Filter balances involving given account, either as source or destination. | users:001 | +| `UseInsertionDate` | **bool* | :heavy_minus_sign: | Use insertion date instead of effective date | | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getbalancesaggregatedresponse.md b/pkg/client/docs/models/operations/getbalancesaggregatedresponse.md new file mode 100644 index 000000000..84e8d3796 --- /dev/null +++ b/pkg/client/docs/models/operations/getbalancesaggregatedresponse.md @@ -0,0 +1,9 @@ +# GetBalancesAggregatedResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `AggregateBalancesResponse` | [*components.AggregateBalancesResponse](../../models/components/aggregatebalancesresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getbalancesrequest.md b/pkg/client/docs/models/operations/getbalancesrequest.md new file mode 100644 index 000000000..e1e57da71 --- /dev/null +++ b/pkg/client/docs/models/operations/getbalancesrequest.md @@ -0,0 +1,12 @@ +# GetBalancesRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Address` | **string* | :heavy_minus_sign: | Filter balances involving given account, either as source or destination. | users:001 | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| | +| `After` | **string* | :heavy_minus_sign: | Pagination cursor, will return accounts after given address, in descending order. | users:003 | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 1000.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getbalancesresponse.md b/pkg/client/docs/models/operations/getbalancesresponse.md new file mode 100644 index 000000000..b605c68b0 --- /dev/null +++ b/pkg/client/docs/models/operations/getbalancesresponse.md @@ -0,0 +1,9 @@ +# GetBalancesResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `BalancesCursorResponse` | [*components.BalancesCursorResponse](../../models/components/balancescursorresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getinforesponse.md b/pkg/client/docs/models/operations/getinforesponse.md new file mode 100644 index 000000000..1f1abf2bd --- /dev/null +++ b/pkg/client/docs/models/operations/getinforesponse.md @@ -0,0 +1,9 @@ +# GetInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ConfigInfoResponse` | [*components.ConfigInfoResponse](../../models/components/configinforesponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getledgerinforequest.md b/pkg/client/docs/models/operations/getledgerinforequest.md new file mode 100644 index 000000000..f45b795dd --- /dev/null +++ b/pkg/client/docs/models/operations/getledgerinforequest.md @@ -0,0 +1,8 @@ +# GetLedgerInfoRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getledgerinforesponse.md b/pkg/client/docs/models/operations/getledgerinforesponse.md new file mode 100644 index 000000000..94e5c0435 --- /dev/null +++ b/pkg/client/docs/models/operations/getledgerinforesponse.md @@ -0,0 +1,9 @@ +# GetLedgerInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `LedgerInfoResponse` | [*components.LedgerInfoResponse](../../models/components/ledgerinforesponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getmappingrequest.md b/pkg/client/docs/models/operations/getmappingrequest.md new file mode 100644 index 000000000..1399e12ec --- /dev/null +++ b/pkg/client/docs/models/operations/getmappingrequest.md @@ -0,0 +1,8 @@ +# GetMappingRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/getmappingresponse.md b/pkg/client/docs/models/operations/getmappingresponse.md new file mode 100644 index 000000000..548ff90db --- /dev/null +++ b/pkg/client/docs/models/operations/getmappingresponse.md @@ -0,0 +1,9 @@ +# GetMappingResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `MappingResponse` | [*components.MappingResponse](../../models/components/mappingresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/gettransactionrequest.md b/pkg/client/docs/models/operations/gettransactionrequest.md new file mode 100644 index 000000000..9b7bcbcb6 --- /dev/null +++ b/pkg/client/docs/models/operations/gettransactionrequest.md @@ -0,0 +1,9 @@ +# GetTransactionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Txid` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/gettransactionresponse.md b/pkg/client/docs/models/operations/gettransactionresponse.md new file mode 100644 index 000000000..894057860 --- /dev/null +++ b/pkg/client/docs/models/operations/gettransactionresponse.md @@ -0,0 +1,9 @@ +# GetTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `TransactionResponse` | [*components.TransactionResponse](../../models/components/transactionresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/listaccountsrequest.md b/pkg/client/docs/models/operations/listaccountsrequest.md new file mode 100644 index 000000000..af41b328e --- /dev/null +++ b/pkg/client/docs/models/operations/listaccountsrequest.md @@ -0,0 +1,15 @@ +# ListAccountsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `After` | **string* | :heavy_minus_sign: | Pagination cursor, will return accounts after given address, in descending order. | users:003 | +| `Address` | **string* | :heavy_minus_sign: | Filter accounts by address pattern (regular expression placed between ^ and $). | users:.+ | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | Filter accounts by metadata key value pairs. Nested objects can be used as seen in the example below. | metadata[key]=value1&metadata[a.nested.key]=value2 | +| `Balance` | **int64* | :heavy_minus_sign: | Filter accounts by their balance (default operator is gte) | 2400 | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 1000.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | +| ~~`PaginationToken`~~ | **string* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Parameter used in pagination requests. Maximum page size is set to 1000.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
Deprecated, please use `cursor` instead.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/listaccountsresponse.md b/pkg/client/docs/models/operations/listaccountsresponse.md new file mode 100644 index 000000000..62f1327e1 --- /dev/null +++ b/pkg/client/docs/models/operations/listaccountsresponse.md @@ -0,0 +1,10 @@ +# ListAccountsResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `AccountsCursorResponse` | [*components.AccountsCursorResponse](../../models/components/accountscursorresponse.md) | :heavy_minus_sign: | OK | +| `ErrorResponse` | **sdkerrors.ErrorResponse* | :heavy_minus_sign: | Not found | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/listlogsrequest.md b/pkg/client/docs/models/operations/listlogsrequest.md new file mode 100644 index 000000000..dc551c20d --- /dev/null +++ b/pkg/client/docs/models/operations/listlogsrequest.md @@ -0,0 +1,13 @@ +# ListLogsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `After` | **string* | :heavy_minus_sign: | Pagination cursor, will return the logs after a given ID. (in descending order). | 1234 | +| `StartTime` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | Filter transactions that occurred after this timestamp.
The format is RFC3339 and is inclusive (for example, "2023-01-02T15:04:01Z" includes the first second of 4th minute).
| | +| `EndTime` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | Filter transactions that occurred before this timestamp.
The format is RFC3339 and is exclusive (for example, "2023-01-02T15:04:01Z" excludes the first second of 4th minute).
| | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 1000.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/listlogsresponse.md b/pkg/client/docs/models/operations/listlogsresponse.md new file mode 100644 index 000000000..b6a7f8982 --- /dev/null +++ b/pkg/client/docs/models/operations/listlogsresponse.md @@ -0,0 +1,9 @@ +# ListLogsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `LogsCursorResponse` | [*components.LogsCursorResponse](../../models/components/logscursorresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/listtransactionsrequest.md b/pkg/client/docs/models/operations/listtransactionsrequest.md new file mode 100644 index 000000000..5744daa73 --- /dev/null +++ b/pkg/client/docs/models/operations/listtransactionsrequest.md @@ -0,0 +1,18 @@ +# ListTransactionsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `PageSize` | **int64* | :heavy_minus_sign: | The maximum number of results to return per page.
| 100 | +| `After` | **string* | :heavy_minus_sign: | Pagination cursor, will return transactions after given txid (in descending order). | 1234 | +| `Reference` | **string* | :heavy_minus_sign: | Find transactions by reference field. | ref:001 | +| `Account` | **string* | :heavy_minus_sign: | Filter transactions with postings involving given account, either as source or destination (regular expression placed between ^ and $). | users:001 | +| `Source` | **string* | :heavy_minus_sign: | Filter transactions with postings involving given account at source (regular expression placed between ^ and $). | users:001 | +| `Destination` | **string* | :heavy_minus_sign: | Filter transactions with postings involving given account at destination (regular expression placed between ^ and $). | users:001 | +| `StartTime` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | Filter transactions that occurred after this timestamp.
The format is RFC3339 and is inclusive (for example, "2023-01-02T15:04:01Z" includes the first second of 4th minute).
| | +| `EndTime` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | Filter transactions that occurred before this timestamp.
The format is RFC3339 and is exclusive (for example, "2023-01-02T15:04:01Z" excludes the first second of 4th minute).
| | +| `Cursor` | **string* | :heavy_minus_sign: | Parameter used in pagination requests. Maximum page size is set to 1000.
Set to the value of next for the next page of results.
Set to the value of previous for the previous page of results.
No other parameters can be set when this parameter is set.
| aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ== | +| `Metadata` | map[string]*any* | :heavy_minus_sign: | Filter transactions by metadata key value pairs. Nested objects can be used as seen in the example below. | | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/listtransactionsresponse.md b/pkg/client/docs/models/operations/listtransactionsresponse.md new file mode 100644 index 000000000..028f53ff5 --- /dev/null +++ b/pkg/client/docs/models/operations/listtransactionsresponse.md @@ -0,0 +1,9 @@ +# ListTransactionsResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `TransactionsCursorResponse` | [*components.TransactionsCursorResponse](../../models/components/transactionscursorresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/metadata.md b/pkg/client/docs/models/operations/metadata.md new file mode 100644 index 000000000..0f347d94e --- /dev/null +++ b/pkg/client/docs/models/operations/metadata.md @@ -0,0 +1,9 @@ +# Metadata + +Filter transactions by metadata key value pairs. Nested objects can be used as seen in the example below. + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/readstatsrequest.md b/pkg/client/docs/models/operations/readstatsrequest.md new file mode 100644 index 000000000..1be5ec747 --- /dev/null +++ b/pkg/client/docs/models/operations/readstatsrequest.md @@ -0,0 +1,8 @@ +# ReadStatsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | +| `Ledger` | *string* | :heavy_check_mark: | name of the ledger | ledger001 | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/readstatsresponse.md b/pkg/client/docs/models/operations/readstatsresponse.md new file mode 100644 index 000000000..bf5012b59 --- /dev/null +++ b/pkg/client/docs/models/operations/readstatsresponse.md @@ -0,0 +1,9 @@ +# ReadStatsResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `StatsResponse` | [*components.StatsResponse](../../models/components/statsresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/reverttransactionrequest.md b/pkg/client/docs/models/operations/reverttransactionrequest.md new file mode 100644 index 000000000..f45867da1 --- /dev/null +++ b/pkg/client/docs/models/operations/reverttransactionrequest.md @@ -0,0 +1,10 @@ +# RevertTransactionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Txid` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `DisableChecks` | **bool* | :heavy_minus_sign: | Allow to disable balances checks | | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/reverttransactionresponse.md b/pkg/client/docs/models/operations/reverttransactionresponse.md new file mode 100644 index 000000000..879646dc2 --- /dev/null +++ b/pkg/client/docs/models/operations/reverttransactionresponse.md @@ -0,0 +1,9 @@ +# RevertTransactionResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `TransactionResponse` | [*components.TransactionResponse](../../models/components/transactionresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/runscriptrequest.md b/pkg/client/docs/models/operations/runscriptrequest.md new file mode 100644 index 000000000..4457efea1 --- /dev/null +++ b/pkg/client/docs/models/operations/runscriptrequest.md @@ -0,0 +1,10 @@ +# RunScriptRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Preview` | **bool* | :heavy_minus_sign: | Set the preview mode. Preview mode doesn't add the logs to the database or publish a message to the message broker. | true | +| `Script` | [components.Script](../../models/components/script.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/runscriptresponse.md b/pkg/client/docs/models/operations/runscriptresponse.md new file mode 100644 index 000000000..bbc1646aa --- /dev/null +++ b/pkg/client/docs/models/operations/runscriptresponse.md @@ -0,0 +1,9 @@ +# RunScriptResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ScriptResponse` | [*components.ScriptResponse](../../models/components/scriptresponse.md) | :heavy_minus_sign: | On success, it will return a 200 status code, and the resulting transaction under the `transaction` field.

On failure, it will also return a 200 status code, and the following fields:
- `details`: contains a URL. When there is an error parsing Numscript, the result can be difficult to read—the provided URL will render the error in an easy-to-read format.
- `errorCode` and `error_code` (deprecated): contains the string code of the error
- `errorMessage` and `error_message` (deprecated): contains a human-readable indication of what went wrong, for example that an account had insufficient funds, or that there was an error in the provided Numscript.
| \ No newline at end of file diff --git a/pkg/client/docs/models/operations/updatemappingrequest.md b/pkg/client/docs/models/operations/updatemappingrequest.md new file mode 100644 index 000000000..188c707e4 --- /dev/null +++ b/pkg/client/docs/models/operations/updatemappingrequest.md @@ -0,0 +1,9 @@ +# UpdateMappingRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `Ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `Mapping` | [components.Mapping](../../models/components/mapping.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/pkg/client/docs/models/operations/updatemappingresponse.md b/pkg/client/docs/models/operations/updatemappingresponse.md new file mode 100644 index 000000000..3d228dd01 --- /dev/null +++ b/pkg/client/docs/models/operations/updatemappingresponse.md @@ -0,0 +1,9 @@ +# UpdateMappingResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `MappingResponse` | [*components.MappingResponse](../../models/components/mappingresponse.md) | :heavy_minus_sign: | OK | \ No newline at end of file diff --git a/pkg/client/docs/models/sdkerrors/errorresponse.md b/pkg/client/docs/models/sdkerrors/errorresponse.md new file mode 100644 index 000000000..601e62804 --- /dev/null +++ b/pkg/client/docs/models/sdkerrors/errorresponse.md @@ -0,0 +1,12 @@ +# ErrorResponse + +Error + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ErrorCode` | [components.ErrorsEnum](../../models/components/errorsenum.md) | :heavy_check_mark: | N/A | INSUFFICIENT_FUND | +| `ErrorMessage` | *string* | :heavy_check_mark: | N/A | [INSUFFICIENT_FUND] account had insufficient funds | +| `Details` | **string* | :heavy_minus_sign: | N/A | https://play.numscript.org/?payload=eyJlcnJvciI6ImFjY291bnQgaGFkIGluc3VmZmljaWVudCBmdW5kcyJ9 | \ No newline at end of file diff --git a/pkg/client/docs/sdks/v1/README.md b/pkg/client/docs/sdks/v1/README.md new file mode 100644 index 000000000..974b44403 --- /dev/null +++ b/pkg/client/docs/sdks/v1/README.md @@ -0,0 +1,1320 @@ +# V1 +(*Ledger.V1*) + +### Available Operations + +* [GetInfo](#getinfo) - Show server information +* [GetLedgerInfo](#getledgerinfo) - Get information about a ledger +* [CountAccounts](#countaccounts) - Count the accounts from a ledger +* [ListAccounts](#listaccounts) - List accounts from a ledger +* [GetAccount](#getaccount) - Get account by its address +* [AddMetadataToAccount](#addmetadatatoaccount) - Add metadata to an account +* [GetMapping](#getmapping) - Get the mapping of a ledger +* [UpdateMapping](#updatemapping) - Update the mapping of a ledger +* [~~RunScript~~](#runscript) - Execute a Numscript :warning: **Deprecated** +* [ReadStats](#readstats) - Get statistics from a ledger +* [CountTransactions](#counttransactions) - Count the transactions from a ledger +* [ListTransactions](#listtransactions) - List transactions from a ledger +* [CreateTransaction](#createtransaction) - Create a new transaction to a ledger +* [GetTransaction](#gettransaction) - Get transaction from a ledger by its ID +* [AddMetadataOnTransaction](#addmetadataontransaction) - Set the metadata of a transaction by its ID +* [RevertTransaction](#reverttransaction) - Revert a ledger transaction by its ID +* [CreateTransactions](#createtransactions) - Create a new batch of transactions to a ledger +* [GetBalances](#getbalances) - Get the balances from a ledger's account +* [GetBalancesAggregated](#getbalancesaggregated) - Get the aggregated balances from selected accounts +* [ListLogs](#listlogs) - List the logs from a ledger + +## GetInfo + +Show server information + +### Example Usage + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.GetInfoResponse](../../models/operations/getinforesponse.md), error** +| Error Object | Status Code | Content Type | +| ----------------------- | ----------------------- | ----------------------- | +| sdkerrors.ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## GetLedgerInfo + +Get information about a ledger + +### Example Usage + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.GetLedgerInfoResponse](../../models/operations/getledgerinforesponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `address` | **string* | :heavy_minus_sign: | Filter accounts by address pattern (regular expression placed between ^ and $). | users:.+ | +| `metadata` | map[string]*any* | :heavy_minus_sign: | 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](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.CountAccountsResponse](../../models/operations/countaccountsresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListAccountsRequest](../../models/operations/listaccountsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.ListAccountsResponse](../../models/operations/listaccountsresponse.md), error** +| Error Object | Status Code | Content Type | +| ----------------------- | ----------------------- | ----------------------- | +| sdkerrors.ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## GetAccount + +Get account by its address + +### Example Usage + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `address` | *string* | :heavy_check_mark: | Exact address of the account. It must match the following regular expressions pattern:
```
^\w+(:\w+)*$
```
| users:001 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.GetAccountResponse](../../models/operations/getaccountresponse.md), error** +| Error Object | Status Code | Content Type | +| ----------------------- | ----------------------- | ----------------------- | +| sdkerrors.ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## AddMetadataToAccount + +Add metadata to an account + +### Example Usage + +```go +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": "", + } + 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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `address` | *string* | :heavy_check_mark: | Exact address of the account. It must match the following regular expressions pattern:
```
^\w+(:\w+)*$
```
| users:001 | +| `requestBody` | map[string]*any* | :heavy_check_mark: | metadata | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.AddMetadataToAccountResponse](../../models/operations/addmetadatatoaccountresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.GetMappingResponse](../../models/operations/getmappingresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `mapping` | [components.Mapping](../../models/components/mapping.md) | :heavy_check_mark: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.UpdateMappingResponse](../../models/operations/updatemappingresponse.md), 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`. + + +> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. + +### Example Usage + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `script` | [components.Script](../../models/components/script.md) | :heavy_check_mark: | N/A | | +| `preview` | **bool* | :heavy_minus_sign: | 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](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.RunScriptResponse](../../models/operations/runscriptresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | name of the ledger | ledger001 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.ReadStatsResponse](../../models/operations/readstatsresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CountTransactionsRequest](../../models/operations/counttransactionsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.CountTransactionsResponse](../../models/operations/counttransactionsresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListTransactionsRequest](../../models/operations/listtransactionsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.ListTransactionsResponse](../../models/operations/listtransactionsresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `postTransaction` | [components.PostTransaction](../../models/components/posttransaction.md) | :heavy_check_mark: | 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* | :heavy_minus_sign: | 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](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.CreateTransactionResponse](../../models/operations/createtransactionresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `txid` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.GetTransactionResponse](../../models/operations/gettransactionresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `txid` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `requestBody` | map[string]*any* | :heavy_minus_sign: | metadata | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.AddMetadataOnTransactionResponse](../../models/operations/addmetadataontransactionresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `txid` | [*big.Int](https://pkg.go.dev/math/big#Int) | :heavy_check_mark: | Transaction ID. | 1234 | +| `disableChecks` | **bool* | :heavy_minus_sign: | Allow to disable balances checks | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.RevertTransactionResponse](../../models/operations/reverttransactionresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `transactions` | [components.Transactions](../../models/components/transactions.md) | :heavy_check_mark: | N/A | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.CreateTransactionsResponse](../../models/operations/createtransactionsresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetBalancesRequest](../../models/operations/getbalancesrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.GetBalancesResponse](../../models/operations/getbalancesresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | +| `ledger` | *string* | :heavy_check_mark: | Name of the ledger. | ledger001 | +| `address` | **string* | :heavy_minus_sign: | Filter balances involving given account, either as source or destination. | users:001 | +| `useInsertionDate` | **bool* | :heavy_minus_sign: | Use insertion date instead of effective date | | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | | + + +### Response + +**[*operations.GetBalancesAggregatedResponse](../../models/operations/getbalancesaggregatedresponse.md), 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 + +```go +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](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListLogsRequest](../../models/operations/listlogsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + + +### Response + +**[*operations.ListLogsResponse](../../models/operations/listlogsresponse.md), error** +| Error Object | Status Code | Content Type | +| ----------------------- | ----------------------- | ----------------------- | +| sdkerrors.ErrorResponse | default | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | diff --git a/pkg/client/docs/sdks/v2/README.md b/pkg/client/docs/sdks/v2/README.md index 85d6f5552..e8cf9c8aa 100644 --- a/pkg/client/docs/sdks/v2/README.md +++ b/pkg/client/docs/sdks/v2/README.md @@ -40,13 +40,19 @@ Show server information package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) ctx := context.Background() res, err := s.Ledger.V2.GetInfo(ctx) @@ -85,13 +91,19 @@ List ledgers package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var pageSize *int64 = client.Int64(100) var cursor *string = client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ==") @@ -134,13 +146,19 @@ Get a ledger package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" ctx := context.Background() res, err := s.Ledger.V2.GetLedger(ctx, ledger) @@ -180,14 +198,19 @@ Create a ledger package main import( - "github.com/formancehq/stack/ledger/client" "github.com/formancehq/stack/ledger/client/models/components" + "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var v2CreateLedgerRequest *components.V2CreateLedgerRequest = &components.V2CreateLedgerRequest{ @@ -234,13 +257,19 @@ Update ledger metadata package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var requestBody map[string]string = map[string]string{ @@ -285,13 +314,19 @@ Delete ledger metadata by key package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var key string = "foo" @@ -334,13 +369,19 @@ Get information about a ledger package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" ctx := context.Background() res, err := s.Ledger.V2.GetLedgerInfo(ctx, ledger) @@ -380,15 +421,20 @@ Bulk request package main import( - "github.com/formancehq/stack/ledger/client" "github.com/formancehq/stack/ledger/client/models/components" + "github.com/formancehq/stack/ledger/client" "math/big" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var requestBody []components.V2BulkElement = []components.V2BulkElement{ @@ -404,7 +450,7 @@ func main() { Source: "users:001", }, }, - Script: &components.Script{ + Script: &components.V2PostTransactionScript{ Plain: "vars { account $user } @@ -464,24 +510,23 @@ Count the accounts from a ledger package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "time" - "github.com/formancehq/stack/ledger/client/types" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" - - var pit *time.Time = types.MustNewTimeFromString("2022-10-10T12:32:37.132Z") - - var requestBody map[string]any = map[string]any{ - "key": "", - } ctx := context.Background() - res, err := s.Ledger.V2.CountAccounts(ctx, ledger, pit, requestBody) + res, err := s.Ledger.V2.CountAccounts(ctx, ledger, nil, nil) if err != nil { log.Fatal(err) } @@ -520,6 +565,7 @@ List accounts from a ledger, sorted by address in descending order. 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" @@ -527,7 +573,12 @@ import( ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) request := operations.V2ListAccountsRequest{ Ledger: "ledger001", PageSize: client.Int64(100), @@ -571,24 +622,25 @@ Get account by its address package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "time" - "github.com/formancehq/stack/ledger/client/types" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var address string = "users:001" - - var expand *string = client.String("") - - var pit *time.Time = types.MustNewTimeFromString("2022-06-03T07:35:25.275Z") ctx := context.Background() - res, err := s.Ledger.V2.GetAccount(ctx, ledger, address, expand, pit) + res, err := s.Ledger.V2.GetAccount(ctx, ledger, address, nil, nil) if err != nil { log.Fatal(err) } @@ -628,6 +680,7 @@ Add metadata to an account 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" @@ -635,7 +688,12 @@ import( ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) request := operations.V2AddMetadataToAccountRequest{ Ledger: "ledger001", Address: "users:001", @@ -682,13 +740,19 @@ Delete metadata by key package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var address string = "" @@ -735,13 +799,19 @@ Get statistics from a ledger. (aggregate metrics on accounts and transactions) package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" ctx := context.Background() res, err := s.Ledger.V2.ReadStats(ctx, ledger) @@ -781,24 +851,23 @@ Count the transactions from a ledger package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "time" - "github.com/formancehq/stack/ledger/client/types" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" - - var pit *time.Time = types.MustNewTimeFromString("2023-09-24T09:44:43.830Z") - - var requestBody map[string]any = map[string]any{ - "key": "", - } ctx := context.Background() - res, err := s.Ledger.V2.CountTransactions(ctx, ledger, pit, requestBody) + res, err := s.Ledger.V2.CountTransactions(ctx, ledger, nil, nil) if err != nil { log.Fatal(err) } @@ -837,6 +906,7 @@ List transactions from a ledger, sorted by id in descending order. 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" @@ -844,7 +914,12 @@ import( ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) request := operations.V2ListTransactionsRequest{ Ledger: "ledger001", PageSize: client.Int64(100), @@ -888,15 +963,20 @@ Create a new transaction to a ledger package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "math/big" - "github.com/formancehq/stack/ledger/client/models/components" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" v2PostTransaction := components.V2PostTransaction{ @@ -908,7 +988,7 @@ func main() { Source: "users:001", }, }, - Script: &components.Script{ + Script: &components.V2PostTransactionScript{ Plain: "vars { account $user } @@ -928,10 +1008,8 @@ func main() { } var dryRun *bool = client.Bool(true) - - var idempotencyKey *string = client.String("") ctx := context.Background() - res, err := s.Ledger.V2.CreateTransaction(ctx, ledger, v2PostTransaction, dryRun, idempotencyKey) + res, err := s.Ledger.V2.CreateTransaction(ctx, ledger, v2PostTransaction, dryRun, nil) if err != nil { log.Fatal(err) } @@ -971,25 +1049,26 @@ Get transaction from a ledger by its ID package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "math/big" "time" - "github.com/formancehq/stack/ledger/client/types" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var id *big.Int = big.NewInt(1234) - - var expand *string = client.String("") - - var pit *time.Time = types.MustNewTimeFromString("2023-08-22T15:58:06.441Z") ctx := context.Background() - res, err := s.Ledger.V2.GetTransaction(ctx, ledger, id, expand, pit) + res, err := s.Ledger.V2.GetTransaction(ctx, ledger, id, nil, nil) if err != nil { log.Fatal(err) } @@ -1029,15 +1108,21 @@ Set the metadata of a transaction by its ID package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" - "math/big" "github.com/formancehq/stack/ledger/client/models/operations" + "math/big" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) request := operations.V2AddMetadataOnTransactionRequest{ Ledger: "ledger001", ID: big.NewInt(1234), @@ -1084,6 +1169,7 @@ Delete metadata by key package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "math/big" "context" @@ -1091,7 +1177,12 @@ import( ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var id *big.Int = big.NewInt(1234) @@ -1137,6 +1228,7 @@ Revert a ledger transaction by its ID package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "math/big" "context" @@ -1144,16 +1236,17 @@ import( ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" var id *big.Int = big.NewInt(1234) - - var force *bool = client.Bool(false) - - var atEffectiveDate *bool = client.Bool(false) ctx := context.Background() - res, err := s.Ledger.V2.RevertTransaction(ctx, ledger, id, force, atEffectiveDate) + res, err := s.Ledger.V2.RevertTransaction(ctx, ledger, id, nil, nil) if err != nil { log.Fatal(err) } @@ -1193,26 +1286,23 @@ Get the aggregated balances from selected accounts package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "time" - "github.com/formancehq/stack/ledger/client/types" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" - - var pit *time.Time = types.MustNewTimeFromString("2023-02-24T06:23:10.823Z") - - var useInsertionDate *bool = client.Bool(false) - - var requestBody map[string]any = map[string]any{ - "key": "", - } ctx := context.Background() - res, err := s.Ledger.V2.GetBalancesAggregated(ctx, ledger, pit, useInsertionDate, requestBody) + res, err := s.Ledger.V2.GetBalancesAggregated(ctx, ledger, nil, nil, nil) if err != nil { log.Fatal(err) } @@ -1252,6 +1342,7 @@ Get list of volumes with balances for (account/asset) 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" @@ -1259,7 +1350,12 @@ import( ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) request := operations.V2GetVolumesWithBalancesRequest{ PageSize: client.Int64(100), Cursor: client.String("aHR0cHM6Ly9nLnBhZ2UvTmVrby1SYW1lbj9zaGFyZQ=="), @@ -1304,6 +1400,7 @@ List the logs from a ledger, sorted by ID in descending order. 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" @@ -1311,7 +1408,12 @@ import( ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) request := operations.V2ListLogsRequest{ Ledger: "ledger001", PageSize: client.Int64(100), @@ -1353,18 +1455,22 @@ func main() { package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" - - var requestBody *string = client.String("") ctx := context.Background() - res, err := s.Ledger.V2.ImportLogs(ctx, ledger, requestBody) + res, err := s.Ledger.V2.ImportLogs(ctx, ledger, nil) if err != nil { log.Fatal(err) } @@ -1402,13 +1508,19 @@ Export logs package main import( + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client" "context" "log" ) func main() { - s := client.New() + s := client.New( + client.WithSecurity(components.Security{ + ClientID: "", + ClientSecret: "", + }), + ) var ledger string = "ledger001" ctx := context.Background() res, err := s.Ledger.V2.ExportLogs(ctx, ledger) diff --git a/pkg/client/formance.go b/pkg/client/formance.go index 93719b35d..fc75add9a 100644 --- a/pkg/client/formance.go +++ b/pkg/client/formance.go @@ -1,11 +1,13 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package client import ( + "context" "fmt" "github.com/formancehq/stack/ledger/client/internal/hooks" "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" "github.com/formancehq/stack/ledger/client/retry" "net/http" "time" @@ -40,8 +42,8 @@ func Float32(f float32) *float32 { return &f } func Float64(f float64) *float64 { return &f } type sdkConfiguration struct { - Client HTTPClient - + Client HTTPClient + Security func(context.Context) (interface{}, error) ServerURL string ServerIndex int Language string @@ -106,6 +108,22 @@ func WithClient(client HTTPClient) SDKOption { } } +// WithSecurity configures the SDK to use the provided security details +func WithSecurity(security components.Security) SDKOption { + return func(sdk *Formance) { + sdk.sdkConfiguration.Security = utils.AsSecuritySource(security) + } +} + +// WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication +func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption { + return func(sdk *Formance) { + sdk.sdkConfiguration.Security = func(ctx context.Context) (interface{}, error) { + return security(ctx) + } + } +} + func WithRetryConfig(retryConfig retry.Config) SDKOption { return func(sdk *Formance) { sdk.sdkConfiguration.RetryConfig = &retryConfig @@ -125,9 +143,9 @@ func New(opts ...SDKOption) *Formance { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "LEDGER_VERSION", - SDKVersion: "0.2.0", - GenVersion: "2.379.3", - UserAgent: "speakeasy-sdk/go 0.2.0 2.379.3 LEDGER_VERSION github.com/formancehq/stack/ledger/client", + SDKVersion: "0.3.0", + GenVersion: "2.384.1", + UserAgent: "speakeasy-sdk/go 0.3.0 2.384.1 LEDGER_VERSION github.com/formancehq/stack/ledger/client", Hooks: hooks.New(), }, } diff --git a/pkg/client/internal/hooks/clientcredentials.go b/pkg/client/internal/hooks/clientcredentials.go new file mode 100644 index 000000000..a7ab67120 --- /dev/null +++ b/pkg/client/internal/hooks/clientcredentials.go @@ -0,0 +1,251 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package hooks + +import ( + "bytes" + "context" + "crypto/md5" + "encoding/hex" + "encoding/json" + "fmt" + "github.com/formancehq/stack/ledger/client/models/components" + "io" + "net/http" + "net/url" + "strings" + "time" +) + +type session struct { + Credentials *credentials + Token string + ExpiresAt *int64 + Scopes []string +} + +type tokenResponse struct { + AccessToken string `json:"access_token"` + TokenType string `json:"token_type"` + ExpiresIn *int64 `json:"expires_in"` +} + +type credentials struct { + ClientID string + ClientSecret string + TokenURL string +} + +type clientCredentialsHook struct { + baseURL string + client HTTPClient + sessions map[string]*session +} + +var ( + _ sdkInitHook = (*clientCredentialsHook)(nil) + _ beforeRequestHook = (*clientCredentialsHook)(nil) + _ afterErrorHook = (*clientCredentialsHook)(nil) +) + +func NewClientCredentialsHook() *clientCredentialsHook { + return &clientCredentialsHook{ + sessions: make(map[string]*session), + } +} + +func (c *clientCredentialsHook) SDKInit(baseURL string, client HTTPClient) (string, HTTPClient) { + c.baseURL = baseURL + c.client = client + return baseURL, client +} + +func (c *clientCredentialsHook) BeforeRequest(ctx BeforeRequestContext, req *http.Request) (*http.Request, error) { + if ctx.OAuth2Scopes == nil { + // OAuth2 not in use + return req, nil + } + + credentials, err := c.getCredentials(ctx.Context, ctx.SecuritySource) + if err != nil { + return nil, &FailEarly{Cause: err} + } + if credentials == nil { + return req, err + } + + sessionKey := getSessionKey(credentials.ClientID, credentials.ClientSecret) + sess, ok := c.sessions[sessionKey] + if !ok || !hasRequiredScopes(sess.Scopes, ctx.OAuth2Scopes) || hasTokenExpired(sess.ExpiresAt) { + s, err := c.doTokenRequest(ctx.Context, credentials, getScopes(ctx.OAuth2Scopes, sess)) + if err != nil { + return nil, fmt.Errorf("failed to get token: %w", err) + } + + c.sessions[sessionKey] = s + sess = s + } + + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", sess.Token)) + + return req, nil +} + +func (c *clientCredentialsHook) AfterError(ctx AfterErrorContext, res *http.Response, err error) (*http.Response, error) { + if ctx.OAuth2Scopes == nil { + // OAuth2 not in use + return res, err + } + + // We don't want to refresh the token if the error is not related to the token + if err != nil { + return res, err + } + + credentials, err := c.getCredentials(ctx.Context, ctx.SecuritySource) + if err != nil { + return nil, &FailEarly{Cause: err} + } + if credentials == nil { + return res, err + } + + if res != nil && res.StatusCode == http.StatusUnauthorized { + sessionKey := getSessionKey(credentials.ClientID, credentials.ClientSecret) + delete(c.sessions, sessionKey) + } + + return res, err +} + +func (c *clientCredentialsHook) doTokenRequest(ctx context.Context, credentials *credentials, scopes []string) (*session, error) { + values := url.Values{} + values.Set("grant_type", "client_credentials") + values.Set("client_id", credentials.ClientID) + values.Set("client_secret", credentials.ClientSecret) + + if len(scopes) > 0 { + values.Set("scope", strings.Join(scopes, " ")) + } + + tokenURL := credentials.TokenURL + u, err := url.Parse(tokenURL) + if err != nil { + return nil, fmt.Errorf("failed to parse token URL: %w", err) + } + if !u.IsAbs() { + tokenURL, err = url.JoinPath(c.baseURL, tokenURL) + if err != nil { + return nil, fmt.Errorf("failed to parse token URL: %w", err) + } + } + + req, err := http.NewRequestWithContext(ctx, http.MethodPost, tokenURL, bytes.NewBufferString(values.Encode())) + if err != nil { + return nil, fmt.Errorf("failed to create token request: %w", err) + } + + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + + res, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("failed to send token request: %w", err) + } + defer res.Body.Close() + + if res.StatusCode < 200 || res.StatusCode >= 300 { + body, _ := io.ReadAll(res.Body) + return nil, fmt.Errorf("unexpected status code: %d: %s", res.StatusCode, body) + } + + var tokenRes tokenResponse + if err := json.NewDecoder(res.Body).Decode(&tokenRes); err != nil { + return nil, fmt.Errorf("failed to decode token response: %w", err) + } + + if tokenRes.TokenType != "Bearer" { + return nil, fmt.Errorf("unexpected token type: %s", tokenRes.TokenType) + } + + var expiresAt *int64 + if tokenRes.ExpiresIn != nil { + expiresAt = new(int64) + *expiresAt = time.Now().Unix() + *tokenRes.ExpiresIn + } + + return &session{ + Credentials: credentials, + Token: tokenRes.AccessToken, + ExpiresAt: expiresAt, + Scopes: scopes, + }, nil +} + +func (c *clientCredentialsHook) getCredentials(ctx context.Context, source func(ctx context.Context) (interface{}, error)) (*credentials, error) { + if source == nil { + return nil, nil + } + + sec, err := source(ctx) + if err != nil { + return nil, err + } + + security, ok := sec.(components.Security) + + if !ok { + return nil, fmt.Errorf("unexpected security type: %T", sec) + } + + return &credentials{ + ClientID: security.ClientID, + ClientSecret: security.ClientSecret, + TokenURL: security.GetTokenURL(), + }, nil +} + +func getSessionKey(clientID, clientSecret string) string { + key := fmt.Sprintf("%s:%s", clientID, clientSecret) + hash := md5.Sum([]byte(key)) + return hex.EncodeToString(hash[:]) +} + +func hasRequiredScopes(scopes []string, requiredScopes []string) bool { + for _, requiredScope := range requiredScopes { + found := false + for _, scope := range scopes { + if scope == requiredScope { + found = true + break + } + } + if !found { + return false + } + } + return true +} + +func getScopes(requiredScopes []string, sess *session) []string { + scopes := requiredScopes + if sess != nil { + for _, scope := range sess.Scopes { + found := false + for _, requiredScope := range requiredScopes { + if scope == requiredScope { + found = true + break + } + } + if !found { + scopes = append(scopes, scope) + } + } + } + + return scopes +} + +func hasTokenExpired(expiresAt *int64) bool { + return expiresAt == nil || time.Now().Unix()+60 >= *expiresAt +} diff --git a/pkg/client/internal/hooks/hooks.go b/pkg/client/internal/hooks/hooks.go index b978f6bef..a1fbccf19 100644 --- a/pkg/client/internal/hooks/hooks.go +++ b/pkg/client/internal/hooks/hooks.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package hooks @@ -71,11 +71,19 @@ type Hooks struct { } func New() *Hooks { + cc := NewClientCredentialsHook() + h := &Hooks{ - sdkInitHooks: []sdkInitHook{}, - beforeRequestHook: []beforeRequestHook{}, - afterSuccessHook: []afterSuccessHook{}, - afterErrorHook: []afterErrorHook{}, + sdkInitHooks: []sdkInitHook{ + cc, + }, + beforeRequestHook: []beforeRequestHook{ + cc, + }, + afterSuccessHook: []afterSuccessHook{}, + afterErrorHook: []afterErrorHook{ + cc, + }, } initHooks(h) diff --git a/pkg/client/internal/utils/contenttype.go b/pkg/client/internal/utils/contenttype.go index 81e669d66..f6487e01e 100644 --- a/pkg/client/internal/utils/contenttype.go +++ b/pkg/client/internal/utils/contenttype.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/form.go b/pkg/client/internal/utils/form.go index 9768ee81b..dcc36fffe 100644 --- a/pkg/client/internal/utils/form.go +++ b/pkg/client/internal/utils/form.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/headers.go b/pkg/client/internal/utils/headers.go index 7af15f9aa..a07608bdc 100644 --- a/pkg/client/internal/utils/headers.go +++ b/pkg/client/internal/utils/headers.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/json.go b/pkg/client/internal/utils/json.go index a0aec02f5..2ef330e53 100644 --- a/pkg/client/internal/utils/json.go +++ b/pkg/client/internal/utils/json.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/pathparams.go b/pkg/client/internal/utils/pathparams.go index 58aabb041..5d3b7aa68 100644 --- a/pkg/client/internal/utils/pathparams.go +++ b/pkg/client/internal/utils/pathparams.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/queryparams.go b/pkg/client/internal/utils/queryparams.go index 4e6ed3573..d83bf61d7 100644 --- a/pkg/client/internal/utils/queryparams.go +++ b/pkg/client/internal/utils/queryparams.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/requestbody.go b/pkg/client/internal/utils/requestbody.go index b4e2b8b39..0fd33cf65 100644 --- a/pkg/client/internal/utils/requestbody.go +++ b/pkg/client/internal/utils/requestbody.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/retries.go b/pkg/client/internal/utils/retries.go index 06d404088..1763518a8 100644 --- a/pkg/client/internal/utils/retries.go +++ b/pkg/client/internal/utils/retries.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/security.go b/pkg/client/internal/utils/security.go index ace81f714..d2558cd73 100644 --- a/pkg/client/internal/utils/security.go +++ b/pkg/client/internal/utils/security.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/internal/utils/utils.go b/pkg/client/internal/utils/utils.go index 50482f2e0..adb2f7055 100644 --- a/pkg/client/internal/utils/utils.go +++ b/pkg/client/internal/utils/utils.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package utils diff --git a/pkg/client/ledger.go b/pkg/client/ledger.go index 71248e1a2..25fcac408 100644 --- a/pkg/client/ledger.go +++ b/pkg/client/ledger.go @@ -1,8 +1,9 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package client type Ledger struct { + V1 *V1 V2 *V2 sdkConfiguration sdkConfiguration @@ -11,6 +12,7 @@ type Ledger struct { func newLedger(sdkConfig sdkConfiguration) *Ledger { return &Ledger{ sdkConfiguration: sdkConfig, + V1: newV1(sdkConfig), V2: newV2(sdkConfig), } } diff --git a/pkg/client/models/components/account.go b/pkg/client/models/components/account.go new file mode 100644 index 000000000..c3a082192 --- /dev/null +++ b/pkg/client/models/components/account.go @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Account struct { + Address string `json:"address"` + Type *string `json:"type,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` +} + +func (o *Account) GetAddress() string { + if o == nil { + return "" + } + return o.Address +} + +func (o *Account) GetType() *string { + if o == nil { + return nil + } + return o.Type +} + +func (o *Account) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} diff --git a/pkg/client/models/components/accountresponse.go b/pkg/client/models/components/accountresponse.go new file mode 100644 index 000000000..8272827c4 --- /dev/null +++ b/pkg/client/models/components/accountresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type AccountResponse struct { + Data AccountWithVolumesAndBalances `json:"data"` +} + +func (o *AccountResponse) GetData() AccountWithVolumesAndBalances { + if o == nil { + return AccountWithVolumesAndBalances{} + } + return o.Data +} diff --git a/pkg/client/models/components/accountscursorresponse.go b/pkg/client/models/components/accountscursorresponse.go new file mode 100644 index 000000000..da12f0630 --- /dev/null +++ b/pkg/client/models/components/accountscursorresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Cursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []Account `json:"data"` +} + +func (o *Cursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *Cursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *Cursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *Cursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *Cursor) GetData() []Account { + if o == nil { + return []Account{} + } + return o.Data +} + +type AccountsCursorResponse struct { + Cursor Cursor `json:"cursor"` +} + +func (o *AccountsCursorResponse) GetCursor() Cursor { + if o == nil { + return Cursor{} + } + return o.Cursor +} diff --git a/pkg/client/models/components/accountwithvolumesandbalances.go b/pkg/client/models/components/accountwithvolumesandbalances.go new file mode 100644 index 000000000..7a2311e12 --- /dev/null +++ b/pkg/client/models/components/accountwithvolumesandbalances.go @@ -0,0 +1,62 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type AccountWithVolumesAndBalances struct { + Address string `json:"address"` + Type *string `json:"type,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` + Volumes map[string]Volume `json:"volumes,omitempty"` + Balances map[string]*big.Int `json:"balances,omitempty"` +} + +func (a AccountWithVolumesAndBalances) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AccountWithVolumesAndBalances) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, false); err != nil { + return err + } + return nil +} + +func (o *AccountWithVolumesAndBalances) GetAddress() string { + if o == nil { + return "" + } + return o.Address +} + +func (o *AccountWithVolumesAndBalances) GetType() *string { + if o == nil { + return nil + } + return o.Type +} + +func (o *AccountWithVolumesAndBalances) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} + +func (o *AccountWithVolumesAndBalances) GetVolumes() map[string]Volume { + if o == nil { + return nil + } + return o.Volumes +} + +func (o *AccountWithVolumesAndBalances) GetBalances() map[string]*big.Int { + if o == nil { + return nil + } + return o.Balances +} diff --git a/pkg/client/models/components/aggregatebalancesresponse.go b/pkg/client/models/components/aggregatebalancesresponse.go new file mode 100644 index 000000000..98d34348d --- /dev/null +++ b/pkg/client/models/components/aggregatebalancesresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type AggregateBalancesResponse struct { + Data map[string]int64 `json:"data"` +} + +func (o *AggregateBalancesResponse) GetData() map[string]int64 { + if o == nil { + return map[string]int64{} + } + return o.Data +} diff --git a/pkg/client/models/components/balancescursorresponse.go b/pkg/client/models/components/balancescursorresponse.go new file mode 100644 index 000000000..ffa4e640c --- /dev/null +++ b/pkg/client/models/components/balancescursorresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type BalancesCursorResponseCursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []map[string]map[string]int64 `json:"data"` +} + +func (o *BalancesCursorResponseCursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *BalancesCursorResponseCursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *BalancesCursorResponseCursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *BalancesCursorResponseCursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *BalancesCursorResponseCursor) GetData() []map[string]map[string]int64 { + if o == nil { + return []map[string]map[string]int64{} + } + return o.Data +} + +type BalancesCursorResponse struct { + Cursor BalancesCursorResponseCursor `json:"cursor"` +} + +func (o *BalancesCursorResponse) GetCursor() BalancesCursorResponseCursor { + if o == nil { + return BalancesCursorResponseCursor{} + } + return o.Cursor +} diff --git a/pkg/client/models/components/config.go b/pkg/client/models/components/config.go new file mode 100644 index 000000000..9d082125e --- /dev/null +++ b/pkg/client/models/components/config.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Config struct { + Storage LedgerStorage `json:"storage"` +} + +func (o *Config) GetStorage() LedgerStorage { + if o == nil { + return LedgerStorage{} + } + return o.Storage +} diff --git a/pkg/client/models/components/configinfo.go b/pkg/client/models/components/configinfo.go new file mode 100644 index 000000000..c157304da --- /dev/null +++ b/pkg/client/models/components/configinfo.go @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type ConfigInfo struct { + Config Config `json:"config"` + Server string `json:"server"` + Version string `json:"version"` +} + +func (o *ConfigInfo) GetConfig() Config { + if o == nil { + return Config{} + } + return o.Config +} + +func (o *ConfigInfo) GetServer() string { + if o == nil { + return "" + } + return o.Server +} + +func (o *ConfigInfo) GetVersion() string { + if o == nil { + return "" + } + return o.Version +} diff --git a/pkg/client/models/components/configinforesponse.go b/pkg/client/models/components/configinforesponse.go new file mode 100644 index 000000000..00b9ef308 --- /dev/null +++ b/pkg/client/models/components/configinforesponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type ConfigInfoResponse struct { + Data ConfigInfo `json:"data"` +} + +func (o *ConfigInfoResponse) GetData() ConfigInfo { + if o == nil { + return ConfigInfo{} + } + return o.Data +} diff --git a/pkg/client/models/components/contract.go b/pkg/client/models/components/contract.go new file mode 100644 index 000000000..caab5a798 --- /dev/null +++ b/pkg/client/models/components/contract.go @@ -0,0 +1,25 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Expr struct { +} + +type Contract struct { + Account *string `json:"account,omitempty"` + Expr Expr `json:"expr"` +} + +func (o *Contract) GetAccount() *string { + if o == nil { + return nil + } + return o.Account +} + +func (o *Contract) GetExpr() Expr { + if o == nil { + return Expr{} + } + return o.Expr +} diff --git a/pkg/client/models/components/errorsenum.go b/pkg/client/models/components/errorsenum.go new file mode 100644 index 000000000..d38e729ed --- /dev/null +++ b/pkg/client/models/components/errorsenum.go @@ -0,0 +1,52 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" +) + +type ErrorsEnum string + +const ( + ErrorsEnumInternal ErrorsEnum = "INTERNAL" + ErrorsEnumInsufficientFund ErrorsEnum = "INSUFFICIENT_FUND" + ErrorsEnumValidation ErrorsEnum = "VALIDATION" + ErrorsEnumConflict ErrorsEnum = "CONFLICT" + ErrorsEnumNoScript ErrorsEnum = "NO_SCRIPT" + ErrorsEnumCompilationFailed ErrorsEnum = "COMPILATION_FAILED" + ErrorsEnumMetadataOverride ErrorsEnum = "METADATA_OVERRIDE" + ErrorsEnumNotFound ErrorsEnum = "NOT_FOUND" +) + +func (e ErrorsEnum) ToPointer() *ErrorsEnum { + return &e +} +func (e *ErrorsEnum) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "INTERNAL": + fallthrough + case "INSUFFICIENT_FUND": + fallthrough + case "VALIDATION": + fallthrough + case "CONFLICT": + fallthrough + case "NO_SCRIPT": + fallthrough + case "COMPILATION_FAILED": + fallthrough + case "METADATA_OVERRIDE": + fallthrough + case "NOT_FOUND": + *e = ErrorsEnum(v) + return nil + default: + return fmt.Errorf("invalid value for ErrorsEnum: %v", v) + } +} diff --git a/pkg/client/models/components/httpmetadata.go b/pkg/client/models/components/httpmetadata.go index 7487a5b0b..e18bdc060 100644 --- a/pkg/client/models/components/httpmetadata.go +++ b/pkg/client/models/components/httpmetadata.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/ledgerinfo.go b/pkg/client/models/components/ledgerinfo.go new file mode 100644 index 000000000..bcc42a98b --- /dev/null +++ b/pkg/client/models/components/ledgerinfo.go @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Storage struct { + Migrations []MigrationInfo `json:"migrations,omitempty"` +} + +func (o *Storage) GetMigrations() []MigrationInfo { + if o == nil { + return nil + } + return o.Migrations +} + +type LedgerInfo struct { + Name *string `json:"name,omitempty"` + Storage *Storage `json:"storage,omitempty"` +} + +func (o *LedgerInfo) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *LedgerInfo) GetStorage() *Storage { + if o == nil { + return nil + } + return o.Storage +} diff --git a/pkg/client/models/components/ledgerinforesponse.go b/pkg/client/models/components/ledgerinforesponse.go new file mode 100644 index 000000000..cba04ab2f --- /dev/null +++ b/pkg/client/models/components/ledgerinforesponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type LedgerInfoResponse struct { + Data *LedgerInfo `json:"data,omitempty"` +} + +func (o *LedgerInfoResponse) GetData() *LedgerInfo { + if o == nil { + return nil + } + return o.Data +} diff --git a/pkg/client/models/components/ledgerstorage.go b/pkg/client/models/components/ledgerstorage.go new file mode 100644 index 000000000..30e3302e7 --- /dev/null +++ b/pkg/client/models/components/ledgerstorage.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type LedgerStorage struct { + Driver string `json:"driver"` + Ledgers []string `json:"ledgers"` +} + +func (o *LedgerStorage) GetDriver() string { + if o == nil { + return "" + } + return o.Driver +} + +func (o *LedgerStorage) GetLedgers() []string { + if o == nil { + return []string{} + } + return o.Ledgers +} diff --git a/pkg/client/models/components/log.go b/pkg/client/models/components/log.go new file mode 100644 index 000000000..1dc011279 --- /dev/null +++ b/pkg/client/models/components/log.go @@ -0,0 +1,90 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" + "github.com/formancehq/stack/ledger/client/internal/utils" + "time" +) + +type Type string + +const ( + TypeNewTransaction Type = "NEW_TRANSACTION" + TypeSetMetadata Type = "SET_METADATA" +) + +func (e Type) ToPointer() *Type { + return &e +} +func (e *Type) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "NEW_TRANSACTION": + fallthrough + case "SET_METADATA": + *e = Type(v) + return nil + default: + return fmt.Errorf("invalid value for Type: %v", v) + } +} + +type Log struct { + ID int64 `json:"id"` + Type Type `json:"type"` + Data map[string]any `json:"data"` + Hash string `json:"hash"` + Date time.Time `json:"date"` +} + +func (l Log) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *Log) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, false); err != nil { + return err + } + return nil +} + +func (o *Log) GetID() int64 { + if o == nil { + return 0 + } + return o.ID +} + +func (o *Log) GetType() Type { + if o == nil { + return Type("") + } + return o.Type +} + +func (o *Log) GetData() map[string]any { + if o == nil { + return map[string]any{} + } + return o.Data +} + +func (o *Log) GetHash() string { + if o == nil { + return "" + } + return o.Hash +} + +func (o *Log) GetDate() time.Time { + if o == nil { + return time.Time{} + } + return o.Date +} diff --git a/pkg/client/models/components/logscursorresponse.go b/pkg/client/models/components/logscursorresponse.go new file mode 100644 index 000000000..091c46930 --- /dev/null +++ b/pkg/client/models/components/logscursorresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type LogsCursorResponseCursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []Log `json:"data"` +} + +func (o *LogsCursorResponseCursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *LogsCursorResponseCursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *LogsCursorResponseCursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *LogsCursorResponseCursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *LogsCursorResponseCursor) GetData() []Log { + if o == nil { + return []Log{} + } + return o.Data +} + +type LogsCursorResponse struct { + Cursor LogsCursorResponseCursor `json:"cursor"` +} + +func (o *LogsCursorResponse) GetCursor() LogsCursorResponseCursor { + if o == nil { + return LogsCursorResponseCursor{} + } + return o.Cursor +} diff --git a/pkg/client/models/components/mapping.go b/pkg/client/models/components/mapping.go new file mode 100644 index 000000000..f14fcab66 --- /dev/null +++ b/pkg/client/models/components/mapping.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Mapping struct { + Contracts []Contract `json:"contracts"` +} + +func (o *Mapping) GetContracts() []Contract { + if o == nil { + return []Contract{} + } + return o.Contracts +} diff --git a/pkg/client/models/components/mappingresponse.go b/pkg/client/models/components/mappingresponse.go new file mode 100644 index 000000000..cda00d26b --- /dev/null +++ b/pkg/client/models/components/mappingresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type MappingResponse struct { + Data *Mapping `json:"data,omitempty"` +} + +func (o *MappingResponse) GetData() *Mapping { + if o == nil { + return nil + } + return o.Data +} diff --git a/pkg/client/models/components/migrationinfo.go b/pkg/client/models/components/migrationinfo.go new file mode 100644 index 000000000..427c31624 --- /dev/null +++ b/pkg/client/models/components/migrationinfo.go @@ -0,0 +1,82 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" + "github.com/formancehq/stack/ledger/client/internal/utils" + "time" +) + +type State string + +const ( + StateToDo State = "TO DO" + StateDone State = "DONE" +) + +func (e State) ToPointer() *State { + return &e +} +func (e *State) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "TO DO": + fallthrough + case "DONE": + *e = State(v) + return nil + default: + return fmt.Errorf("invalid value for State: %v", v) + } +} + +type MigrationInfo struct { + Version *int64 `json:"version,omitempty"` + Name *string `json:"name,omitempty"` + Date *time.Time `json:"date,omitempty"` + State *State `json:"state,omitempty"` +} + +func (m MigrationInfo) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(m, "", false) +} + +func (m *MigrationInfo) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &m, "", false, false); err != nil { + return err + } + return nil +} + +func (o *MigrationInfo) GetVersion() *int64 { + if o == nil { + return nil + } + return o.Version +} + +func (o *MigrationInfo) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *MigrationInfo) GetDate() *time.Time { + if o == nil { + return nil + } + return o.Date +} + +func (o *MigrationInfo) GetState() *State { + if o == nil { + return nil + } + return o.State +} diff --git a/pkg/client/models/components/posting.go b/pkg/client/models/components/posting.go new file mode 100644 index 000000000..ab77c35b8 --- /dev/null +++ b/pkg/client/models/components/posting.go @@ -0,0 +1,54 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type Posting struct { + Amount *big.Int `json:"amount"` + Asset string `json:"asset"` + Destination string `json:"destination"` + Source string `json:"source"` +} + +func (p Posting) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(p, "", false) +} + +func (p *Posting) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &p, "", false, false); err != nil { + return err + } + return nil +} + +func (o *Posting) GetAmount() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Amount +} + +func (o *Posting) GetAsset() string { + if o == nil { + return "" + } + return o.Asset +} + +func (o *Posting) GetDestination() string { + if o == nil { + return "" + } + return o.Destination +} + +func (o *Posting) GetSource() string { + if o == nil { + return "" + } + return o.Source +} diff --git a/pkg/client/models/components/posttransaction.go b/pkg/client/models/components/posttransaction.go new file mode 100644 index 000000000..a580b461f --- /dev/null +++ b/pkg/client/models/components/posttransaction.go @@ -0,0 +1,81 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "time" +) + +type PostTransactionScript struct { + Plain string `json:"plain"` + Vars map[string]any `json:"vars,omitempty"` +} + +func (o *PostTransactionScript) GetPlain() string { + if o == nil { + return "" + } + return o.Plain +} + +func (o *PostTransactionScript) GetVars() map[string]any { + if o == nil { + return nil + } + return o.Vars +} + +type PostTransaction struct { + Timestamp *time.Time `json:"timestamp,omitempty"` + Postings []Posting `json:"postings,omitempty"` + Script *PostTransactionScript `json:"script,omitempty"` + Reference *string `json:"reference,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` +} + +func (p PostTransaction) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(p, "", false) +} + +func (p *PostTransaction) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &p, "", false, false); err != nil { + return err + } + return nil +} + +func (o *PostTransaction) GetTimestamp() *time.Time { + if o == nil { + return nil + } + return o.Timestamp +} + +func (o *PostTransaction) GetPostings() []Posting { + if o == nil { + return nil + } + return o.Postings +} + +func (o *PostTransaction) GetScript() *PostTransactionScript { + if o == nil { + return nil + } + return o.Script +} + +func (o *PostTransaction) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *PostTransaction) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} diff --git a/pkg/client/models/components/script.go b/pkg/client/models/components/script.go new file mode 100644 index 000000000..7193035d4 --- /dev/null +++ b/pkg/client/models/components/script.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Script struct { + Plain string `json:"plain"` + Vars map[string]any `json:"vars,omitempty"` + // Reference to attach to the generated transaction + Reference *string `json:"reference,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` +} + +func (o *Script) GetPlain() string { + if o == nil { + return "" + } + return o.Plain +} + +func (o *Script) GetVars() map[string]any { + if o == nil { + return nil + } + return o.Vars +} + +func (o *Script) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *Script) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} diff --git a/pkg/client/models/components/scriptresponse.go b/pkg/client/models/components/scriptresponse.go new file mode 100644 index 000000000..21dd04456 --- /dev/null +++ b/pkg/client/models/components/scriptresponse.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type ScriptResponse struct { + ErrorCode *ErrorsEnum `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Details *string `json:"details,omitempty"` + Transaction *Transaction `json:"transaction,omitempty"` +} + +func (o *ScriptResponse) GetErrorCode() *ErrorsEnum { + if o == nil { + return nil + } + return o.ErrorCode +} + +func (o *ScriptResponse) GetErrorMessage() *string { + if o == nil { + return nil + } + return o.ErrorMessage +} + +func (o *ScriptResponse) GetDetails() *string { + if o == nil { + return nil + } + return o.Details +} + +func (o *ScriptResponse) GetTransaction() *Transaction { + if o == nil { + return nil + } + return o.Transaction +} diff --git a/pkg/client/models/components/security.go b/pkg/client/models/components/security.go new file mode 100644 index 000000000..f40aee125 --- /dev/null +++ b/pkg/client/models/components/security.go @@ -0,0 +1,42 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" +) + +type Security struct { + ClientID string `security:"scheme,type=oauth2,subtype=client_credentials,name=clientID"` + ClientSecret string `security:"scheme,type=oauth2,subtype=client_credentials,name=clientSecret"` + tokenURL string `const:"/api/auth/oauth/token"` +} + +func (s Security) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *Security) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil { + return err + } + return nil +} + +func (o *Security) GetClientID() string { + if o == nil { + return "" + } + return o.ClientID +} + +func (o *Security) GetClientSecret() string { + if o == nil { + return "" + } + return o.ClientSecret +} + +func (o *Security) GetTokenURL() string { + return "/api/auth/oauth/token" +} diff --git a/pkg/client/models/components/stats.go b/pkg/client/models/components/stats.go new file mode 100644 index 000000000..f29eed042 --- /dev/null +++ b/pkg/client/models/components/stats.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Stats struct { + Accounts int64 `json:"accounts"` + Transactions int64 `json:"transactions"` +} + +func (o *Stats) GetAccounts() int64 { + if o == nil { + return 0 + } + return o.Accounts +} + +func (o *Stats) GetTransactions() int64 { + if o == nil { + return 0 + } + return o.Transactions +} diff --git a/pkg/client/models/components/statsresponse.go b/pkg/client/models/components/statsresponse.go new file mode 100644 index 000000000..617c7c067 --- /dev/null +++ b/pkg/client/models/components/statsresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type StatsResponse struct { + Data Stats `json:"data"` +} + +func (o *StatsResponse) GetData() Stats { + if o == nil { + return Stats{} + } + return o.Data +} diff --git a/pkg/client/models/components/transaction.go b/pkg/client/models/components/transaction.go new file mode 100644 index 000000000..db820be2c --- /dev/null +++ b/pkg/client/models/components/transaction.go @@ -0,0 +1,79 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" + "time" +) + +type Transaction struct { + Timestamp time.Time `json:"timestamp"` + Postings []Posting `json:"postings"` + Reference *string `json:"reference,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` + Txid *big.Int `json:"txid"` + PreCommitVolumes map[string]map[string]Volume `json:"preCommitVolumes,omitempty"` + PostCommitVolumes map[string]map[string]Volume `json:"postCommitVolumes,omitempty"` +} + +func (t Transaction) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(t, "", false) +} + +func (t *Transaction) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &t, "", false, false); err != nil { + return err + } + return nil +} + +func (o *Transaction) GetTimestamp() time.Time { + if o == nil { + return time.Time{} + } + return o.Timestamp +} + +func (o *Transaction) GetPostings() []Posting { + if o == nil { + return []Posting{} + } + return o.Postings +} + +func (o *Transaction) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *Transaction) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} + +func (o *Transaction) GetTxid() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Txid +} + +func (o *Transaction) GetPreCommitVolumes() map[string]map[string]Volume { + if o == nil { + return nil + } + return o.PreCommitVolumes +} + +func (o *Transaction) GetPostCommitVolumes() map[string]map[string]Volume { + if o == nil { + return nil + } + return o.PostCommitVolumes +} diff --git a/pkg/client/models/components/transactiondata.go b/pkg/client/models/components/transactiondata.go new file mode 100644 index 000000000..58cfdeb1e --- /dev/null +++ b/pkg/client/models/components/transactiondata.go @@ -0,0 +1,54 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "time" +) + +type TransactionData struct { + Postings []Posting `json:"postings"` + Reference *string `json:"reference,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` + Timestamp *time.Time `json:"timestamp,omitempty"` +} + +func (t TransactionData) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(t, "", false) +} + +func (t *TransactionData) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &t, "", false, false); err != nil { + return err + } + return nil +} + +func (o *TransactionData) GetPostings() []Posting { + if o == nil { + return []Posting{} + } + return o.Postings +} + +func (o *TransactionData) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *TransactionData) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} + +func (o *TransactionData) GetTimestamp() *time.Time { + if o == nil { + return nil + } + return o.Timestamp +} diff --git a/pkg/client/models/components/transactionresponse.go b/pkg/client/models/components/transactionresponse.go new file mode 100644 index 000000000..fe0d4ffaf --- /dev/null +++ b/pkg/client/models/components/transactionresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type TransactionResponse struct { + Data Transaction `json:"data"` +} + +func (o *TransactionResponse) GetData() Transaction { + if o == nil { + return Transaction{} + } + return o.Data +} diff --git a/pkg/client/models/components/transactions.go b/pkg/client/models/components/transactions.go new file mode 100644 index 000000000..9a72dcf8d --- /dev/null +++ b/pkg/client/models/components/transactions.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Transactions struct { + Transactions []TransactionData `json:"transactions"` +} + +func (o *Transactions) GetTransactions() []TransactionData { + if o == nil { + return []TransactionData{} + } + return o.Transactions +} diff --git a/pkg/client/models/components/transactionscursorresponse.go b/pkg/client/models/components/transactionscursorresponse.go new file mode 100644 index 000000000..1845a8580 --- /dev/null +++ b/pkg/client/models/components/transactionscursorresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type TransactionsCursorResponseCursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitempty"` + Next *string `json:"next,omitempty"` + Data []Transaction `json:"data"` +} + +func (o *TransactionsCursorResponseCursor) GetPageSize() int64 { + if o == nil { + return 0 + } + return o.PageSize +} + +func (o *TransactionsCursorResponseCursor) GetHasMore() bool { + if o == nil { + return false + } + return o.HasMore +} + +func (o *TransactionsCursorResponseCursor) GetPrevious() *string { + if o == nil { + return nil + } + return o.Previous +} + +func (o *TransactionsCursorResponseCursor) GetNext() *string { + if o == nil { + return nil + } + return o.Next +} + +func (o *TransactionsCursorResponseCursor) GetData() []Transaction { + if o == nil { + return []Transaction{} + } + return o.Data +} + +type TransactionsCursorResponse struct { + Cursor TransactionsCursorResponseCursor `json:"cursor"` +} + +func (o *TransactionsCursorResponse) GetCursor() TransactionsCursorResponseCursor { + if o == nil { + return TransactionsCursorResponseCursor{} + } + return o.Cursor +} diff --git a/pkg/client/models/components/transactionsresponse.go b/pkg/client/models/components/transactionsresponse.go new file mode 100644 index 000000000..534b64421 --- /dev/null +++ b/pkg/client/models/components/transactionsresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type TransactionsResponse struct { + Data []Transaction `json:"data"` +} + +func (o *TransactionsResponse) GetData() []Transaction { + if o == nil { + return []Transaction{} + } + return o.Data +} diff --git a/pkg/client/models/components/v2account.go b/pkg/client/models/components/v2account.go index ae75c8304..8d8c58f65 100644 --- a/pkg/client/models/components/v2account.go +++ b/pkg/client/models/components/v2account.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2accountresponse.go b/pkg/client/models/components/v2accountresponse.go index 82470b692..c4017dd0d 100644 --- a/pkg/client/models/components/v2accountresponse.go +++ b/pkg/client/models/components/v2accountresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2accountscursorresponse.go b/pkg/client/models/components/v2accountscursorresponse.go index 1f0a921a8..d8453cb36 100644 --- a/pkg/client/models/components/v2accountscursorresponse.go +++ b/pkg/client/models/components/v2accountscursorresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2aggregatebalancesresponse.go b/pkg/client/models/components/v2aggregatebalancesresponse.go index 6f23e9532..5ac12c30c 100644 --- a/pkg/client/models/components/v2aggregatebalancesresponse.go +++ b/pkg/client/models/components/v2aggregatebalancesresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2bulkelement.go b/pkg/client/models/components/v2bulkelement.go index ad4c3c9bb..5e2739491 100644 --- a/pkg/client/models/components/v2bulkelement.go +++ b/pkg/client/models/components/v2bulkelement.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2bulkelementaddmetadata.go b/pkg/client/models/components/v2bulkelementaddmetadata.go index f059cdf0b..c43dd7a90 100644 --- a/pkg/client/models/components/v2bulkelementaddmetadata.go +++ b/pkg/client/models/components/v2bulkelementaddmetadata.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2bulkelementcreatetransaction.go b/pkg/client/models/components/v2bulkelementcreatetransaction.go index d06abc2dc..fac83e604 100644 --- a/pkg/client/models/components/v2bulkelementcreatetransaction.go +++ b/pkg/client/models/components/v2bulkelementcreatetransaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2bulkelementdeletemetadata.go b/pkg/client/models/components/v2bulkelementdeletemetadata.go index a4b351642..d5d870589 100644 --- a/pkg/client/models/components/v2bulkelementdeletemetadata.go +++ b/pkg/client/models/components/v2bulkelementdeletemetadata.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2bulkelementresult.go b/pkg/client/models/components/v2bulkelementresult.go index 6730a0bc1..16a7af557 100644 --- a/pkg/client/models/components/v2bulkelementresult.go +++ b/pkg/client/models/components/v2bulkelementresult.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2bulkelementreverttransaction.go b/pkg/client/models/components/v2bulkelementreverttransaction.go index e1f4c5b19..3365f1079 100644 --- a/pkg/client/models/components/v2bulkelementreverttransaction.go +++ b/pkg/client/models/components/v2bulkelementreverttransaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2bulkresponse.go b/pkg/client/models/components/v2bulkresponse.go index 2d5cd5c74..06eace58f 100644 --- a/pkg/client/models/components/v2bulkresponse.go +++ b/pkg/client/models/components/v2bulkresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2configinforesponse.go b/pkg/client/models/components/v2configinforesponse.go index e4d2d8c18..f22a1df9a 100644 --- a/pkg/client/models/components/v2configinforesponse.go +++ b/pkg/client/models/components/v2configinforesponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2createledgerrequest.go b/pkg/client/models/components/v2createledgerrequest.go index 9f1aed0f4..6d2dd9f42 100644 --- a/pkg/client/models/components/v2createledgerrequest.go +++ b/pkg/client/models/components/v2createledgerrequest.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2createtransactionresponse.go b/pkg/client/models/components/v2createtransactionresponse.go index 0fea3d18a..6638ac8d4 100644 --- a/pkg/client/models/components/v2createtransactionresponse.go +++ b/pkg/client/models/components/v2createtransactionresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2errorsenum.go b/pkg/client/models/components/v2errorsenum.go index cde83a325..defc9c108 100644 --- a/pkg/client/models/components/v2errorsenum.go +++ b/pkg/client/models/components/v2errorsenum.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2expandedtransaction.go b/pkg/client/models/components/v2expandedtransaction.go index 518cbd3fd..976a7c6b2 100644 --- a/pkg/client/models/components/v2expandedtransaction.go +++ b/pkg/client/models/components/v2expandedtransaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2getledgerresponse.go b/pkg/client/models/components/v2getledgerresponse.go index 9d4c134ad..f264cd736 100644 --- a/pkg/client/models/components/v2getledgerresponse.go +++ b/pkg/client/models/components/v2getledgerresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2gettransactionresponse.go b/pkg/client/models/components/v2gettransactionresponse.go index 8033f820c..d8772bc9a 100644 --- a/pkg/client/models/components/v2gettransactionresponse.go +++ b/pkg/client/models/components/v2gettransactionresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2ledger.go b/pkg/client/models/components/v2ledger.go index 4b15cc99a..32fca8770 100644 --- a/pkg/client/models/components/v2ledger.go +++ b/pkg/client/models/components/v2ledger.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2ledgerinfo.go b/pkg/client/models/components/v2ledgerinfo.go index 2047a9a4f..e806a1a9b 100644 --- a/pkg/client/models/components/v2ledgerinfo.go +++ b/pkg/client/models/components/v2ledgerinfo.go @@ -1,12 +1,12 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components -type Storage struct { +type V2LedgerInfoStorage struct { Migrations []V2MigrationInfo `json:"migrations,omitempty"` } -func (o *Storage) GetMigrations() []V2MigrationInfo { +func (o *V2LedgerInfoStorage) GetMigrations() []V2MigrationInfo { if o == nil { return nil } @@ -14,8 +14,8 @@ func (o *Storage) GetMigrations() []V2MigrationInfo { } type V2LedgerInfo struct { - Name *string `json:"name,omitempty"` - Storage *Storage `json:"storage,omitempty"` + Name *string `json:"name,omitempty"` + Storage *V2LedgerInfoStorage `json:"storage,omitempty"` } func (o *V2LedgerInfo) GetName() *string { @@ -25,7 +25,7 @@ func (o *V2LedgerInfo) GetName() *string { return o.Name } -func (o *V2LedgerInfo) GetStorage() *Storage { +func (o *V2LedgerInfo) GetStorage() *V2LedgerInfoStorage { if o == nil { return nil } diff --git a/pkg/client/models/components/v2ledgerinforesponse.go b/pkg/client/models/components/v2ledgerinforesponse.go index a07fccb05..2d1151669 100644 --- a/pkg/client/models/components/v2ledgerinforesponse.go +++ b/pkg/client/models/components/v2ledgerinforesponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2ledgerlistresponse.go b/pkg/client/models/components/v2ledgerlistresponse.go index 1aa4b35d5..053795379 100644 --- a/pkg/client/models/components/v2ledgerlistresponse.go +++ b/pkg/client/models/components/v2ledgerlistresponse.go @@ -1,8 +1,8 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components -type Cursor struct { +type V2LedgerListResponseCursor struct { PageSize int64 `json:"pageSize"` HasMore bool `json:"hasMore"` Previous *string `json:"previous,omitempty"` @@ -10,35 +10,35 @@ type Cursor struct { Data []V2Ledger `json:"data"` } -func (o *Cursor) GetPageSize() int64 { +func (o *V2LedgerListResponseCursor) GetPageSize() int64 { if o == nil { return 0 } return o.PageSize } -func (o *Cursor) GetHasMore() bool { +func (o *V2LedgerListResponseCursor) GetHasMore() bool { if o == nil { return false } return o.HasMore } -func (o *Cursor) GetPrevious() *string { +func (o *V2LedgerListResponseCursor) GetPrevious() *string { if o == nil { return nil } return o.Previous } -func (o *Cursor) GetNext() *string { +func (o *V2LedgerListResponseCursor) GetNext() *string { if o == nil { return nil } return o.Next } -func (o *Cursor) GetData() []V2Ledger { +func (o *V2LedgerListResponseCursor) GetData() []V2Ledger { if o == nil { return []V2Ledger{} } @@ -46,12 +46,12 @@ func (o *Cursor) GetData() []V2Ledger { } type V2LedgerListResponse struct { - Cursor Cursor `json:"cursor"` + Cursor V2LedgerListResponseCursor `json:"cursor"` } -func (o *V2LedgerListResponse) GetCursor() Cursor { +func (o *V2LedgerListResponse) GetCursor() V2LedgerListResponseCursor { if o == nil { - return Cursor{} + return V2LedgerListResponseCursor{} } return o.Cursor } diff --git a/pkg/client/models/components/v2log.go b/pkg/client/models/components/v2log.go index c81489095..faf4b8b6d 100644 --- a/pkg/client/models/components/v2log.go +++ b/pkg/client/models/components/v2log.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components @@ -10,18 +10,18 @@ import ( "time" ) -type Type string +type V2LogType string const ( - TypeNewTransaction Type = "NEW_TRANSACTION" - TypeSetMetadata Type = "SET_METADATA" - TypeRevertedTransaction Type = "REVERTED_TRANSACTION" + V2LogTypeNewTransaction V2LogType = "NEW_TRANSACTION" + V2LogTypeSetMetadata V2LogType = "SET_METADATA" + V2LogTypeRevertedTransaction V2LogType = "REVERTED_TRANSACTION" ) -func (e Type) ToPointer() *Type { +func (e V2LogType) ToPointer() *V2LogType { return &e } -func (e *Type) UnmarshalJSON(data []byte) error { +func (e *V2LogType) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { return err @@ -32,16 +32,16 @@ func (e *Type) UnmarshalJSON(data []byte) error { case "SET_METADATA": fallthrough case "REVERTED_TRANSACTION": - *e = Type(v) + *e = V2LogType(v) return nil default: - return fmt.Errorf("invalid value for Type: %v", v) + return fmt.Errorf("invalid value for V2LogType: %v", v) } } type V2Log struct { ID *big.Int `json:"id"` - Type Type `json:"type"` + Type V2LogType `json:"type"` Data map[string]any `json:"data"` Hash string `json:"hash"` Date time.Time `json:"date"` @@ -65,9 +65,9 @@ func (o *V2Log) GetID() *big.Int { return o.ID } -func (o *V2Log) GetType() Type { +func (o *V2Log) GetType() V2LogType { if o == nil { - return Type("") + return V2LogType("") } return o.Type } diff --git a/pkg/client/models/components/v2logscursorresponse.go b/pkg/client/models/components/v2logscursorresponse.go index f74346dde..610a21619 100644 --- a/pkg/client/models/components/v2logscursorresponse.go +++ b/pkg/client/models/components/v2logscursorresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2migrationinfo.go b/pkg/client/models/components/v2migrationinfo.go index 8cef4660b..07a0a6869 100644 --- a/pkg/client/models/components/v2migrationinfo.go +++ b/pkg/client/models/components/v2migrationinfo.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components @@ -9,17 +9,17 @@ import ( "time" ) -type State string +type V2MigrationInfoState string const ( - StateToDo State = "TO DO" - StateDone State = "DONE" + V2MigrationInfoStateToDo V2MigrationInfoState = "TO DO" + V2MigrationInfoStateDone V2MigrationInfoState = "DONE" ) -func (e State) ToPointer() *State { +func (e V2MigrationInfoState) ToPointer() *V2MigrationInfoState { return &e } -func (e *State) UnmarshalJSON(data []byte) error { +func (e *V2MigrationInfoState) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { return err @@ -28,18 +28,18 @@ func (e *State) UnmarshalJSON(data []byte) error { case "TO DO": fallthrough case "DONE": - *e = State(v) + *e = V2MigrationInfoState(v) return nil default: - return fmt.Errorf("invalid value for State: %v", v) + return fmt.Errorf("invalid value for V2MigrationInfoState: %v", v) } } type V2MigrationInfo struct { - Version *int64 `json:"version,omitempty"` - Name *string `json:"name,omitempty"` - Date *time.Time `json:"date,omitempty"` - State *State `json:"state,omitempty"` + Version *int64 `json:"version,omitempty"` + Name *string `json:"name,omitempty"` + Date *time.Time `json:"date,omitempty"` + State *V2MigrationInfoState `json:"state,omitempty"` } func (v V2MigrationInfo) MarshalJSON() ([]byte, error) { @@ -74,7 +74,7 @@ func (o *V2MigrationInfo) GetDate() *time.Time { return o.Date } -func (o *V2MigrationInfo) GetState() *State { +func (o *V2MigrationInfo) GetState() *V2MigrationInfoState { if o == nil { return nil } diff --git a/pkg/client/models/components/v2posting.go b/pkg/client/models/components/v2posting.go index c9466d6c6..f228d864e 100644 --- a/pkg/client/models/components/v2posting.go +++ b/pkg/client/models/components/v2posting.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2posttransaction.go b/pkg/client/models/components/v2posttransaction.go index c99ba1a7d..45ad15533 100644 --- a/pkg/client/models/components/v2posttransaction.go +++ b/pkg/client/models/components/v2posttransaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components @@ -7,19 +7,19 @@ import ( "time" ) -type Script struct { +type V2PostTransactionScript struct { Plain string `json:"plain"` Vars map[string]any `json:"vars,omitempty"` } -func (o *Script) GetPlain() string { +func (o *V2PostTransactionScript) GetPlain() string { if o == nil { return "" } return o.Plain } -func (o *Script) GetVars() map[string]any { +func (o *V2PostTransactionScript) GetVars() map[string]any { if o == nil { return nil } @@ -27,11 +27,11 @@ func (o *Script) GetVars() map[string]any { } type V2PostTransaction struct { - Timestamp *time.Time `json:"timestamp,omitempty"` - Postings []V2Posting `json:"postings,omitempty"` - Script *Script `json:"script,omitempty"` - Reference *string `json:"reference,omitempty"` - Metadata map[string]string `json:"metadata"` + Timestamp *time.Time `json:"timestamp,omitempty"` + Postings []V2Posting `json:"postings,omitempty"` + Script *V2PostTransactionScript `json:"script,omitempty"` + Reference *string `json:"reference,omitempty"` + Metadata map[string]string `json:"metadata"` } func (v V2PostTransaction) MarshalJSON() ([]byte, error) { @@ -59,7 +59,7 @@ func (o *V2PostTransaction) GetPostings() []V2Posting { return o.Postings } -func (o *V2PostTransaction) GetScript() *Script { +func (o *V2PostTransaction) GetScript() *V2PostTransactionScript { if o == nil { return nil } diff --git a/pkg/client/models/components/v2reverttransactionresponse.go b/pkg/client/models/components/v2reverttransactionresponse.go index 61ef5e3fe..f1b8f9683 100644 --- a/pkg/client/models/components/v2reverttransactionresponse.go +++ b/pkg/client/models/components/v2reverttransactionresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2stats.go b/pkg/client/models/components/v2stats.go index fab3171ca..738a060b8 100644 --- a/pkg/client/models/components/v2stats.go +++ b/pkg/client/models/components/v2stats.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2statsresponse.go b/pkg/client/models/components/v2statsresponse.go index 1242429ca..951c758fa 100644 --- a/pkg/client/models/components/v2statsresponse.go +++ b/pkg/client/models/components/v2statsresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2targetid.go b/pkg/client/models/components/v2targetid.go index d6fbb53bd..61f725f77 100644 --- a/pkg/client/models/components/v2targetid.go +++ b/pkg/client/models/components/v2targetid.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2targettype.go b/pkg/client/models/components/v2targettype.go index c5e16fb80..a1a365c60 100644 --- a/pkg/client/models/components/v2targettype.go +++ b/pkg/client/models/components/v2targettype.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2transaction.go b/pkg/client/models/components/v2transaction.go index fd1371ec7..747a9738a 100644 --- a/pkg/client/models/components/v2transaction.go +++ b/pkg/client/models/components/v2transaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2transactionscursorresponse.go b/pkg/client/models/components/v2transactionscursorresponse.go index d6744db48..ed42ff90f 100644 --- a/pkg/client/models/components/v2transactionscursorresponse.go +++ b/pkg/client/models/components/v2transactionscursorresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2volume.go b/pkg/client/models/components/v2volume.go index fb8a37422..f945d94e0 100644 --- a/pkg/client/models/components/v2volume.go +++ b/pkg/client/models/components/v2volume.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2volumeswithbalance.go b/pkg/client/models/components/v2volumeswithbalance.go index dca503d0f..ffab6e30d 100644 --- a/pkg/client/models/components/v2volumeswithbalance.go +++ b/pkg/client/models/components/v2volumeswithbalance.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/v2volumeswithbalancecursorresponse.go b/pkg/client/models/components/v2volumeswithbalancecursorresponse.go index 35e7a0afa..b03a5cf09 100644 --- a/pkg/client/models/components/v2volumeswithbalancecursorresponse.go +++ b/pkg/client/models/components/v2volumeswithbalancecursorresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package components diff --git a/pkg/client/models/components/volume.go b/pkg/client/models/components/volume.go new file mode 100644 index 000000000..3639b1a83 --- /dev/null +++ b/pkg/client/models/components/volume.go @@ -0,0 +1,46 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "math/big" +) + +type Volume struct { + Input *big.Int `json:"input"` + Output *big.Int `json:"output"` + Balance *big.Int `json:"balance,omitempty"` +} + +func (v Volume) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(v, "", false) +} + +func (v *Volume) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &v, "", false, false); err != nil { + return err + } + return nil +} + +func (o *Volume) GetInput() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Input +} + +func (o *Volume) GetOutput() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Output +} + +func (o *Volume) GetBalance() *big.Int { + if o == nil { + return nil + } + return o.Balance +} diff --git a/pkg/client/models/operations/addmetadataontransaction.go b/pkg/client/models/operations/addmetadataontransaction.go new file mode 100644 index 000000000..a9d0a60b9 --- /dev/null +++ b/pkg/client/models/operations/addmetadataontransaction.go @@ -0,0 +1,61 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "math/big" +) + +type AddMetadataOnTransactionRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Transaction ID. + Txid *big.Int `pathParam:"style=simple,explode=false,name=txid"` + // metadata + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (a AddMetadataOnTransactionRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AddMetadataOnTransactionRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, false); err != nil { + return err + } + return nil +} + +func (o *AddMetadataOnTransactionRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *AddMetadataOnTransactionRequest) GetTxid() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Txid +} + +func (o *AddMetadataOnTransactionRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type AddMetadataOnTransactionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *AddMetadataOnTransactionResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/pkg/client/models/operations/addmetadatatoaccount.go b/pkg/client/models/operations/addmetadatatoaccount.go new file mode 100644 index 000000000..35fca0062 --- /dev/null +++ b/pkg/client/models/operations/addmetadatatoaccount.go @@ -0,0 +1,52 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type AddMetadataToAccountRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Exact address of the account. It must match the following regular expressions pattern: + // ``` + // ^\w+(:\w+)*$ + // ``` + // + Address string `pathParam:"style=simple,explode=false,name=address"` + // metadata + RequestBody map[string]any `request:"mediaType=application/json"` +} + +func (o *AddMetadataToAccountRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *AddMetadataToAccountRequest) GetAddress() string { + if o == nil { + return "" + } + return o.Address +} + +func (o *AddMetadataToAccountRequest) GetRequestBody() map[string]any { + if o == nil { + return nil + } + return o.RequestBody +} + +type AddMetadataToAccountResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` +} + +func (o *AddMetadataToAccountResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} diff --git a/pkg/client/models/operations/countaccounts.go b/pkg/client/models/operations/countaccounts.go new file mode 100644 index 000000000..b4304435f --- /dev/null +++ b/pkg/client/models/operations/countaccounts.go @@ -0,0 +1,56 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type CountAccountsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Filter accounts by address pattern (regular expression placed between ^ and $). + Address *string `queryParam:"style=form,explode=true,name=address"` + // Filter accounts by metadata key value pairs. The filter can be used like this metadata[key]=value1&metadata[a.nested.key]=value2 + Metadata map[string]any `queryParam:"style=deepObject,explode=true,name=metadata"` +} + +func (o *CountAccountsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *CountAccountsRequest) GetAddress() *string { + if o == nil { + return nil + } + return o.Address +} + +func (o *CountAccountsRequest) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} + +type CountAccountsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + Headers map[string][]string +} + +func (o *CountAccountsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CountAccountsResponse) GetHeaders() map[string][]string { + if o == nil { + return map[string][]string{} + } + return o.Headers +} diff --git a/pkg/client/models/operations/counttransactions.go b/pkg/client/models/operations/counttransactions.go new file mode 100644 index 000000000..b860993bb --- /dev/null +++ b/pkg/client/models/operations/counttransactions.go @@ -0,0 +1,122 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +// Metadata - Filter transactions by metadata key value pairs. Nested objects can be used as seen in the example below. +type Metadata struct { +} + +type CountTransactionsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Filter transactions by reference field. + Reference *string `queryParam:"style=form,explode=true,name=reference"` + // Filter transactions with postings involving given account, either as source or destination (regular expression placed between ^ and $). + Account *string `queryParam:"style=form,explode=true,name=account"` + // Filter transactions with postings involving given account at source (regular expression placed between ^ and $). + Source *string `queryParam:"style=form,explode=true,name=source"` + // Filter transactions with postings involving given account at destination (regular expression placed between ^ and $). + Destination *string `queryParam:"style=form,explode=true,name=destination"` + // Filter transactions that occurred after this timestamp. + // The format is RFC3339 and is inclusive (for example, "2023-01-02T15:04:01Z" includes the first second of 4th minute). + // + StartTime *time.Time `queryParam:"style=form,explode=true,name=startTime"` + // Filter transactions that occurred before this timestamp. + // The format is RFC3339 and is exclusive (for example, "2023-01-02T15:04:01Z" excludes the first second of 4th minute). + // + EndTime *time.Time `queryParam:"style=form,explode=true,name=endTime"` + // Filter transactions by metadata key value pairs. Nested objects can be used as seen in the example below. + Metadata *Metadata `queryParam:"style=deepObject,explode=true,name=metadata"` +} + +func (c CountTransactionsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CountTransactionsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, false); err != nil { + return err + } + return nil +} + +func (o *CountTransactionsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *CountTransactionsRequest) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *CountTransactionsRequest) GetAccount() *string { + if o == nil { + return nil + } + return o.Account +} + +func (o *CountTransactionsRequest) GetSource() *string { + if o == nil { + return nil + } + return o.Source +} + +func (o *CountTransactionsRequest) GetDestination() *string { + if o == nil { + return nil + } + return o.Destination +} + +func (o *CountTransactionsRequest) GetStartTime() *time.Time { + if o == nil { + return nil + } + return o.StartTime +} + +func (o *CountTransactionsRequest) GetEndTime() *time.Time { + if o == nil { + return nil + } + return o.EndTime +} + +func (o *CountTransactionsRequest) GetMetadata() *Metadata { + if o == nil { + return nil + } + return o.Metadata +} + +type CountTransactionsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + Headers map[string][]string +} + +func (o *CountTransactionsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CountTransactionsResponse) GetHeaders() map[string][]string { + if o == nil { + return map[string][]string{} + } + return o.Headers +} diff --git a/pkg/client/models/operations/createtransaction.go b/pkg/client/models/operations/createtransaction.go new file mode 100644 index 000000000..6f883d303 --- /dev/null +++ b/pkg/client/models/operations/createtransaction.go @@ -0,0 +1,60 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type CreateTransactionRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Set the preview mode. Preview mode doesn't add the logs to the database or publish a message to the message broker. + Preview *bool `queryParam:"style=form,explode=true,name=preview"` + // The request body must contain at least one of the following objects: + // - `postings`: suitable for simple transactions + // - `script`: enabling more complex transactions with Numscript + // + PostTransaction components.PostTransaction `request:"mediaType=application/json"` +} + +func (o *CreateTransactionRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *CreateTransactionRequest) GetPreview() *bool { + if o == nil { + return nil + } + return o.Preview +} + +func (o *CreateTransactionRequest) GetPostTransaction() components.PostTransaction { + if o == nil { + return components.PostTransaction{} + } + return o.PostTransaction +} + +type CreateTransactionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + TransactionsResponse *components.TransactionsResponse +} + +func (o *CreateTransactionResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateTransactionResponse) GetTransactionsResponse() *components.TransactionsResponse { + if o == nil { + return nil + } + return o.TransactionsResponse +} diff --git a/pkg/client/models/operations/createtransactions.go b/pkg/client/models/operations/createtransactions.go new file mode 100644 index 000000000..2a2542245 --- /dev/null +++ b/pkg/client/models/operations/createtransactions.go @@ -0,0 +1,47 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type CreateTransactionsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + Transactions components.Transactions `request:"mediaType=application/json"` +} + +func (o *CreateTransactionsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *CreateTransactionsRequest) GetTransactions() components.Transactions { + if o == nil { + return components.Transactions{} + } + return o.Transactions +} + +type CreateTransactionsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + TransactionsResponse *components.TransactionsResponse +} + +func (o *CreateTransactionsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateTransactionsResponse) GetTransactionsResponse() *components.TransactionsResponse { + if o == nil { + return nil + } + return o.TransactionsResponse +} diff --git a/pkg/client/models/operations/getaccount.go b/pkg/client/models/operations/getaccount.go new file mode 100644 index 000000000..e4a7f6114 --- /dev/null +++ b/pkg/client/models/operations/getaccount.go @@ -0,0 +1,52 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type GetAccountRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Exact address of the account. It must match the following regular expressions pattern: + // ``` + // ^\w+(:\w+)*$ + // ``` + // + Address string `pathParam:"style=simple,explode=false,name=address"` +} + +func (o *GetAccountRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *GetAccountRequest) GetAddress() string { + if o == nil { + return "" + } + return o.Address +} + +type GetAccountResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + AccountResponse *components.AccountResponse +} + +func (o *GetAccountResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetAccountResponse) GetAccountResponse() *components.AccountResponse { + if o == nil { + return nil + } + return o.AccountResponse +} diff --git a/pkg/client/models/operations/getbalances.go b/pkg/client/models/operations/getbalances.go new file mode 100644 index 000000000..b35954e17 --- /dev/null +++ b/pkg/client/models/operations/getbalances.go @@ -0,0 +1,92 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" +) + +type GetBalancesRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Filter balances involving given account, either as source or destination. + Address *string `queryParam:"style=form,explode=true,name=address"` + // The maximum number of results to return per page. + // + PageSize *int64 `default:"15" queryParam:"style=form,explode=true,name=pageSize"` + // Pagination cursor, will return accounts after given address, in descending order. + After *string `queryParam:"style=form,explode=true,name=after"` + // Parameter used in pagination requests. Maximum page size is set to 1000. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` +} + +func (g GetBalancesRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetBalancesRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, false); err != nil { + return err + } + return nil +} + +func (o *GetBalancesRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *GetBalancesRequest) GetAddress() *string { + if o == nil { + return nil + } + return o.Address +} + +func (o *GetBalancesRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *GetBalancesRequest) GetAfter() *string { + if o == nil { + return nil + } + return o.After +} + +func (o *GetBalancesRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +type GetBalancesResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + BalancesCursorResponse *components.BalancesCursorResponse +} + +func (o *GetBalancesResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetBalancesResponse) GetBalancesCursorResponse() *components.BalancesCursorResponse { + if o == nil { + return nil + } + return o.BalancesCursorResponse +} diff --git a/pkg/client/models/operations/getbalancesaggregated.go b/pkg/client/models/operations/getbalancesaggregated.go new file mode 100644 index 000000000..ce3f5a754 --- /dev/null +++ b/pkg/client/models/operations/getbalancesaggregated.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type GetBalancesAggregatedRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Filter balances involving given account, either as source or destination. + Address *string `queryParam:"style=form,explode=true,name=address"` + // Use insertion date instead of effective date + UseInsertionDate *bool `queryParam:"style=form,explode=true,name=useInsertionDate"` +} + +func (o *GetBalancesAggregatedRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *GetBalancesAggregatedRequest) GetAddress() *string { + if o == nil { + return nil + } + return o.Address +} + +func (o *GetBalancesAggregatedRequest) GetUseInsertionDate() *bool { + if o == nil { + return nil + } + return o.UseInsertionDate +} + +type GetBalancesAggregatedResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + AggregateBalancesResponse *components.AggregateBalancesResponse +} + +func (o *GetBalancesAggregatedResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetBalancesAggregatedResponse) GetAggregateBalancesResponse() *components.AggregateBalancesResponse { + if o == nil { + return nil + } + return o.AggregateBalancesResponse +} diff --git a/pkg/client/models/operations/getinfo.go b/pkg/client/models/operations/getinfo.go new file mode 100644 index 000000000..05ea225e0 --- /dev/null +++ b/pkg/client/models/operations/getinfo.go @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type GetInfoResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + ConfigInfoResponse *components.ConfigInfoResponse +} + +func (o *GetInfoResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetInfoResponse) GetConfigInfoResponse() *components.ConfigInfoResponse { + if o == nil { + return nil + } + return o.ConfigInfoResponse +} diff --git a/pkg/client/models/operations/getledgerinfo.go b/pkg/client/models/operations/getledgerinfo.go new file mode 100644 index 000000000..19a390966 --- /dev/null +++ b/pkg/client/models/operations/getledgerinfo.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type GetLedgerInfoRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` +} + +func (o *GetLedgerInfoRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +type GetLedgerInfoResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + LedgerInfoResponse *components.LedgerInfoResponse +} + +func (o *GetLedgerInfoResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetLedgerInfoResponse) GetLedgerInfoResponse() *components.LedgerInfoResponse { + if o == nil { + return nil + } + return o.LedgerInfoResponse +} diff --git a/pkg/client/models/operations/getmapping.go b/pkg/client/models/operations/getmapping.go new file mode 100644 index 000000000..85223bb9d --- /dev/null +++ b/pkg/client/models/operations/getmapping.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type GetMappingRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` +} + +func (o *GetMappingRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +type GetMappingResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + MappingResponse *components.MappingResponse +} + +func (o *GetMappingResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetMappingResponse) GetMappingResponse() *components.MappingResponse { + if o == nil { + return nil + } + return o.MappingResponse +} diff --git a/pkg/client/models/operations/gettransaction.go b/pkg/client/models/operations/gettransaction.go new file mode 100644 index 000000000..4e96f8359 --- /dev/null +++ b/pkg/client/models/operations/gettransaction.go @@ -0,0 +1,61 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "math/big" +) + +type GetTransactionRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Transaction ID. + Txid *big.Int `pathParam:"style=simple,explode=false,name=txid"` +} + +func (g GetTransactionRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetTransactionRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, false); err != nil { + return err + } + return nil +} + +func (o *GetTransactionRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *GetTransactionRequest) GetTxid() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Txid +} + +type GetTransactionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + TransactionResponse *components.TransactionResponse +} + +func (o *GetTransactionResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetTransactionResponse) GetTransactionResponse() *components.TransactionResponse { + if o == nil { + return nil + } + return o.TransactionResponse +} diff --git a/pkg/client/models/operations/listaccounts.go b/pkg/client/models/operations/listaccounts.go new file mode 100644 index 000000000..bb5113209 --- /dev/null +++ b/pkg/client/models/operations/listaccounts.go @@ -0,0 +1,136 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "github.com/formancehq/stack/ledger/client/models/sdkerrors" +) + +type ListAccountsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // The maximum number of results to return per page. + // + PageSize *int64 `default:"15" queryParam:"style=form,explode=true,name=pageSize"` + // Pagination cursor, will return accounts after given address, in descending order. + After *string `queryParam:"style=form,explode=true,name=after"` + // Filter accounts by address pattern (regular expression placed between ^ and $). + Address *string `queryParam:"style=form,explode=true,name=address"` + // Filter accounts by metadata key value pairs. Nested objects can be used as seen in the example below. + Metadata map[string]any `queryParam:"style=deepObject,explode=true,name=metadata"` + // Filter accounts by their balance (default operator is gte) + Balance *int64 `queryParam:"style=form,explode=true,name=balance"` + // Parameter used in pagination requests. Maximum page size is set to 1000. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` + // Parameter used in pagination requests. Maximum page size is set to 1000. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // Deprecated, please use `cursor` instead. + // + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + PaginationToken *string `queryParam:"style=form,explode=true,name=pagination_token"` +} + +func (l ListAccountsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListAccountsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, false); err != nil { + return err + } + return nil +} + +func (o *ListAccountsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *ListAccountsRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *ListAccountsRequest) GetAfter() *string { + if o == nil { + return nil + } + return o.After +} + +func (o *ListAccountsRequest) GetAddress() *string { + if o == nil { + return nil + } + return o.Address +} + +func (o *ListAccountsRequest) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} + +func (o *ListAccountsRequest) GetBalance() *int64 { + if o == nil { + return nil + } + return o.Balance +} + +func (o *ListAccountsRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +func (o *ListAccountsRequest) GetPaginationToken() *string { + if o == nil { + return nil + } + return o.PaginationToken +} + +type ListAccountsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + AccountsCursorResponse *components.AccountsCursorResponse + // Not found + ErrorResponse *sdkerrors.ErrorResponse +} + +func (o *ListAccountsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListAccountsResponse) GetAccountsCursorResponse() *components.AccountsCursorResponse { + if o == nil { + return nil + } + return o.AccountsCursorResponse +} + +func (o *ListAccountsResponse) GetErrorResponse() *sdkerrors.ErrorResponse { + if o == nil { + return nil + } + return o.ErrorResponse +} diff --git a/pkg/client/models/operations/listlogs.go b/pkg/client/models/operations/listlogs.go new file mode 100644 index 000000000..b5a963d86 --- /dev/null +++ b/pkg/client/models/operations/listlogs.go @@ -0,0 +1,106 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type ListLogsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // The maximum number of results to return per page. + // + PageSize *int64 `default:"15" queryParam:"style=form,explode=true,name=pageSize"` + // Pagination cursor, will return the logs after a given ID. (in descending order). + After *string `queryParam:"style=form,explode=true,name=after"` + // Filter transactions that occurred after this timestamp. + // The format is RFC3339 and is inclusive (for example, "2023-01-02T15:04:01Z" includes the first second of 4th minute). + // + StartTime *time.Time `queryParam:"style=form,explode=true,name=startTime"` + // Filter transactions that occurred before this timestamp. + // The format is RFC3339 and is exclusive (for example, "2023-01-02T15:04:01Z" excludes the first second of 4th minute). + // + EndTime *time.Time `queryParam:"style=form,explode=true,name=endTime"` + // Parameter used in pagination requests. Maximum page size is set to 1000. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` +} + +func (l ListLogsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListLogsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, false); err != nil { + return err + } + return nil +} + +func (o *ListLogsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *ListLogsRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *ListLogsRequest) GetAfter() *string { + if o == nil { + return nil + } + return o.After +} + +func (o *ListLogsRequest) GetStartTime() *time.Time { + if o == nil { + return nil + } + return o.StartTime +} + +func (o *ListLogsRequest) GetEndTime() *time.Time { + if o == nil { + return nil + } + return o.EndTime +} + +func (o *ListLogsRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +type ListLogsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + LogsCursorResponse *components.LogsCursorResponse +} + +func (o *ListLogsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListLogsResponse) GetLogsCursorResponse() *components.LogsCursorResponse { + if o == nil { + return nil + } + return o.LogsCursorResponse +} diff --git a/pkg/client/models/operations/listtransactions.go b/pkg/client/models/operations/listtransactions.go new file mode 100644 index 000000000..6daa50137 --- /dev/null +++ b/pkg/client/models/operations/listtransactions.go @@ -0,0 +1,151 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "time" +) + +type ListTransactionsRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // The maximum number of results to return per page. + // + PageSize *int64 `default:"15" queryParam:"style=form,explode=true,name=pageSize"` + // Pagination cursor, will return transactions after given txid (in descending order). + After *string `queryParam:"style=form,explode=true,name=after"` + // Find transactions by reference field. + Reference *string `queryParam:"style=form,explode=true,name=reference"` + // Filter transactions with postings involving given account, either as source or destination (regular expression placed between ^ and $). + Account *string `queryParam:"style=form,explode=true,name=account"` + // Filter transactions with postings involving given account at source (regular expression placed between ^ and $). + Source *string `queryParam:"style=form,explode=true,name=source"` + // Filter transactions with postings involving given account at destination (regular expression placed between ^ and $). + Destination *string `queryParam:"style=form,explode=true,name=destination"` + // Filter transactions that occurred after this timestamp. + // The format is RFC3339 and is inclusive (for example, "2023-01-02T15:04:01Z" includes the first second of 4th minute). + // + StartTime *time.Time `queryParam:"style=form,explode=true,name=startTime"` + // Filter transactions that occurred before this timestamp. + // The format is RFC3339 and is exclusive (for example, "2023-01-02T15:04:01Z" excludes the first second of 4th minute). + // + EndTime *time.Time `queryParam:"style=form,explode=true,name=endTime"` + // Parameter used in pagination requests. Maximum page size is set to 1000. + // Set to the value of next for the next page of results. + // Set to the value of previous for the previous page of results. + // No other parameters can be set when this parameter is set. + // + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` + // Filter transactions by metadata key value pairs. Nested objects can be used as seen in the example below. + Metadata map[string]any `queryParam:"style=deepObject,explode=true,name=metadata"` +} + +func (l ListTransactionsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListTransactionsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, false); err != nil { + return err + } + return nil +} + +func (o *ListTransactionsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *ListTransactionsRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +func (o *ListTransactionsRequest) GetAfter() *string { + if o == nil { + return nil + } + return o.After +} + +func (o *ListTransactionsRequest) GetReference() *string { + if o == nil { + return nil + } + return o.Reference +} + +func (o *ListTransactionsRequest) GetAccount() *string { + if o == nil { + return nil + } + return o.Account +} + +func (o *ListTransactionsRequest) GetSource() *string { + if o == nil { + return nil + } + return o.Source +} + +func (o *ListTransactionsRequest) GetDestination() *string { + if o == nil { + return nil + } + return o.Destination +} + +func (o *ListTransactionsRequest) GetStartTime() *time.Time { + if o == nil { + return nil + } + return o.StartTime +} + +func (o *ListTransactionsRequest) GetEndTime() *time.Time { + if o == nil { + return nil + } + return o.EndTime +} + +func (o *ListTransactionsRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +func (o *ListTransactionsRequest) GetMetadata() map[string]any { + if o == nil { + return nil + } + return o.Metadata +} + +type ListTransactionsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + TransactionsCursorResponse *components.TransactionsCursorResponse +} + +func (o *ListTransactionsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListTransactionsResponse) GetTransactionsCursorResponse() *components.TransactionsCursorResponse { + if o == nil { + return nil + } + return o.TransactionsCursorResponse +} diff --git a/pkg/client/models/operations/options.go b/pkg/client/models/operations/options.go index 85fc63930..fedc0031f 100644 --- a/pkg/client/models/operations/options.go +++ b/pkg/client/models/operations/options.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/readstats.go b/pkg/client/models/operations/readstats.go new file mode 100644 index 000000000..5a95cadff --- /dev/null +++ b/pkg/client/models/operations/readstats.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type ReadStatsRequest struct { + // name of the ledger + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` +} + +func (o *ReadStatsRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +type ReadStatsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + StatsResponse *components.StatsResponse +} + +func (o *ReadStatsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ReadStatsResponse) GetStatsResponse() *components.StatsResponse { + if o == nil { + return nil + } + return o.StatsResponse +} diff --git a/pkg/client/models/operations/reverttransaction.go b/pkg/client/models/operations/reverttransaction.go new file mode 100644 index 000000000..af8d63c2b --- /dev/null +++ b/pkg/client/models/operations/reverttransaction.go @@ -0,0 +1,70 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "math/big" +) + +type RevertTransactionRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Transaction ID. + Txid *big.Int `pathParam:"style=simple,explode=false,name=txid"` + // Allow to disable balances checks + DisableChecks *bool `queryParam:"style=form,explode=true,name=disableChecks"` +} + +func (r RevertTransactionRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *RevertTransactionRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, false); err != nil { + return err + } + return nil +} + +func (o *RevertTransactionRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *RevertTransactionRequest) GetTxid() *big.Int { + if o == nil { + return big.NewInt(0) + } + return o.Txid +} + +func (o *RevertTransactionRequest) GetDisableChecks() *bool { + if o == nil { + return nil + } + return o.DisableChecks +} + +type RevertTransactionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + TransactionResponse *components.TransactionResponse +} + +func (o *RevertTransactionResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *RevertTransactionResponse) GetTransactionResponse() *components.TransactionResponse { + if o == nil { + return nil + } + return o.TransactionResponse +} diff --git a/pkg/client/models/operations/runscript.go b/pkg/client/models/operations/runscript.go new file mode 100644 index 000000000..0555f3893 --- /dev/null +++ b/pkg/client/models/operations/runscript.go @@ -0,0 +1,62 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type RunScriptRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + // Set the preview mode. Preview mode doesn't add the logs to the database or publish a message to the message broker. + Preview *bool `queryParam:"style=form,explode=true,name=preview"` + Script components.Script `request:"mediaType=application/json"` +} + +func (o *RunScriptRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *RunScriptRequest) GetPreview() *bool { + if o == nil { + return nil + } + return o.Preview +} + +func (o *RunScriptRequest) GetScript() components.Script { + if o == nil { + return components.Script{} + } + return o.Script +} + +type RunScriptResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // On success, it will return a 200 status code, and the resulting transaction under the `transaction` field. + // + // On failure, it will also return a 200 status code, and the following fields: + // - `details`: contains a URL. When there is an error parsing Numscript, the result can be difficult to read—the provided URL will render the error in an easy-to-read format. + // - `errorCode` and `error_code` (deprecated): contains the string code of the error + // - `errorMessage` and `error_message` (deprecated): contains a human-readable indication of what went wrong, for example that an account had insufficient funds, or that there was an error in the provided Numscript. + // + ScriptResponse *components.ScriptResponse +} + +func (o *RunScriptResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *RunScriptResponse) GetScriptResponse() *components.ScriptResponse { + if o == nil { + return nil + } + return o.ScriptResponse +} diff --git a/pkg/client/models/operations/updatemapping.go b/pkg/client/models/operations/updatemapping.go new file mode 100644 index 000000000..ee84332f3 --- /dev/null +++ b/pkg/client/models/operations/updatemapping.go @@ -0,0 +1,47 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/stack/ledger/client/models/components" +) + +type UpdateMappingRequest struct { + // Name of the ledger. + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + Mapping *components.Mapping `request:"mediaType=application/json"` +} + +func (o *UpdateMappingRequest) GetLedger() string { + if o == nil { + return "" + } + return o.Ledger +} + +func (o *UpdateMappingRequest) GetMapping() *components.Mapping { + if o == nil { + return nil + } + return o.Mapping +} + +type UpdateMappingResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + MappingResponse *components.MappingResponse +} + +func (o *UpdateMappingResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *UpdateMappingResponse) GetMappingResponse() *components.MappingResponse { + if o == nil { + return nil + } + return o.MappingResponse +} diff --git a/pkg/client/models/operations/v2addmetadataontransaction.go b/pkg/client/models/operations/v2addmetadataontransaction.go index ed2cdfa2e..52e5c5c9d 100644 --- a/pkg/client/models/operations/v2addmetadataontransaction.go +++ b/pkg/client/models/operations/v2addmetadataontransaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2addmetadatatoaccount.go b/pkg/client/models/operations/v2addmetadatatoaccount.go index 488ca4eff..95fd332b5 100644 --- a/pkg/client/models/operations/v2addmetadatatoaccount.go +++ b/pkg/client/models/operations/v2addmetadatatoaccount.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2countaccounts.go b/pkg/client/models/operations/v2countaccounts.go index e3338f5f0..33239ba92 100644 --- a/pkg/client/models/operations/v2countaccounts.go +++ b/pkg/client/models/operations/v2countaccounts.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2counttransactions.go b/pkg/client/models/operations/v2counttransactions.go index b8d04f077..acc7bbe0d 100644 --- a/pkg/client/models/operations/v2counttransactions.go +++ b/pkg/client/models/operations/v2counttransactions.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2createbulk.go b/pkg/client/models/operations/v2createbulk.go index c66e0e825..50ab92604 100644 --- a/pkg/client/models/operations/v2createbulk.go +++ b/pkg/client/models/operations/v2createbulk.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2createledger.go b/pkg/client/models/operations/v2createledger.go index dcad13ceb..322ff14e8 100644 --- a/pkg/client/models/operations/v2createledger.go +++ b/pkg/client/models/operations/v2createledger.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2createtransaction.go b/pkg/client/models/operations/v2createtransaction.go index d0877f3a3..aeb743cd1 100644 --- a/pkg/client/models/operations/v2createtransaction.go +++ b/pkg/client/models/operations/v2createtransaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2deleteaccountmetadata.go b/pkg/client/models/operations/v2deleteaccountmetadata.go index f879e039f..851f8048d 100644 --- a/pkg/client/models/operations/v2deleteaccountmetadata.go +++ b/pkg/client/models/operations/v2deleteaccountmetadata.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2deleteledgermetadata.go b/pkg/client/models/operations/v2deleteledgermetadata.go index 95c965fa6..82cbbd789 100644 --- a/pkg/client/models/operations/v2deleteledgermetadata.go +++ b/pkg/client/models/operations/v2deleteledgermetadata.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2deletetransactionmetadata.go b/pkg/client/models/operations/v2deletetransactionmetadata.go index 8afabd9bc..33613091c 100644 --- a/pkg/client/models/operations/v2deletetransactionmetadata.go +++ b/pkg/client/models/operations/v2deletetransactionmetadata.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2exportlogs.go b/pkg/client/models/operations/v2exportlogs.go index d809a63d5..42c0e4557 100644 --- a/pkg/client/models/operations/v2exportlogs.go +++ b/pkg/client/models/operations/v2exportlogs.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2getaccount.go b/pkg/client/models/operations/v2getaccount.go index fe39e1406..b54f77eeb 100644 --- a/pkg/client/models/operations/v2getaccount.go +++ b/pkg/client/models/operations/v2getaccount.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2getbalancesaggregated.go b/pkg/client/models/operations/v2getbalancesaggregated.go index 246e207ab..e482bbbbf 100644 --- a/pkg/client/models/operations/v2getbalancesaggregated.go +++ b/pkg/client/models/operations/v2getbalancesaggregated.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2getinfo.go b/pkg/client/models/operations/v2getinfo.go index b0d35667e..136491d88 100644 --- a/pkg/client/models/operations/v2getinfo.go +++ b/pkg/client/models/operations/v2getinfo.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2getledger.go b/pkg/client/models/operations/v2getledger.go index 55ae63db6..6a239e206 100644 --- a/pkg/client/models/operations/v2getledger.go +++ b/pkg/client/models/operations/v2getledger.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2getledgerinfo.go b/pkg/client/models/operations/v2getledgerinfo.go index 6f4a731d1..5bf4982d3 100644 --- a/pkg/client/models/operations/v2getledgerinfo.go +++ b/pkg/client/models/operations/v2getledgerinfo.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2gettransaction.go b/pkg/client/models/operations/v2gettransaction.go index 41374e832..a1f264107 100644 --- a/pkg/client/models/operations/v2gettransaction.go +++ b/pkg/client/models/operations/v2gettransaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2getvolumeswithbalances.go b/pkg/client/models/operations/v2getvolumeswithbalances.go index f16a8e955..82a036286 100644 --- a/pkg/client/models/operations/v2getvolumeswithbalances.go +++ b/pkg/client/models/operations/v2getvolumeswithbalances.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2importlogs.go b/pkg/client/models/operations/v2importlogs.go index ba8760967..d5722de7e 100644 --- a/pkg/client/models/operations/v2importlogs.go +++ b/pkg/client/models/operations/v2importlogs.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2listaccounts.go b/pkg/client/models/operations/v2listaccounts.go index 85162a159..4f18a0fb5 100644 --- a/pkg/client/models/operations/v2listaccounts.go +++ b/pkg/client/models/operations/v2listaccounts.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2listledgers.go b/pkg/client/models/operations/v2listledgers.go index 30eac5552..4c88234f4 100644 --- a/pkg/client/models/operations/v2listledgers.go +++ b/pkg/client/models/operations/v2listledgers.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2listlogs.go b/pkg/client/models/operations/v2listlogs.go index ac959703f..1f792f6f0 100644 --- a/pkg/client/models/operations/v2listlogs.go +++ b/pkg/client/models/operations/v2listlogs.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2listtransactions.go b/pkg/client/models/operations/v2listtransactions.go index 68164b1d1..8eaddb731 100644 --- a/pkg/client/models/operations/v2listtransactions.go +++ b/pkg/client/models/operations/v2listtransactions.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2readstats.go b/pkg/client/models/operations/v2readstats.go index 8047b44bb..74f7c8492 100644 --- a/pkg/client/models/operations/v2readstats.go +++ b/pkg/client/models/operations/v2readstats.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2reverttransaction.go b/pkg/client/models/operations/v2reverttransaction.go index d5d9e992c..786e3a47d 100644 --- a/pkg/client/models/operations/v2reverttransaction.go +++ b/pkg/client/models/operations/v2reverttransaction.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/operations/v2updateledgermetadata.go b/pkg/client/models/operations/v2updateledgermetadata.go index aa5c6db14..e8d8e69dd 100644 --- a/pkg/client/models/operations/v2updateledgermetadata.go +++ b/pkg/client/models/operations/v2updateledgermetadata.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package operations diff --git a/pkg/client/models/sdkerrors/errorresponse.go b/pkg/client/models/sdkerrors/errorresponse.go new file mode 100644 index 000000000..cde5b6825 --- /dev/null +++ b/pkg/client/models/sdkerrors/errorresponse.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdkerrors + +import ( + "encoding/json" + "github.com/formancehq/stack/ledger/client/models/components" +) + +// ErrorResponse - Error +type ErrorResponse struct { + ErrorCode components.ErrorsEnum `json:"errorCode"` + ErrorMessage string `json:"errorMessage"` + Details *string `json:"details,omitempty"` +} + +var _ error = &ErrorResponse{} + +func (e *ErrorResponse) Error() string { + data, _ := json.Marshal(e) + return string(data) +} diff --git a/pkg/client/models/sdkerrors/sdkerror.go b/pkg/client/models/sdkerrors/sdkerror.go index b72f471b2..7d63b9813 100644 --- a/pkg/client/models/sdkerrors/sdkerror.go +++ b/pkg/client/models/sdkerrors/sdkerror.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package sdkerrors diff --git a/pkg/client/models/sdkerrors/v2errorresponse.go b/pkg/client/models/sdkerrors/v2errorresponse.go index 15e9fc1c7..d69616862 100644 --- a/pkg/client/models/sdkerrors/v2errorresponse.go +++ b/pkg/client/models/sdkerrors/v2errorresponse.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package sdkerrors diff --git a/pkg/client/retry/config.go b/pkg/client/retry/config.go index a9b559bc3..c051b0a46 100644 --- a/pkg/client/retry/config.go +++ b/pkg/client/retry/config.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package retry diff --git a/pkg/client/types/bigint.go b/pkg/client/types/bigint.go index 4765ef202..9c6a086d5 100644 --- a/pkg/client/types/bigint.go +++ b/pkg/client/types/bigint.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/pkg/client/types/date.go b/pkg/client/types/date.go index 131f364d5..5b2782f21 100644 --- a/pkg/client/types/date.go +++ b/pkg/client/types/date.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/pkg/client/types/datetime.go b/pkg/client/types/datetime.go index c07ddcd51..3eff332da 100644 --- a/pkg/client/types/datetime.go +++ b/pkg/client/types/datetime.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/pkg/client/types/decimal.go b/pkg/client/types/decimal.go index f7def7289..d8429bc6b 100644 --- a/pkg/client/types/decimal.go +++ b/pkg/client/types/decimal.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/pkg/client/types/pointers.go b/pkg/client/types/pointers.go index 1ed80cfbb..950d6a358 100644 --- a/pkg/client/types/pointers.go +++ b/pkg/client/types/pointers.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package types diff --git a/pkg/client/v1.go b/pkg/client/v1.go new file mode 100644 index 000000000..64127606d --- /dev/null +++ b/pkg/client/v1.go @@ -0,0 +1,3728 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package client + +import ( + "bytes" + "context" + "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/formancehq/stack/ledger/client/internal/hooks" + "github.com/formancehq/stack/ledger/client/internal/utils" + "github.com/formancehq/stack/ledger/client/models/components" + "github.com/formancehq/stack/ledger/client/models/operations" + "github.com/formancehq/stack/ledger/client/models/sdkerrors" + "io" + "math/big" + "net/http" + "net/url" +) + +type V1 struct { + sdkConfiguration sdkConfiguration +} + +func newV1(sdkConfig sdkConfiguration) *V1 { + return &V1{ + sdkConfiguration: sdkConfig, + } +} + +// GetInfo - Show server information +func (s *V1) GetInfo(ctx context.Context, opts ...operations.Option) (*operations.GetInfoResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getInfo", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/_info") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetInfoResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.ConfigInfoResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ConfigInfoResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetLedgerInfo - Get information about a ledger +func (s *V1) GetLedgerInfo(ctx context.Context, ledger string, opts ...operations.Option) (*operations.GetLedgerInfoResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getLedgerInfo", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.GetLedgerInfoRequest{ + Ledger: ledger, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/_info", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetLedgerInfoResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.LedgerInfoResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.LedgerInfoResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CountAccounts - Count the accounts from a ledger +func (s *V1) CountAccounts(ctx context.Context, ledger string, address *string, metadata map[string]any, opts ...operations.Option) (*operations.CountAccountsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "countAccounts", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.CountAccountsRequest{ + Ledger: ledger, + Address: address, + Metadata: metadata, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/accounts", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "HEAD", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CountAccountsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + res.Headers = httpRes.Header + + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListAccounts - List accounts from a ledger +// List accounts from a ledger, sorted by address in descending order. +func (s *V1) ListAccounts(ctx context.Context, request operations.ListAccountsRequest, opts ...operations.Option) (*operations.ListAccountsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "listAccounts", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/accounts", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListAccountsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.AccountsCursorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.AccountsCursorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ErrorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetAccount - Get account by its address +func (s *V1) GetAccount(ctx context.Context, ledger string, address string, opts ...operations.Option) (*operations.GetAccountResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getAccount", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.GetAccountRequest{ + Ledger: ledger, + Address: address, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/accounts/{address}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetAccountResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.AccountResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.AccountResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// AddMetadataToAccount - Add metadata to an account +func (s *V1) AddMetadataToAccount(ctx context.Context, ledger string, address string, requestBody map[string]any, opts ...operations.Option) (*operations.AddMetadataToAccountResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "addMetadataToAccount", + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.AddMetadataToAccountRequest{ + Ledger: ledger, + Address: address, + RequestBody: requestBody, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/accounts/{address}/metadata", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, true, false, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.AddMetadataToAccountResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetMapping - Get the mapping of a ledger +func (s *V1) GetMapping(ctx context.Context, ledger string, opts ...operations.Option) (*operations.GetMappingResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getMapping", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.GetMappingRequest{ + Ledger: ledger, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/mapping", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetMappingResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.MappingResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.MappingResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpdateMapping - Update the mapping of a ledger +func (s *V1) UpdateMapping(ctx context.Context, ledger string, mapping *components.Mapping, opts ...operations.Option) (*operations.UpdateMappingResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "updateMapping", + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.UpdateMappingRequest{ + Ledger: ledger, + Mapping: mapping, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/mapping", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, true, false, "Mapping", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpdateMappingResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.MappingResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.MappingResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// RunScript - Execute a Numscript +// This route is deprecated, and has been merged into `POST /{ledger}/transactions`. +// +// Deprecated method: This will be removed in a future release, please migrate away from it as soon as possible. +func (s *V1) RunScript(ctx context.Context, ledger string, script components.Script, preview *bool, opts ...operations.Option) (*operations.RunScriptResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "runScript", + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.RunScriptRequest{ + Ledger: ledger, + Preview: preview, + Script: script, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/script", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Script", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.RunScriptResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.ScriptResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ScriptResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// ReadStats - Get statistics from a ledger +// Get statistics from a ledger. (aggregate metrics on accounts and transactions) +func (s *V1) ReadStats(ctx context.Context, ledger string, opts ...operations.Option) (*operations.ReadStatsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "readStats", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.ReadStatsRequest{ + Ledger: ledger, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/stats", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ReadStatsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.StatsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.StatsResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CountTransactions - Count the transactions from a ledger +func (s *V1) CountTransactions(ctx context.Context, request operations.CountTransactionsRequest, opts ...operations.Option) (*operations.CountTransactionsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "countTransactions", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/transactions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "HEAD", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CountTransactionsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + res.Headers = httpRes.Header + + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListTransactions - List transactions from a ledger +// List transactions from a ledger, sorted by txid in descending order. +func (s *V1) ListTransactions(ctx context.Context, request operations.ListTransactionsRequest, opts ...operations.Option) (*operations.ListTransactionsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "listTransactions", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/transactions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListTransactionsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.TransactionsCursorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.TransactionsCursorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateTransaction - Create a new transaction to a ledger +func (s *V1) CreateTransaction(ctx context.Context, ledger string, postTransaction components.PostTransaction, preview *bool, opts ...operations.Option) (*operations.CreateTransactionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "createTransaction", + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.CreateTransactionRequest{ + Ledger: ledger, + Preview: preview, + PostTransaction: postTransaction, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/transactions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "PostTransaction", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateTransactionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.TransactionsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.TransactionsResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetTransaction - Get transaction from a ledger by its ID +func (s *V1) GetTransaction(ctx context.Context, ledger string, txid *big.Int, opts ...operations.Option) (*operations.GetTransactionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getTransaction", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.GetTransactionRequest{ + Ledger: ledger, + Txid: txid, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/transactions/{txid}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetTransactionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.TransactionResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.TransactionResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// AddMetadataOnTransaction - Set the metadata of a transaction by its ID +func (s *V1) AddMetadataOnTransaction(ctx context.Context, ledger string, txid *big.Int, requestBody map[string]any, opts ...operations.Option) (*operations.AddMetadataOnTransactionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "addMetadataOnTransaction", + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.AddMetadataOnTransactionRequest{ + Ledger: ledger, + Txid: txid, + RequestBody: requestBody, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/transactions/{txid}/metadata", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, true, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.AddMetadataOnTransactionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 204: + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// RevertTransaction - Revert a ledger transaction by its ID +func (s *V1) RevertTransaction(ctx context.Context, ledger string, txid *big.Int, disableChecks *bool, opts ...operations.Option) (*operations.RevertTransactionResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "revertTransaction", + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.RevertTransactionRequest{ + Ledger: ledger, + Txid: txid, + DisableChecks: disableChecks, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/transactions/{txid}/revert", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.RevertTransactionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.TransactionResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.TransactionResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateTransactions - Create a new batch of transactions to a ledger +func (s *V1) CreateTransactions(ctx context.Context, ledger string, transactions components.Transactions, opts ...operations.Option) (*operations.CreateTransactionsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "CreateTransactions", + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.CreateTransactionsRequest{ + Ledger: ledger, + Transactions: transactions, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/transactions/batch", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Transactions", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateTransactionsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.TransactionsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.TransactionsResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetBalances - Get the balances from a ledger's account +func (s *V1) GetBalances(ctx context.Context, request operations.GetBalancesRequest, opts ...operations.Option) (*operations.GetBalancesResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getBalances", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/balances", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetBalancesResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.BalancesCursorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.BalancesCursorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetBalancesAggregated - Get the aggregated balances from selected accounts +func (s *V1) GetBalancesAggregated(ctx context.Context, ledger string, address *string, useInsertionDate *bool, opts ...operations.Option) (*operations.GetBalancesAggregatedResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getBalancesAggregated", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + request := operations.GetBalancesAggregatedRequest{ + Ledger: ledger, + Address: address, + UseInsertionDate: useInsertionDate, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/aggregate/balances", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetBalancesAggregatedResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.AggregateBalancesResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.AggregateBalancesResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListLogs - List the logs from a ledger +// List the logs from a ledger, sorted by ID in descending order. +func (s *V1) ListLogs(ctx context.Context, request operations.ListLogsRequest, opts ...operations.Option) (*operations.ListLogsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "listLogs", + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := utils.GenerateURL(ctx, baseURL, "/{ledger}/logs", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"default"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListLogsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out components.LogsCursorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.LogsCursorResponse = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrorResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} diff --git a/pkg/client/v2.go b/pkg/client/v2.go index 72a655ac6..1b6fad03d 100644 --- a/pkg/client/v2.go +++ b/pkg/client/v2.go @@ -1,4 +1,4 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. package client @@ -34,8 +34,8 @@ func (s *V2) GetInfo(ctx context.Context, opts ...operations.Option) (*operation hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2GetInfo", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} @@ -74,6 +74,10 @@ func (s *V2) GetInfo(ctx context.Context, opts ...operations.Option) (*operation req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -221,8 +225,8 @@ func (s *V2) ListLedgers(ctx context.Context, pageSize *int64, cursor *string, o hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2ListLedgers", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2ListLedgersRequest{ @@ -270,6 +274,10 @@ func (s *V2) ListLedgers(ctx context.Context, pageSize *int64, cursor *string, o return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -405,8 +413,8 @@ func (s *V2) GetLedger(ctx context.Context, ledger string, opts ...operations.Op hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2GetLedger", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2GetLedgerRequest{ @@ -449,6 +457,10 @@ func (s *V2) GetLedger(ctx context.Context, ledger string, opts ...operations.Op req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -584,8 +596,8 @@ func (s *V2) CreateLedger(ctx context.Context, ledger string, v2CreateLedgerRequ hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2CreateLedger", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2CreateLedgerRequest{ @@ -635,6 +647,10 @@ func (s *V2) CreateLedger(ctx context.Context, ledger string, v2CreateLedgerRequ req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -759,8 +775,8 @@ func (s *V2) UpdateLedgerMetadata(ctx context.Context, ledger string, requestBod hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2UpdateLedgerMetadata", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2UpdateLedgerMetadataRequest{ @@ -810,6 +826,10 @@ func (s *V2) UpdateLedgerMetadata(ctx context.Context, ledger string, requestBod req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -946,8 +966,8 @@ func (s *V2) DeleteLedgerMetadata(ctx context.Context, ledger string, key string hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2DeleteLedgerMetadata", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2DeleteLedgerMetadataRequest{ @@ -991,6 +1011,10 @@ func (s *V2) DeleteLedgerMetadata(ctx context.Context, ledger string, key string req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1115,8 +1139,8 @@ func (s *V2) GetLedgerInfo(ctx context.Context, ledger string, opts ...operation hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2GetLedgerInfo", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2GetLedgerInfoRequest{ @@ -1159,6 +1183,10 @@ func (s *V2) GetLedgerInfo(ctx context.Context, ledger string, opts ...operation req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1294,8 +1322,8 @@ func (s *V2) CreateBulk(ctx context.Context, ledger string, requestBody []compon hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2CreateBulk", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2CreateBulkRequest{ @@ -1345,6 +1373,10 @@ func (s *V2) CreateBulk(ctx context.Context, ledger string, requestBody []compon req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1482,8 +1514,8 @@ func (s *V2) CountAccounts(ctx context.Context, ledger string, pit *time.Time, r hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2CountAccounts", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2CountAccountsRequest{ @@ -1538,6 +1570,10 @@ func (s *V2) CountAccounts(ctx context.Context, ledger string, pit *time.Time, r return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1665,8 +1701,8 @@ func (s *V2) ListAccounts(ctx context.Context, request operations.V2ListAccounts hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2ListAccounts", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} @@ -1715,6 +1751,10 @@ func (s *V2) ListAccounts(ctx context.Context, request operations.V2ListAccounts return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -1850,8 +1890,8 @@ func (s *V2) GetAccount(ctx context.Context, ledger string, address string, expa hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2GetAccount", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2GetAccountRequest{ @@ -1901,6 +1941,10 @@ func (s *V2) GetAccount(ctx context.Context, ledger string, address string, expa return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -2036,8 +2080,8 @@ func (s *V2) AddMetadataToAccount(ctx context.Context, request operations.V2AddM hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2AddMetadataToAccount", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} @@ -2088,6 +2132,10 @@ func (s *V2) AddMetadataToAccount(ctx context.Context, request operations.V2AddM return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -2213,8 +2261,8 @@ func (s *V2) DeleteAccountMetadata(ctx context.Context, ledger string, address s hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2DeleteAccountMetadata", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2DeleteAccountMetadataRequest{ @@ -2259,6 +2307,10 @@ func (s *V2) DeleteAccountMetadata(ctx context.Context, ledger string, address s req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -2384,8 +2436,8 @@ func (s *V2) ReadStats(ctx context.Context, ledger string, opts ...operations.Op hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2ReadStats", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2ReadStatsRequest{ @@ -2428,6 +2480,10 @@ func (s *V2) ReadStats(ctx context.Context, ledger string, opts ...operations.Op req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -2563,8 +2619,8 @@ func (s *V2) CountTransactions(ctx context.Context, ledger string, pit *time.Tim hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2CountTransactions", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2CountTransactionsRequest{ @@ -2619,6 +2675,10 @@ func (s *V2) CountTransactions(ctx context.Context, ledger string, pit *time.Tim return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -2746,8 +2806,8 @@ func (s *V2) ListTransactions(ctx context.Context, request operations.V2ListTran hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2ListTransactions", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} @@ -2796,6 +2856,10 @@ func (s *V2) ListTransactions(ctx context.Context, request operations.V2ListTran return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -2931,8 +2995,8 @@ func (s *V2) CreateTransaction(ctx context.Context, ledger string, v2PostTransac hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2CreateTransaction", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2CreateTransactionRequest{ @@ -2990,6 +3054,10 @@ func (s *V2) CreateTransaction(ctx context.Context, ledger string, v2PostTransac return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -3125,8 +3193,8 @@ func (s *V2) GetTransaction(ctx context.Context, ledger string, id *big.Int, exp hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2GetTransaction", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2GetTransactionRequest{ @@ -3176,6 +3244,10 @@ func (s *V2) GetTransaction(ctx context.Context, ledger string, id *big.Int, exp return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -3311,8 +3383,8 @@ func (s *V2) AddMetadataOnTransaction(ctx context.Context, request operations.V2 hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2AddMetadataOnTransaction", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} @@ -3363,6 +3435,10 @@ func (s *V2) AddMetadataOnTransaction(ctx context.Context, request operations.V2 return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -3488,8 +3564,8 @@ func (s *V2) DeleteTransactionMetadata(ctx context.Context, ledger string, id *b hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2DeleteTransactionMetadata", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2DeleteTransactionMetadataRequest{ @@ -3534,6 +3610,10 @@ func (s *V2) DeleteTransactionMetadata(ctx context.Context, ledger string, id *b req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -3658,8 +3738,8 @@ func (s *V2) RevertTransaction(ctx context.Context, ledger string, id *big.Int, hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2RevertTransaction", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2RevertTransactionRequest{ @@ -3709,6 +3789,10 @@ func (s *V2) RevertTransaction(ctx context.Context, ledger string, id *big.Int, return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -3844,8 +3928,8 @@ func (s *V2) GetBalancesAggregated(ctx context.Context, ledger string, pit *time hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2GetBalancesAggregated", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2GetBalancesAggregatedRequest{ @@ -3901,6 +3985,10 @@ func (s *V2) GetBalancesAggregated(ctx context.Context, ledger string, pit *time return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -4036,8 +4124,8 @@ func (s *V2) GetVolumesWithBalances(ctx context.Context, request operations.V2Ge hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2GetVolumesWithBalances", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} @@ -4086,6 +4174,10 @@ func (s *V2) GetVolumesWithBalances(ctx context.Context, request operations.V2Ge return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -4222,8 +4314,8 @@ func (s *V2) ListLogs(ctx context.Context, request operations.V2ListLogsRequest, hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2ListLogs", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:read"}, + SecuritySource: s.sdkConfiguration.Security, } o := operations.Options{} @@ -4272,6 +4364,10 @@ func (s *V2) ListLogs(ctx context.Context, request operations.V2ListLogsRequest, return nil, fmt.Errorf("error populating query params: %w", err) } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -4406,8 +4502,8 @@ func (s *V2) ImportLogs(ctx context.Context, ledger string, requestBody *string, hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2ImportLogs", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2ImportLogsRequest{ @@ -4457,6 +4553,10 @@ func (s *V2) ImportLogs(ctx context.Context, ledger string, requestBody *string, req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { @@ -4581,8 +4681,8 @@ func (s *V2) ExportLogs(ctx context.Context, ledger string, opts ...operations.O hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v2ExportLogs", - OAuth2Scopes: []string{}, - SecuritySource: nil, + OAuth2Scopes: []string{"ledger:read", "ledger:write"}, + SecuritySource: s.sdkConfiguration.Security, } request := operations.V2ExportLogsRequest{ @@ -4625,6 +4725,10 @@ func (s *V2) ExportLogs(ctx context.Context, ledger string, opts ...operations.O req.Header.Set("Accept", "*/*") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + globalRetryConfig := s.sdkConfiguration.RetryConfig retryConfig := o.Retries if retryConfig == nil { diff --git a/test/performance/performance_test.go b/test/performance/performance_test.go index 6be9dd040..ad8aff9fe 100644 --- a/test/performance/performance_test.go +++ b/test/performance/performance_test.go @@ -73,7 +73,7 @@ func BenchmarkWorstCase(b *testing.B) { transactionResponse, err := testServer.Client().Ledger.V2.CreateTransaction(ctx, ledgerName, components.V2PostTransaction{ Timestamp: nil, Postings: nil, - Script: &components.Script{ + Script: &components.V2PostTransactionScript{ Plain: `vars { account $account }