-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.go
62 lines (53 loc) · 1.35 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package api
import (
"log"
"github.com/exotel/goapi/assets/types"
"github.com/exotel/goapi/resources"
)
//Client is the iam client struct that calls all the other services
type Client struct {
AccountSid string `url:"AccountSid"`
UserName string
ResourceID string `url:"ResourceID"`
url string
data resources.IResource
action types.Action
validActions types.Action
baseURL string
logger *log.Logger
mode types.Mode
Credentials types.Credentials
}
//New Creates an instance of iam client
func New(cr types.Credentials) *Client {
return &Client{Credentials: cr, baseURL: "http://api.suffix.io/"}
}
//SetAccountSid sets the account sid of the user
func (c *Client) SetAccountSid(accountSid string) *Client {
c.AccountSid = accountSid
return c
}
//SetUserName sets the user name of the user
func (c *Client) SetUserName(userName string) *Client {
c.UserName = userName
return c
}
//Debug set the client in debug mode
func (c *Client) Debug(debug bool) *Client {
if debug {
c.mode = types.DEBUG
return c
}
c.mode = types.PRODUCTION
return c
}
//SetLogger sets logger for the class
func (c *Client) SetLogger(logger *log.Logger) *Client {
c.logger = logger
return c
}
//SetBaseURL sets the base url for making api requests
func (c *Client) SetBaseURL(url string) *Client {
c.baseURL = url
return c
}