Skip to content

Commit

Permalink
feat: update speakeasy (#1100)
Browse files Browse the repository at this point in the history
Co-authored-by: Maxence Maireaux <[email protected]>
Co-authored-by: David Ragot <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2024
1 parent 34f706d commit 2e03d96
Show file tree
Hide file tree
Showing 1,718 changed files with 10,299 additions and 9,132 deletions.
2 changes: 1 addition & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sources:
speakeasy:
FROM core+base-image
RUN apk update && apk add yarn jq unzip curl
ARG VERSION=v1.109.1
ARG VERSION=v1.126.4
ARG TARGETARCH
RUN curl -fsSL https://github.com/speakeasy-api/speakeasy/releases/download/${VERSION}/speakeasy_linux_$TARGETARCH.zip -o /tmp/speakeasy_linux_$TARGETARCH.zip
RUN unzip /tmp/speakeasy_linux_$TARGETARCH.zip speakeasy
Expand Down
4 changes: 2 additions & 2 deletions components/fctl/cmd/payments/accounts/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type ListStore struct {
Cursor *shared.AccountsCursorCursor `json:"cursor"`
Cursor *shared.Cursor `json:"cursor"`
}

type ListController struct {
Expand All @@ -26,7 +26,7 @@ var _ fctl.Controller[*ListStore] = (*ListController)(nil)

func NewListStore() *ListStore {
return &ListStore{
Cursor: &shared.AccountsCursorCursor{},
Cursor: &shared.Cursor{},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (c *UpdateStatusController) Run(cmd *cobra.Command, args []string) (fctl.Re
//nolint:gosimple
response, err := client.Payments.UdpateTransferInitiationStatus(cmd.Context(), operations.UdpateTransferInitiationStatusRequest{
UpdateTransferInitiationStatusRequest: shared.UpdateTransferInitiationStatusRequest{
Status: shared.UpdateTransferInitiationStatusRequestStatus(args[1]),
Status: shared.Status(args[1]),
},
TransferID: args[0],
})
Expand Down
10 changes: 4 additions & 6 deletions components/fctl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/formancehq/fctl/cmd/webhooks"
"github.com/formancehq/fctl/membershipclient"
fctl "github.com/formancehq/fctl/pkg"
"github.com/formancehq/formance-sdk-go/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors"
"github.com/formancehq/stack/libs/go-libs/api"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -119,7 +119,7 @@ func extractOpenAPIErrorMessage(err error) error {
return err
}

func unwrapOpenAPIError(err error) *shared.V2ErrorResponse {
func unwrapOpenAPIError(err error) *sdkerrors.V2Error {
openapiError := &membershipclient.GenericOpenAPIError{}
if errors.As(err, &openapiError) {
body := openapiError.Body()
Expand All @@ -133,11 +133,9 @@ func unwrapOpenAPIError(err error) *shared.V2ErrorResponse {
}

if errResponse.ErrorCode != "" {
errorCode := shared.V2ErrorsEnum(errResponse.ErrorCode)
return &shared.V2ErrorResponse{
ErrorCode: errorCode,
return &sdkerrors.V2Error{
ErrorCode: sdkerrors.ErrorCode(errResponse.ErrorCode),
ErrorMessage: errResponse.ErrorMessage,
Details: &errResponse.Details,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/fctl/cmd/webhooks/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (

fctl "github.com/formancehq/fctl/pkg"
"github.com/formancehq/formance-sdk-go/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/pkg/models/shared"
"github.com/formancehq/formance-sdk-go/pkg/models/sdkerrors"
"github.com/pkg/errors"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
)

type DeleteWebhookStore struct {
ErrorResponse *shared.WebhooksErrorResponse `json:"error"`
Success bool `json:"success"`
ErrorResponse *sdkerrors.WebhooksErrorResponse `json:"error"`
Success bool `json:"success"`
}

type DeleteWebhookController struct {
Expand Down
347 changes: 347 additions & 0 deletions components/fctl/membershipclient/go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type CreateTransactionWrapper struct {
// OK
CreateTransactionResponse *CreateTransactionResponse
// Error
ErrorResponse *shared.ErrorResponse
ErrorResponse *shared.Error
StatusCode int
RawResponse *http.Response
}
Expand Down
12 changes: 5 additions & 7 deletions ee/wallets/pkg/api/handler_wallets_debit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,17 @@ type testCase struct {
}

type apiErrorMock struct {
ErrorCode shared.ErrorsEnum `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
Details *string `json:"details,omitempty"`
ErrorCode shared.WalletsErrorResponseErrorCode `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
}

func (a *apiErrorMock) Model() any {
if a == nil {
return nil
}
return shared.ErrorResponse{
return shared.WalletsErrorResponse{
ErrorCode: a.ErrorCode,
ErrorMessage: a.ErrorMessage,
Details: a.Details,
}
}

Expand Down Expand Up @@ -141,7 +139,7 @@ var walletDebitTestCases = []testCase{
Amount: wallet.NewMonetary(big.NewInt(100), "USD"),
},
postTransactionError: &apiErrorMock{
ErrorCode: shared.ErrorsEnumInsufficientFund,
ErrorCode: shared.WalletsErrorResponseErrorCodeInsufficientFund,
},
expectedStatusCode: http.StatusBadRequest,
expectedErrorCode: string(shared.ErrorsEnumInsufficientFund),
Expand Down Expand Up @@ -246,7 +244,7 @@ var walletDebitTestCases = []testCase{
}
},
expectedStatusCode: http.StatusBadRequest,
expectedErrorCode: string(shared.ErrorErrorCodeValidation),
expectedErrorCode: string(shared.WalletsErrorResponseErrorCodeValidation),
},
{
name: "with custom balance as destination",
Expand Down
4 changes: 2 additions & 2 deletions ee/wallets/pkg/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ func (m *Manager) CreateTransaction(ctx context.Context, postTransaction PostTra
if _, err := m.client.CreateTransaction(ctx, m.ledgerName, postTransaction); err != nil {
apiErr, ok := err.(GenericOpenAPIError)
if ok {
respErr, ok := apiErr.Model().(shared.ErrorResponse)
respErr, ok := apiErr.Model().(shared.WalletsErrorResponse)
if ok {
switch respErr.ErrorCode {
case shared.ErrorsEnumInsufficientFund:
case shared.WalletsErrorResponseErrorCodeInsufficientFund:
return ErrInsufficientFundError
}
}
Expand Down
Empty file modified releases/sdks/go/.gitattributes
100755 → 100644
Empty file.
5 changes: 4 additions & 1 deletion releases/sdks/go/.github/workflows/speakeasy_sdk_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ jobs:
tag_name: ${{ steps.extract_branch.outputs.branch }}
release_name: Release ${{ steps.extract_branch.outputs.branch }}
draft: false
prerelease: false
prerelease: false
- run: gh repo edit --default-branch=release/${{ steps.extract_branch.outputs.branch }}
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
Empty file modified releases/sdks/go/.gitignore
100755 → 100644
Empty file.
Loading

0 comments on commit 2e03d96

Please sign in to comment.