Skip to content

Commit

Permalink
debug: fix get customer by code
Browse files Browse the repository at this point in the history
  • Loading branch information
erfandiakoo committed Dec 6, 2024
1 parent 7cf1e7f commit 003dd4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 003dd4b

Please sign in to comment.