-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
64 lines (60 loc) · 1.72 KB
/
account.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
63
64
package sib
import (
"math"
)
// AccountDetails conveys information and account limits
type AccountDetails struct {
Code string `json:"code"`
Message string `json:"message"`
Data []struct {
PlanType string `json:"plan_type,omitempty"`
Credits int `json:"credits,omitempty"`
CreditType string `json:"credit_type,omitempty"`
ClientID int `json:"client_id,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Email string `json:"email,omitempty"`
Company string `json:"company,omitempty"`
Address string `json:"address,omitempty"`
City string `json:"city,omitempty"`
ZipCode string `json:"zip_code,omitempty"`
Country string `json:"country,omitempty"`
} `json:"data"`
}
// SMTPAccountDetails conveys SMTP account information and limits
type SMTPAccountDetails struct {
Code string `json:"code"`
Message string `json:"message"`
Data struct {
TrackingData struct {
SiteID string `json:"site_id"`
Email string `json:"email"`
Fname string `json:"fname"`
Lname string `json:"lname"`
CompanyName string `json:"company_name"`
} `json:"tracking_data"`
RelayData struct {
Result string `json:"result"`
Status string `json:"status"`
Message string `json:"message"`
} `json:"relay_data"`
} `json:"data"`
}
// SMTPCreditCount returns the number of credits available in the account
func (account AccountDetails) SMTPCreditCount() int {
for _, v := range account.Data {
switch v.PlanType {
case "PAG":
fallthrough
case "FREE":
fallthrough
case "CREDIT_REC":
return v.Credits
case "UNLIMITED":
return math.MaxInt32
default:
return 0
}
}
return 0
}