-
Notifications
You must be signed in to change notification settings - Fork 1
/
activity_data.go
45 lines (37 loc) · 1017 Bytes
/
activity_data.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
package zerobouncego
import (
"net/url"
"strconv"
"gopkg.in/guregu/null.v4"
)
type ActivityDataResponse struct {
Found bool `json:"found"`
ActiveInDaysRaw null.String `json:"active_in_days"`
}
func (a ActivityDataResponse) ActiveInDays() int {
if !a.ActiveInDaysRaw.Valid {
return -1
}
conversion, error_ := strconv.Atoi(a.ActiveInDaysRaw.String)
if error_ != nil {
return -1
}
return conversion
}
// GetActivityData check the activity of an email address
func GetActivityData(email_address string) (*ActivityDataResponse, error) {
var error_ error
request_parameters := url.Values{}
request_parameters.Set("email", email_address)
request_parameters.Set("api_key", API_KEY)
url_to_access, error_ := PrepareURL(ENDPOINT_ACTIVITY_DATA, request_parameters)
if error_ != nil {
return nil, error_
}
response_object := &ActivityDataResponse{}
error_ = DoGetRequest(url_to_access, response_object)
if error_ != nil {
return nil, error_
}
return response_object, nil
}