Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cmd/auth/clients/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/auth"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down Expand Up @@ -95,7 +95,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab
trusted := fctl.GetBool(cmd, c.trustedFlag)
description := fctl.GetString(cmd, c.descriptionFlag)

request := shared.CreateClientRequest{
request := auth.ClientOptions1{
Public: &public,
RedirectUris: fctl.GetStringSlice(cmd, c.redirectUriFlag),
Description: &description,
Expand All @@ -114,13 +114,13 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab
}

c.store.Client = &CreateClient{
ID: response.CreateClientResponse.Data.ID,
Name: response.CreateClientResponse.Data.Name,
Description: fctl.StringPointerToString(response.CreateClientResponse.Data.Description),
IsPublic: fctl.BoolPointerToString(response.CreateClientResponse.Data.Public),
RedirectUri: strings.Join(response.CreateClientResponse.Data.RedirectUris, ","),
PostLogoutRedirectUri: strings.Join(response.CreateClientResponse.Data.PostLogoutRedirectUris, ","),
Scopes: response.CreateClientResponse.Data.Scopes,
ID: response.CreateClientResponse.ClientOptions.ID,
Name: response.CreateClientResponse.ClientOptions.Name,
Description: fctl.StringPointerToString(response.CreateClientResponse.ClientOptions.Description),
IsPublic: fctl.BoolPointerToString(response.CreateClientResponse.ClientOptions.Public),
RedirectUri: strings.Join(response.CreateClientResponse.ClientOptions.RedirectUris, ","),
PostLogoutRedirectUri: strings.Join(response.CreateClientResponse.ClientOptions.PostLogoutRedirectUris, ","),
Scopes: response.CreateClientResponse.ClientOptions.Scopes,
}

return c, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/auth/clients/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/auth/clients/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/auth"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down Expand Up @@ -73,7 +73,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable
return nil, fmt.Errorf("unexpected status code: %d", clients.StatusCode)
}

c.store.Clients = fctl.Map(clients.ListClientsResponse.Data, func(o shared.Client) Client {
c.store.Clients = fctl.Map(clients.ListClientsResponse.Data, func(o auth.ClientOptions) Client {
return Client{
ID: o.ID,
Name: o.Name,
Expand Down
12 changes: 6 additions & 6 deletions cmd/auth/clients/secrets/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/auth"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down Expand Up @@ -65,7 +65,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab

request := operations.CreateSecretRequest{
ClientID: args[0],
CreateSecretRequest: &shared.CreateSecretRequest{
SecretOptions: &auth.SecretOptions{
Name: args[1],
Metadata: nil,
},
Expand All @@ -79,9 +79,9 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab
return nil, fmt.Errorf("unexpected status code: %d", response.StatusCode)
}

c.store.SecretId = response.CreateSecretResponse.Data.ID
c.store.Name = response.CreateSecretResponse.Data.Name
c.store.Clear = response.CreateSecretResponse.Data.Clear
c.store.SecretId = response.CreateSecretResponse.SecretOptions.ID
c.store.Name = response.CreateSecretResponse.SecretOptions.Name
c.store.Clear = response.CreateSecretResponse.SecretOptions.Clear

return c, nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/auth/clients/secrets/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down
8 changes: 4 additions & 4 deletions cmd/auth/clients/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/auth"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

"github.com/formancehq/fctl/v3/cmd/auth/clients/views"
fctl "github.com/formancehq/fctl/v3/pkg"
)

type ShowStore struct {
Client *shared.Client `json:"client,omitempty"`
Client *auth.ClientOptions `json:"client,omitempty"`
}
type ShowController struct {
store *ShowStore
Expand Down Expand Up @@ -70,7 +70,7 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable
return nil, fmt.Errorf("unexpected status code: %d", response.StatusCode)
}

c.store.Client = response.ReadClientResponse.Data
c.store.Client = response.ReadClientResponse.ClientOptions

return c, nil
}
Expand Down
20 changes: 10 additions & 10 deletions cmd/auth/clients/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/auth"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down Expand Up @@ -104,7 +104,7 @@ func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab

request := operations.UpdateClientRequest{
ClientID: args[0],
CreateClientRequest: &shared.CreateClientRequest{
ClientOptions: &auth.ClientOptions1{
Public: &public,
RedirectUris: fctl.GetStringSlice(cmd, c.redirectUriFlag),
Description: &description,
Expand All @@ -123,13 +123,13 @@ func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab
return nil, fmt.Errorf("unexpected status code: %d", response.StatusCode)
}

c.store.Client.ID = response.UpdateClientResponse.Data.ID
c.store.Client.Name = response.UpdateClientResponse.Data.Name
c.store.Client.Description = fctl.StringPointerToString(response.UpdateClientResponse.Data.Description)
c.store.Client.IsPublic = fctl.BoolPointerToString(response.UpdateClientResponse.Data.Public)
c.store.Client.RedirectUri = strings.Join(response.UpdateClientResponse.Data.RedirectUris, ",")
c.store.Client.PostLogoutRedirectUri = strings.Join(response.UpdateClientResponse.Data.PostLogoutRedirectUris, ",")
c.store.Client.Scopes = response.UpdateClientResponse.Data.Scopes
c.store.Client.ID = response.CreateClientResponse.ClientOptions.ID
c.store.Client.Name = response.CreateClientResponse.ClientOptions.Name
c.store.Client.Description = fctl.StringPointerToString(response.CreateClientResponse.ClientOptions.Description)
c.store.Client.IsPublic = fctl.BoolPointerToString(response.CreateClientResponse.ClientOptions.Public)
c.store.Client.RedirectUri = strings.Join(response.CreateClientResponse.ClientOptions.RedirectUris, ",")
c.store.Client.PostLogoutRedirectUri = strings.Join(response.CreateClientResponse.ClientOptions.PostLogoutRedirectUris, ",")
c.store.Client.Scopes = response.CreateClientResponse.ClientOptions.Scopes

return c, nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/auth/clients/views/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

"github.com/pterm/pterm"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/auth"

fctl "github.com/formancehq/fctl/v3/pkg"
)

func PrintClient(out io.Writer, client *shared.Client) error {
func PrintClient(out io.Writer, client *auth.ClientOptions) error {
tableData := pterm.TableData{}
tableData = append(tableData, []string{pterm.LightCyan("ID"), client.ID})
tableData = append(tableData, []string{pterm.LightCyan("Name"), client.Name})
Expand Down
6 changes: 3 additions & 3 deletions cmd/auth/clients/views/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (

"github.com/pterm/pterm"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/auth"

fctl "github.com/formancehq/fctl/v3/pkg"
)

func PrintSecrets(out io.Writer, secrets []shared.ClientSecret) error {
func PrintSecrets(out io.Writer, secrets []auth.ClientSecret) error {
fctl.Section.WithWriter(out).Println("Secrets :")

return pterm.DefaultTable.
WithWriter(out).
WithHasHeader(true).
WithData(fctl.Prepend(
fctl.Map(secrets, func(secret shared.ClientSecret) []string {
fctl.Map(secrets, func(secret auth.ClientSecret) []string {
return []string{
secret.ID, secret.Name, secret.LastDigits,
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/auth/users/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/auth"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down Expand Up @@ -70,7 +70,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable
return nil, fmt.Errorf("unexpected status code: %d", listUsersResponse.StatusCode)
}

c.store.Users = fctl.Map(listUsersResponse.ListUsersResponse.Data, func(o shared.User) User {
c.store.Users = fctl.Map(listUsersResponse.ListUsersResponse.Data, func(o auth.User) User {
return User{
ID: *o.ID,
Subject: *o.Subject,
Expand Down
8 changes: 4 additions & 4 deletions cmd/auth/users/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down Expand Up @@ -68,9 +68,9 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable
}

c.store.User = &User{
ID: *readUserResponse.ReadUserResponse.Data.ID,
Subject: *readUserResponse.ReadUserResponse.Data.Subject,
Email: *readUserResponse.ReadUserResponse.Data.Email,
ID: *readUserResponse.ReadUserResponse.User.ID,
Subject: *readUserResponse.ReadUserResponse.User.Subject,
Email: *readUserResponse.ReadUserResponse.User.Email,
}

return c, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/ledger/accounts/delete_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

"github.com/formancehq/fctl/v3/cmd/ledger/internal"
fctl "github.com/formancehq/fctl/v3/pkg"
Expand Down
10 changes: 5 additions & 5 deletions cmd/ledger/accounts/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/ledger"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

"github.com/formancehq/fctl/v3/cmd/ledger/internal"
fctl "github.com/formancehq/fctl/v3/pkg"
)

type ListStore struct {
Accounts []shared.V2Account `json:"accounts"`
Accounts []ledger.V2Account `json:"accounts"`
}
type ListController struct {
store *ListStore
Expand Down Expand Up @@ -75,7 +75,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable

request := operations.V2ListAccountsRequest{
Ledger: fctl.GetString(cmd, internal.LedgerFlag),
Query: map[string]any{
RequestBody: map[string]any{
"$and": body,
},
}
Expand All @@ -91,7 +91,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable

func (c *ListController) Render(cmd *cobra.Command, args []string) error {

tableData := fctl.Map(c.store.Accounts, func(account shared.V2Account) []string {
tableData := fctl.Map(c.store.Accounts, func(account ledger.V2Account) []string {
return []string{
account.Address,
fctl.MetadataAsShortString(account.Metadata),
Expand Down
2 changes: 1 addition & 1 deletion cmd/ledger/accounts/set_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"
"github.com/formancehq/go-libs/v4/collectionutils"

"github.com/formancehq/fctl/v3/cmd/ledger/internal"
Expand Down
10 changes: 5 additions & 5 deletions cmd/ledger/accounts/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/ledger"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"
"github.com/formancehq/go-libs/v4/collectionutils"

internal "github.com/formancehq/fctl/v3/cmd/ledger/internal"
fctl "github.com/formancehq/fctl/v3/pkg"
)

type ShowStore struct {
Account *shared.AccountWithVolumesAndBalances `json:"account"`
Account *ledger.AccountWithVolumesAndBalances `json:"account"`
}
type ShowController struct {
store *ShowStore
Expand Down Expand Up @@ -59,15 +59,15 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable
}

ledger := fctl.GetString(cmd, internal.LedgerFlag)
response, err := stackClient.Ledger.V1.GetAccount(cmd.Context(), operations.GetAccountRequest{
response, err := stackClient.Ledger.V1.GetAccountLedger(cmd.Context(), operations.GetAccountLedgerRequest{
Address: args[0],
Ledger: ledger,
})
if err != nil {
return nil, err
}

c.store.Account = &response.AccountResponse.Data
c.store.Account = &response.AccountResponse.AccountWithVolumesAndBalances

return c, nil
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/ledger/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v3/pkg/models/shared"
ledgermodels "github.com/formancehq/formance-sdk-go/v4/pkg/models/ledger"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"
"github.com/formancehq/go-libs/v4/pointer"

fctl "github.com/formancehq/fctl/v3/pkg"
Expand Down Expand Up @@ -92,10 +92,10 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab
}

_, err = stackClient.Ledger.V2.CreateLedger(cmd.Context(), operations.V2CreateLedgerRequest{
V2CreateLedgerRequest: shared.V2CreateLedgerRequest{
Bucket: pointer.For(fctl.GetString(cmd, bucketNameFlag)),
Metadata: metadata,
Features: features,
V2CreateLedgerRequest: ledgermodels.V2CreateLedgerRequest{
Bucket: pointer.For(fctl.GetString(cmd, bucketNameFlag)),
V2Metadata: metadata,
Features: features,
},
Ledger: args[0],
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/ledger/delete_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

fctl "github.com/formancehq/fctl/v3/pkg"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/ledger/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/spf13/cobra"

"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v4/pkg/models/operations"

"github.com/formancehq/fctl/v3/cmd/ledger/internal"
fctl "github.com/formancehq/fctl/v3/pkg"
Expand Down
Loading
Loading