2016-01-29 20:53:56 +01:00
|
|
|
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 {
|
2016-07-21 21:57:49 +02:00
|
|
|
ID string `json:"id"`
|
|
|
|
Address string `json:"address"`
|
|
|
|
Default bool `json:"default,omitempty"`
|
|
|
|
URL string `json:"href,omitempty"`
|
2016-01-29 20:53:56 +01:00
|
|
|
}
|
2016-07-21 21:57:49 +02:00
|
|
|
|
2016-01-29 20:53:56 +01:00
|
|
|
func (e Email) String() string {
|
|
|
|
return Stringify(e)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EmailServiceOp implements EmailService
|
|
|
|
type EmailServiceOp struct {
|
|
|
|
client *Client
|
|
|
|
}
|
|
|
|
|
2016-07-21 21:57:49 +02:00
|
|
|
// Get retrieves an email by id
|
2016-01-29 20:53:56 +01:00
|
|
|
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
|
|
|
|
}
|