This repository has been archived by the owner on Jan 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmerchants.go
59 lines (50 loc) · 1.79 KB
/
merchants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package starling
import (
"context"
"net/http"
)
// Merchant represents details of a merchant
type Merchant struct {
UID string `json:"merchantUid"`
Name string `json:"name"`
Website string `json:"website"`
PhoneNumber string `json:"phoneNumber"`
TwitterUsername string `json:"twitterUsername"`
}
// MerchantLocation represents details of a merchant location
type MerchantLocation struct {
UID string `json:"merchantLocationUid"`
MerchantUID string `json:"merchantUid"`
MerchantName string `json:"merchantName"`
LocationName string `json:"locationName"`
Address string `json:"address"`
PhoneNumber string `json:"phoneNUmber"`
GooglePlaceID string `json:"googlePlaceId"`
MastercardMerchantCategoryCode int32 `json:"mastercardMerchantCategoryCode"`
}
// Merchant returns an individual merchant based on the UID.
func (c *Client) Merchant(ctx context.Context, uid string) (*Merchant, *http.Response, error) {
req, err := c.NewRequest("GET", "/api/v1/merchants/"+uid, nil)
if err != nil {
return nil, nil, err
}
mer := new(Merchant)
resp, err := c.Do(ctx, req, mer)
if err != nil {
return nil, resp, err
}
return mer, resp, err
}
// MerchantLocation returns an individual merchant location based on the merchant UID and location UID.
func (c *Client) MerchantLocation(ctx context.Context, mUID, lUID string) (*MerchantLocation, *http.Response, error) {
req, err := c.NewRequest("GET", "/api/v1/merchants/"+mUID+"/locations/"+lUID, nil)
if err != nil {
return nil, nil, err
}
merLoc := new(MerchantLocation)
resp, err := c.Do(ctx, req, merLoc)
if err != nil {
return nil, resp, err
}
return merLoc, resp, err
}