-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathVerifySessionInterface.cs
executable file
·352 lines (328 loc) · 13.7 KB
/
VerifySessionInterface.cs
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Plivo.Client;
namespace Plivo.Resource.VerifySession
{
/// <summary>
/// VerifySession interface.
/// </summary>
public class VerifySessionInterface : ResourceInterface
{
/// <summary>
/// Initializes a new instance of the <see cref="T:plivo.Resource.VerifySession.VerifySessionInterface"/> class.
/// </summary>
/// <param name="client">Client.</param>
public VerifySessionInterface(HttpClient client) : base(client)
{
Uri = "Account/" + Client.GetAuthId() + "/Verify/Session/";
}
#region Create
/// <summary>
/// Create VerifySession with the specified recipient, app_uuid, channel, url, method.
/// </summary>
/// <returns>The create.</returns>
/// <param name="recipient">Recipient.</param>
/// <param name="app_uuid">App UUID.</param>
/// <param name="channel">Channel.</param>
/// <param name="url">URL.</param>
/// <param name="method">Method.</param>
/// <param name="locale">Locale.</param>
/// <param name="brand_name">BrandName.</param>
/// <param name="app_hash">AppHash.</param>
/// <param name="code_length">CodeLength.</param>
/// <param name="dtmf">dtmf.</param>
/// <param name="fraud_check">FraudCheck.</param>
public VerifySessionCreateResponse Create(
string recipient, string app_uuid = null, string channel = null, string url = null,
string method = null, string locale = null, string brand_name = null, string app_hash = null, int code_length = 0, int? dtmf = null, string fraud_check = null)
{
Dictionary<string, object> data = null;
var mandatoryParams = new List<string> { "recipient" };
data = CreateData(
mandatoryParams,
new
{
recipient,
app_uuid,
channel,
url,
method,
locale,
brand_name,
app_hash,
code_length,
dtmf,
fraud_check
});
return ExecuteWithExceptionUnwrap(() =>
{
var result = Task.Run(async () => await Client.Update<VerifySessionCreateResponse>(Uri, data).ConfigureAwait(false)).Result;
result.Object.StatusCode = result.StatusCode;
return result.Object;
});
}
/// <summary>
/// Asynchronously Create VerifySession with the specified recipient, app_uuid, channel, url, method.
/// </summary>
/// <returns>The create.</returns>
/// <param name="recipient">Recipient.</param>
/// <param name="app_uuid">App UUID.</param>
/// <param name="channel">Channel.</param>
/// <param name="url">URL.</param>
/// <param name="method">Method.</param>
/// <param name="locale">Locale.</param>
/// <param name="brand_name">BrandName.</param>
/// <param name="app_hash">AppHash.</param>
/// <param name="code_length">CodeLength.</param>
/// <param name="dtmf">dtmf.</param>
/// <param name="fraud_check">FraudCheck.</param>
public async Task<VerifySessionCreateResponse> CreateAsync(
string recipient, string app_uuid = null, string channel = null, string url = null,
string method = null, string locale = null, string brand_name = null, string app_hash = null, int code_length = 0, int? dtmf = null, string fraud_check = null)
{
Dictionary<string, object> data = null;
var mandatoryParams = new List<string> { "recipient" };
data = CreateData(
mandatoryParams,
new
{
recipient,
app_uuid,
channel,
url,
method,
locale,
brand_name,
app_hash,
code_length,
dtmf,
fraud_check
});
var result = await Client.Update<VerifySessionCreateResponse>(Uri, data);
result.Object.StatusCode = result.StatusCode;
return result.Object;
}
#endregion
#region Get
/// <summary>
/// Get Session with the specified session_uuid.
/// </summary>
/// <returns>The get.</returns>
/// <param name="session_uuid">Session UUID.</param>
public VerifySession Get(string session_uuid)
{
return ExecuteWithExceptionUnwrap(() =>
{
var verify_session = Task.Run(async () => await GetResource<VerifySession>(session_uuid).ConfigureAwait(false)).Result;
verify_session.Interface = this;
return verify_session;
});
}
/// <summary>
/// Asynchronously get Session with the specified session_uuid.
/// </summary>
/// <returns>The get.</returns>
/// <param name="session_uuid">Session UUID.</param>
public async Task<VerifySession> GetAsync(string messageUuid)
{
var message = await GetResource<VerifySession>(messageUuid);
message.Interface = this;
return message;
}
#endregion
#region List
/// <summary>
/// List Session with the specified params.
/// </summary>
/// <returns>The list.</returns>
/// <param name="limit">Limit.</param>
/// <param name="offset">Offset.</param>
/// <param name="status">Status.</param>
/// <param name="recipient">Recipient.</param>
/// <param name="app_uuid">AppUUID.</param>
/// <param name="country">Country.</param>
/// <param name="alias">Alias.</param>
/// <param name="subaccount">Subaccount.</param>
/// <param name="session_time__gt">SessionTimeGT.</param>
/// <param name="session_time__gte">SessionTimeGTE.</param>
/// <param name="session_time__lt">SessionTimeLT.</param>
/// <param name="session_time__lte">SessionTimeLTE.</param>
/// <param name="session_time">SessionTime.</param>
/// <param name="brand_name">BrandName.</param>
/// <param name="app_hash">AppHash.</param>
public VerifySessionListResponse<VerifySession> List(
uint? limit = null,
uint? offset = null,
string status = null,
string recipient = null,
string app_uuid = null,
string country = null,
string alias = null,
string subaccount = null,
string brand_name = null,
string app_hash = null,
DateTime? session_time__gt = null,
DateTime? session_time__gte = null,
DateTime? session_time__lt = null,
DateTime? session_time__lte = null,
DateTime? session_time = null
)
{
var _session_time__gt = session_time__gt?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var _session_time__gte = session_time__gte?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var _session_time__lt = session_time__lt?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var _session_time__lte = session_time__lte?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var _session_time = session_time?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var mandatoryParams = new List<string> { "" };
var data = CreateData(
mandatoryParams, new
{
limit,
offset,
status,
recipient,
app_uuid,
country,
alias,
subaccount,
brand_name,
app_hash,
_session_time__gt,
_session_time__gte,
_session_time__lt,
_session_time__lte,
_session_time
});
return ExecuteWithExceptionUnwrap(() =>
{
var resources = Task.Run(async () => await ListResources<VerifySessionListResponse<VerifySession>>(data).ConfigureAwait(false)).Result;
resources.Sessions.ForEach(
(obj) => obj.Interface = this
);
return resources;
});
}
/// <summary>
/// List Session with the specified params.
/// </summary>
/// <returns>The list.</returns>
/// <param name="limit">Limit.</param>
/// <param name="offset">Offset.</param>
/// <param name="status">Status.</param>
/// <param name="recipient">Recipient.</param>
/// <param name="app_uuid">AppUUID.</param>
/// <param name="country">Country.</param>
/// <param name="alias">Alias.</param>
/// <param name="subaccount">Subaccount.</param>
/// <param name="session_time__gt">SessionTimeGT.</param>
/// <param name="session_time__gte">SessionTimeGTE.</param>
/// <param name="session_time__lt">SessionTimeLT.</param>
/// <param name="session_time__lte">SessionTimeLTE.</param>
/// <param name="session_time">SessionTime.</param>
/// <param name="brand_name">BrandName.</param>
/// <param name="app_hash">AppHash.</param>
public async Task<VerifySessionListResponse<VerifySession>> ListAsync(
uint? limit = null,
uint? offset = null,
string status = null,
string recipient = null,
string app_uuid = null,
string country = null,
string alias = null,
string subaccount = null,
string brand_name = null,
string app_hash = null,
DateTime? session_time__gt = null,
DateTime? session_time__gte = null,
DateTime? session_time__lt = null,
DateTime? session_time__lte = null,
DateTime? session_time = null
)
{
var _session_time__gt = session_time__gt?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var _session_time__gte = session_time__gte?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var _session_time__lt = session_time__lt?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var _session_time__lte = session_time__lte?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var _session_time = session_time?.ToString("yyyy-MM-dd HH':'mm':'ss''") ?? null;
var mandatoryParams = new List<string> { "" };
var data = CreateData(
mandatoryParams, new
{
limit,
offset,
status,
recipient,
app_uuid,
country,
alias,
subaccount,
brand_name,
app_hash,
_session_time__gt,
_session_time__gte,
_session_time__lt,
_session_time__lte,
_session_time
});
var resources = await ListResources<VerifySessionListResponse<VerifySession>>(data);
resources.Sessions.ForEach(
(obj) => obj.Interface = this
);
return resources;
}
#endregion
#region Validate
/// <summary>
/// Validate VerifySession with the specified session_uuid, otp.
/// </summary>
/// <returns>The validate.</returns>
/// <param name="session_uuid">SessionUUID.</param>
/// <param name="otp">OTP.</param>
public VerifySessionCreateResponse Validate(
string session_uuid=null, string otp = null)
{
Dictionary<string, object> data = null;
var mandatoryParams = new List<string> { "session_uuid", "otp" };
data = CreateData(
mandatoryParams,
new
{
session_uuid,
otp
});
return ExecuteWithExceptionUnwrap(() =>
{
var result = Task.Run(async () => await Client.Update<VerifySessionCreateResponse>(Uri+session_uuid+"/", data).ConfigureAwait(false)).Result;
result.Object.StatusCode = result.StatusCode;
return result.Object;
});
}
/// <summary>
/// Asynchronously Validate VerifySession with the specified session_uuid, otp.
/// </summary>
/// <returns>The validate.</returns>
/// <param name="session_uuid">SessionUUID.</param>
/// <param name="otp">OTP.</param>
///
public async Task<VerifySessionCreateResponse> ValidateAsync(
string session_uuid=null, string otp = null)
{
Dictionary<string, object> data = null;
var mandatoryParams = new List<string> { "session_uuid", "otp" };
data = CreateData(
mandatoryParams,
new
{
session_uuid,
otp
});
var result = await Client.Update<VerifySessionCreateResponse>(Uri+session_uuid+"/", data);
result.Object.StatusCode = result.StatusCode;
return result.Object;
}
#endregion
}
}