From 003dd4b5ccb826a7122c0eafdf2a714f5e7c6139 Mon Sep 17 00:00:00 2001 From: Erfan Diakoo Date: Fri, 6 Dec 2024 20:15:24 +0330 Subject: [PATCH] debug: fix get customer by code --- client.go | 4 ++-- client_test.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 08d7a30..8e13524 100644 --- a/client.go +++ b/client.go @@ -242,12 +242,12 @@ func (g *GoArpa) GetCustomerByMobile(ctx context.Context, accessToken string, co return result, nil } -func (g *GoArpa) GetCustomerByBusinessCode(ctx context.Context, accessToken, businessCode string) (*GetCustomerResponse, error) { +func (g *GoArpa) GetCustomerByBusinessCode(ctx context.Context, accessToken string, cookie []*http.Cookie, businessCode string) (*GetCustomerResponse, error) { const errMessage = "could not get customer info" var result GetCustomerResponse - resp, err := g.GetRequestWithBearerAuth(ctx, accessToken). + resp, err := g.GetRequestWithBearerAuthWithCookie(ctx, accessToken, cookie). SetQueryParam(constant.BusinessCodeKey, businessCode). SetResult(&result). Get(fmt.Sprintf("%s/%s", g.basePath, g.Config.GetCustomerEndpoint)) diff --git a/client_test.go b/client_test.go index f8b6baf..213211b 100644 --- a/client_test.go +++ b/client_test.go @@ -225,11 +225,12 @@ func Test_GetCustomerByMobile(t *testing.T) { func Test_GetCustomerByBusinessCode(t *testing.T) { t.Parallel() client := NewClientWithDebug(t) - token, _ := GetToken(t, client) + token, cookie := GetToken(t, client) customerInfo, err := client.GetCustomerByBusinessCode( context.Background(), token, + cookie, "127013", ) require.NoError(t, err, "Expected no error when fetching valid customer info") @@ -241,6 +242,7 @@ func Test_GetCustomerByBusinessCode(t *testing.T) { _, err = client.GetCustomerByBusinessCode( context.Background(), token, + cookie, "127013", ) require.Error(t, err, "Expected an error when request fails")