twilio-ruby 5.29.0 → 5.29.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGES.md +31 -0
  4. data/README.md +2 -2
  5. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +6 -2
  6. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +2 -1
  7. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +9 -7
  8. data/lib/twilio-ruby/rest/autopilot/v1/assistant.rb +16 -0
  9. data/lib/twilio-ruby/rest/autopilot/v1/assistant/export_assistant.rb +222 -0
  10. data/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +18 -6
  11. data/lib/twilio-ruby/rest/insights.rb +5 -5
  12. data/lib/twilio-ruby/rest/insights/v1.rb +10 -10
  13. data/lib/twilio-ruby/rest/insights/v1/call.rb +242 -0
  14. data/lib/twilio-ruby/rest/insights/v1/call/event.rb +278 -0
  15. data/lib/twilio-ruby/rest/insights/v1/call/metric.rb +268 -0
  16. data/lib/twilio-ruby/rest/insights/v1/call/summary.rb +305 -0
  17. data/lib/twilio-ruby/rest/preview.rb +5 -4
  18. data/lib/twilio-ruby/rest/preview/marketplace.rb +2 -4
  19. data/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb +9 -11
  20. data/lib/twilio-ruby/rest/preview/marketplace/available_add_on/available_add_on_extension.rb +14 -11
  21. data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb +27 -30
  22. data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on/installed_add_on_extension.rb +17 -14
  23. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +9 -5
  24. data/lib/twilio-ruby/twiml/voice_response.rb +42 -0
  25. data/lib/twilio-ruby/version.rb +1 -1
  26. data/spec/integration/api/v2010/account/call_spec.rb +263 -45
  27. data/spec/integration/autopilot/v1/assistant/export_assistant_spec.rb +49 -0
  28. data/spec/integration/autopilot/v1/assistant_spec.rb +8 -4
  29. data/spec/integration/flex_api/v1/flex_flow_spec.rb +8 -4
  30. data/spec/integration/insights/v1/call/event_spec.rb +171 -0
  31. data/spec/integration/insights/v1/call/metric_spec.rb +159 -0
  32. data/spec/integration/insights/v1/{summary_spec.rb → call/summary_spec.rb} +4 -2
  33. data/spec/integration/insights/v1/call_spec.rb +47 -0
  34. data/spec/integration/verify/v2/service/verification_spec.rb +36 -0
  35. metadata +17 -5
  36. data/lib/twilio-ruby/rest/insights/v1/summary.rb +0 -302
@@ -29,11 +29,11 @@ module Twilio
29
29
  end
30
30
 
31
31
  ##
32
- # @param [String] call_sid The call_sid
33
- # @return [Twilio::REST::Insights::V1::CallSummaryInstance] if call_sid was passed.
34
- # @return [Twilio::REST::Insights::V1::CallSummaryList]
35
- def summary(call_sid=:unset)
36
- self.v1.summary(call_sid)
32
+ # @param [String] sid The sid
33
+ # @return [Twilio::REST::Insights::V1::CallInstance] if sid was passed.
34
+ # @return [Twilio::REST::Insights::V1::CallList]
35
+ def calls(sid=:unset)
36
+ self.v1.calls(sid)
37
37
  end
38
38
 
39
39
  ##
@@ -15,20 +15,20 @@ module Twilio
15
15
  def initialize(domain)
16
16
  super
17
17
  @version = 'v1'
18
- @summary = nil
18
+ @calls = nil
19
19
  end
20
20
 
21
21
  ##
22
- # @param [String] call_sid The call_sid
23
- # @return [Twilio::REST::Insights::V1::CallSummaryContext] if call_sid was passed.
24
- # @return [Twilio::REST::Insights::V1::CallSummaryList]
25
- def summary(call_sid=:unset)
26
- if call_sid.nil?
27
- raise ArgumentError, 'call_sid cannot be nil'
28
- elsif call_sid == :unset
29
- @summary ||= CallSummaryList.new self
22
+ # @param [String] sid The sid
23
+ # @return [Twilio::REST::Insights::V1::CallContext] if sid was passed.
24
+ # @return [Twilio::REST::Insights::V1::CallList]
25
+ def calls(sid=:unset)
26
+ if sid.nil?
27
+ raise ArgumentError, 'sid cannot be nil'
28
+ elsif sid == :unset
29
+ @calls ||= CallList.new self
30
30
  else
31
- CallSummaryContext.new(self, call_sid)
31
+ CallContext.new(self, sid)
32
32
  end
33
33
  end
34
34
 
@@ -0,0 +1,242 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Insights < Domain
12
+ class V1 < Version
13
+ ##
14
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
15
+ class CallList < ListResource
16
+ ##
17
+ # Initialize the CallList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [CallList] CallList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ end
26
+
27
+ ##
28
+ # Provide a user friendly representation
29
+ def to_s
30
+ '#<Twilio.Insights.V1.CallList>'
31
+ end
32
+ end
33
+
34
+ ##
35
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
36
+ class CallPage < Page
37
+ ##
38
+ # Initialize the CallPage
39
+ # @param [Version] version Version that contains the resource
40
+ # @param [Response] response Response from the API
41
+ # @param [Hash] solution Path solution for the resource
42
+ # @return [CallPage] CallPage
43
+ def initialize(version, response, solution)
44
+ super(version, response)
45
+
46
+ # Path Solution
47
+ @solution = solution
48
+ end
49
+
50
+ ##
51
+ # Build an instance of CallInstance
52
+ # @param [Hash] payload Payload response from the API
53
+ # @return [CallInstance] CallInstance
54
+ def get_instance(payload)
55
+ CallInstance.new(@version, payload, )
56
+ end
57
+
58
+ ##
59
+ # Provide a user friendly representation
60
+ def to_s
61
+ '<Twilio.Insights.V1.CallPage>'
62
+ end
63
+ end
64
+
65
+ ##
66
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
67
+ class CallContext < InstanceContext
68
+ ##
69
+ # Initialize the CallContext
70
+ # @param [Version] version Version that contains the resource
71
+ # @param [String] sid The sid
72
+ # @return [CallContext] CallContext
73
+ def initialize(version, sid)
74
+ super(version)
75
+
76
+ # Path Solution
77
+ @solution = {sid: sid, }
78
+ @uri = "/Voice/#{@solution[:sid]}"
79
+
80
+ # Dependents
81
+ @events = nil
82
+ @metrics = nil
83
+ @summary = nil
84
+ end
85
+
86
+ ##
87
+ # Fetch a CallInstance
88
+ # @return [CallInstance] Fetched CallInstance
89
+ def fetch
90
+ params = Twilio::Values.of({})
91
+
92
+ payload = @version.fetch(
93
+ 'GET',
94
+ @uri,
95
+ params,
96
+ )
97
+
98
+ CallInstance.new(@version, payload, sid: @solution[:sid], )
99
+ end
100
+
101
+ ##
102
+ # Access the events
103
+ # @return [EventList]
104
+ # @return [EventContext]
105
+ def events
106
+ unless @events
107
+ @events = EventList.new(@version, call_sid: @solution[:sid], )
108
+ end
109
+
110
+ @events
111
+ end
112
+
113
+ ##
114
+ # Access the metrics
115
+ # @return [MetricList]
116
+ # @return [MetricContext]
117
+ def metrics
118
+ unless @metrics
119
+ @metrics = MetricList.new(@version, call_sid: @solution[:sid], )
120
+ end
121
+
122
+ @metrics
123
+ end
124
+
125
+ ##
126
+ # Access the summary
127
+ # @return [CallSummaryList]
128
+ # @return [CallSummaryContext]
129
+ def summary
130
+ CallSummaryContext.new(@version, @solution[:sid], )
131
+ end
132
+
133
+ ##
134
+ # Provide a user friendly representation
135
+ def to_s
136
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
137
+ "#<Twilio.Insights.V1.CallContext #{context}>"
138
+ end
139
+
140
+ ##
141
+ # Provide a detailed, user friendly representation
142
+ def inspect
143
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
144
+ "#<Twilio.Insights.V1.CallContext #{context}>"
145
+ end
146
+ end
147
+
148
+ ##
149
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
150
+ class CallInstance < InstanceResource
151
+ ##
152
+ # Initialize the CallInstance
153
+ # @param [Version] version Version that contains the resource
154
+ # @param [Hash] payload payload that contains response from Twilio
155
+ # @param [String] sid The sid
156
+ # @return [CallInstance] CallInstance
157
+ def initialize(version, payload, sid: nil)
158
+ super(version)
159
+
160
+ # Marshaled Properties
161
+ @properties = {'sid' => payload['sid'], 'url' => payload['url'], 'links' => payload['links'], }
162
+
163
+ # Context
164
+ @instance_context = nil
165
+ @params = {'sid' => sid || @properties['sid'], }
166
+ end
167
+
168
+ ##
169
+ # Generate an instance context for the instance, the context is capable of
170
+ # performing various actions. All instance actions are proxied to the context
171
+ # @return [CallContext] CallContext for this CallInstance
172
+ def context
173
+ unless @instance_context
174
+ @instance_context = CallContext.new(@version, @params['sid'], )
175
+ end
176
+ @instance_context
177
+ end
178
+
179
+ ##
180
+ # @return [String] The sid
181
+ def sid
182
+ @properties['sid']
183
+ end
184
+
185
+ ##
186
+ # @return [String] The url
187
+ def url
188
+ @properties['url']
189
+ end
190
+
191
+ ##
192
+ # @return [String] The links
193
+ def links
194
+ @properties['links']
195
+ end
196
+
197
+ ##
198
+ # Fetch a CallInstance
199
+ # @return [CallInstance] Fetched CallInstance
200
+ def fetch
201
+ context.fetch
202
+ end
203
+
204
+ ##
205
+ # Access the events
206
+ # @return [events] events
207
+ def events
208
+ context.events
209
+ end
210
+
211
+ ##
212
+ # Access the metrics
213
+ # @return [metrics] metrics
214
+ def metrics
215
+ context.metrics
216
+ end
217
+
218
+ ##
219
+ # Access the summary
220
+ # @return [summary] summary
221
+ def summary
222
+ context.summary
223
+ end
224
+
225
+ ##
226
+ # Provide a user friendly representation
227
+ def to_s
228
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
229
+ "<Twilio.Insights.V1.CallInstance #{values}>"
230
+ end
231
+
232
+ ##
233
+ # Provide a detailed, user friendly representation
234
+ def inspect
235
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
236
+ "<Twilio.Insights.V1.CallInstance #{values}>"
237
+ end
238
+ end
239
+ end
240
+ end
241
+ end
242
+ end
@@ -0,0 +1,278 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Insights < Domain
12
+ class V1 < Version
13
+ class CallContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
16
+ class EventList < ListResource
17
+ ##
18
+ # Initialize the EventList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] call_sid The call_sid
21
+ # @return [EventList] EventList
22
+ def initialize(version, call_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {call_sid: call_sid}
27
+ @uri = "/Voice/#{@solution[:call_sid]}/Events"
28
+ end
29
+
30
+ ##
31
+ # Lists EventInstance records from the API as a list.
32
+ # Unlike stream(), this operation is eager and will load `limit` records into
33
+ # memory before returning.
34
+ # @param [event.TwilioEdge] edge The edge
35
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
36
+ # guarantees to never return more than limit. Default is no limit
37
+ # @param [Integer] page_size Number of records to fetch per request, when
38
+ # not set will use the default value of 50 records. If no page_size is defined
39
+ # but a limit is defined, stream() will attempt to read the limit with the most
40
+ # efficient page size, i.e. min(limit, 1000)
41
+ # @return [Array] Array of up to limit results
42
+ def list(edge: :unset, limit: nil, page_size: nil)
43
+ self.stream(edge: edge, limit: limit, page_size: page_size).entries
44
+ end
45
+
46
+ ##
47
+ # Streams EventInstance records from the API as an Enumerable.
48
+ # This operation lazily loads records as efficiently as possible until the limit
49
+ # is reached.
50
+ # @param [event.TwilioEdge] edge The edge
51
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
52
+ # guarantees to never return more than limit. Default is no limit.
53
+ # @param [Integer] page_size Number of records to fetch per request, when
54
+ # not set will use the default value of 50 records. If no page_size is defined
55
+ # but a limit is defined, stream() will attempt to read the limit with the most
56
+ # efficient page size, i.e. min(limit, 1000)
57
+ # @return [Enumerable] Enumerable that will yield up to limit results
58
+ def stream(edge: :unset, limit: nil, page_size: nil)
59
+ limits = @version.read_limits(limit, page_size)
60
+
61
+ page = self.page(edge: edge, page_size: limits[:page_size], )
62
+
63
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
64
+ end
65
+
66
+ ##
67
+ # When passed a block, yields EventInstance records from the API.
68
+ # This operation lazily loads records as efficiently as possible until the limit
69
+ # is reached.
70
+ def each
71
+ limits = @version.read_limits
72
+
73
+ page = self.page(page_size: limits[:page_size], )
74
+
75
+ @version.stream(page,
76
+ limit: limits[:limit],
77
+ page_limit: limits[:page_limit]).each {|x| yield x}
78
+ end
79
+
80
+ ##
81
+ # Retrieve a single page of EventInstance records from the API.
82
+ # Request is executed immediately.
83
+ # @param [event.TwilioEdge] edge The edge
84
+ # @param [String] page_token PageToken provided by the API
85
+ # @param [Integer] page_number Page Number, this value is simply for client state
86
+ # @param [Integer] page_size Number of records to return, defaults to 50
87
+ # @return [Page] Page of EventInstance
88
+ def page(edge: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
89
+ params = Twilio::Values.of({
90
+ 'Edge' => edge,
91
+ 'PageToken' => page_token,
92
+ 'Page' => page_number,
93
+ 'PageSize' => page_size,
94
+ })
95
+ response = @version.page(
96
+ 'GET',
97
+ @uri,
98
+ params
99
+ )
100
+ EventPage.new(@version, response, @solution)
101
+ end
102
+
103
+ ##
104
+ # Retrieve a single page of EventInstance records from the API.
105
+ # Request is executed immediately.
106
+ # @param [String] target_url API-generated URL for the requested results page
107
+ # @return [Page] Page of EventInstance
108
+ def get_page(target_url)
109
+ response = @version.domain.request(
110
+ 'GET',
111
+ target_url
112
+ )
113
+ EventPage.new(@version, response, @solution)
114
+ end
115
+
116
+ ##
117
+ # Provide a user friendly representation
118
+ def to_s
119
+ '#<Twilio.Insights.V1.EventList>'
120
+ end
121
+ end
122
+
123
+ ##
124
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
125
+ class EventPage < Page
126
+ ##
127
+ # Initialize the EventPage
128
+ # @param [Version] version Version that contains the resource
129
+ # @param [Response] response Response from the API
130
+ # @param [Hash] solution Path solution for the resource
131
+ # @return [EventPage] EventPage
132
+ def initialize(version, response, solution)
133
+ super(version, response)
134
+
135
+ # Path Solution
136
+ @solution = solution
137
+ end
138
+
139
+ ##
140
+ # Build an instance of EventInstance
141
+ # @param [Hash] payload Payload response from the API
142
+ # @return [EventInstance] EventInstance
143
+ def get_instance(payload)
144
+ EventInstance.new(@version, payload, call_sid: @solution[:call_sid], )
145
+ end
146
+
147
+ ##
148
+ # Provide a user friendly representation
149
+ def to_s
150
+ '<Twilio.Insights.V1.EventPage>'
151
+ end
152
+ end
153
+
154
+ ##
155
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
156
+ class EventInstance < InstanceResource
157
+ ##
158
+ # Initialize the EventInstance
159
+ # @param [Version] version Version that contains the resource
160
+ # @param [Hash] payload payload that contains response from Twilio
161
+ # @param [String] call_sid The call_sid
162
+ # @return [EventInstance] EventInstance
163
+ def initialize(version, payload, call_sid: nil)
164
+ super(version)
165
+
166
+ # Marshaled Properties
167
+ @properties = {
168
+ 'timestamp' => payload['timestamp'],
169
+ 'call_sid' => payload['call_sid'],
170
+ 'account_sid' => payload['account_sid'],
171
+ 'edge' => payload['edge'],
172
+ 'group' => payload['group'],
173
+ 'level' => payload['level'],
174
+ 'name' => payload['name'],
175
+ 'client' => payload['client'],
176
+ 'gateway' => payload['gateway'],
177
+ 'carrier_edge' => payload['carrier_edge'],
178
+ 'sip_edge' => payload['sip_edge'],
179
+ 'sdk_edge' => payload['sdk_edge'],
180
+ 'client_edge' => payload['client_edge'],
181
+ }
182
+ end
183
+
184
+ ##
185
+ # @return [String] The timestamp
186
+ def timestamp
187
+ @properties['timestamp']
188
+ end
189
+
190
+ ##
191
+ # @return [String] The call_sid
192
+ def call_sid
193
+ @properties['call_sid']
194
+ end
195
+
196
+ ##
197
+ # @return [String] The account_sid
198
+ def account_sid
199
+ @properties['account_sid']
200
+ end
201
+
202
+ ##
203
+ # @return [event.TwilioEdge] The edge
204
+ def edge
205
+ @properties['edge']
206
+ end
207
+
208
+ ##
209
+ # @return [String] The group
210
+ def group
211
+ @properties['group']
212
+ end
213
+
214
+ ##
215
+ # @return [event.Level] The level
216
+ def level
217
+ @properties['level']
218
+ end
219
+
220
+ ##
221
+ # @return [String] The name
222
+ def name
223
+ @properties['name']
224
+ end
225
+
226
+ ##
227
+ # @return [Hash] The client
228
+ def client
229
+ @properties['client']
230
+ end
231
+
232
+ ##
233
+ # @return [Hash] The gateway
234
+ def gateway
235
+ @properties['gateway']
236
+ end
237
+
238
+ ##
239
+ # @return [Hash] The carrier_edge
240
+ def carrier_edge
241
+ @properties['carrier_edge']
242
+ end
243
+
244
+ ##
245
+ # @return [Hash] The sip_edge
246
+ def sip_edge
247
+ @properties['sip_edge']
248
+ end
249
+
250
+ ##
251
+ # @return [Hash] The sdk_edge
252
+ def sdk_edge
253
+ @properties['sdk_edge']
254
+ end
255
+
256
+ ##
257
+ # @return [Hash] The client_edge
258
+ def client_edge
259
+ @properties['client_edge']
260
+ end
261
+
262
+ ##
263
+ # Provide a user friendly representation
264
+ def to_s
265
+ "<Twilio.Insights.V1.EventInstance>"
266
+ end
267
+
268
+ ##
269
+ # Provide a detailed, user friendly representation
270
+ def inspect
271
+ "<Twilio.Insights.V1.EventInstance>"
272
+ end
273
+ end
274
+ end
275
+ end
276
+ end
277
+ end
278
+ end