-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprovider.go
50 lines (42 loc) · 1.53 KB
/
provider.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
package lytics
const (
providerEndpoint = "provider/:id"
providerListEndpoint = "provider"
)
type Provider struct {
Id string `json:"id"`
Slug string `json:"slug"`
Hidden bool `json:"hidden"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Description string `json:"description"`
Categories []string `json:"categories"`
AuthMethod string `json:"auth_method,omitempty"`
AuthDescription string `json:"auth_description"`
NoAuth bool `json:"no_auth"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
// GetProviders returns a list of all providers (mailchimp, campaign monitor, etc)
// https://www.getlytics.com/developers/rest-api#provider-list
func (l *Client) GetProviders() ([]Provider, error) {
res := ApiResp{}
data := []Provider{}
// make the request
err := l.Get(providerListEndpoint, nil, nil, &res, &data)
if err != nil {
return data, err
}
return data, nil
}
// GetProvider returns a single provider based on id
// https://www.getlytics.com/developers/rest-api#provider
func (l *Client) GetProvider(id string) (Provider, error) {
res := ApiResp{}
data := Provider{}
// make the request
err := l.Get(parseLyticsURL(providerEndpoint, map[string]string{"id": id}), nil, nil, &res, &data)
if err != nil {
return data, err
}
return data, nil
}