forked from segmentio/gads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomer.go
59 lines (52 loc) · 1.84 KB
/
customer.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 gads
import "encoding/xml"
type CustomerService struct {
Auth
}
type Customer struct {
ID int64 `xml:"customerId,omitempty"`
CurrencyCode string `xml:"currencyCode,omitempty"`
DateTimeZone string `xml:"dateTimeZone,omitempty"`
DescriptiveName string `xml:"descriptiveName,omitempty"`
CanManageClients bool `xml:"canManageClients,omitempty"`
IsTestAccount bool `xml:"testAccount,omitempty"`
AutoTaggingEnabled bool `xml:"autoTaggingEnabled,omitempty"`
TrackingURLTemplate string `xml:"trackingUrlTemplate,omitempty"`
ConversionTrackingSettings ConversionTrackingSettings `xml:"conversionTrackingSettings"`
RemarketingSettings RemarketingSettings `xml:"remarketingSettings"`
}
type RemarketingSettings struct {
Snippet string `xml:"snippet"`
}
func NewCustomerService(auth *Auth) *CustomerService {
return &CustomerService{Auth: *auth}
}
// GetCustomers Important Notes:
// Starting with v201607, if clientCustomerId is specified in the request header, only details of that customer will be returned.
// To do this for prior versions, use the get() method instead.
func (s *CustomerService) GetCustomers() (customers []Customer, err error) {
respBody, err := s.Auth.request(
customerServiceUrl,
"getCustomers",
struct {
XMLName xml.Name
}{
XMLName: xml.Name{
Space: baseMcmUrl,
Local: "getCustomers",
},
},
nil,
)
if err != nil {
return customers, err
}
getResp := struct {
Customers []Customer `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return customers, err
}
return getResp.Customers, nil
}