-
Notifications
You must be signed in to change notification settings - Fork 23
/
verify.go
135 lines (120 loc) · 4.67 KB
/
verify.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package plivo
import (
"time"
)
type VerifyService struct {
client *Client
Session
}
type SessionList struct {
APIID string `json:"api_id"`
Meta struct {
Limit int `json:"limit"`
Offset int `json:"offset"`
Next *string `json:"next"`
Previous *string `json:"previous"`
} `json:"meta"`
Sessions []Session `json:"sessions"`
}
type Session struct {
APIID string `json:"api_id,omitempty"`
SessionUUID string `json:"session_uuid,omitempty"`
AppUUID string `json:"app_uuid,omitempty"`
Alias string `json:"alias,omitempty"`
Recipient string `json:"recipient,omitempty"`
Channel string `json:"channel,omitempty"`
Status string `json:"status,omitempty"`
Count int `json:"count,omitempty"`
RequesterIP string `json:"requestor_ip,omitempty"`
CountryISO string `json:"destination_country_iso2,omitempty"`
DestinationNetwork *string `json:"destination_network,omitempty"`
AttemptDetails []AttemptDetails `json:"attempt_details,omitempty"`
Charges Charges `json:"charges,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
type AttemptDetails struct {
Channel string `json:"channel,omitempty"`
AttemptUUID string `json:"attempt_uuid,omitempty"`
Status string `json:"status,omitempty"`
Time time.Time `json:"time,omitempty"`
}
type Charges struct {
TotalCharge string `json:"total_charge,omitempty"`
ValidationCharge string `json:"validation_charge,omitempty"`
AttemptCharges []AttemptCharges `json:"attempt_charges,omitempty"`
}
type AttemptCharges struct {
AttemptUUID string `json:"attempt_uuid,omitempty"`
Channel string `json:"channel,omitempty"`
Charge string `json:"charge,omitempty"`
}
type SessionCreateParams struct {
Recipient string `json:"recipient,omitempty"`
// Optional parameters.
AppUUID string `json:"app_uuid,omitempty"`
Channel string `json:"channel,omitempty"`
URL string `json:"url,omitempty"`
Method string `json:"method,omitempty"`
Src string `json:"src,omitempty"`
}
type SessionCreateResponseBody struct {
APIID string `json:"api_id,omitempty"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
SessionUUID string `json:"session_uuid,omitempty"`
}
type SessionValidationParams struct {
OTP string `json:"otp,omitempty"`
}
type SessionListParams struct {
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
Status string `url:"status,omitempty"`
Recipient string `url:"recipient,omitempty"`
AppUUID string `url:"app_uuid,omitempty"`
Country string `url:"country,omitempty"`
Alias string `url:"alias,omitempty"`
SessionTime string `url:"session_time,omitempty"`
Subaccount string `url:"subaccount,omitempty"`
SessionTimeGreaterThan string `url:"session_time__gt,omitempty"`
SessionTimeGreaterOrEqual string `url:"session_time__gte,omitempty"`
SessionTimeLessThan string `url:"session_time__lt,omitempty"`
SessionTimeLessOrEqual string `url:"session_time__lte,omitempty"`
}
func (service *VerifyService) Create(params SessionCreateParams) (response *SessionCreateResponseBody, err error) {
req, err := service.client.NewRequest("POST", params, "Verify/Session")
if err != nil {
return
}
response = &SessionCreateResponseBody{}
err = service.client.ExecuteRequest(req, response)
return
}
func (service *VerifyService) Get(sessionUUID string) (response *Session, err error) {
req, err := service.client.NewRequest("GET", nil, "Verify/Session/%s", sessionUUID)
if err != nil {
return
}
response = &Session{}
err = service.client.ExecuteRequest(req, response)
return
}
func (service *VerifyService) List(params SessionListParams) (response *SessionList, err error) {
req, err := service.client.NewRequest("GET", params, "Verify/Session")
if err != nil {
return
}
response = &SessionList{}
err = service.client.ExecuteRequest(req, response)
return
}
func (service *VerifyService) Validate(params SessionValidationParams, sessionUUID string) (response *SessionCreateResponseBody, err error) {
req, err := service.client.NewRequest("POST", params, "Verify/Session/%s", sessionUUID)
if err != nil {
return
}
response = &SessionCreateResponseBody{}
err = service.client.ExecuteRequest(req, response)
return
}