-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
43 lines (36 loc) · 1.08 KB
/
client.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
package mytarget
import (
"github.com/kachit/mytarget-sdk-go/config"
mytarget_http "github.com/kachit/mytarget-sdk-go/http"
"github.com/kachit/mytarget-sdk-go/management"
"github.com/kachit/mytarget-sdk-go/marketing"
"github.com/kachit/mytarget-sdk-go/reporting"
"net/http"
)
type Client struct {
transport *mytarget_http.Transport
}
func (c *Client) Reporting() *reporting.Factory {
return &reporting.Factory{Transport: c.transport}
}
func (c *Client) Management() *management.Factory {
return &management.Factory{Transport: c.transport}
}
func (c *Client) Marketing() *marketing.Factory {
return &marketing.Factory{Transport: c.transport}
}
func NewClientFromConfig(config *config.Config, cl *http.Client) *Client {
if cl == nil {
cl = &http.Client{}
}
transport := mytarget_http.NewHttpTransport(config, cl)
return &Client{transport}
}
func NewClientFromCredentials(accessToken string, cl *http.Client) *Client {
cfg := config.NewConfig(accessToken)
if cl == nil {
cl = &http.Client{}
}
transport := mytarget_http.NewHttpTransport(cfg, cl)
return &Client{transport}
}