-
Notifications
You must be signed in to change notification settings - Fork 1
/
company.go
35 lines (28 loc) · 935 Bytes
/
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
package sptrans
const (
defaultCompanyPath = "Empresa"
)
// CompanyService provide functions to request companies endpoints
type CompanyService service
// CompanyResponse structure, see documentation on http://www.sptrans.com.br/desenvolvedores/APIOlhoVivo/Documentacao.aspx?1#docApi-empresas
type CompanyResponse struct {
Hour string `json:"hr"`
Operations []*CompanyOperation `json:"e"`
}
// CompanyOperation structure
type CompanyOperation struct {
Id int64 `json:"a"`
Companies []*Company `json:"e"`
}
//Company structure
type Company struct {
Id int64 `json:"c"`
OperationId int64 `json:"a"`
Name string `json:"n"`
}
// All returns all companies
func (r *CompanyService) All() ([]*CompanyOperation, error) {
var companyResponse *CompanyResponse
_, err := r.client.Request("GET", defaultCompanyPath, nil, &companyResponse)
return companyResponse.Operations, err
}