From afed91482fc61d5759295c9931967ad8c32dbeb2 Mon Sep 17 00:00:00 2001 From: Harald Nordgren Date: Wed, 24 Apr 2024 11:04:41 +0200 Subject: [PATCH] client.go: Fix issue with how platform is set on call() --- client.go | 6 ++++-- purchases_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 2420153..2b423e1 100644 --- a/client.go +++ b/client.go @@ -48,9 +48,11 @@ func (c *Client) call(method, path string, reqBody interface{}, platform string, } req.Header.Add("Authorization", "Bearer "+c.apiKey) req.Header.Add("Content-Type", "application/json") - if platform != "" { - req.Header.Add("X-Platform", "ios") + + if platform == "" { + platform = "ios" } + req.Header.Add("X-Platform", platform) resp, err := c.http.Do(req) if err != nil { diff --git a/purchases_test.go b/purchases_test.go index 5f49d1e..9e93adf 100644 --- a/purchases_test.go +++ b/purchases_test.go @@ -16,7 +16,7 @@ func TestCreatePurchaseWithoutOpts(t *testing.T) { cl.expectMethod(t, "POST") cl.expectPath(t, "/v1/receipts") - cl.expectXPlatform(t, "") + cl.expectXPlatform(t, "ios") cl.expectBody(t, `{"app_user_id":"123","fetch_token":"testreceipt"}`) }