-
Notifications
You must be signed in to change notification settings - Fork 2
/
entity_get_entities.go
55 lines (47 loc) · 1.26 KB
/
entity_get_entities.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
package sila
import (
"strconv"
"github.com/bpancost/sila/domain"
)
func (client ClientImpl) GetEntities() GetEntities {
return &GetEntitiesMsg{
Header: client.generateHeader(),
Message: "header_msg",
}
}
type GetEntitiesMsg struct {
Header *Header `json:"header"`
Message string `json:"message"`
EntityType string `json:"entity_type,omitempty"`
Page int32 `json:"-"`
PerPage int32 `json:"-"`
}
func (msg *GetEntitiesMsg) SetEntityType(entityType string) GetEntities {
msg.EntityType = entityType
return msg
}
func (msg *GetEntitiesMsg) SetPage(page int32) GetEntities {
msg.Page = page
return msg
}
func (msg *GetEntitiesMsg) SetPerPage(perPage int32) GetEntities {
msg.PerPage = perPage
return msg
}
func (msg *GetEntitiesMsg) Do() (domain.GetEntitiesResponse, error) {
var responseBody domain.GetEntitiesResponse
path := "/get_entities"
var params string
if msg.Page > 0 {
params = "?page=" + strconv.FormatInt(int64(msg.Page), 10)
}
if msg.PerPage > 0 {
if len(params) > 0 {
params += "&per_page=" + strconv.FormatInt(int64(msg.PerPage), 10)
} else {
params = "?per_page=" + strconv.FormatInt(int64(msg.PerPage), 10)
}
}
err := instance.performCall(path+params, msg, &responseBody)
return responseBody, err
}