-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.go
62 lines (55 loc) · 1.77 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
package infusion
import (
"encoding/json"
"errors"
"io/ioutil"
)
// AccountProfile the details about the account for the authorized account
type AccountProfile struct {
Address struct {
CountryCode string `json:"country_code"`
Field string `json:"field"`
Line1 string `json:"line1"`
Line2 string `json:"line2"`
Locality string `json:"locality"`
PostalCode string `json:"postal_code"`
Region string `json:"region"`
ZipCode string `json:"zip_code"`
ZipFour string `json:"zip_four"`
} `json:"address"`
BusinessGoals []string `json:"business_goals"`
BusinessPrimaryColor string `json:"business_primary_color"`
BusinessSecondaryColor string `json:"business_secondary_color"`
BusinessType string `json:"business_type"`
CurrencyCode string `json:"currency_code"`
Email string `json:"email"`
LanguageTag string `json:"language_tag"`
LogoURL string `json:"logo_url"`
Name string `json:"name"`
Phone string `json:"phone"`
PhoneExt string `json:"phone_ext"`
TimeZone string `json:"time_zone"`
Website string `json:"website"`
}
// GetAccountProfile Request the Account Details from Infusion
func GetAccountProfile() (AccountProfile, error) {
ap := AccountProfile{}
r, err := getRequest("/account/profile")
if err != nil {
return ap, err
}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
return ap, err
}
if r.StatusCode == 401 {
return ap, errors.New("Invalid status code from Infusion")
}
err = json.Unmarshal(body, &ap)
if err != nil {
return ap, err
}
log.Info("Account recieved for " + ap.Name)
log.Info(string(body))
return ap, err
}