forked from equinixmetal-archive/packngo
-
Notifications
You must be signed in to change notification settings - Fork 3
/
email.go
41 lines (33 loc) · 879 Bytes
/
email.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
package packngo
const emailBasePath = "/emails"
// EmailService interface defines available email methods
type EmailService interface {
Get(string) (*Email, *Response, error)
}
// Email represents a user's email address
type Email struct {
ID string `json:"id"`
Address string `json:"address"`
Default bool `json:"default,omitempty"`
URL string `json:"href,omitempty"`
}
func (e Email) String() string {
return Stringify(e)
}
// EmailServiceOp implements EmailService
type EmailServiceOp struct {
client *Client
}
// Get retrieves an email by id
func (s *EmailServiceOp) Get(emailID string) (*Email, *Response, error) {
req, err := s.client.NewRequest("GET", emailBasePath, nil)
if err != nil {
return nil, nil, err
}
email := new(Email)
resp, err := s.client.Do(req, email)
if err != nil {
return nil, resp, err
}
return email, resp, err
}