forked from jinmatt/go-quickbooks.v2
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompany.go
86 lines (79 loc) · 2.61 KB
/
company.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package quickbooks
import (
"encoding/json"
"fmt"
)
// Company quickbooks object type
type Company struct {
CompanyInfo `json:"CompanyInfo"`
Time string `json:"time"`
}
type CompanyInfo struct {
CompanyName string `json:"CompanyName"`
LegalName string `json:"LegalName"`
CompanyAddr struct {
ID string `json:"Id"`
Line1 string `json:"Line1"`
City string `json:"City"`
Country string `json:"Country"`
CountrySubDivisionCode string `json:"CountrySubDivisionCode"`
PostalCode string `json:"PostalCode"`
} `json:"CompanyAddr"`
CustomerCommunicationAddr struct {
ID string `json:"Id"`
Line1 string `json:"Line1"`
City string `json:"City"`
Country string `json:"Country"`
CountrySubDivisionCode string `json:"CountrySubDivisionCode"`
PostalCode string `json:"PostalCode"`
} `json:"CustomerCommunicationAddr"`
LegalAddr struct {
ID string `json:"Id"`
Line1 string `json:"Line1"`
City string `json:"City"`
Country string `json:"Country"`
CountrySubDivisionCode string `json:"CountrySubDivisionCode"`
PostalCode string `json:"PostalCode"`
} `json:"LegalAddr"`
PrimaryPhone struct {
FreeFormNumber string `json:"FreeFormNumber"`
} `json:"PrimaryPhone"`
CompanyStartDate string `json:"CompanyStartDate"`
FiscalYearStartMonth string `json:"FiscalYearStartMonth"`
Country string `json:"Country"`
Email struct {
Address string `json:"Address"`
} `json:"Email"`
WebAddr struct {
} `json:"WebAddr"`
SupportedLanguages string `json:"SupportedLanguages"`
NameValue []struct {
Name string `json:"Name"`
Value string `json:"Value"`
} `json:"NameValue"`
Domain string `json:"domain"`
Sparse bool `json:"sparse"`
ID string `json:"Id"`
SyncToken string `json:"SyncToken"`
MetaData struct {
CreateTime string `json:"CreateTime"`
LastUpdatedTime string `json:"LastUpdatedTime"`
} `json:"MetaData"`
}
// GetCompanyInfo returns company info bases on realmID/companyID passed to NewClient options
func (q *Quickbooks) GetCompanyInfo() (*Company, error) {
endpoint := fmt.Sprintf("/company/%s/companyinfo/%s", q.RealmID, q.RealmID)
res, err := q.makeGetRequest(endpoint)
if err != nil {
return nil, err
}
if res.Body != nil {
defer res.Body.Close()
}
company := Company{}
err = json.NewDecoder(res.Body).Decode(&company)
if err != nil {
return nil, err
}
return &company, nil
}