From a782efa4f933c90c846dbc289edf18db97327b31 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 6 Sep 2025 03:58:33 +0000 Subject: [PATCH 1/8] chore(internal): codegen related update --- internal/apijson/decodeparam_test.go | 88 ++++++++++++++++++++++++++++ internal/apijson/union.go | 48 ++++++++------- 2 files changed, 115 insertions(+), 21 deletions(-) diff --git a/internal/apijson/decodeparam_test.go b/internal/apijson/decodeparam_test.go index 77a9a49..652fdb7 100644 --- a/internal/apijson/decodeparam_test.go +++ b/internal/apijson/decodeparam_test.go @@ -351,6 +351,36 @@ func init() { }) } +type FooVariant struct { + Type string `json:"type,required"` + Value string `json:"value,required"` +} + +type BarVariant struct { + Type string `json:"type,required"` + Enable bool `json:"enable,required"` +} + +type MultiDiscriminatorUnion struct { + OfFoo *FooVariant `json:",inline"` + OfBar *BarVariant `json:",inline"` + + paramUnion +} + +func init() { + apijson.RegisterDiscriminatedUnion[MultiDiscriminatorUnion]("type", map[string]reflect.Type{ + "foo": reflect.TypeOf(FooVariant{}), + "foo_v2": reflect.TypeOf(FooVariant{}), + "bar": reflect.TypeOf(BarVariant{}), + "bar_legacy": reflect.TypeOf(BarVariant{}), + }) +} + +func (m *MultiDiscriminatorUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, m) +} + func (d *DiscriminatedUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, d) } @@ -408,3 +438,61 @@ func TestDiscriminatedUnion(t *testing.T) { }) } } + +func TestMultiDiscriminatorUnion(t *testing.T) { + tests := map[string]struct { + raw string + target MultiDiscriminatorUnion + shouldFail bool + }{ + "foo_variant": { + raw: `{"type":"foo","value":"test"}`, + target: MultiDiscriminatorUnion{OfFoo: &FooVariant{ + Type: "foo", + Value: "test", + }}, + }, + "foo_v2_variant": { + raw: `{"type":"foo_v2","value":"test_v2"}`, + target: MultiDiscriminatorUnion{OfFoo: &FooVariant{ + Type: "foo_v2", + Value: "test_v2", + }}, + }, + "bar_variant": { + raw: `{"type":"bar","enable":true}`, + target: MultiDiscriminatorUnion{OfBar: &BarVariant{ + Type: "bar", + Enable: true, + }}, + }, + "bar_legacy_variant": { + raw: `{"type":"bar_legacy","enable":false}`, + target: MultiDiscriminatorUnion{OfBar: &BarVariant{ + Type: "bar_legacy", + Enable: false, + }}, + }, + "invalid_type": { + raw: `{"type":"unknown","value":"test"}`, + target: MultiDiscriminatorUnion{}, + shouldFail: true, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + var dst MultiDiscriminatorUnion + err := json.Unmarshal([]byte(test.raw), &dst) + if err != nil && !test.shouldFail { + t.Fatalf("failed unmarshal with err: %v", err) + } + if err == nil && test.shouldFail { + t.Fatalf("expected unmarshal to fail but it succeeded") + } + if !reflect.DeepEqual(dst, test.target) { + t.Fatalf("failed equality, got %#v but expected %#v", dst, test.target) + } + }) + } +} diff --git a/internal/apijson/union.go b/internal/apijson/union.go index 4ce6926..d63956c 100644 --- a/internal/apijson/union.go +++ b/internal/apijson/union.go @@ -39,12 +39,10 @@ func RegisterDiscriminatedUnion[T any](key string, mappings map[string]reflect.T func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { type variantDecoder struct { - decoder decoderFunc - field reflect.StructField - discriminatorValue any + decoder decoderFunc + field reflect.StructField } - - variants := []variantDecoder{} + decoders := []variantDecoder{} for i := 0; i < t.NumField(); i++ { field := t.Field(i) @@ -53,18 +51,26 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { } decoder := d.typeDecoder(field.Type) - variants = append(variants, variantDecoder{ + decoders = append(decoders, variantDecoder{ decoder: decoder, field: field, }) } + type discriminatedDecoder struct { + variantDecoder + discriminator any + } + discriminatedDecoders := []discriminatedDecoder{} unionEntry, discriminated := unionRegistry[t] - for _, unionVariant := range unionEntry.variants { - for i := 0; i < len(variants); i++ { - variant := &variants[i] - if variant.field.Type.Elem() == unionVariant.Type { - variant.discriminatorValue = unionVariant.DiscriminatorValue + for _, variant := range unionEntry.variants { + // For each union variant, find a matching decoder and save it + for _, decoder := range decoders { + if decoder.field.Type.Elem() == variant.Type { + discriminatedDecoders = append(discriminatedDecoders, discriminatedDecoder{ + decoder, + variant.DiscriminatorValue, + }) break } } @@ -73,10 +79,10 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { return func(n gjson.Result, v reflect.Value, state *decoderState) error { if discriminated && n.Type == gjson.JSON && len(unionEntry.discriminatorKey) != 0 { discriminator := n.Get(unionEntry.discriminatorKey).Value() - for _, variant := range variants { - if discriminator == variant.discriminatorValue { - inner := v.FieldByIndex(variant.field.Index) - return variant.decoder(n, inner, state) + for _, decoder := range discriminatedDecoders { + if discriminator == decoder.discriminator { + inner := v.FieldByIndex(decoder.field.Index) + return decoder.decoder(n, inner, state) } } return errors.New("apijson: was not able to find discriminated union variant") @@ -85,15 +91,15 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { // Set bestExactness to worse than loose bestExactness := loose - 1 bestVariant := -1 - for i, variant := range variants { + for i, decoder := range decoders { // Pointers are used to discern JSON object variants from value variants - if n.Type != gjson.JSON && variant.field.Type.Kind() == reflect.Ptr { + if n.Type != gjson.JSON && decoder.field.Type.Kind() == reflect.Ptr { continue } sub := decoderState{strict: state.strict, exactness: exact} - inner := v.FieldByIndex(variant.field.Index) - err := variant.decoder(n, inner, &sub) + inner := v.FieldByIndex(decoder.field.Index) + err := decoder.decoder(n, inner, &sub) if err != nil { continue } @@ -116,11 +122,11 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { return errors.New("apijson: was not able to coerce type as union strictly") } - for i := 0; i < len(variants); i++ { + for i := 0; i < len(decoders); i++ { if i == bestVariant { continue } - v.FieldByIndex(variants[i].field.Index).SetZero() + v.FieldByIndex(decoders[i].field.Index).SetZero() } return nil From d744de6d7d132a63d75851df6d332b15798c4882 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 02:54:07 +0000 Subject: [PATCH 2/8] chore: bump minimum go version to 1.22 --- go.mod | 2 +- internal/encoding/json/shims/shims.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 76b644e..4a37637 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Munchpass/checkbook -go 1.21 +go 1.22 require ( github.com/tidwall/gjson v1.14.4 diff --git a/internal/encoding/json/shims/shims.go b/internal/encoding/json/shims/shims.go index b65a016..fe9a71a 100644 --- a/internal/encoding/json/shims/shims.go +++ b/internal/encoding/json/shims/shims.go @@ -1,5 +1,5 @@ // This package provides shims over Go 1.2{2,3} APIs -// which are missing from Go 1.21, and used by the Go 1.24 encoding/json package. +// which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. // // Inside the vendored package, all shim code has comments that begin look like // // SHIM(...): ... From b37ee7a270ba115331498b2287ee056585e48ed3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 02:55:07 +0000 Subject: [PATCH 3/8] chore: update more docs for 1.22 --- CONTRIBUTING.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21882e5..fbf9b9c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ $ ./scripts/lint This will install all the required dependencies and build the SDK. -You can also [install go 1.18+ manually](https://go.dev/doc/install). +You can also [install go 1.22+ manually](https://go.dev/doc/install). ## Modifying/Adding code diff --git a/README.md b/README.md index 9b2e7da..74007d6 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ go get -u 'github.com/Munchpass/checkbook@v0.2.0' ## Requirements -This library requires Go 1.18+. +This library requires Go 1.22+. ## Usage From c73bccf25d2357526c49fbdccad07ee5da9c70b7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 02:55:45 +0000 Subject: [PATCH 4/8] fix: use slices.Concat instead of sometimes modifying r.Options --- accountbank.go | 15 ++++++++------- accountbankiav.go | 5 +++-- accountcard.go | 9 +++++---- accountinterac.go | 9 +++++---- accountpaypal.go | 9 +++++---- accountvcc.go | 9 +++++---- accountvcctransaction.go | 5 +++-- accountvenmo.go | 9 +++++---- accountwallet.go | 5 +++-- accountwire.go | 9 +++++---- approval.go | 19 ++++++++++--------- check.go | 31 ++++++++++++++++--------------- checkdeposit.go | 5 +++-- client.go | 3 ++- directory.go | 9 +++++---- directoryaccount.go | 7 ++++--- invoice.go | 13 +++++++------ mailbox.go | 7 ++++--- mailboxmail.go | 7 ++++--- subscription.go | 13 +++++++------ user.go | 13 +++++++------ userapikey.go | 7 ++++--- 22 files changed, 120 insertions(+), 98 deletions(-) diff --git a/accountbank.go b/accountbank.go index e0bc310..147436c 100644 --- a/accountbank.go +++ b/accountbank.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -38,7 +39,7 @@ func NewAccountBankService(opts ...option.RequestOption) (r AccountBankService) // Add a new bank account func (r *AccountBankService) New(ctx context.Context, body AccountBankNewParams, opts ...option.RequestOption) (res *AccountBankNewResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/bank" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -46,7 +47,7 @@ func (r *AccountBankService) New(ctx context.Context, body AccountBankNewParams, // Update an existing bank account func (r *AccountBankService) Update(ctx context.Context, bankID string, body AccountBankUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if bankID == "" { err = errors.New("missing required bank_id parameter") @@ -59,7 +60,7 @@ func (r *AccountBankService) Update(ctx context.Context, bankID string, body Acc // Get the bank accounts for a user func (r *AccountBankService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountBankListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/bank" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -67,7 +68,7 @@ func (r *AccountBankService) List(ctx context.Context, opts ...option.RequestOpt // Remove the specified bank account func (r *AccountBankService) Delete(ctx context.Context, bankID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if bankID == "" { err = errors.New("missing required bank_id parameter") @@ -80,7 +81,7 @@ func (r *AccountBankService) Delete(ctx context.Context, bankID string, opts ... // Release the micro-deposits for a bank account func (r *AccountBankService) Release(ctx context.Context, body AccountBankReleaseParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) path := "v3/account/bank/release" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) @@ -89,7 +90,7 @@ func (r *AccountBankService) Release(ctx context.Context, body AccountBankReleas // Return a list of our supported institutions for instant account verification func (r *AccountBankService) GetInstitutions(ctx context.Context, opts ...option.RequestOption) (res *AccountBankGetInstitutionsResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/bank/institutions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -97,7 +98,7 @@ func (r *AccountBankService) GetInstitutions(ctx context.Context, opts ...option // Verify the micro-deposits for a bank account func (r *AccountBankService) Verify(ctx context.Context, body AccountBankVerifyParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) path := "v3/account/bank/verify" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) diff --git a/accountbankiav.go b/accountbankiav.go index 1726664..c754b15 100644 --- a/accountbankiav.go +++ b/accountbankiav.go @@ -5,6 +5,7 @@ package checkbook import ( "context" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -34,7 +35,7 @@ func NewAccountBankIavService(opts ...option.RequestOption) (r AccountBankIavSer // Add a new bank account with instant account verification func (r *AccountBankIavService) New(ctx context.Context, body AccountBankIavNewParams, opts ...option.RequestOption) (res *AccountBankIavNewResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/bank/iav" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -42,7 +43,7 @@ func (r *AccountBankIavService) New(ctx context.Context, body AccountBankIavNewP // Retrieve the bank account(s) associated with the Plaid token func (r *AccountBankIavService) Plaid(ctx context.Context, body AccountBankIavPlaidParams, opts ...option.RequestOption) (res *AccountBankIavPlaidResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/bank/iav/plaid" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return diff --git a/accountcard.go b/accountcard.go index 90bb74a..6e0dfff 100644 --- a/accountcard.go +++ b/accountcard.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -36,7 +37,7 @@ func NewAccountCardService(opts ...option.RequestOption) (r AccountCardService) // Add a new card func (r *AccountCardService) New(ctx context.Context, body AccountCardNewParams, opts ...option.RequestOption) (res *AccountCardNewResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/card" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -44,7 +45,7 @@ func (r *AccountCardService) New(ctx context.Context, body AccountCardNewParams, // Update the specified card func (r *AccountCardService) Update(ctx context.Context, cardID string, body AccountCardUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if cardID == "" { err = errors.New("missing required card_id parameter") @@ -57,7 +58,7 @@ func (r *AccountCardService) Update(ctx context.Context, cardID string, body Acc // Return the cards func (r *AccountCardService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountCardListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/card" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -65,7 +66,7 @@ func (r *AccountCardService) List(ctx context.Context, opts ...option.RequestOpt // Remove the specified card func (r *AccountCardService) Delete(ctx context.Context, cardID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if cardID == "" { err = errors.New("missing required card_id parameter") diff --git a/accountinterac.go b/accountinterac.go index fce647c..dd78e4c 100644 --- a/accountinterac.go +++ b/accountinterac.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -36,7 +37,7 @@ func NewAccountInteracService(opts ...option.RequestOption) (r AccountInteracSer // Add a new Interac account for a user func (r *AccountInteracService) New(ctx context.Context, body AccountInteracNewParams, opts ...option.RequestOption) (res *InteracAccountResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/interac" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -44,7 +45,7 @@ func (r *AccountInteracService) New(ctx context.Context, body AccountInteracNewP // Update an existing Interac account func (r *AccountInteracService) Update(ctx context.Context, interacID string, body AccountInteracUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if interacID == "" { err = errors.New("missing required interac_id parameter") @@ -57,7 +58,7 @@ func (r *AccountInteracService) Update(ctx context.Context, interacID string, bo // Return the Interac accounts of a user func (r *AccountInteracService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountInteracListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/interac" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -65,7 +66,7 @@ func (r *AccountInteracService) List(ctx context.Context, opts ...option.Request // Remove an existing Interac account func (r *AccountInteracService) Delete(ctx context.Context, interacID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if interacID == "" { err = errors.New("missing required interac_id parameter") diff --git a/accountpaypal.go b/accountpaypal.go index b28aff9..bc064d2 100644 --- a/accountpaypal.go +++ b/accountpaypal.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -36,7 +37,7 @@ func NewAccountPaypalService(opts ...option.RequestOption) (r AccountPaypalServi // Add a new Paypal account for a user func (r *AccountPaypalService) New(ctx context.Context, body AccountPaypalNewParams, opts ...option.RequestOption) (res *PaypalAccountResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/paypal" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -44,7 +45,7 @@ func (r *AccountPaypalService) New(ctx context.Context, body AccountPaypalNewPar // Update an existing Paypal account func (r *AccountPaypalService) Update(ctx context.Context, paypalID string, body AccountPaypalUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if paypalID == "" { err = errors.New("missing required paypal_id parameter") @@ -57,7 +58,7 @@ func (r *AccountPaypalService) Update(ctx context.Context, paypalID string, body // Return the Paypal accounts of a user func (r *AccountPaypalService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountPaypalListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/paypal" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -65,7 +66,7 @@ func (r *AccountPaypalService) List(ctx context.Context, opts ...option.RequestO // Remove an existing PayPal account func (r *AccountPaypalService) Delete(ctx context.Context, paypalID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if paypalID == "" { err = errors.New("missing required paypal_id parameter") diff --git a/accountvcc.go b/accountvcc.go index bf3e520..fc185ad 100644 --- a/accountvcc.go +++ b/accountvcc.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -39,7 +40,7 @@ func NewAccountVccService(opts ...option.RequestOption) (r AccountVccService) { // Add a new vcc func (r *AccountVccService) New(ctx context.Context, body AccountVccNewParams, opts ...option.RequestOption) (res *AccountVccNewResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/vcc" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -47,7 +48,7 @@ func (r *AccountVccService) New(ctx context.Context, body AccountVccNewParams, o // Update the specified vcc func (r *AccountVccService) Update(ctx context.Context, vccID string, body AccountVccUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if vccID == "" { err = errors.New("missing required vcc_id parameter") @@ -60,7 +61,7 @@ func (r *AccountVccService) Update(ctx context.Context, vccID string, body Accou // Return the virtual cards func (r *AccountVccService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountVccListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/vcc" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -68,7 +69,7 @@ func (r *AccountVccService) List(ctx context.Context, opts ...option.RequestOpti // Remove the specified vcc func (r *AccountVccService) Delete(ctx context.Context, vccID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if vccID == "" { err = errors.New("missing required vcc_id parameter") diff --git a/accountvcctransaction.go b/accountvcctransaction.go index c9be21e..eb671f6 100644 --- a/accountvcctransaction.go +++ b/accountvcctransaction.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -39,7 +40,7 @@ func NewAccountVccTransactionService(opts ...option.RequestOption) (r AccountVcc // Get the requested transaction for the specified VCC func (r *AccountVccTransactionService) Get(ctx context.Context, transactionID string, query AccountVccTransactionGetParams, opts ...option.RequestOption) (res *Transaction, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if query.VccID == "" { err = errors.New("missing required vcc_id parameter") return @@ -55,7 +56,7 @@ func (r *AccountVccTransactionService) Get(ctx context.Context, transactionID st // Get the transactions for the specified VCC func (r *AccountVccTransactionService) List(ctx context.Context, vccID string, query AccountVccTransactionListParams, opts ...option.RequestOption) (res *AccountVccTransactionListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if vccID == "" { err = errors.New("missing required vcc_id parameter") return diff --git a/accountvenmo.go b/accountvenmo.go index 8c70862..be18098 100644 --- a/accountvenmo.go +++ b/accountvenmo.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -36,7 +37,7 @@ func NewAccountVenmoService(opts ...option.RequestOption) (r AccountVenmoService // Add a new Venmo account for a user func (r *AccountVenmoService) New(ctx context.Context, body AccountVenmoNewParams, opts ...option.RequestOption) (res *VenmoAccountResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/venmo" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -44,7 +45,7 @@ func (r *AccountVenmoService) New(ctx context.Context, body AccountVenmoNewParam // Update an existing Venmo account func (r *AccountVenmoService) Update(ctx context.Context, venmoID string, body AccountVenmoUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if venmoID == "" { err = errors.New("missing required venmo_id parameter") @@ -57,7 +58,7 @@ func (r *AccountVenmoService) Update(ctx context.Context, venmoID string, body A // Return the Venmo accounts of a user func (r *AccountVenmoService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountVenmoListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/venmo" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -65,7 +66,7 @@ func (r *AccountVenmoService) List(ctx context.Context, opts ...option.RequestOp // Remove an existing Venmo account func (r *AccountVenmoService) Delete(ctx context.Context, venmoID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if venmoID == "" { err = errors.New("missing required venmo_id parameter") diff --git a/accountwallet.go b/accountwallet.go index 56bc225..19275f2 100644 --- a/accountwallet.go +++ b/accountwallet.go @@ -6,6 +6,7 @@ import ( "context" "encoding/json" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" shimjson "github.com/Munchpass/checkbook/internal/encoding/json" @@ -36,7 +37,7 @@ func NewAccountWalletService(opts ...option.RequestOption) (r AccountWalletServi // Update wallet func (r *AccountWalletService) New(ctx context.Context, body AccountWalletNewParams, opts ...option.RequestOption) (res *AccountWalletNewResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/wallet" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...) return @@ -44,7 +45,7 @@ func (r *AccountWalletService) New(ctx context.Context, body AccountWalletNewPar // Get wallet accounts for user func (r *AccountWalletService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountWalletListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/wallet" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return diff --git a/accountwire.go b/accountwire.go index 27c9075..42122b0 100644 --- a/accountwire.go +++ b/accountwire.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -36,7 +37,7 @@ func NewAccountWireService(opts ...option.RequestOption) (r AccountWireService) // Create a new wire account func (r *AccountWireService) New(ctx context.Context, body AccountWireNewParams, opts ...option.RequestOption) (res *WireAccountResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/wire" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -44,7 +45,7 @@ func (r *AccountWireService) New(ctx context.Context, body AccountWireNewParams, // Update an existing wire account func (r *AccountWireService) Update(ctx context.Context, accountID string, body AccountWireUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if accountID == "" { err = errors.New("missing required account_id parameter") @@ -57,7 +58,7 @@ func (r *AccountWireService) Update(ctx context.Context, accountID string, body // Return the wire accounts func (r *AccountWireService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountWireListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/account/wire" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -65,7 +66,7 @@ func (r *AccountWireService) List(ctx context.Context, opts ...option.RequestOpt // Remove an existing wire account func (r *AccountWireService) Delete(ctx context.Context, wireID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if wireID == "" { err = errors.New("missing required wire_id parameter") diff --git a/approval.go b/approval.go index 2f44a63..6c754be 100644 --- a/approval.go +++ b/approval.go @@ -9,6 +9,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -41,7 +42,7 @@ func NewApprovalService(opts ...option.RequestOption) (r ApprovalService) { // Get the specified payment approval func (r *ApprovalService) Get(ctx context.Context, approvalID string, opts ...option.RequestOption) (res *GetApproval, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if approvalID == "" { err = errors.New("missing required approval_id parameter") return @@ -53,7 +54,7 @@ func (r *ApprovalService) Get(ctx context.Context, approvalID string, opts ...op // Update the specified paynent approval func (r *ApprovalService) Update(ctx context.Context, approvalID string, body ApprovalUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if approvalID == "" { err = errors.New("missing required approval_id parameter") @@ -66,7 +67,7 @@ func (r *ApprovalService) Update(ctx context.Context, approvalID string, body Ap // Return approvals func (r *ApprovalService) List(ctx context.Context, query ApprovalListParams, opts ...option.RequestOption) (res *ApprovalListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/approval" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return @@ -74,7 +75,7 @@ func (r *ApprovalService) List(ctx context.Context, query ApprovalListParams, op // Cancel the specified check approval func (r *ApprovalService) Delete(ctx context.Context, approvalID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if approvalID == "" { err = errors.New("missing required approval_id parameter") @@ -87,7 +88,7 @@ func (r *ApprovalService) Delete(ctx context.Context, approvalID string, opts .. // Create a new approval digital payment func (r *ApprovalService) NewDigital(ctx context.Context, body ApprovalNewDigitalParams, opts ...option.RequestOption) (res *GetApproval, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/approval/digital" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -95,7 +96,7 @@ func (r *ApprovalService) NewDigital(ctx context.Context, body ApprovalNewDigita // Create a new multi-party payment approval func (r *ApprovalService) NewMulti(ctx context.Context, body ApprovalNewMultiParams, opts ...option.RequestOption) (res *GetApproval, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/approval/multi" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -103,7 +104,7 @@ func (r *ApprovalService) NewMulti(ctx context.Context, body ApprovalNewMultiPar // Create a new physical check approval func (r *ApprovalService) NewPhysical(ctx context.Context, body ApprovalNewPhysicalParams, opts ...option.RequestOption) (res *GetApproval, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/approval/physical" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -111,7 +112,7 @@ func (r *ApprovalService) NewPhysical(ctx context.Context, body ApprovalNewPhysi // Create a live payment from an approval func (r *ApprovalService) Release(ctx context.Context, body ApprovalReleaseParams, opts ...option.RequestOption) (res *GetCheck, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/approval/release" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -119,7 +120,7 @@ func (r *ApprovalService) Release(ctx context.Context, body ApprovalReleaseParam // Get the attachment for a payment approval func (r *ApprovalService) GetAttachment(ctx context.Context, approvalID string, opts ...option.RequestOption) (res *Error, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if approvalID == "" { err = errors.New("missing required approval_id parameter") return diff --git a/check.go b/check.go index 630e85c..9ba3a78 100644 --- a/check.go +++ b/check.go @@ -9,6 +9,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -43,7 +44,7 @@ func NewCheckService(opts ...option.RequestOption) (r CheckService) { // Get the specified payment func (r *CheckService) Get(ctx context.Context, checkID string, opts ...option.RequestOption) (res *GetCheck, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if checkID == "" { err = errors.New("missing required check_id parameter") return @@ -55,7 +56,7 @@ func (r *CheckService) Get(ctx context.Context, checkID string, opts ...option.R // Return the sent/received payments func (r *CheckService) List(ctx context.Context, query CheckListParams, opts ...option.RequestOption) (res *CheckListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/check" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return @@ -63,7 +64,7 @@ func (r *CheckService) List(ctx context.Context, query CheckListParams, opts ... // Create a digital payment func (r *CheckService) NewDigital(ctx context.Context, body CheckNewDigitalParams, opts ...option.RequestOption) (res *GetCheck, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/check/digital" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -71,7 +72,7 @@ func (r *CheckService) NewDigital(ctx context.Context, body CheckNewDigitalParam // Create a new multi party payment func (r *CheckService) NewMulti(ctx context.Context, body CheckNewMultiParams, opts ...option.RequestOption) (res *GetCheck, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/check/multi" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -79,7 +80,7 @@ func (r *CheckService) NewMulti(ctx context.Context, body CheckNewMultiParams, o // Create a new paper check func (r *CheckService) NewPhysical(ctx context.Context, body CheckNewPhysicalParams, opts ...option.RequestOption) (res *GetCheck, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/check/physical" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -87,7 +88,7 @@ func (r *CheckService) NewPhysical(ctx context.Context, body CheckNewPhysicalPar // Endorse a multi party payment func (r *CheckService) Endorse(ctx context.Context, checkID string, body CheckEndorseParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if checkID == "" { err = errors.New("missing required check_id parameter") @@ -100,7 +101,7 @@ func (r *CheckService) Endorse(ctx context.Context, checkID string, body CheckEn // Get the attachment for a payment func (r *CheckService) GetAttachment(ctx context.Context, checkID string, opts ...option.RequestOption) (res *Error, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if checkID == "" { err = errors.New("missing required check_id parameter") return @@ -112,7 +113,7 @@ func (r *CheckService) GetAttachment(ctx context.Context, checkID string, opts . // Get details on a failed payment func (r *CheckService) GetFailDetails(ctx context.Context, checkID string, opts ...option.RequestOption) (res *CheckGetFailDetailsResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if checkID == "" { err = errors.New("missing required check_id parameter") return @@ -124,7 +125,7 @@ func (r *CheckService) GetFailDetails(ctx context.Context, checkID string, opts // Get tracking details on a mailed check func (r *CheckService) GetTrackingDetails(ctx context.Context, checkID string, opts ...option.RequestOption) (res *CheckGetTrackingDetailsResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if checkID == "" { err = errors.New("missing required check_id parameter") return @@ -136,7 +137,7 @@ func (r *CheckService) GetTrackingDetails(ctx context.Context, checkID string, o // Get the verification code func (r *CheckService) GetVerificationCode(ctx context.Context, checkID string, opts ...option.RequestOption) (res *Error, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if checkID == "" { err = errors.New("missing required check_id parameter") return @@ -148,7 +149,7 @@ func (r *CheckService) GetVerificationCode(ctx context.Context, checkID string, // Resend payment notification func (r *CheckService) Notify(ctx context.Context, checkID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if checkID == "" { err = errors.New("missing required check_id parameter") @@ -161,7 +162,7 @@ func (r *CheckService) Notify(ctx context.Context, checkID string, opts ...optio // Preview a new payment func (r *CheckService) Preview(ctx context.Context, body CheckPreviewParams, opts ...option.RequestOption) (res *CheckPreviewResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/check/preview" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -169,7 +170,7 @@ func (r *CheckService) Preview(ctx context.Context, body CheckPreviewParams, opt // Print a check func (r *CheckService) Print(ctx context.Context, checkID string, opts ...option.RequestOption) (res *Error, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if checkID == "" { err = errors.New("missing required check_id parameter") return @@ -181,7 +182,7 @@ func (r *CheckService) Print(ctx context.Context, checkID string, opts ...option // Trigger a webhook notification on sandbox func (r *CheckService) TriggerWebhook(ctx context.Context, checkID string, body CheckTriggerWebhookParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if checkID == "" { err = errors.New("missing required check_id parameter") @@ -194,7 +195,7 @@ func (r *CheckService) TriggerWebhook(ctx context.Context, checkID string, body // Void the specified payment func (r *CheckService) Void(ctx context.Context, checkID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if checkID == "" { err = errors.New("missing required check_id parameter") diff --git a/checkdeposit.go b/checkdeposit.go index bfb5041..97a1a5b 100644 --- a/checkdeposit.go +++ b/checkdeposit.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -37,7 +38,7 @@ func NewCheckDepositService(opts ...option.RequestOption) (r CheckDepositService // Deposit a payment func (r *CheckDepositService) New(ctx context.Context, checkID string, body CheckDepositNewParams, opts ...option.RequestOption) (res *GetCheck, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if checkID == "" { err = errors.New("missing required check_id parameter") return @@ -49,7 +50,7 @@ func (r *CheckDepositService) New(ctx context.Context, checkID string, body Chec // Get details on a deposited payment func (r *CheckDepositService) Get(ctx context.Context, checkID string, opts ...option.RequestOption) (res *CheckDepositGetResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if checkID == "" { err = errors.New("missing required check_id parameter") return diff --git a/client.go b/client.go index f3e1e8e..153f090 100644 --- a/client.go +++ b/client.go @@ -6,6 +6,7 @@ import ( "context" "net/http" "os" + "slices" "github.com/Munchpass/checkbook/internal/requestconfig" "github.com/Munchpass/checkbook/option" @@ -92,7 +93,7 @@ func NewClient(opts ...option.RequestOption) (r Client) { // For even greater flexibility, see [option.WithResponseInto] and // [option.WithResponseBodyInto]. func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error { - opts = append(r.Options, opts...) + opts = slices.Concat(r.Options, opts) return requestconfig.ExecuteNewRequest(ctx, method, path, params, res, opts...) } diff --git a/directory.go b/directory.go index be59223..5a8ae2f 100644 --- a/directory.go +++ b/directory.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/apiquery" @@ -40,7 +41,7 @@ func NewDirectoryService(opts ...option.RequestOption) (r DirectoryService) { // Create a new directory item func (r *DirectoryService) New(ctx context.Context, body DirectoryNewParams, opts ...option.RequestOption) (res *CreateDirectoryResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/directory" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -48,7 +49,7 @@ func (r *DirectoryService) New(ctx context.Context, body DirectoryNewParams, opt // Return the directory entry func (r *DirectoryService) Get(ctx context.Context, query DirectoryGetParams, opts ...option.RequestOption) (res *DirectoryGetResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/directory" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return @@ -56,7 +57,7 @@ func (r *DirectoryService) Get(ctx context.Context, query DirectoryGetParams, op // Update a directory item func (r *DirectoryService) Update(ctx context.Context, directoryID string, body DirectoryUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if directoryID == "" { err = errors.New("missing required directory_id parameter") @@ -69,7 +70,7 @@ func (r *DirectoryService) Update(ctx context.Context, directoryID string, body // Remove the directory item func (r *DirectoryService) Delete(ctx context.Context, directoryID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if directoryID == "" { err = errors.New("missing required directory_id parameter") diff --git a/directoryaccount.go b/directoryaccount.go index f9e53ee..219184a 100644 --- a/directoryaccount.go +++ b/directoryaccount.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/requestconfig" @@ -36,7 +37,7 @@ func NewDirectoryAccountService(opts ...option.RequestOption) (r DirectoryAccoun // Remove a directory account func (r *DirectoryAccountService) Delete(ctx context.Context, accountID string, body DirectoryAccountDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if body.DirectoryID == "" { err = errors.New("missing required directory_id parameter") @@ -53,7 +54,7 @@ func (r *DirectoryAccountService) Delete(ctx context.Context, accountID string, // Create a new directory bank account func (r *DirectoryAccountService) NewBank(ctx context.Context, directoryID string, body DirectoryAccountNewBankParams, opts ...option.RequestOption) (res *DirectoryAccountNewBankResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if directoryID == "" { err = errors.New("missing required directory_id parameter") return @@ -65,7 +66,7 @@ func (r *DirectoryAccountService) NewBank(ctx context.Context, directoryID strin // Create a new directory card account func (r *DirectoryAccountService) NewCard(ctx context.Context, directoryID string, body DirectoryAccountNewCardParams, opts ...option.RequestOption) (res *DirectoryAccountNewCardResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if directoryID == "" { err = errors.New("missing required directory_id parameter") return diff --git a/invoice.go b/invoice.go index 5db38ea..0f8b040 100644 --- a/invoice.go +++ b/invoice.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -39,7 +40,7 @@ func NewInvoiceService(opts ...option.RequestOption) (r InvoiceService) { // Create a new invoice func (r *InvoiceService) New(ctx context.Context, body InvoiceNewParams, opts ...option.RequestOption) (res *InvoiceNewResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/invoice" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -47,7 +48,7 @@ func (r *InvoiceService) New(ctx context.Context, body InvoiceNewParams, opts .. // Get the specified invoice func (r *InvoiceService) Get(ctx context.Context, invoiceID string, opts ...option.RequestOption) (res *GetInvoice, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if invoiceID == "" { err = errors.New("missing required invoice_id parameter") return @@ -59,7 +60,7 @@ func (r *InvoiceService) Get(ctx context.Context, invoiceID string, opts ...opti // Get sent/received invoices func (r *InvoiceService) List(ctx context.Context, query InvoiceListParams, opts ...option.RequestOption) (res *InvoiceListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/invoice" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return @@ -67,7 +68,7 @@ func (r *InvoiceService) List(ctx context.Context, query InvoiceListParams, opts // Get the attachment for an invoice func (r *InvoiceService) GetAttachment(ctx context.Context, invoiceID string, opts ...option.RequestOption) (res *Error, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if invoiceID == "" { err = errors.New("missing required invoice_id parameter") return @@ -79,7 +80,7 @@ func (r *InvoiceService) GetAttachment(ctx context.Context, invoiceID string, op // Pay an outstanding invoice func (r *InvoiceService) Pay(ctx context.Context, body InvoicePayParams, opts ...option.RequestOption) (res *InvoicePayResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/invoice/payment" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -87,7 +88,7 @@ func (r *InvoiceService) Pay(ctx context.Context, body InvoicePayParams, opts .. // Cancel the specified invoice func (r *InvoiceService) Void(ctx context.Context, invoiceID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if invoiceID == "" { err = errors.New("missing required invoice_id parameter") diff --git a/mailbox.go b/mailbox.go index db725c1..10b0ecd 100644 --- a/mailbox.go +++ b/mailbox.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "github.com/Munchpass/checkbook/internal/apijson" "github.com/Munchpass/checkbook/internal/apiquery" @@ -40,7 +41,7 @@ func NewMailboxService(opts ...option.RequestOption) (r MailboxService) { // Create a new mailbox func (r *MailboxService) New(ctx context.Context, opts ...option.RequestOption) (res *CreateMailboxResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/mailbox" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...) return @@ -48,7 +49,7 @@ func (r *MailboxService) New(ctx context.Context, opts ...option.RequestOption) // Get mailbox details func (r *MailboxService) Get(ctx context.Context, mailboxID string, opts ...option.RequestOption) (res *CreateMailboxResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if mailboxID == "" { err = errors.New("missing required mailbox_id parameter") return @@ -60,7 +61,7 @@ func (r *MailboxService) Get(ctx context.Context, mailboxID string, opts ...opti // Return the mailboxes for the current user func (r *MailboxService) List(ctx context.Context, query MailboxListParams, opts ...option.RequestOption) (res *MailboxListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/mailbox" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return diff --git a/mailboxmail.go b/mailboxmail.go index 0f899bb..7ab52a9 100644 --- a/mailboxmail.go +++ b/mailboxmail.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -39,7 +40,7 @@ func NewMailboxMailService(opts ...option.RequestOption) (r MailboxMailService) // Get mailbox item func (r *MailboxMailService) Get(ctx context.Context, itemID string, query MailboxMailGetParams, opts ...option.RequestOption) (res *MailResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if query.MailboxID == "" { err = errors.New("missing required mailbox_id parameter") return @@ -55,7 +56,7 @@ func (r *MailboxMailService) Get(ctx context.Context, itemID string, query Mailb // Get mailbox items func (r *MailboxMailService) List(ctx context.Context, mailboxID string, query MailboxMailListParams, opts ...option.RequestOption) (res *MailboxMailListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if mailboxID == "" { err = errors.New("missing required mailbox_id parameter") return @@ -67,7 +68,7 @@ func (r *MailboxMailService) List(ctx context.Context, mailboxID string, query M // Get mailbox item func (r *MailboxMailService) GetAttachment(ctx context.Context, itemID string, query MailboxMailGetAttachmentParams, opts ...option.RequestOption) (res *Error, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if query.MailboxID == "" { err = errors.New("missing required mailbox_id parameter") return diff --git a/subscription.go b/subscription.go index 8c4bd29..d542302 100644 --- a/subscription.go +++ b/subscription.go @@ -9,6 +9,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -40,7 +41,7 @@ func NewSubscriptionService(opts ...option.RequestOption) (r SubscriptionService // Get the specified subscription func (r *SubscriptionService) Get(ctx context.Context, subscriptionID string, opts ...option.RequestOption) (res *GetSubscriptionResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if subscriptionID == "" { err = errors.New("missing required subscription_id parameter") return @@ -52,7 +53,7 @@ func (r *SubscriptionService) Get(ctx context.Context, subscriptionID string, op // Update the specified subscription func (r *SubscriptionService) Update(ctx context.Context, subscriptionID string, body SubscriptionUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if subscriptionID == "" { err = errors.New("missing required subscription_id parameter") @@ -65,7 +66,7 @@ func (r *SubscriptionService) Update(ctx context.Context, subscriptionID string, // Return the subscriptions func (r *SubscriptionService) List(ctx context.Context, query SubscriptionListParams, opts ...option.RequestOption) (res *SubscriptionListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/subscription" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return @@ -73,7 +74,7 @@ func (r *SubscriptionService) List(ctx context.Context, query SubscriptionListPa // Remove the specified subscription func (r *SubscriptionService) Delete(ctx context.Context, subscriptionID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if subscriptionID == "" { err = errors.New("missing required subscription_id parameter") @@ -86,7 +87,7 @@ func (r *SubscriptionService) Delete(ctx context.Context, subscriptionID string, // Create a new invoice subscription func (r *SubscriptionService) NewInvoice(ctx context.Context, body SubscriptionNewInvoiceParams, opts ...option.RequestOption) (res *CreateSubscriptionResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/subscription/invoice" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -94,7 +95,7 @@ func (r *SubscriptionService) NewInvoice(ctx context.Context, body SubscriptionN // Create a new payment subscription func (r *SubscriptionService) NewPayment(ctx context.Context, body SubscriptionNewPaymentParams, opts ...option.RequestOption) (res *CreateSubscriptionResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/subscription/check" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return diff --git a/user.go b/user.go index 65b9e46..c383df4 100644 --- a/user.go +++ b/user.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -41,7 +42,7 @@ func NewUserService(opts ...option.RequestOption) (r UserService) { // Create a new marketplace user func (r *UserService) New(ctx context.Context, body UserNewParams, opts ...option.RequestOption) (res *UserNewResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/user" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -49,7 +50,7 @@ func (r *UserService) New(ctx context.Context, body UserNewParams, opts ...optio // Get user information func (r *UserService) Get(ctx context.Context, opts ...option.RequestOption) (res *UserGetResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/user" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -57,7 +58,7 @@ func (r *UserService) Get(ctx context.Context, opts ...option.RequestOption) (re // Update existing user information func (r *UserService) Update(ctx context.Context, body UserUpdateParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) path := "v3/user" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, nil, opts...) @@ -66,7 +67,7 @@ func (r *UserService) Update(ctx context.Context, body UserUpdateParams, opts .. // Return the marketplace users func (r *UserService) List(ctx context.Context, query UserListParams, opts ...option.RequestOption) (res *UserListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/user/list" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return @@ -74,7 +75,7 @@ func (r *UserService) List(ctx context.Context, query UserListParams, opts ...op // Delete the marketplace user func (r *UserService) Delete(ctx context.Context, userID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if userID == "" { err = errors.New("missing required user_id parameter") @@ -87,7 +88,7 @@ func (r *UserService) Delete(ctx context.Context, userID string, opts ...option. // Add signature func (r *UserService) AddSignature(ctx context.Context, body UserAddSignatureParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) path := "v3/user/signature" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) diff --git a/userapikey.go b/userapikey.go index fed30d7..77976aa 100644 --- a/userapikey.go +++ b/userapikey.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "slices" "time" "github.com/Munchpass/checkbook/internal/apijson" @@ -37,7 +38,7 @@ func NewUserAPIKeyService(opts ...option.RequestOption) (r UserAPIKeyService) { // Generate new API keys for the user func (r *UserAPIKeyService) New(ctx context.Context, body UserAPIKeyNewParams, opts ...option.RequestOption) (res *NewAPIKey, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/user/api_key" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -45,7 +46,7 @@ func (r *UserAPIKeyService) New(ctx context.Context, body UserAPIKeyNewParams, o // Return the API keys for the user func (r *UserAPIKeyService) Get(ctx context.Context, opts ...option.RequestOption) (res *UserAPIKeyGetResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v3/user/api_key" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return @@ -53,7 +54,7 @@ func (r *UserAPIKeyService) Get(ctx context.Context, opts ...option.RequestOptio // Delete API key for user func (r *UserAPIKeyService) Delete(ctx context.Context, keyID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if keyID == "" { err = errors.New("missing required key_id parameter") From e90cb1978646d52cdccbc8c42fa8c9e7c7160b14 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 02:56:16 +0000 Subject: [PATCH 5/8] chore: do not install brew dependencies in ./scripts/bootstrap by default --- scripts/bootstrap | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/bootstrap b/scripts/bootstrap index d6ac165..5ab3066 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi From 0a6b6da4e7ebfbdf7ec4795cadfe1c9f0b5c04ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 26 Sep 2025 02:27:03 +0000 Subject: [PATCH 6/8] fix: bugfix for setting JSON keys with special characters --- internal/apijson/encoder.go | 14 +++++++------- internal/apijson/union.go | 4 ++-- packages/param/encoder.go | 7 ++++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/internal/apijson/encoder.go b/internal/apijson/encoder.go index 8358a2f..ab7a3c1 100644 --- a/internal/apijson/encoder.go +++ b/internal/apijson/encoder.go @@ -16,6 +16,10 @@ import ( var encoders sync.Map // map[encoderEntry]encoderFunc +// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have +// special characters that sjson interprets as a path. +var EscapeSJSONKey = strings.NewReplacer("\\", "\\\\", "|", "\\|", "#", "\\#", "@", "\\@", "*", "\\*", ".", "\\.", ":", "\\:", "?", "\\?").Replace + func Marshal(value any) ([]byte, error) { e := &encoder{dateFormat: time.RFC3339} return e.marshal(value) @@ -270,7 +274,7 @@ func (e *encoder) newStructTypeEncoder(t reflect.Type) encoderFunc { if encoded == nil { continue } - json, err = sjson.SetRawBytes(json, ef.tag.name, encoded) + json, err = sjson.SetRawBytes(json, EscapeSJSONKey(ef.tag.name), encoded) if err != nil { return nil, err } @@ -348,7 +352,7 @@ func (e *encoder) encodeMapEntries(json []byte, v reflect.Value) ([]byte, error) } encodedKeyString = string(encodedKeyBytes) } - encodedKey := []byte(sjsonReplacer.Replace(encodedKeyString)) + encodedKey := []byte(encodedKeyString) pairs = append(pairs, mapPair{key: encodedKey, value: iter.Value()}) } @@ -366,7 +370,7 @@ func (e *encoder) encodeMapEntries(json []byte, v reflect.Value) ([]byte, error) if len(encodedValue) == 0 { continue } - json, err = sjson.SetRawBytes(json, string(p.key), encodedValue) + json, err = sjson.SetRawBytes(json, EscapeSJSONKey(string(p.key)), encodedValue) if err != nil { return nil, err } @@ -386,7 +390,3 @@ func (e *encoder) newMapEncoder(_ reflect.Type) encoderFunc { return json, nil } } - -// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have -// special characters that sjson interprets as a path. -var sjsonReplacer *strings.Replacer = strings.NewReplacer(".", "\\.", ":", "\\:", "*", "\\*") diff --git a/internal/apijson/union.go b/internal/apijson/union.go index d63956c..7c8acbe 100644 --- a/internal/apijson/union.go +++ b/internal/apijson/union.go @@ -78,7 +78,7 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { return func(n gjson.Result, v reflect.Value, state *decoderState) error { if discriminated && n.Type == gjson.JSON && len(unionEntry.discriminatorKey) != 0 { - discriminator := n.Get(unionEntry.discriminatorKey).Value() + discriminator := n.Get(EscapeSJSONKey(unionEntry.discriminatorKey)).Value() for _, decoder := range discriminatedDecoders { if discriminator == decoder.discriminator { inner := v.FieldByIndex(decoder.field.Index) @@ -162,7 +162,7 @@ func (d *decoderBuilder) newUnionDecoder(t reflect.Type) decoderFunc { } if len(unionEntry.discriminatorKey) != 0 { - discriminatorValue := n.Get(unionEntry.discriminatorKey).Value() + discriminatorValue := n.Get(EscapeSJSONKey(unionEntry.discriminatorKey)).Value() if discriminatorValue == variant.DiscriminatorValue { inner := reflect.New(variant.Type).Elem() err := decoder(n, inner, state) diff --git a/packages/param/encoder.go b/packages/param/encoder.go index c163110..fd8356a 100644 --- a/packages/param/encoder.go +++ b/packages/param/encoder.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "reflect" + "strings" "time" shimjson "github.com/Munchpass/checkbook/internal/encoding/json" @@ -14,6 +15,10 @@ import ( // EncodedAsDate is not be stable and shouldn't be relied upon type EncodedAsDate Opt[time.Time] +// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have +// special characters that sjson interprets as a path. +var EscapeSJSONKey = strings.NewReplacer("\\", "\\\\", "|", "\\|", "#", "\\#", "@", "\\@", "*", "\\*", ".", "\\.", ":", "\\:", "?", "\\?").Replace + type forceOmit int func (m EncodedAsDate) MarshalJSON() ([]byte, error) { @@ -52,7 +57,7 @@ func MarshalWithExtras[T ParamStruct, R any](f T, underlying any, extras map[str } continue } - bytes, err = sjson.SetBytes(bytes, k, v) + bytes, err = sjson.SetBytes(bytes, EscapeSJSONKey(k), v) if err != nil { return nil, err } From 5bdac522c3e3a76a34808a5e94de1c09c6d3ccd1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Nov 2025 03:49:03 +0000 Subject: [PATCH 7/8] chore(internal): grammar fix (it's -> its) --- README.md | 2 +- packages/respjson/respjson.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 74007d6..189e652 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ custom := param.Override[checkbook.FooParams](12) ### Request unions -Unions are represented as a struct with fields prefixed by "Of" for each of it's variants, +Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized. Sub-properties of the union can be accessed via methods on the union struct. diff --git a/packages/respjson/respjson.go b/packages/respjson/respjson.go index cc0088c..9e61c5c 100644 --- a/packages/respjson/respjson.go +++ b/packages/respjson/respjson.go @@ -5,7 +5,7 @@ package respjson // Use [Field.Valid] to check if an optional value was null or omitted. // // A Field will always occur in the following structure, where it -// mirrors the original field in it's parent struct: +// mirrors the original field in its parent struct: // // type ExampleObject struct { // Foo bool `json:"foo"` From 3f15644638dfd6845a05f665790d69c8fec6c6c1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Nov 2025 03:49:17 +0000 Subject: [PATCH 8/8] release: 0.2.1 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 18 ++++++++++++++++++ README.md | 2 +- internal/version.go | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 10f3091..b06ba91 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0" + ".": "0.2.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bb449f..816ee27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 0.2.1 (2025-11-04) + +Full Changelog: [v0.2.0...v0.2.1](https://github.com/Munchpass/checkbook/compare/v0.2.0...v0.2.1) + +### Bug Fixes + +* bugfix for setting JSON keys with special characters ([0a6b6da](https://github.com/Munchpass/checkbook/commit/0a6b6da4e7ebfbdf7ec4795cadfe1c9f0b5c04ae)) +* use slices.Concat instead of sometimes modifying r.Options ([c73bccf](https://github.com/Munchpass/checkbook/commit/c73bccf25d2357526c49fbdccad07ee5da9c70b7)) + + +### Chores + +* bump minimum go version to 1.22 ([d744de6](https://github.com/Munchpass/checkbook/commit/d744de6d7d132a63d75851df6d332b15798c4882)) +* do not install brew dependencies in ./scripts/bootstrap by default ([e90cb19](https://github.com/Munchpass/checkbook/commit/e90cb1978646d52cdccbc8c42fa8c9e7c7160b14)) +* **internal:** codegen related update ([a782efa](https://github.com/Munchpass/checkbook/commit/a782efa4f933c90c846dbc289edf18db97327b31)) +* **internal:** grammar fix (it's -> its) ([5bdac52](https://github.com/Munchpass/checkbook/commit/5bdac522c3e3a76a34808a5e94de1c09c6d3ccd1)) +* update more docs for 1.22 ([b37ee7a](https://github.com/Munchpass/checkbook/commit/b37ee7a270ba115331498b2287ee056585e48ed3)) + ## 0.2.0 (2025-09-05) Full Changelog: [v0.1.0...v0.2.0](https://github.com/Munchpass/checkbook/compare/v0.1.0...v0.2.0) diff --git a/README.md b/README.md index 189e652..9cd5fab 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Or to pin the version: ```sh -go get -u 'github.com/Munchpass/checkbook@v0.2.0' +go get -u 'github.com/Munchpass/checkbook@v0.2.1' ``` diff --git a/internal/version.go b/internal/version.go index 774c6c4..a230145 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.2.0" // x-release-please-version +const PackageVersion = "0.2.1" // x-release-please-version