From a3a037846118acb3ab161d12b717afaabcab0e4e Mon Sep 17 00:00:00 2001 From: Nazar Vovk Date: Fri, 31 Jan 2025 15:08:20 +0200 Subject: [PATCH 1/2] Updated golang-jwt/jwt to v5 --- README.md | 2 +- appstore/api/model.go | 77 +++++++++++++++++++++++++++++++++---- appstore/api/store.go | 2 +- appstore/api/token.go | 13 +------ appstore/mocks/appstore.go | 2 +- appstore/notification_v2.go | 2 +- appstore/validator.go | 2 +- appstore/validator_test.go | 8 ++-- go.mod | 2 +- go.sum | 4 +- 10 files changed, 83 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 4afdbb8..3d9c08d 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ func main() { ```go import ( "github.com/awa/go-iap/appstore" - "github.com/golang-jwt/jwt/v4" + "github.com/golang-jwt/jwt/v5" ) func main() { diff --git a/appstore/api/model.go b/appstore/api/model.go index c0ca8d5..db907be 100644 --- a/appstore/api/model.go +++ b/appstore/api/model.go @@ -1,6 +1,9 @@ package api -import "github.com/awa/go-iap/appstore" +import ( + "github.com/awa/go-iap/appstore" + "github.com/golang-jwt/jwt/v5" +) // OrderLookupResponse https://developer.apple.com/documentation/appstoreserverapi/orderlookupresponse type OrderLookupResponse struct { @@ -83,6 +86,9 @@ type ConsumptionRequestBody struct { RefundPreference int32 `json:"refundPreference"` } +// Verify that JWSRenewalInfoDecodedPayload implements jwt.Claims +var _ jwt.Claims = JWSRenewalInfoDecodedPayload{} + // JWSRenewalInfoDecodedPayload https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfodecodedpayload type JWSRenewalInfoDecodedPayload struct { AutoRenewProductId string `json:"autoRenewProductId"` @@ -105,8 +111,34 @@ type JWSRenewalInfoDecodedPayload struct { EligibleWinBackOfferIds []string `json:"eligibleWinBackOfferIds,omitempty"` } -func (J JWSRenewalInfoDecodedPayload) Valid() error { - return nil +// GetAudience implements jwt.Claims. +func (J JWSRenewalInfoDecodedPayload) GetAudience() (jwt.ClaimStrings, error) { + return nil, nil +} + +// GetExpirationTime implements jwt.Claims. +func (J JWSRenewalInfoDecodedPayload) GetExpirationTime() (*jwt.NumericDate, error) { + return nil, nil +} + +// GetIssuedAt implements jwt.Claims. +func (J JWSRenewalInfoDecodedPayload) GetIssuedAt() (*jwt.NumericDate, error) { + return nil, nil +} + +// GetIssuer implements jwt.Claims. +func (J JWSRenewalInfoDecodedPayload) GetIssuer() (string, error) { + return "", nil +} + +// GetNotBefore implements jwt.Claims. +func (J JWSRenewalInfoDecodedPayload) GetNotBefore() (*jwt.NumericDate, error) { + return nil, nil +} + +// GetSubject implements jwt.Claims. +func (J JWSRenewalInfoDecodedPayload) GetSubject() (string, error) { + return "", nil } // JWSDecodedHeader https://developer.apple.com/documentation/appstoreserverapi/jwsdecodedheader @@ -143,6 +175,9 @@ const ( OfferDiscountTypePayUpFront OfferDiscountType = "PAY_UP_FRONT" ) +// Verify that JWSTransaction implements jwt.Claims +var _ jwt.Claims = JWSTransaction{} + // JWSTransaction https://developer.apple.com/documentation/appstoreserverapi/jwstransaction type JWSTransaction struct { TransactionID string `json:"transactionId,omitempty"` @@ -173,8 +208,34 @@ type JWSTransaction struct { OfferDiscountType OfferDiscountType `json:"offerDiscountType,omitempty"` } -func (J JWSTransaction) Valid() error { - return nil +// GetAudience implements jwt.Claims. +func (J JWSTransaction) GetAudience() (jwt.ClaimStrings, error) { + return nil, nil +} + +// GetExpirationTime implements jwt.Claims. +func (J JWSTransaction) GetExpirationTime() (*jwt.NumericDate, error) { + return nil, nil +} + +// GetIssuedAt implements jwt.Claims. +func (J JWSTransaction) GetIssuedAt() (*jwt.NumericDate, error) { + return nil, nil +} + +// GetIssuer implements jwt.Claims. +func (J JWSTransaction) GetIssuer() (string, error) { + return "", nil +} + +// GetNotBefore implements jwt.Claims. +func (J JWSTransaction) GetNotBefore() (*jwt.NumericDate, error) { + return nil, nil +} + +// GetSubject implements jwt.Claims. +func (J JWSTransaction) GetSubject() (string, error) { + return "", nil } // https://developer.apple.com/documentation/appstoreserverapi/extendreasoncode @@ -258,8 +319,10 @@ type SendTestNotificationResponse struct { TestNotificationToken string `json:"testNotificationToken"` } -type AutoRenewSubscriptionStatus int32 -type AutoRenewStatus int32 +type ( + AutoRenewSubscriptionStatus int32 + AutoRenewStatus int32 +) const ( SubscriptionActive AutoRenewSubscriptionStatus = 1 diff --git a/appstore/api/store.go b/appstore/api/store.go index 5d1bfd3..655d32c 100644 --- a/appstore/api/store.go +++ b/appstore/api/store.go @@ -16,7 +16,7 @@ import ( "strings" "time" - "github.com/golang-jwt/jwt/v4" + "github.com/golang-jwt/jwt/v5" ) const ( diff --git a/appstore/api/token.go b/appstore/api/token.go index b1c1ee5..8eab1e5 100644 --- a/appstore/api/token.go +++ b/appstore/api/token.go @@ -5,11 +5,10 @@ import ( "crypto/x509" "encoding/pem" "errors" - "os" "sync" "time" - "github.com/golang-jwt/jwt/v4" + "github.com/golang-jwt/jwt/v5" "github.com/google/uuid" ) @@ -113,16 +112,6 @@ func (t *Token) Generate() error { return nil } -// loadKeyFromFile loads a .p8 certificate from a local file and returns a *ecdsa.PrivateKey. -func (t *Token) loadKeyFromFile(filename string) (*ecdsa.PrivateKey, error) { - bytes, err := os.ReadFile(filename) - if err != nil { - return nil, err - } - - return t.passKeyFromByte(bytes) -} - // passKeyFromByte loads a .p8 certificate from an in memory byte array and returns an *ecdsa.PrivateKey. func (t *Token) passKeyFromByte(bytes []byte) (*ecdsa.PrivateKey, error) { block, _ := pem.Decode(bytes) diff --git a/appstore/mocks/appstore.go b/appstore/mocks/appstore.go index c75ed57..a540fb3 100644 --- a/appstore/mocks/appstore.go +++ b/appstore/mocks/appstore.go @@ -13,7 +13,7 @@ import ( reflect "reflect" appstore "github.com/awa/go-iap/appstore" - jwt "github.com/golang-jwt/jwt/v4" + jwt "github.com/golang-jwt/jwt/v5" gomock "go.uber.org/mock/gomock" ) diff --git a/appstore/notification_v2.go b/appstore/notification_v2.go index edaea0a..c986197 100644 --- a/appstore/notification_v2.go +++ b/appstore/notification_v2.go @@ -1,6 +1,6 @@ package appstore -import "github.com/golang-jwt/jwt/v4" +import "github.com/golang-jwt/jwt/v5" // NotificationTypeV2 is type type NotificationTypeV2 string diff --git a/appstore/validator.go b/appstore/validator.go index fc34afd..bd8a398 100644 --- a/appstore/validator.go +++ b/appstore/validator.go @@ -12,7 +12,7 @@ import ( "net/http" "time" - "github.com/golang-jwt/jwt/v4" + "github.com/golang-jwt/jwt/v5" ) const ( diff --git a/appstore/validator_test.go b/appstore/validator_test.go index 4109282..1deac96 100644 --- a/appstore/validator_test.go +++ b/appstore/validator_test.go @@ -3,7 +3,6 @@ package appstore import ( "context" "errors" - "github.com/golang-jwt/jwt/v4" "io" "net/http" "net/http/httptest" @@ -11,6 +10,8 @@ import ( "strings" "testing" "time" + + "github.com/golang-jwt/jwt/v5" ) func TestHandleError(t *testing.T) { @@ -325,7 +326,7 @@ func TestParseNotificationV2(t *testing.T) { tokenStr := `eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlFTURDQ0E3YWdBd0lCQWdJUWFQb1BsZHZwU29FSDBsQnJqRFB2OWpBS0JnZ3Foa2pPUFFRREF6QjFNVVF3UWdZRFZRUURERHRCY0hCc1pTQlhiM0pzWkhkcFpHVWdSR1YyWld4dmNHVnlJRkpsYkdGMGFXOXVjeUJEWlhKMGFXWnBZMkYwYVc5dUlFRjFkR2h2Y21sMGVURUxNQWtHQTFVRUN3d0NSell4RXpBUkJnTlZCQW9NQ2tGd2NHeGxJRWx1WXk0eEN6QUpCZ05WQkFZVEFsVlRNQjRYRFRJeE1EZ3lOVEF5TlRBek5Gb1hEVEl6TURreU5EQXlOVEF6TTFvd2daSXhRREErQmdOVkJBTU1OMUJ5YjJRZ1JVTkRJRTFoWXlCQmNIQWdVM1J2Y21VZ1lXNWtJR2xVZFc1bGN5QlRkRzl5WlNCU1pXTmxhWEIwSUZOcFoyNXBibWN4TERBcUJnTlZCQXNNSTBGd2NHeGxJRmR2Y214a2QybGtaU0J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tDedYcsC4mA1shpxdb33E5Pzz__uVLr-l8Ogs7JI5j34ML0Ig9YkM2cMnwScN7dmGg` token := jwt.Token{} if err := client.ParseNotificationV2(tokenStr, &token); err != nil { - //t.Errorf("expected an error to be nil since the tokenStr is legal") + // t.Errorf("expected an error to be nil since the tokenStr is legal") } claims, ok := token.Claims.(jwt.MapClaims) if !ok { @@ -342,11 +343,10 @@ func TestClient_ParseNotificationV2WithClaim(t *testing.T) { tokenStr := `eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlFTURDQ0E3YWdBd0lCQWdJUWFQb1BsZHZwU29FSDBsQnJqRFB2OWpBS0JnZ3Foa2pPUFFRREF6QjFNVVF3UWdZRFZRUURERHRCY0hCc1pTQlhiM0pzWkhkcFpHVWdSR1YyWld4dmNHVnlJRkpsYkdGMGFXOXVjeUJEWlhKMGFXWnBZMkYwYVc5dUlFRjFkR2h2Y21sMGVURUxNQWtHQTFVRUN3d0NSell4RXpBUkJnTlZCQW9NQ2tGd2NHeGxJRWx1WXk0eEN6QUpCZ05WQkFZVEFsVlRNQjRYRFRJeE1EZ3lOVEF5TlRBek5Gb1hEVEl6TURreU5EQXlOVEF6TTFvd2daSXhRREErQmdOVkJBTU1OMUJ5YjJRZ1JVTkRJRTFoWXlCQmNIQWdVM1J2Y21VZ1lXNWtJR2xVZFc1bGN5QlRkRzl5WlNCU1pXTmxhWEIwSUZOcFoyNXBibWN4TERBcUJnTlZCQXNNSTBGd2NHeGxJRmR2Y214a2QybGtaU0JFWlhabGJHOXdaWElnVW1Wc1lYUnBiMjV6TVJNd0VRWURWUVFLREFwQmNIQnNaU0JKYm1NdU1Rc3dDUVlEVlFRR0V3SlZVekJaTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEEwSUFCT29UY2FQY3BlaXBOTDllUTA2dEN1N3BVY3dkQ1hkTjh2R3FhVWpkNThaOHRMeGlVQzBkQmVBK2V1TVlnZ2gxLzVpQWsrRk14VUZtQTJhMXI0YUNa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qVHV4eEV0WC8xSDdZeVlsM0o2WVJiVHpCUEVWb0EvVmhZREtYMUR5eE5CMGNUZGRxWGw1ZHZNVnp0SzUxN0lEdll1VlRaWHBta09sRUtNYU5DTUVBd0hRWURWUjBPQkJZRUZMdXczcUZZTTRpYXBJcVozcjY5NjYvYXl5U3JNQThHQTFVZEV3RUIvd1FGTUFNQkFmOHdEZ1lEVlIwUEFRSC9CQVFEQWdFR01Bb0dDQ3FHU000OUJBTURBMmdBTUdVQ01RQ0Q2Y0hFRmw0YVhUUVkyZTN2OUd3T0FFWkx1Tit5UmhIRkQvM21lb3locG12T3dnUFVuUFdUeG5TNGF0K3FJeFVDTUcxbWloREsxQTNVVDgyTlF6NjBpbU9sTTI3amJkb1h0MlFmeUZNbStZaGlkRGtMRjF2TFVhZ002QmdENTZLeUtBPT0iXX0.eyJvcmlnaW5hbFRyYW5zYWN0aW9uSWQiOiIyMDAwMDAwMzM1MzEwNjQ0IiwiYXV0b1JlbmV3UHJvZHVjdElkIjoiY28ucmluZ2FsYXJtLnN3dGljaC5xdWFydGVybHkyIiwicHJvZHVjdElkIjoiY28ucmluZ2FsYXJtLnN3dGljaC5xdWFydGVybHkyIiwiYXV0b1JlbmV3U3RhdHVzIjoxLCJzaWduZWREYXRlIjoxNjg0ODIyNzc4NDkyLCJlbnZpcm9ubWVudCI6IlNhbmRib3giLCJyZWNlbnRTdWJzY3JpcHRpb25TdGFydERhdGUiOjE2ODQ4MjI3MzgwMDB9.khbuzTxSizdky-EIu75DtDedYcsC4mA1shpxdb33E5Pzz__uVLr-l8Ogs7JI5j34ML0Ig9YkM2cMnwScN7dmGg` if err := client.ParseNotificationV2WithClaim(tokenStr, result); err != nil { - //t.Errorf("expected an error to be nil since the tokenStr is legal") + // t.Errorf("expected an error to be nil since the tokenStr is legal") } if result.OriginalTransactionId != "2000000335310644" { t.Errorf("The expected originalTransactionId should be 2000000335310644") } - } diff --git a/go.mod b/go.mod index 4102b86..2c9c844 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/awa/go-iap go 1.22.0 require ( - github.com/golang-jwt/jwt/v4 v4.5.1 + github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/uuid v1.6.0 github.com/stretchr/testify v1.10.0 go.uber.org/mock v0.5.0 diff --git a/go.sum b/go.sum index 8488d62..3034415 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= -github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= From aff14ad315fea72fbd27f56f7c48d7800747237d Mon Sep 17 00:00:00 2001 From: Nazar Vovk Date: Fri, 31 Jan 2025 15:18:48 +0200 Subject: [PATCH 2/2] Fix mocks --- appstore/mocks/appstore.go | 34 +++++---- appstore/mocks/store.go | 138 ++++++++++++++++++----------------- playstore/mocks/playstore.go | 5 ++ 3 files changed, 93 insertions(+), 84 deletions(-) diff --git a/appstore/mocks/appstore.go b/appstore/mocks/appstore.go index a540fb3..ebfc96a 100644 --- a/appstore/mocks/appstore.go +++ b/appstore/mocks/appstore.go @@ -5,6 +5,7 @@ // // mockgen -destination=mocks/appstore.go -package=mocks github.com/awa/go-iap/appstore IAPClient // + // Package mocks is a generated GoMock package. package mocks @@ -21,6 +22,7 @@ import ( type MockIAPClient struct { ctrl *gomock.Controller recorder *MockIAPClientMockRecorder + isgomock struct{} } // MockIAPClientMockRecorder is the mock recorder for MockIAPClient. @@ -41,58 +43,58 @@ func (m *MockIAPClient) EXPECT() *MockIAPClientMockRecorder { } // ParseNotificationV2 mocks base method. -func (m *MockIAPClient) ParseNotificationV2(arg0 string, arg1 *jwt.Token) error { +func (m *MockIAPClient) ParseNotificationV2(tokenStr string, result *jwt.Token) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParseNotificationV2", arg0, arg1) + ret := m.ctrl.Call(m, "ParseNotificationV2", tokenStr, result) ret0, _ := ret[0].(error) return ret0 } // ParseNotificationV2 indicates an expected call of ParseNotificationV2. -func (mr *MockIAPClientMockRecorder) ParseNotificationV2(arg0, arg1 any) *gomock.Call { +func (mr *MockIAPClientMockRecorder) ParseNotificationV2(tokenStr, result any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseNotificationV2", reflect.TypeOf((*MockIAPClient)(nil).ParseNotificationV2), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseNotificationV2", reflect.TypeOf((*MockIAPClient)(nil).ParseNotificationV2), tokenStr, result) } // ParseNotificationV2WithClaim mocks base method. -func (m *MockIAPClient) ParseNotificationV2WithClaim(arg0 string, arg1 jwt.Claims) error { +func (m *MockIAPClient) ParseNotificationV2WithClaim(tokenStr string, result jwt.Claims) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParseNotificationV2WithClaim", arg0, arg1) + ret := m.ctrl.Call(m, "ParseNotificationV2WithClaim", tokenStr, result) ret0, _ := ret[0].(error) return ret0 } // ParseNotificationV2WithClaim indicates an expected call of ParseNotificationV2WithClaim. -func (mr *MockIAPClientMockRecorder) ParseNotificationV2WithClaim(arg0, arg1 any) *gomock.Call { +func (mr *MockIAPClientMockRecorder) ParseNotificationV2WithClaim(tokenStr, result any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseNotificationV2WithClaim", reflect.TypeOf((*MockIAPClient)(nil).ParseNotificationV2WithClaim), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseNotificationV2WithClaim", reflect.TypeOf((*MockIAPClient)(nil).ParseNotificationV2WithClaim), tokenStr, result) } // Verify mocks base method. -func (m *MockIAPClient) Verify(arg0 context.Context, arg1 appstore.IAPRequest, arg2 any) error { +func (m *MockIAPClient) Verify(ctx context.Context, reqBody appstore.IAPRequest, resp any) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Verify", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "Verify", ctx, reqBody, resp) ret0, _ := ret[0].(error) return ret0 } // Verify indicates an expected call of Verify. -func (mr *MockIAPClientMockRecorder) Verify(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockIAPClientMockRecorder) Verify(ctx, reqBody, resp any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verify", reflect.TypeOf((*MockIAPClient)(nil).Verify), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verify", reflect.TypeOf((*MockIAPClient)(nil).Verify), ctx, reqBody, resp) } // VerifyWithStatus mocks base method. -func (m *MockIAPClient) VerifyWithStatus(arg0 context.Context, arg1 appstore.IAPRequest, arg2 any) (int, error) { +func (m *MockIAPClient) VerifyWithStatus(ctx context.Context, reqBody appstore.IAPRequest, resp any) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyWithStatus", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "VerifyWithStatus", ctx, reqBody, resp) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // VerifyWithStatus indicates an expected call of VerifyWithStatus. -func (mr *MockIAPClientMockRecorder) VerifyWithStatus(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockIAPClientMockRecorder) VerifyWithStatus(ctx, reqBody, resp any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyWithStatus", reflect.TypeOf((*MockIAPClient)(nil).VerifyWithStatus), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyWithStatus", reflect.TypeOf((*MockIAPClient)(nil).VerifyWithStatus), ctx, reqBody, resp) } diff --git a/appstore/mocks/store.go b/appstore/mocks/store.go index 3406e71..727160d 100644 --- a/appstore/mocks/store.go +++ b/appstore/mocks/store.go @@ -5,6 +5,7 @@ // // mockgen -destination=../mocks/store.go -package=mocks github.com/awa/go-iap/appstore/api StoreAPIClient // + // Package mocks is a generated GoMock package. package mocks @@ -23,6 +24,7 @@ import ( type MockStoreAPIClient struct { ctrl *gomock.Controller recorder *MockStoreAPIClientMockRecorder + isgomock struct{} } // MockStoreAPIClientMockRecorder is the mock recorder for MockStoreAPIClient. @@ -43,9 +45,9 @@ func (m *MockStoreAPIClient) EXPECT() *MockStoreAPIClientMockRecorder { } // Do mocks base method. -func (m *MockStoreAPIClient) Do(arg0 context.Context, arg1, arg2 string, arg3 io.Reader) (int, []byte, error) { +func (m *MockStoreAPIClient) Do(ctx context.Context, method, url string, body io.Reader) (int, []byte, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Do", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "Do", ctx, method, url, body) ret0, _ := ret[0].(int) ret1, _ := ret[1].([]byte) ret2, _ := ret[2].(error) @@ -53,105 +55,105 @@ func (m *MockStoreAPIClient) Do(arg0 context.Context, arg1, arg2 string, arg3 io } // Do indicates an expected call of Do. -func (mr *MockStoreAPIClientMockRecorder) Do(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) Do(ctx, method, url, body any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockStoreAPIClient)(nil).Do), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockStoreAPIClient)(nil).Do), ctx, method, url, body) } // ExtendSubscriptionRenewalDate mocks base method. -func (m *MockStoreAPIClient) ExtendSubscriptionRenewalDate(arg0 context.Context, arg1 string, arg2 api.ExtendRenewalDateRequest) (int, error) { +func (m *MockStoreAPIClient) ExtendSubscriptionRenewalDate(ctx context.Context, originalTransactionId string, body api.ExtendRenewalDateRequest) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExtendSubscriptionRenewalDate", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "ExtendSubscriptionRenewalDate", ctx, originalTransactionId, body) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // ExtendSubscriptionRenewalDate indicates an expected call of ExtendSubscriptionRenewalDate. -func (mr *MockStoreAPIClientMockRecorder) ExtendSubscriptionRenewalDate(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) ExtendSubscriptionRenewalDate(ctx, originalTransactionId, body any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExtendSubscriptionRenewalDate", reflect.TypeOf((*MockStoreAPIClient)(nil).ExtendSubscriptionRenewalDate), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExtendSubscriptionRenewalDate", reflect.TypeOf((*MockStoreAPIClient)(nil).ExtendSubscriptionRenewalDate), ctx, originalTransactionId, body) } // ExtendSubscriptionRenewalDateForAll mocks base method. -func (m *MockStoreAPIClient) ExtendSubscriptionRenewalDateForAll(arg0 context.Context, arg1 api.MassExtendRenewalDateRequest) (int, error) { +func (m *MockStoreAPIClient) ExtendSubscriptionRenewalDateForAll(ctx context.Context, body api.MassExtendRenewalDateRequest) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExtendSubscriptionRenewalDateForAll", arg0, arg1) + ret := m.ctrl.Call(m, "ExtendSubscriptionRenewalDateForAll", ctx, body) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // ExtendSubscriptionRenewalDateForAll indicates an expected call of ExtendSubscriptionRenewalDateForAll. -func (mr *MockStoreAPIClientMockRecorder) ExtendSubscriptionRenewalDateForAll(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) ExtendSubscriptionRenewalDateForAll(ctx, body any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExtendSubscriptionRenewalDateForAll", reflect.TypeOf((*MockStoreAPIClient)(nil).ExtendSubscriptionRenewalDateForAll), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExtendSubscriptionRenewalDateForAll", reflect.TypeOf((*MockStoreAPIClient)(nil).ExtendSubscriptionRenewalDateForAll), ctx, body) } // GetALLSubscriptionStatuses mocks base method. -func (m *MockStoreAPIClient) GetALLSubscriptionStatuses(arg0 context.Context, arg1 string, arg2 *url.Values) (*api.StatusResponse, error) { +func (m *MockStoreAPIClient) GetALLSubscriptionStatuses(ctx context.Context, originalTransactionId string, query *url.Values) (*api.StatusResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetALLSubscriptionStatuses", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetALLSubscriptionStatuses", ctx, originalTransactionId, query) ret0, _ := ret[0].(*api.StatusResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // GetALLSubscriptionStatuses indicates an expected call of GetALLSubscriptionStatuses. -func (mr *MockStoreAPIClientMockRecorder) GetALLSubscriptionStatuses(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) GetALLSubscriptionStatuses(ctx, originalTransactionId, query any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetALLSubscriptionStatuses", reflect.TypeOf((*MockStoreAPIClient)(nil).GetALLSubscriptionStatuses), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetALLSubscriptionStatuses", reflect.TypeOf((*MockStoreAPIClient)(nil).GetALLSubscriptionStatuses), ctx, originalTransactionId, query) } // GetAllNotificationHistory mocks base method. -func (m *MockStoreAPIClient) GetAllNotificationHistory(arg0 context.Context, arg1 api.NotificationHistoryRequest, arg2 time.Duration) ([]api.NotificationHistoryResponseItem, error) { +func (m *MockStoreAPIClient) GetAllNotificationHistory(ctx context.Context, body api.NotificationHistoryRequest, duration time.Duration) ([]api.NotificationHistoryResponseItem, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAllNotificationHistory", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetAllNotificationHistory", ctx, body, duration) ret0, _ := ret[0].([]api.NotificationHistoryResponseItem) ret1, _ := ret[1].(error) return ret0, ret1 } // GetAllNotificationHistory indicates an expected call of GetAllNotificationHistory. -func (mr *MockStoreAPIClientMockRecorder) GetAllNotificationHistory(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) GetAllNotificationHistory(ctx, body, duration any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllNotificationHistory", reflect.TypeOf((*MockStoreAPIClient)(nil).GetAllNotificationHistory), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllNotificationHistory", reflect.TypeOf((*MockStoreAPIClient)(nil).GetAllNotificationHistory), ctx, body, duration) } // GetNotificationHistory mocks base method. -func (m *MockStoreAPIClient) GetNotificationHistory(arg0 context.Context, arg1 api.NotificationHistoryRequest, arg2 string) (*api.NotificationHistoryResponses, error) { +func (m *MockStoreAPIClient) GetNotificationHistory(ctx context.Context, body api.NotificationHistoryRequest, paginationToken string) (*api.NotificationHistoryResponses, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNotificationHistory", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetNotificationHistory", ctx, body, paginationToken) ret0, _ := ret[0].(*api.NotificationHistoryResponses) ret1, _ := ret[1].(error) return ret0, ret1 } // GetNotificationHistory indicates an expected call of GetNotificationHistory. -func (mr *MockStoreAPIClientMockRecorder) GetNotificationHistory(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) GetNotificationHistory(ctx, body, paginationToken any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNotificationHistory", reflect.TypeOf((*MockStoreAPIClient)(nil).GetNotificationHistory), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNotificationHistory", reflect.TypeOf((*MockStoreAPIClient)(nil).GetNotificationHistory), ctx, body, paginationToken) } // GetRefundHistory mocks base method. -func (m *MockStoreAPIClient) GetRefundHistory(arg0 context.Context, arg1 string) ([]*api.RefundLookupResponse, error) { +func (m *MockStoreAPIClient) GetRefundHistory(ctx context.Context, originalTransactionId string) ([]*api.RefundLookupResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetRefundHistory", arg0, arg1) + ret := m.ctrl.Call(m, "GetRefundHistory", ctx, originalTransactionId) ret0, _ := ret[0].([]*api.RefundLookupResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // GetRefundHistory indicates an expected call of GetRefundHistory. -func (mr *MockStoreAPIClientMockRecorder) GetRefundHistory(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) GetRefundHistory(ctx, originalTransactionId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRefundHistory", reflect.TypeOf((*MockStoreAPIClient)(nil).GetRefundHistory), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRefundHistory", reflect.TypeOf((*MockStoreAPIClient)(nil).GetRefundHistory), ctx, originalTransactionId) } // GetSubscriptionRenewalDataStatus mocks base method. -func (m *MockStoreAPIClient) GetSubscriptionRenewalDataStatus(arg0 context.Context, arg1, arg2 string) (int, *api.MassExtendRenewalDateStatusResponse, error) { +func (m *MockStoreAPIClient) GetSubscriptionRenewalDataStatus(ctx context.Context, productId, requestIdentifier string) (int, *api.MassExtendRenewalDateStatusResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSubscriptionRenewalDataStatus", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetSubscriptionRenewalDataStatus", ctx, productId, requestIdentifier) ret0, _ := ret[0].(int) ret1, _ := ret[1].(*api.MassExtendRenewalDateStatusResponse) ret2, _ := ret[2].(error) @@ -159,15 +161,15 @@ func (m *MockStoreAPIClient) GetSubscriptionRenewalDataStatus(arg0 context.Conte } // GetSubscriptionRenewalDataStatus indicates an expected call of GetSubscriptionRenewalDataStatus. -func (mr *MockStoreAPIClientMockRecorder) GetSubscriptionRenewalDataStatus(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) GetSubscriptionRenewalDataStatus(ctx, productId, requestIdentifier any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubscriptionRenewalDataStatus", reflect.TypeOf((*MockStoreAPIClient)(nil).GetSubscriptionRenewalDataStatus), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubscriptionRenewalDataStatus", reflect.TypeOf((*MockStoreAPIClient)(nil).GetSubscriptionRenewalDataStatus), ctx, productId, requestIdentifier) } // GetTestNotificationStatus mocks base method. -func (m *MockStoreAPIClient) GetTestNotificationStatus(arg0 context.Context, arg1 string) (int, []byte, error) { +func (m *MockStoreAPIClient) GetTestNotificationStatus(ctx context.Context, testNotificationToken string) (int, []byte, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTestNotificationStatus", arg0, arg1) + ret := m.ctrl.Call(m, "GetTestNotificationStatus", ctx, testNotificationToken) ret0, _ := ret[0].(int) ret1, _ := ret[1].([]byte) ret2, _ := ret[2].(error) @@ -175,120 +177,120 @@ func (m *MockStoreAPIClient) GetTestNotificationStatus(arg0 context.Context, arg } // GetTestNotificationStatus indicates an expected call of GetTestNotificationStatus. -func (mr *MockStoreAPIClientMockRecorder) GetTestNotificationStatus(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) GetTestNotificationStatus(ctx, testNotificationToken any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTestNotificationStatus", reflect.TypeOf((*MockStoreAPIClient)(nil).GetTestNotificationStatus), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTestNotificationStatus", reflect.TypeOf((*MockStoreAPIClient)(nil).GetTestNotificationStatus), ctx, testNotificationToken) } // GetTransactionHistory mocks base method. -func (m *MockStoreAPIClient) GetTransactionHistory(arg0 context.Context, arg1 string, arg2 *url.Values) ([]*api.HistoryResponse, error) { +func (m *MockStoreAPIClient) GetTransactionHistory(ctx context.Context, originalTransactionId string, query *url.Values) ([]*api.HistoryResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTransactionHistory", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetTransactionHistory", ctx, originalTransactionId, query) ret0, _ := ret[0].([]*api.HistoryResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // GetTransactionHistory indicates an expected call of GetTransactionHistory. -func (mr *MockStoreAPIClientMockRecorder) GetTransactionHistory(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) GetTransactionHistory(ctx, originalTransactionId, query any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactionHistory", reflect.TypeOf((*MockStoreAPIClient)(nil).GetTransactionHistory), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactionHistory", reflect.TypeOf((*MockStoreAPIClient)(nil).GetTransactionHistory), ctx, originalTransactionId, query) } // GetTransactionInfo mocks base method. -func (m *MockStoreAPIClient) GetTransactionInfo(arg0 context.Context, arg1 string) (*api.TransactionInfoResponse, error) { +func (m *MockStoreAPIClient) GetTransactionInfo(ctx context.Context, transactionId string) (*api.TransactionInfoResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTransactionInfo", arg0, arg1) + ret := m.ctrl.Call(m, "GetTransactionInfo", ctx, transactionId) ret0, _ := ret[0].(*api.TransactionInfoResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // GetTransactionInfo indicates an expected call of GetTransactionInfo. -func (mr *MockStoreAPIClientMockRecorder) GetTransactionInfo(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) GetTransactionInfo(ctx, transactionId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactionInfo", reflect.TypeOf((*MockStoreAPIClient)(nil).GetTransactionInfo), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactionInfo", reflect.TypeOf((*MockStoreAPIClient)(nil).GetTransactionInfo), ctx, transactionId) } // LookupOrderID mocks base method. -func (m *MockStoreAPIClient) LookupOrderID(arg0 context.Context, arg1 string) (*api.OrderLookupResponse, error) { +func (m *MockStoreAPIClient) LookupOrderID(ctx context.Context, orderId string) (*api.OrderLookupResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LookupOrderID", arg0, arg1) + ret := m.ctrl.Call(m, "LookupOrderID", ctx, orderId) ret0, _ := ret[0].(*api.OrderLookupResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // LookupOrderID indicates an expected call of LookupOrderID. -func (mr *MockStoreAPIClientMockRecorder) LookupOrderID(arg0, arg1 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) LookupOrderID(ctx, orderId any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupOrderID", reflect.TypeOf((*MockStoreAPIClient)(nil).LookupOrderID), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupOrderID", reflect.TypeOf((*MockStoreAPIClient)(nil).LookupOrderID), ctx, orderId) } // ParseJWSEncodeString mocks base method. -func (m *MockStoreAPIClient) ParseJWSEncodeString(arg0 string) (any, error) { +func (m *MockStoreAPIClient) ParseJWSEncodeString(jwsEncode string) (any, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParseJWSEncodeString", arg0) + ret := m.ctrl.Call(m, "ParseJWSEncodeString", jwsEncode) ret0, _ := ret[0].(any) ret1, _ := ret[1].(error) return ret0, ret1 } // ParseJWSEncodeString indicates an expected call of ParseJWSEncodeString. -func (mr *MockStoreAPIClientMockRecorder) ParseJWSEncodeString(arg0 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) ParseJWSEncodeString(jwsEncode any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseJWSEncodeString", reflect.TypeOf((*MockStoreAPIClient)(nil).ParseJWSEncodeString), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseJWSEncodeString", reflect.TypeOf((*MockStoreAPIClient)(nil).ParseJWSEncodeString), jwsEncode) } // ParseSignedTransaction mocks base method. -func (m *MockStoreAPIClient) ParseSignedTransaction(arg0 string) (*api.JWSTransaction, error) { +func (m *MockStoreAPIClient) ParseSignedTransaction(transaction string) (*api.JWSTransaction, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParseSignedTransaction", arg0) + ret := m.ctrl.Call(m, "ParseSignedTransaction", transaction) ret0, _ := ret[0].(*api.JWSTransaction) ret1, _ := ret[1].(error) return ret0, ret1 } // ParseSignedTransaction indicates an expected call of ParseSignedTransaction. -func (mr *MockStoreAPIClientMockRecorder) ParseSignedTransaction(arg0 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) ParseSignedTransaction(transaction any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseSignedTransaction", reflect.TypeOf((*MockStoreAPIClient)(nil).ParseSignedTransaction), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseSignedTransaction", reflect.TypeOf((*MockStoreAPIClient)(nil).ParseSignedTransaction), transaction) } // ParseSignedTransactions mocks base method. -func (m *MockStoreAPIClient) ParseSignedTransactions(arg0 []string) ([]*api.JWSTransaction, error) { +func (m *MockStoreAPIClient) ParseSignedTransactions(transactions []string) ([]*api.JWSTransaction, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ParseSignedTransactions", arg0) + ret := m.ctrl.Call(m, "ParseSignedTransactions", transactions) ret0, _ := ret[0].([]*api.JWSTransaction) ret1, _ := ret[1].(error) return ret0, ret1 } // ParseSignedTransactions indicates an expected call of ParseSignedTransactions. -func (mr *MockStoreAPIClientMockRecorder) ParseSignedTransactions(arg0 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) ParseSignedTransactions(transactions any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseSignedTransactions", reflect.TypeOf((*MockStoreAPIClient)(nil).ParseSignedTransactions), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParseSignedTransactions", reflect.TypeOf((*MockStoreAPIClient)(nil).ParseSignedTransactions), transactions) } // SendConsumptionInfo mocks base method. -func (m *MockStoreAPIClient) SendConsumptionInfo(arg0 context.Context, arg1 string, arg2 api.ConsumptionRequestBody) (int, error) { +func (m *MockStoreAPIClient) SendConsumptionInfo(ctx context.Context, originalTransactionId string, body api.ConsumptionRequestBody) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendConsumptionInfo", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "SendConsumptionInfo", ctx, originalTransactionId, body) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // SendConsumptionInfo indicates an expected call of SendConsumptionInfo. -func (mr *MockStoreAPIClientMockRecorder) SendConsumptionInfo(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) SendConsumptionInfo(ctx, originalTransactionId, body any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendConsumptionInfo", reflect.TypeOf((*MockStoreAPIClient)(nil).SendConsumptionInfo), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendConsumptionInfo", reflect.TypeOf((*MockStoreAPIClient)(nil).SendConsumptionInfo), ctx, originalTransactionId, body) } // SendRequestTestNotification mocks base method. -func (m *MockStoreAPIClient) SendRequestTestNotification(arg0 context.Context) (int, []byte, error) { +func (m *MockStoreAPIClient) SendRequestTestNotification(ctx context.Context) (int, []byte, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendRequestTestNotification", arg0) + ret := m.ctrl.Call(m, "SendRequestTestNotification", ctx) ret0, _ := ret[0].(int) ret1, _ := ret[1].([]byte) ret2, _ := ret[2].(error) @@ -296,7 +298,7 @@ func (m *MockStoreAPIClient) SendRequestTestNotification(arg0 context.Context) ( } // SendRequestTestNotification indicates an expected call of SendRequestTestNotification. -func (mr *MockStoreAPIClientMockRecorder) SendRequestTestNotification(arg0 any) *gomock.Call { +func (mr *MockStoreAPIClientMockRecorder) SendRequestTestNotification(ctx any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendRequestTestNotification", reflect.TypeOf((*MockStoreAPIClient)(nil).SendRequestTestNotification), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendRequestTestNotification", reflect.TypeOf((*MockStoreAPIClient)(nil).SendRequestTestNotification), ctx) } diff --git a/playstore/mocks/playstore.go b/playstore/mocks/playstore.go index 6c3b768..129c77d 100644 --- a/playstore/mocks/playstore.go +++ b/playstore/mocks/playstore.go @@ -5,6 +5,7 @@ // // mockgen -destination=mocks/playstore.go -package=mocks github.com/awa/go-iap/playstore IABProduct,IABSubscription,IABSubscriptionV2,IABMonetization // + // Package mocks is a generated GoMock package. package mocks @@ -20,6 +21,7 @@ import ( type MockIABProduct struct { ctrl *gomock.Controller recorder *MockIABProductMockRecorder + isgomock struct{} } // MockIABProductMockRecorder is the mock recorder for MockIABProduct. @@ -86,6 +88,7 @@ func (mr *MockIABProductMockRecorder) VerifyProduct(arg0, arg1, arg2, arg3 any) type MockIABSubscription struct { ctrl *gomock.Controller recorder *MockIABSubscriptionMockRecorder + isgomock struct{} } // MockIABSubscriptionMockRecorder is the mock recorder for MockIABSubscription. @@ -195,6 +198,7 @@ func (mr *MockIABSubscriptionMockRecorder) VerifySubscription(arg0, arg1, arg2, type MockIABSubscriptionV2 struct { ctrl *gomock.Controller recorder *MockIABSubscriptionV2MockRecorder + isgomock struct{} } // MockIABSubscriptionV2MockRecorder is the mock recorder for MockIABSubscriptionV2. @@ -248,6 +252,7 @@ func (mr *MockIABSubscriptionV2MockRecorder) VerifySubscriptionV2(arg0, arg1, ar type MockIABMonetization struct { ctrl *gomock.Controller recorder *MockIABMonetizationMockRecorder + isgomock struct{} } // MockIABMonetizationMockRecorder is the mock recorder for MockIABMonetization.