-
Notifications
You must be signed in to change notification settings - Fork 23
/
end_users.go
100 lines (86 loc) · 2.98 KB
/
end_users.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package plivo
import "time"
type EndUserService struct {
client *Client
}
type EndUserGetResponse struct {
CreatedAt time.Time `json:"created_at"`
EndUserID string `json:"end_user_id"`
Name string `json:"name"`
LastName string `json:"last_name"`
EndUserType string `json:"end_user_type"`
}
type EndUserListParams struct {
Limit int `json:"limit,omitempty" url:"limit,omitempty"`
Offset int `json:"offset,omitempty" url:"offset,omitempty"`
Name string `json:"name,omitempty" url:"name,omitempty"`
LastName string `json:"last_name,omitempty" url:"last_name,omitempty"`
EndUserType string `json:"end_user_type,omitempty" url:"end_user_type,omitempty"`
}
type EndUserListResponse struct {
BaseListResponse
Objects []EndUserGetResponse `json:"objects" url:"objects"`
}
type CreateEndUserResponse struct {
CreatedAt time.Time `json:"created_at"`
EndUserID string `json:"end_user_id"`
Name string `json:"name"`
LastName string `json:"last_name"`
EndUserType string `json:"end_user_type"`
APIID string `json:"api_id"`
Message string `json:"message"`
}
type EndUserParams struct {
Name string `json:"name,omitempty" url:"name,omitempty"`
LastName string `json:"last_name,omitempty" url:"last_name,omitempty"`
EndUserType string `json:"end_user_type,omitempty" url:"end_user_type,omitempty"`
}
type UpdateEndUserParams struct {
EndUserParams
EndUserID string `json:"end_user_id"`
}
type UpdateEndUserResponse BaseResponse
func (service *EndUserService) Get(endUserId string) (response *EndUserGetResponse, err error) {
req, err := service.client.NewRequest("GET", nil, "EndUser/%s", endUserId)
if err != nil {
return nil, err
}
response = &EndUserGetResponse{}
err = service.client.ExecuteRequest(req, response)
return
}
func (service *EndUserService) List(params EndUserListParams) (response *EndUserListResponse, err error) {
request, err := service.client.NewRequest("GET", params, "EndUser")
if err != nil {
return
}
response = &EndUserListResponse{}
err = service.client.ExecuteRequest(request, response)
return
}
func (service *EndUserService) Create(params EndUserParams) (response *CreateEndUserResponse, err error) {
request, err := service.client.NewRequest("POST", params, "EndUser")
if err != nil {
return
}
response = &CreateEndUserResponse{}
err = service.client.ExecuteRequest(request, response)
return
}
func (service *EndUserService) Update(params UpdateEndUserParams) (response *UpdateEndUserResponse, err error) {
request, err := service.client.NewRequest("POST", params, "EndUser/%s", params.EndUserID)
if err != nil {
return
}
response = &UpdateEndUserResponse{}
err = service.client.ExecuteRequest(request, response)
return
}
func (service *EndUserService) Delete(endUserId string) (err error) {
req, err := service.client.NewRequest("DELETE", nil, "EndUser/%s", endUserId)
if err != nil {
return
}
err = service.client.ExecuteRequest(req, nil)
return
}