diff --git a/playstore/validator.go b/playstore/validator.go index e6610e2..3d58a56 100644 --- a/playstore/validator.go +++ b/playstore/validator.go @@ -45,6 +45,7 @@ type IABSubscriptionV2 interface { // The IABMonetization type is an interface for monetization service type IABMonetization interface { + ConvertRegionPrices(ctx context.Context, packageName string, price *androidpublisher.Money) (*androidpublisher.ConvertRegionPricesResponse, error) GetSubscription(ctx context.Context, packageName string, productID string) (*androidpublisher.Subscription, error) GetSubscriptionOffer(context.Context, string, string, string, string) (*androidpublisher.SubscriptionOffer, error) } @@ -233,6 +234,20 @@ func (c *Client) DeferSubscription(ctx context.Context, packageName string, subs return result, err } +// ConvertRegionPrices +func (c *Client) ConvertRegionPrices(ctx context.Context, + packageName string, + price *androidpublisher.Money, +) (*androidpublisher.ConvertRegionPricesResponse, error) { + ps := androidpublisher.NewMonetizationService(c.service) + convertRegionPricesRequest := &androidpublisher.ConvertRegionPricesRequest{ + Price: price, + } + result, err := ps.ConvertRegionPrices(packageName, convertRegionPricesRequest).Context(ctx).Do() + + return result, err +} + // GetSubscription reads a single subscription. func (c *Client) GetSubscription(ctx context.Context, packageName string, diff --git a/playstore/validator_test.go b/playstore/validator_test.go index 39d74c1..681734f 100644 --- a/playstore/validator_test.go +++ b/playstore/validator_test.go @@ -277,6 +277,29 @@ func TestDeferSubscription(t *testing.T) { // TODO Normal scenario } +func TestConvertRegionPrices(t *testing.T) { + t.Parallel() + // Exception scenario + expected := "googleapi: Error 404: Package not found: package., notFound" + + client, _ := New(jsonKey) + ctx := context.Background() + price := &androidpublisher.Money{ + CurrencyCode: "USD", + Nanos: 1 * 1000, + Units: 1, + ForceSendFields: nil, + NullFields: nil, + } + _, err := client.ConvertRegionPrices(ctx, "package", price) + + if err == nil || err.Error() != expected { + t.Errorf("got %v", err) + } + + // TODO Normal scenario +} + func TestGetSubscription(t *testing.T) { t.Parallel() // Exception scenario