twilio-ruby 7.10.3 → 7.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,940 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Sample/reference Twilio API.
8
+ # This is the reference API for the rest-proxy server.
9
+ #
10
+ # NOTE: This class is auto generated by OpenAPI Generator.
11
+ # https://openapi-generator.tech
12
+ # Do not edit the class manually.
13
+ #
14
+
15
+
16
+ module Twilio
17
+ module REST
18
+ class Insights < InsightsBase
19
+ class V2 < Version
20
+ class ReportList < ListResource
21
+
22
+ class AccountReportAnsweringMachineDetection
23
+ # @param [total_calls]: [Integer] Total number of calls with answering machine detection enabled (AMD).
24
+ # @param [answered_by_human_percentage]: [Float] Percentage of calls marked as answered by human.
25
+ # @param [answered_by_machine_percentage]: [Float] Percentage of calls marked as answered by machined related like the following: `machine_start`, `machine_end_beep`, `machine_end_silence`, `machine_end_other`, `fax`
26
+ attr_accessor :total_calls, :answered_by_human_percentage, :answered_by_machine_percentage
27
+ def initialize(payload)
28
+ @total_calls = payload["total_calls"]
29
+ @answered_by_human_percentage = payload["answered_by_human_percentage"]
30
+ @answered_by_machine_percentage = payload["answered_by_machine_percentage"]
31
+ end
32
+ def to_json(options = {})
33
+ {
34
+ "total_calls": @total_calls,
35
+ "answered_by_human_percentage": @answered_by_human_percentage,
36
+ "answered_by_machine_percentage": @answered_by_machine_percentage,
37
+ }.to_json(options)
38
+ end
39
+ end
40
+
41
+ class AccountReportCallDirection
42
+ # @param [outbound]: [Integer] Number of outbound calls
43
+ # @param [inbound]: [Integer] Number of inbound calls
44
+ attr_accessor :outbound, :inbound
45
+ def initialize(payload)
46
+ @outbound = payload["outbound"]
47
+ @inbound = payload["inbound"]
48
+ end
49
+ def to_json(options = {})
50
+ {
51
+ "outbound": @outbound,
52
+ "inbound": @inbound,
53
+ }.to_json(options)
54
+ end
55
+ end
56
+
57
+ class AccountReportCallState
58
+ # @param [completed]: [Integer] Number of completed calls
59
+ # @param [fail]: [Integer] Number of failed calls
60
+ # @param [busy]: [Integer] Number of busy calls
61
+ # @param [noanswer]: [Integer] Number of no-answer calls
62
+ # @param [canceled]: [Integer] Number of canceled calls
63
+ attr_accessor :completed, :fail, :busy, :noanswer, :canceled
64
+ def initialize(payload)
65
+ @completed = payload["completed"]
66
+ @fail = payload["fail"]
67
+ @busy = payload["busy"]
68
+ @noanswer = payload["noanswer"]
69
+ @canceled = payload["canceled"]
70
+ end
71
+ def to_json(options = {})
72
+ {
73
+ "completed": @completed,
74
+ "fail": @fail,
75
+ "busy": @busy,
76
+ "noanswer": @noanswer,
77
+ "canceled": @canceled,
78
+ }.to_json(options)
79
+ end
80
+ end
81
+
82
+ class AccountReportCallType
83
+ # @param [carrier]: [Integer] Number of carrier calls
84
+ # @param [sip]: [Integer] Number of SIP calls
85
+ # @param [trunking]: [Integer] Number of trunking calls
86
+ # @param [client]: [Integer] Number of client calls
87
+ # @param [whatsapp]: [Integer] Number of WhatsApp Business calls
88
+ attr_accessor :carrier, :sip, :trunking, :client, :whatsapp
89
+ def initialize(payload)
90
+ @carrier = payload["carrier"]
91
+ @sip = payload["sip"]
92
+ @trunking = payload["trunking"]
93
+ @client = payload["client"]
94
+ @whatsapp = payload["whatsapp"]
95
+ end
96
+ def to_json(options = {})
97
+ {
98
+ "carrier": @carrier,
99
+ "sip": @sip,
100
+ "trunking": @trunking,
101
+ "client": @client,
102
+ "whatsapp": @whatsapp,
103
+ }.to_json(options)
104
+ end
105
+ end
106
+
107
+ class AccountReportKYT
108
+ # @param [outbound_carrier_calling]: [AccountReportKYTOutboundCarrierCalling]
109
+ attr_accessor :outbound_carrier_calling
110
+ def initialize(payload)
111
+ @outbound_carrier_calling = payload["outbound_carrier_calling"]
112
+ end
113
+ def to_json(options = {})
114
+ {
115
+ "outbound_carrier_calling": @outbound_carrier_calling,
116
+ }.to_json(options)
117
+ end
118
+ end
119
+
120
+ class AccountReportKYTOutboundCarrierCalling
121
+ # @param [unique_calling_numbers]: [Integer] Number of unique PSTN calling numbers to non-Twilio numbers during the report period.
122
+ # @param [unique_called_numbers]: [Integer] Number of unique non-Twilio PSTN called numbers during the report period.
123
+ # @param [blocked_calls_by_carrier]: [Array<CountyCarrierValue>] Percentage of blocked calls by carrier per country.
124
+ # @param [short_duration_calls_percentage]: [Float] Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured.
125
+ # @param [long_duration_calls_percentage]: [Float] Percentage of long duration calls ( >= 60 seconds)
126
+ # @param [potential_robocalls_percentage]: [Float] Percentage of completed outbound calls to unassigned or unallocated phone numbers.
127
+ # @param [branded_calling]: [BrandedCalling]
128
+ # @param [voice_integrity]: [VoiceIntegrity]
129
+ # @param [stir_shaken]: [StirShaken]
130
+ attr_accessor :unique_calling_numbers, :unique_called_numbers, :blocked_calls_by_carrier, :short_duration_calls_percentage, :long_duration_calls_percentage, :potential_robocalls_percentage, :branded_calling, :voice_integrity, :stir_shaken
131
+ def initialize(payload)
132
+ @unique_calling_numbers = payload["unique_calling_numbers"]
133
+ @unique_called_numbers = payload["unique_called_numbers"]
134
+ @blocked_calls_by_carrier = payload["blocked_calls_by_carrier"]
135
+ @short_duration_calls_percentage = payload["short_duration_calls_percentage"]
136
+ @long_duration_calls_percentage = payload["long_duration_calls_percentage"]
137
+ @potential_robocalls_percentage = payload["potential_robocalls_percentage"]
138
+ @branded_calling = payload["branded_calling"]
139
+ @voice_integrity = payload["voice_integrity"]
140
+ @stir_shaken = payload["stir_shaken"]
141
+ end
142
+ def to_json(options = {})
143
+ {
144
+ "unique_calling_numbers": @unique_calling_numbers,
145
+ "unique_called_numbers": @unique_called_numbers,
146
+ "blocked_calls_by_carrier": @blocked_calls_by_carrier,
147
+ "short_duration_calls_percentage": @short_duration_calls_percentage,
148
+ "long_duration_calls_percentage": @long_duration_calls_percentage,
149
+ "potential_robocalls_percentage": @potential_robocalls_percentage,
150
+ "branded_calling": @branded_calling,
151
+ "voice_integrity": @voice_integrity,
152
+ "stir_shaken": @stir_shaken,
153
+ }.to_json(options)
154
+ end
155
+ end
156
+
157
+ class AccountReportNetworkIssues
158
+ # @param [sdk]: [AccountReportNetworkIssuesSdk]
159
+ # @param [twilio_gateway]: [AccountReportNetworkIssuesTwilioGateway]
160
+ attr_accessor :sdk, :twilio_gateway
161
+ def initialize(payload)
162
+ @sdk = payload["sdk"]
163
+ @twilio_gateway = payload["twilio_gateway"]
164
+ end
165
+ def to_json(options = {})
166
+ {
167
+ "sdk": @sdk,
168
+ "twilio_gateway": @twilio_gateway,
169
+ }.to_json(options)
170
+ end
171
+ end
172
+
173
+ class AccountReportNetworkIssuesSdk
174
+ # @param [ice_failures_percentage]: [Float] Percentage of ICE connection failure tag that ICE candidates have failed to find compatible connection.
175
+ # @param [high_latency_percentage]: [Float] Percentage of calls with high latency.
176
+ # @param [high_packet_loss_percentage]: [Float] Percentage of calls with high packet loss.
177
+ # @param [high_jitter_percentage]: [Float] Percentage of calls with high jitter.
178
+ attr_accessor :ice_failures_percentage, :high_latency_percentage, :high_packet_loss_percentage, :high_jitter_percentage
179
+ def initialize(payload)
180
+ @ice_failures_percentage = payload["ice_failures_percentage"]
181
+ @high_latency_percentage = payload["high_latency_percentage"]
182
+ @high_packet_loss_percentage = payload["high_packet_loss_percentage"]
183
+ @high_jitter_percentage = payload["high_jitter_percentage"]
184
+ end
185
+ def to_json(options = {})
186
+ {
187
+ "ice_failures_percentage": @ice_failures_percentage,
188
+ "high_latency_percentage": @high_latency_percentage,
189
+ "high_packet_loss_percentage": @high_packet_loss_percentage,
190
+ "high_jitter_percentage": @high_jitter_percentage,
191
+ }.to_json(options)
192
+ end
193
+ end
194
+
195
+ class AccountReportNetworkIssuesTwilioGateway
196
+ # @param [high_latency_percentage]: [Float] Percentage of calls with high latency.
197
+ # @param [high_packet_loss_percentage]: [Float] Percentage of calls with high packet loss.
198
+ # @param [high_jitter_percentage]: [Float] Percentage of calls with high jitter.
199
+ attr_accessor :high_latency_percentage, :high_packet_loss_percentage, :high_jitter_percentage
200
+ def initialize(payload)
201
+ @high_latency_percentage = payload["high_latency_percentage"]
202
+ @high_packet_loss_percentage = payload["high_packet_loss_percentage"]
203
+ @high_jitter_percentage = payload["high_jitter_percentage"]
204
+ end
205
+ def to_json(options = {})
206
+ {
207
+ "high_latency_percentage": @high_latency_percentage,
208
+ "high_packet_loss_percentage": @high_packet_loss_percentage,
209
+ "high_jitter_percentage": @high_jitter_percentage,
210
+ }.to_json(options)
211
+ end
212
+ end
213
+
214
+ class BrandedCalling
215
+ # @param [total_branded_calls]: [Integer] Total number of Branded bundled calls.
216
+ # @param [percent_branded_calls]: [Float] Percentage of Branded bundled calls over total outbound calls.
217
+ # @param [answer_rate]: [Float] Answer rate for Branded bundled calls.
218
+ # @param [human_answer_rate]: [Float] Rate of Branded bundled calls that were answered by Human.
219
+ # @param [engagement_rate]: [Float] Engagement Rate for Branded bundled calls where its call length is longer than 60 seconds.
220
+ # @param [by_use_case]: [Array<BrandedUseCaseDetail>] Details of branded calls by use case.
221
+ attr_accessor :total_branded_calls, :percent_branded_calls, :answer_rate, :human_answer_rate, :engagement_rate, :by_use_case
222
+ def initialize(payload)
223
+ @total_branded_calls = payload["total_branded_calls"]
224
+ @percent_branded_calls = payload["percent_branded_calls"]
225
+ @answer_rate = payload["answer_rate"]
226
+ @human_answer_rate = payload["human_answer_rate"]
227
+ @engagement_rate = payload["engagement_rate"]
228
+ @by_use_case = payload["by_use_case"]
229
+ end
230
+ def to_json(options = {})
231
+ {
232
+ "total_branded_calls": @total_branded_calls,
233
+ "percent_branded_calls": @percent_branded_calls,
234
+ "answer_rate": @answer_rate,
235
+ "human_answer_rate": @human_answer_rate,
236
+ "engagement_rate": @engagement_rate,
237
+ "by_use_case": @by_use_case,
238
+ }.to_json(options)
239
+ end
240
+ end
241
+
242
+ class BrandedUseCaseDetail
243
+ # @param [use_case]: [String] The name of supported use case for Branded calls.
244
+ # @param [enabled_phonenumbers]: [Integer] The number of phone numbers enabled Branded calls.
245
+ # @param [total_calls]: [Integer] The number of total outbound calls for the use case.
246
+ # @param [answer_rate]: [Float] Answer rate per each use case for Branded bundled calls.
247
+ # @param [human_answer_rate]: [Float] Rate of Branded bundled calls that were answered by Human per each use case for Branded bundled calls.
248
+ # @param [engagement_rate]: [Float] Engagement Rate for Branded bundled calls where its call length is longer than 60 seconds per each use case for Branded bundled calls.
249
+ attr_accessor :use_case, :enabled_phonenumbers, :total_calls, :answer_rate, :human_answer_rate, :engagement_rate
250
+ def initialize(payload)
251
+ @use_case = payload["use_case"]
252
+ @enabled_phonenumbers = payload["enabled_phonenumbers"]
253
+ @total_calls = payload["total_calls"]
254
+ @answer_rate = payload["answer_rate"]
255
+ @human_answer_rate = payload["human_answer_rate"]
256
+ @engagement_rate = payload["engagement_rate"]
257
+ end
258
+ def to_json(options = {})
259
+ {
260
+ "use_case": @use_case,
261
+ "enabled_phonenumbers": @enabled_phonenumbers,
262
+ "total_calls": @total_calls,
263
+ "answer_rate": @answer_rate,
264
+ "human_answer_rate": @human_answer_rate,
265
+ "engagement_rate": @engagement_rate,
266
+ }.to_json(options)
267
+ end
268
+ end
269
+
270
+ class CountyCarrierValueCarriers
271
+ # @param [carrier]: [String] The name of the carrier.
272
+ # @param [total_calls]: [Integer] Total number of outbound calls for the carrier in the country.
273
+ # @param [blocked_calls]: [Integer] Total number of blocked outbound calls for the carrier in the country.
274
+ # @param [blocked_calls_percentage]: [Float] Percentage of blocked outbound calls for the carrier in the country.
275
+ attr_accessor :carrier, :total_calls, :blocked_calls, :blocked_calls_percentage
276
+ def initialize(payload)
277
+ @carrier = payload["carrier"]
278
+ @total_calls = payload["total_calls"]
279
+ @blocked_calls = payload["blocked_calls"]
280
+ @blocked_calls_percentage = payload["blocked_calls_percentage"]
281
+ end
282
+ def to_json(options = {})
283
+ {
284
+ "carrier": @carrier,
285
+ "total_calls": @total_calls,
286
+ "blocked_calls": @blocked_calls,
287
+ "blocked_calls_percentage": @blocked_calls_percentage,
288
+ }.to_json(options)
289
+ end
290
+ end
291
+
292
+ class InsightsV2CreateAccountReportRequest
293
+ # @param [time_range]: [ReportList.InsightsV2CreateAccountReportRequestTimeRange]
294
+ # @param [filters]: [Array<ReportList.ReportFilter>]
295
+ attr_accessor :time_range, :filters
296
+ def initialize(payload)
297
+ @time_range = payload["time_range"]
298
+ @filters = payload["filters"]
299
+ end
300
+ def to_json(options = {})
301
+ {
302
+ "time_range": @time_range,
303
+ "filters": @filters,
304
+ }.to_json(options)
305
+ end
306
+ end
307
+
308
+ class InsightsV2CreateAccountReportRequestTimeRange
309
+ # @param [start_time]: [Time] Start time of the report
310
+ # @param [end_time]: [Time] End time of the report
311
+ attr_accessor :start_time, :end_time
312
+ def initialize(payload)
313
+ @start_time = payload["start_time"]
314
+ @end_time = payload["end_time"]
315
+ end
316
+ def to_json(options = {})
317
+ {
318
+ "start_time": @start_time,
319
+ "end_time": @end_time,
320
+ }.to_json(options)
321
+ end
322
+ end
323
+
324
+ class ReportFilter
325
+ # @param [key]: [String] The name of the filter 'call_state', 'call_direction', 'call_type', 'twilio_regions', 'caller_country_code', 'callee_country_code', 'silent'
326
+ # @param [values]: [Array<String>] List of supported filter values for the field name
327
+ attr_accessor :key, :values
328
+ def initialize(payload)
329
+ @key = payload["key"]
330
+ @values = payload["values"]
331
+ end
332
+ def to_json(options = {})
333
+ {
334
+ "key": @key,
335
+ "values": @values,
336
+ }.to_json(options)
337
+ end
338
+ end
339
+
340
+ class StirShaken
341
+ # @param [call_count]: [StirShakenCallCount]
342
+ # @param [percentage]: [StirShakenPercentage]
343
+ # @param [answer_rate]: [StirShakenAnswerRate]
344
+ attr_accessor :call_count, :percentage, :answer_rate
345
+ def initialize(payload)
346
+ @call_count = payload["call_count"]
347
+ @percentage = payload["percentage"]
348
+ @answer_rate = payload["answer_rate"]
349
+ end
350
+ def to_json(options = {})
351
+ {
352
+ "call_count": @call_count,
353
+ "percentage": @percentage,
354
+ "answer_rate": @answer_rate,
355
+ }.to_json(options)
356
+ end
357
+ end
358
+
359
+ class StirShakenAnswerRate
360
+ # @param [stsh_a]: [Float] Answer rate for Stir Shaken category A.
361
+ # @param [stsh_b]: [Float] Answer rate for Stir Shaken category B.
362
+ # @param [stsh_c]: [Float] Answer rate for Stir Shaken category C.
363
+ attr_accessor :stsh_a, :stsh_b, :stsh_c
364
+ def initialize(payload)
365
+ @stsh_a = payload["stsh_a"]
366
+ @stsh_b = payload["stsh_b"]
367
+ @stsh_c = payload["stsh_c"]
368
+ end
369
+ def to_json(options = {})
370
+ {
371
+ "stsh_a": @stsh_a,
372
+ "stsh_b": @stsh_b,
373
+ "stsh_c": @stsh_c,
374
+ }.to_json(options)
375
+ end
376
+ end
377
+
378
+ class StirShakenCallCount
379
+ # @param [stsh_a]: [Integer] Total number of calls for Stir Shaken category A.
380
+ # @param [stsh_b]: [Integer] Total number of calls for Stir Shaken category B.
381
+ # @param [stsh_c]: [Integer] Total number of calls for Stir Shaken category C.
382
+ attr_accessor :stsh_a, :stsh_b, :stsh_c
383
+ def initialize(payload)
384
+ @stsh_a = payload["stsh_a"]
385
+ @stsh_b = payload["stsh_b"]
386
+ @stsh_c = payload["stsh_c"]
387
+ end
388
+ def to_json(options = {})
389
+ {
390
+ "stsh_a": @stsh_a,
391
+ "stsh_b": @stsh_b,
392
+ "stsh_c": @stsh_c,
393
+ }.to_json(options)
394
+ end
395
+ end
396
+
397
+ class StirShakenPercentage
398
+ # @param [stsh_a]: [Float] Percentage of calls for Stir Shaken category A.
399
+ # @param [stsh_b]: [Float] Percentage of calls for Stir Shaken category B.
400
+ # @param [stsh_c]: [Float] Percentage of calls for Stir Shaken category C.
401
+ attr_accessor :stsh_a, :stsh_b, :stsh_c
402
+ def initialize(payload)
403
+ @stsh_a = payload["stsh_a"]
404
+ @stsh_b = payload["stsh_b"]
405
+ @stsh_c = payload["stsh_c"]
406
+ end
407
+ def to_json(options = {})
408
+ {
409
+ "stsh_a": @stsh_a,
410
+ "stsh_b": @stsh_b,
411
+ "stsh_c": @stsh_c,
412
+ }.to_json(options)
413
+ end
414
+ end
415
+
416
+ class VoiceIntegrity
417
+ # @param [enabled_calls]: [Integer] Total number of calls with Voice Integrity enabled.
418
+ # @param [enabled_percentage]: [Float] Percentage of calls with Voice Integrity enabled.
419
+ # @param [calls_per_bundle]: [Array<VoiceIntegrityCallsPerBundle>] Number of calls per Voice Integrity enabled Bundle Sid.
420
+ attr_accessor :enabled_calls, :enabled_percentage, :calls_per_bundle
421
+ def initialize(payload)
422
+ @enabled_calls = payload["enabled_calls"]
423
+ @enabled_percentage = payload["enabled_percentage"]
424
+ @calls_per_bundle = payload["calls_per_bundle"]
425
+ end
426
+ def to_json(options = {})
427
+ {
428
+ "enabled_calls": @enabled_calls,
429
+ "enabled_percentage": @enabled_percentage,
430
+ "calls_per_bundle": @calls_per_bundle,
431
+ }.to_json(options)
432
+ end
433
+ end
434
+
435
+ class VoiceIntegrityCallsPerBundle
436
+ # @param [bundle_sid]: [String] Voice Integrity Approved Profile Sid.
437
+ # @param [enabled_phonenumbers]: [Integer] The number of Voice Integrity enabled and registered phone numbers per Bundle Sid.
438
+ # @param [total_calls]: [Integer] The number of outbound calls on Voice Integrity enabled and registered number per Bundle Sid.
439
+ # @param [answer_rate]: [Float] Answer rate for calls on Voice Integrity enabled and registered number per Bundle Sid.
440
+ # @param [human_answer_rate]: [Float] Rate for calls on Voice Integrity enabled and registered number per Bundle Sid that were answered by Human per each use case for Branded bundled calls.
441
+ attr_accessor :bundle_sid, :enabled_phonenumbers, :total_calls, :answer_rate, :human_answer_rate
442
+ def initialize(payload)
443
+ @bundle_sid = payload["bundle_sid"]
444
+ @enabled_phonenumbers = payload["enabled_phonenumbers"]
445
+ @total_calls = payload["total_calls"]
446
+ @answer_rate = payload["answer_rate"]
447
+ @human_answer_rate = payload["human_answer_rate"]
448
+ end
449
+ def to_json(options = {})
450
+ {
451
+ "bundle_sid": @bundle_sid,
452
+ "enabled_phonenumbers": @enabled_phonenumbers,
453
+ "total_calls": @total_calls,
454
+ "answer_rate": @answer_rate,
455
+ "human_answer_rate": @human_answer_rate,
456
+ }.to_json(options)
457
+ end
458
+ end
459
+
460
+
461
+ ##
462
+ # Initialize the ReportList
463
+ # @param [Version] version Version that contains the resource
464
+ # @return [ReportList] ReportList
465
+ def initialize(version)
466
+ super(version)
467
+
468
+ # Path Solution
469
+ @solution = { }
470
+
471
+
472
+ end
473
+
474
+
475
+
476
+ # Provide a user friendly representation
477
+ def to_s
478
+ '#<Twilio.Insights.V2.ReportList>'
479
+ end
480
+ end
481
+
482
+
483
+ class ReportContext < InstanceContext
484
+ ##
485
+ # Initialize the ReportContext
486
+ # @param [Version] version Version that contains the resource
487
+ # @param [String] report_id A unique request id.
488
+ # @return [ReportContext] ReportContext
489
+ def initialize(version, report_id)
490
+ super(version)
491
+
492
+
493
+ # Path Solution
494
+ @solution = { report_id: report_id, }
495
+ @uri = "/Voice/Reports/#{@solution[:report_id]}"
496
+
497
+
498
+ end
499
+ ##
500
+ # Create the ReportInstance
501
+ # @param [InsightsV2CreateAccountReportRequest] insights_v2_create_account_report_request
502
+ # @return [ReportInstance] Created ReportInstance
503
+ def create(insights_v2_create_account_report_request: :unset
504
+ )
505
+
506
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
507
+ headers['Content-Type'] = 'application/json'
508
+
509
+
510
+
511
+
512
+ payload = @version.create('POST', @uri, headers: headers, data: insights_v2_create_account_report_request.to_json)
513
+ ReportInstance.new(
514
+ @version,
515
+ payload,
516
+ report_id: @solution[:report_id],
517
+ )
518
+ end
519
+
520
+ ##
521
+ # Create the ReportInstanceMetadata
522
+ # @param [InsightsV2CreateAccountReportRequest] insights_v2_create_account_report_request
523
+ # @return [ReportInstance] Created ReportInstance
524
+ def create_with_metadata(insights_v2_create_account_report_request: :unset
525
+ )
526
+
527
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
528
+ headers['Content-Type'] = 'application/json'
529
+
530
+
531
+
532
+
533
+ response = @version.create_with_metadata('POST', @uri, headers: headers, data: insights_v2_create_account_report_request.to_json)
534
+ report_instance = ReportInstance.new(
535
+ @version,
536
+ response.body,
537
+ report_id: @solution[:report_id],
538
+ )
539
+ ReportInstanceMetadata.new(
540
+ @version,
541
+ report_instance,
542
+ response.headers,
543
+ response.status_code
544
+ )
545
+ end
546
+
547
+ ##
548
+ # Fetch the ReportInstance
549
+ # @return [ReportInstance] Fetched ReportInstance
550
+ def fetch
551
+
552
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
553
+
554
+
555
+
556
+
557
+
558
+ payload = @version.fetch('GET', @uri, headers: headers)
559
+ ReportInstance.new(
560
+ @version,
561
+ payload,
562
+ report_id: @solution[:report_id],
563
+ )
564
+ end
565
+
566
+ ##
567
+ # Fetch the ReportInstanceMetadata
568
+ # @return [ReportInstance] Fetched ReportInstance
569
+ def fetch_with_metadata
570
+
571
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
572
+
573
+
574
+
575
+
576
+
577
+ response = @version.fetch_with_metadata('GET', @uri, headers: headers)
578
+ report_instance = ReportInstance.new(
579
+ @version,
580
+ response.body,
581
+ report_id: @solution[:report_id],
582
+ )
583
+ ReportInstanceMetadata.new(
584
+ @version,
585
+ report_instance,
586
+ response.headers,
587
+ response.status_code
588
+ )
589
+ end
590
+
591
+
592
+ ##
593
+ # Provide a user friendly representation
594
+ def to_s
595
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
596
+ "#<Twilio.Insights.V2.ReportContext #{context}>"
597
+ end
598
+
599
+ ##
600
+ # Provide a detailed, user friendly representation
601
+ def inspect
602
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
603
+ "#<Twilio.Insights.V2.ReportContext #{context}>"
604
+ end
605
+ end
606
+
607
+ class ReportInstanceMetadata < InstanceResourceMetadata
608
+ ##
609
+ # Initializes a new ReportInstanceMetadata.
610
+ # @param [Version] version Version that contains the resource
611
+ # @param [}ReportInstance] report_instance The instance associated with the metadata.
612
+ # @param [Hash] headers Header object with response headers.
613
+ # @param [Integer] status_code The HTTP status code of the response.
614
+ # @return [ReportInstanceMetadata] The initialized instance with metadata.
615
+ def initialize(version, report_instance, headers, status_code)
616
+ super(version, headers, status_code)
617
+ @report_instance = report_instance
618
+ end
619
+
620
+ def report
621
+ @report_instance
622
+ end
623
+
624
+ def headers
625
+ @headers
626
+ end
627
+
628
+ def status_code
629
+ @status_code
630
+ end
631
+
632
+ def to_s
633
+ "<Twilio.Api.V2010.ReportInstanceMetadata status=#{@status_code}>"
634
+ end
635
+ end
636
+
637
+ class ReportListResponse < InstanceListResource
638
+ # @param [Array<ReportInstance>] instance
639
+ # @param [Hash{String => Object}] headers
640
+ # @param [Integer] status_code
641
+ def initialize(version, payload, key)
642
+ @report_instance = payload.body[key].map do |data|
643
+ ReportInstance.new(version, data)
644
+ end
645
+ @headers = payload.headers
646
+ @status_code = payload.status_code
647
+ end
648
+
649
+ def report_instance
650
+ @instance
651
+ end
652
+ end
653
+
654
+ class ReportPage < Page
655
+ ##
656
+ # Initialize the ReportPage
657
+ # @param [Version] version Version that contains the resource
658
+ # @param [Response] response Response from the API
659
+ # @param [Hash] solution Path solution for the resource
660
+ # @return [ReportPage] ReportPage
661
+ def initialize(version, response, solution)
662
+ super(version, response)
663
+
664
+
665
+ # Path Solution
666
+ @solution = solution
667
+ end
668
+
669
+ ##
670
+ # Build an instance of ReportInstance
671
+ # @param [Hash] payload Payload response from the API
672
+ # @return [ReportInstance] ReportInstance
673
+ def get_instance(payload)
674
+ ReportInstance.new(@version, payload)
675
+ end
676
+
677
+ ##
678
+ # Provide a user friendly representation
679
+ def to_s
680
+ '<Twilio.Insights.V2.ReportPage>'
681
+ end
682
+ end
683
+
684
+ class ReportPageMetadata < PageMetadata
685
+ attr_reader :report_page
686
+
687
+ def initialize(version, response, solution, limit)
688
+ super(version, response)
689
+ @report_page = []
690
+ @limit = limit
691
+ key = get_key(response.body)
692
+ records = 0
693
+ while( limit != :unset && records < limit )
694
+ @report_page << ReportListResponse.new(version, @payload, key, limit - records)
695
+ @payload = self.next_page
696
+ break unless @payload
697
+ records += @payload.body[key].size
698
+ end
699
+ # Path Solution
700
+ @solution = solution
701
+ end
702
+
703
+ def each
704
+ @report_page.each do |record|
705
+ yield record
706
+ end
707
+ end
708
+
709
+ def to_s
710
+ '<Twilio::REST::Insights::V2PageMetadata>';
711
+ end
712
+ end
713
+ class ReportListResponse < InstanceListResource
714
+
715
+ # @param [Array<ReportInstance>] instance
716
+ # @param [Hash{String => Object}] headers
717
+ # @param [Integer] status_code
718
+ def initialize(version, payload, key, limit = :unset)
719
+ data_list = payload.body[key]
720
+ if limit != :unset
721
+ data_list = data_list[0, limit]
722
+ end
723
+ @report = data_list.map do |data|
724
+ ReportInstance.new(version, data)
725
+ end
726
+ @headers = payload.headers
727
+ @status_code = payload.status_code
728
+ end
729
+
730
+ def report
731
+ @report
732
+ end
733
+
734
+ def headers
735
+ @headers
736
+ end
737
+
738
+ def status_code
739
+ @status_code
740
+ end
741
+ end
742
+
743
+ class ReportInstance < InstanceResource
744
+ ##
745
+ # Initialize the ReportInstance
746
+ # @param [Version] version Version that contains the resource
747
+ # @param [Hash] payload payload that contains response from Twilio
748
+ # @param [String] account_sid The SID of the
749
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Report
750
+ # resource.
751
+ # @param [String] sid The SID of the Call resource to fetch.
752
+ # @return [ReportInstance] ReportInstance
753
+ def initialize(version, payload , report_id: nil)
754
+ super(version)
755
+
756
+
757
+ # Marshaled Properties
758
+ @properties = {
759
+ 'account_sid' => payload['account_sid'],
760
+ 'report_id' => payload['report_id'],
761
+ 'status' => payload['status'],
762
+ 'request_meta' => payload['request_meta'],
763
+ 'url' => payload['url'],
764
+ 'handle' => payload['handle'],
765
+ 'total_calls' => payload['total_calls'] == nil ? payload['total_calls'] : payload['total_calls'].to_i,
766
+ 'call_answer_score' => payload['call_answer_score'],
767
+ 'call_state_percentage' => payload['call_state_percentage'],
768
+ 'silent_calls_percentage' => payload['silent_calls_percentage'],
769
+ 'calls_by_device_type' => payload['calls_by_device_type'],
770
+ 'answer_rate_device_type' => payload['answer_rate_device_type'],
771
+ 'blocked_calls_by_carrier' => payload['blocked_calls_by_carrier'],
772
+ 'short_duration_calls_percentage' => payload['short_duration_calls_percentage'],
773
+ 'long_duration_calls_percentage' => payload['long_duration_calls_percentage'],
774
+ 'potential_robocalls_percentage' => payload['potential_robocalls_percentage'],
775
+ 'answering_machine_detection' => payload['answering_machine_detection'],
776
+ 'report' => payload['report'],
777
+ }
778
+
779
+ # Context
780
+ @instance_context = nil
781
+ @params = { 'report_id' => report_id || @properties['report_id'] , }
782
+ end
783
+
784
+ ##
785
+ # Generate an instance context for the instance, the context is capable of
786
+ # performing various actions. All instance actions are proxied to the context
787
+ # @return [ReportContext] CallContext for this CallInstance
788
+ def context
789
+ unless @instance_context
790
+ @instance_context = ReportContext.new(@version , @params['report_id'])
791
+ end
792
+ @instance_context
793
+ end
794
+
795
+ ##
796
+ # @return [String] The unique SID identifier of the Account.
797
+ def account_sid
798
+ @properties['account_sid']
799
+ end
800
+
801
+ ##
802
+ # @return [String] The report identifier as Voice Insights Report TTID.
803
+ def report_id
804
+ @properties['report_id']
805
+ end
806
+
807
+ ##
808
+ # @return [ReportStatus]
809
+ def status
810
+ @properties['status']
811
+ end
812
+
813
+ ##
814
+ # @return [ReportMetadata]
815
+ def request_meta
816
+ @properties['request_meta']
817
+ end
818
+
819
+ ##
820
+ # @return [String] The URL of this resource.
821
+ def url
822
+ @properties['url']
823
+ end
824
+
825
+ ##
826
+ # @return [String] Inbound phone number handle represented in the report.
827
+ def handle
828
+ @properties['handle']
829
+ end
830
+
831
+ ##
832
+ # @return [String] Total number of calls made with the given handle during the report period.
833
+ def total_calls
834
+ @properties['total_calls']
835
+ end
836
+
837
+ ##
838
+ # @return [Float] The call answer score measures customers behavior to the delivered calls. The score is a value between 0 and 100, where 100 indicates that all calls were successfully answered.
839
+ def call_answer_score
840
+ @properties['call_answer_score']
841
+ end
842
+
843
+ ##
844
+ # @return [InsightsV2InboundPhoneNumberReportCallStatePercentage]
845
+ def call_state_percentage
846
+ @properties['call_state_percentage']
847
+ end
848
+
849
+ ##
850
+ # @return [Float] Percentage of inbound calls with silence tags over total outbound calls. A silent tag is indicative of a connectivity issue or muted audio.
851
+ def silent_calls_percentage
852
+ @properties['silent_calls_percentage']
853
+ end
854
+
855
+ ##
856
+ # @return [Hash<String, Integer>] Number of calls made with each device type. `voip`, `mobile`, `landline`, `unknown`
857
+ def calls_by_device_type
858
+ @properties['calls_by_device_type']
859
+ end
860
+
861
+ ##
862
+ # @return [Hash<String, Float>] Answer rate for each device type. `voip`, `mobile`, `landline`, `unknown`
863
+ def answer_rate_device_type
864
+ @properties['answer_rate_device_type']
865
+ end
866
+
867
+ ##
868
+ # @return [Array<CountyCarrierValue>] Percentage of blocked calls by carrier per country.
869
+ def blocked_calls_by_carrier
870
+ @properties['blocked_calls_by_carrier']
871
+ end
872
+
873
+ ##
874
+ # @return [Float] Percentage of completed outbound calls under 10 seconds (PSTN Short call tags); More than 15% is typically low trust measured.
875
+ def short_duration_calls_percentage
876
+ @properties['short_duration_calls_percentage']
877
+ end
878
+
879
+ ##
880
+ # @return [Float] Percentage of long duration calls ( >= 60 seconds)
881
+ def long_duration_calls_percentage
882
+ @properties['long_duration_calls_percentage']
883
+ end
884
+
885
+ ##
886
+ # @return [Float] Percentage of completed outbound calls to unassigned or unallocated phone numbers.
887
+ def potential_robocalls_percentage
888
+ @properties['potential_robocalls_percentage']
889
+ end
890
+
891
+ ##
892
+ # @return [InsightsV2OutboundPhoneNumberReportAnsweringMachineDetection]
893
+ def answering_machine_detection
894
+ @properties['answering_machine_detection']
895
+ end
896
+
897
+ ##
898
+ # @return [AccountReport]
899
+ def report
900
+ @properties['report']
901
+ end
902
+
903
+ ##
904
+ # Create the ReportInstance
905
+ # @param [InsightsV2CreateAccountReportRequest] insights_v2_create_account_report_request
906
+ # @return [ReportInstance] Created ReportInstance
907
+ def create(insights_v2_create_account_report_request: :unset
908
+ )
909
+
910
+ context.create(
911
+ )
912
+ end
913
+
914
+ ##
915
+ # Fetch the ReportInstance
916
+ # @return [ReportInstance] Fetched ReportInstance
917
+ def fetch
918
+
919
+ context.fetch
920
+ end
921
+
922
+ ##
923
+ # Provide a user friendly representation
924
+ def to_s
925
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
926
+ "<Twilio.Insights.V2.ReportInstance #{values}>"
927
+ end
928
+
929
+ ##
930
+ # Provide a detailed, user friendly representation
931
+ def inspect
932
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
933
+ "<Twilio.Insights.V2.ReportInstance #{values}>"
934
+ end
935
+ end
936
+
937
+ end
938
+ end
939
+ end
940
+ end