-
Notifications
You must be signed in to change notification settings - Fork 26
/
client.go
42 lines (37 loc) · 844 Bytes
/
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
package nexmo
import (
"errors"
"net/http"
)
// Client encapsulates the Nexmo functions.
// Should be created with NewClient()
type Client struct {
Account *Account
SMS *SMS
USSD *USSD
Verify *Verification
HTTPClient *http.Client
apiKey string
apiSecret string
useOauth bool
}
// NewClient creates a new Client type with the
// provided API key / API secret.
func NewClient(apiKey, apiSecret string) (*Client, error) {
if apiKey == "" {
return nil, errors.New("apiKey can not be empty")
} else if apiSecret == "" {
return nil, errors.New("apiSecret can not be empty")
}
c := &Client{
apiKey: apiKey,
apiSecret: apiSecret,
useOauth: false,
}
c.Account = &Account{c}
c.SMS = &SMS{c}
c.USSD = &USSD{c}
c.Verify = &Verification{c}
c.HTTPClient = http.DefaultClient
return c, nil
}