twilio-ruby 5.42.0 → 5.43.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +27 -0
  3. data/README.md +18 -2
  4. data/lib/twilio-ruby.rb +1 -1
  5. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +20 -0
  6. data/lib/twilio-ruby/rest/api/v2010/account/call/event.rb +201 -0
  7. data/lib/twilio-ruby/rest/client.rb +29 -3
  8. data/lib/twilio-ruby/rest/events/v1/subscription.rb +12 -5
  9. data/lib/twilio-ruby/rest/insights/v1/room/participant.rb +1 -8
  10. data/lib/twilio-ruby/rest/serverless/v1/service.rb +5 -5
  11. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +4 -4
  12. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +4 -4
  13. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +4 -4
  14. data/lib/twilio-ruby/rest/serverless/v1/service/build/build_status.rb +4 -4
  15. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +4 -4
  16. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +4 -4
  17. data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +4 -4
  18. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +4 -4
  19. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  20. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +4 -4
  21. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +4 -4
  22. data/lib/twilio-ruby/rest/sync/v1/service/document.rb +15 -5
  23. data/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb +15 -5
  24. data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb +28 -5
  25. data/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb +15 -5
  26. data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb +28 -5
  27. data/lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb +15 -5
  28. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +12 -9
  29. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb +16 -16
  30. data/lib/twilio-ruby/rest/verify/v2/service.rb +3 -3
  31. data/lib/twilio-ruby/rest/verify/v2/service/entity.rb +3 -1
  32. data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +5 -3
  33. data/lib/twilio-ruby/util/configuration.rb +5 -1
  34. data/lib/twilio-ruby/version.rb +1 -1
  35. data/spec/integration/api/v2010/account/call/event_spec.rb +102 -0
  36. data/spec/integration/api/v2010/account/call_spec.rb +20 -10
  37. data/spec/integration/events/v1/subscription_spec.rb +49 -0
  38. data/spec/integration/insights/v1/room/participant_spec.rb +0 -2
  39. data/spec/rest/client_spec.rb +24 -2
  40. data/twilio-ruby.gemspec +1 -0
  41. metadata +19 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9778eed7f661d600a460a4f11f0cc9c4ecb1f9327ae1fa0bc7f17701b45f783
4
- data.tar.gz: 1efe2eaf64fed893801694ec1f9dd68a40ac98be3e444ef2989b7acf520331bc
3
+ metadata.gz: ec5ff54dd66649c891ed4290835b064e07dd8fc969cb2cfed80be83f17b1d253
4
+ data.tar.gz: 0d2492ccc67cca79e4c12387aaf8a62184d48f2a6193480e7655448846b0e64b
5
5
  SHA512:
6
- metadata.gz: 147bb2ba1d376c0d8f7e0335c0c744ba07696cf05ca1368a586750ec746692715a5415b1179c4b8485cec6e42670192704b288cf993cd25e8485888f348da2f4
7
- data.tar.gz: 61de95cc6c57cf05b0acf95e6f4ab218402651d3fea976cb88f21527e868b184fb6a0ac9b278e3e6597c31e233b0391801d1d7f660a57c4468189f605a51bd15
6
+ metadata.gz: 256b0e576d26bf990e61f6393edd819709b770a6bfe3677a6cd177f4f2d9270e5cd50da413d5a2700cbfadb8d4343eb9046a4be5f0d6d87f13edf9d2c54d0ae8
7
+ data.tar.gz: 14d7a20171b7577e19c57ede894867deb382e558c77bd0c677385128fe4bb972d93f6b9ae8da7008aba5b3086f201f5cc6cc0cd61f3dd9cae7e9dd7488f8b4eb
data/CHANGES.md CHANGED
@@ -1,6 +1,33 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ [2020-11-18] Version 5.43.0
5
+ ---------------------------
6
+ **Library - Feature**
7
+ - [PR #538](https://github.com/twilio/twilio-ruby/pull/538): adding http logging for ruby. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
8
+
9
+ **Api**
10
+ - Add new call events resource - GET /2010-04-01/Accounts/{account_sid}/Calls/{call_sid}/Events.json
11
+
12
+ **Conversations**
13
+ - Fixed default response property issue for Service Notifications Configuration
14
+
15
+ **Insights**
16
+ - Removing call_sid from participant summary. **(breaking change)**
17
+
18
+ **Serverless**
19
+ - Allow Service unique name to be used in path (in place of SID) in Service update request
20
+
21
+ **Sync**
22
+ - Added HideExpired query parameter for filtering Sync Documents with expired
23
+
24
+ **Verify**
25
+ - Challenge `Details` and `HiddenDetails` properties are now marked as `PII`
26
+ - Challenge `expiration_date` attribute updated to set a default value of five (5) minutes and to allow max dates of one (1) hour after creation.
27
+ - Entity `identity` attribute updated to allow values between 8 and 64 characters.
28
+ - Verify Service frinedly_name attribute updated from 64 max lenght to 30 characters.
29
+
30
+
4
31
  [2020-11-05] Version 5.42.0
5
32
  ---------------------------
6
33
  **Library - Feature**
data/README.md CHANGED
@@ -34,13 +34,13 @@ This library supports the following Ruby implementations:
34
34
  To install using [Bundler][bundler] grab the latest stable version:
35
35
 
36
36
  ```ruby
37
- gem 'twilio-ruby', '~> 5.42.0'
37
+ gem 'twilio-ruby', '~> 5.43.0'
38
38
  ```
39
39
 
40
40
  To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
41
41
 
42
42
  ```bash
43
- gem install twilio-ruby -v 5.42.0
43
+ gem install twilio-ruby -v 5.43.0
44
44
  ```
45
45
 
46
46
  To build and install the development branch yourself from the latest source:
@@ -81,6 +81,22 @@ To take advantage of Twilio's [Global Infrastructure](https://www.twilio.com/doc
81
81
  @client.edge = 'sydney'
82
82
  ```
83
83
 
84
+ ### Enable Debug logging
85
+
86
+ In order to enable debug logging, pass in a 'logger' instance to the client with the level set to at least 'DEBUG'
87
+
88
+ ```ruby
89
+ @client = Twilio::REST::Client.new account_sid, auth_token
90
+ myLogger = Logger.new(STDOUT)
91
+ myLogger.level = Logger::DEBUG
92
+ @client.logger = myLogger
93
+
94
+ @client = Twilio::REST::Client.new account_sid, auth_token
95
+ myLogger = Logger.new('my_log.log')
96
+ myLogger.level = Logger::DEBUG
97
+ @client.logger = myLogger
98
+ ```
99
+
84
100
  This will result in the `hostname` transforming from `api.twilio.com` to `api.sydney.au1.twilio.com`.
85
101
 
86
102
  ### Make a Call
@@ -38,7 +38,7 @@ module Twilio
38
38
  autoload :JWT, File.join(File.dirname(__FILE__), 'twilio-ruby', 'jwt', 'jwt.rb')
39
39
  autoload :TwiML, File.join(File.dirname(__FILE__), 'twilio-ruby', 'twiml', 'twiml.rb')
40
40
 
41
- def_delegators :configuration, :account_sid, :auth_token, :http_client, :region, :edge
41
+ def_delegators :configuration, :account_sid, :auth_token, :http_client, :region, :edge, :logger
42
42
 
43
43
  ##
44
44
  # Pre-configure with account SID and auth token so that you don't need to
@@ -426,6 +426,7 @@ module Twilio
426
426
  @recordings = nil
427
427
  @notifications = nil
428
428
  @feedback = nil
429
+ @events = nil
429
430
  @payments = nil
430
431
  end
431
432
 
@@ -546,6 +547,18 @@ module Twilio
546
547
  FeedbackContext.new(@version, @solution[:account_sid], @solution[:sid], )
547
548
  end
548
549
 
550
+ ##
551
+ # Access the events
552
+ # @return [EventList]
553
+ # @return [EventContext]
554
+ def events
555
+ unless @events
556
+ @events = EventList.new(@version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
557
+ end
558
+
559
+ @events
560
+ end
561
+
549
562
  ##
550
563
  # Access the payments
551
564
  # @return [PaymentList]
@@ -885,6 +898,13 @@ module Twilio
885
898
  context.feedback
886
899
  end
887
900
 
901
+ ##
902
+ # Access the events
903
+ # @return [events] events
904
+ def events
905
+ context.events
906
+ end
907
+
888
908
  ##
889
909
  # Access the payments
890
910
  # @return [payments] payments
@@ -0,0 +1,201 @@
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 Api < Domain
12
+ class V2010 < Version
13
+ class AccountContext < InstanceContext
14
+ class CallContext < InstanceContext
15
+ class EventList < ListResource
16
+ ##
17
+ # Initialize the EventList
18
+ # @param [Version] version Version that contains the resource
19
+ # @param [String] account_sid The SID of the
20
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call
21
+ # resource.
22
+ # @param [String] call_sid The unique string that that we created to identify this
23
+ # Call resource.
24
+ # @return [EventList] EventList
25
+ def initialize(version, account_sid: nil, call_sid: nil)
26
+ super(version)
27
+
28
+ # Path Solution
29
+ @solution = {account_sid: account_sid, call_sid: call_sid}
30
+ @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:call_sid]}/Events.json"
31
+ end
32
+
33
+ ##
34
+ # Lists EventInstance records from the API as a list.
35
+ # Unlike stream(), this operation is eager and will load `limit` records into
36
+ # memory before returning.
37
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
38
+ # guarantees to never return more than limit. Default is no limit
39
+ # @param [Integer] page_size Number of records to fetch per request, when
40
+ # not set will use the default value of 50 records. If no page_size is defined
41
+ # but a limit is defined, stream() will attempt to read the limit with the most
42
+ # efficient page size, i.e. min(limit, 1000)
43
+ # @return [Array] Array of up to limit results
44
+ def list(limit: nil, page_size: nil)
45
+ self.stream(limit: limit, page_size: page_size).entries
46
+ end
47
+
48
+ ##
49
+ # Streams EventInstance records from the API as an Enumerable.
50
+ # This operation lazily loads records as efficiently as possible until the limit
51
+ # is reached.
52
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
53
+ # guarantees to never return more than limit. Default is no limit.
54
+ # @param [Integer] page_size Number of records to fetch per request, when
55
+ # not set will use the default value of 50 records. If no page_size is defined
56
+ # but a limit is defined, stream() will attempt to read the limit with the most
57
+ # efficient page size, i.e. min(limit, 1000)
58
+ # @return [Enumerable] Enumerable that will yield up to limit results
59
+ def stream(limit: nil, page_size: nil)
60
+ limits = @version.read_limits(limit, page_size)
61
+
62
+ page = self.page(page_size: limits[:page_size], )
63
+
64
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
65
+ end
66
+
67
+ ##
68
+ # When passed a block, yields EventInstance records from the API.
69
+ # This operation lazily loads records as efficiently as possible until the limit
70
+ # is reached.
71
+ def each
72
+ limits = @version.read_limits
73
+
74
+ page = self.page(page_size: limits[:page_size], )
75
+
76
+ @version.stream(page,
77
+ limit: limits[:limit],
78
+ page_limit: limits[:page_limit]).each {|x| yield x}
79
+ end
80
+
81
+ ##
82
+ # Retrieve a single page of EventInstance records from the API.
83
+ # Request is executed immediately.
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(page_token: :unset, page_number: :unset, page_size: :unset)
89
+ params = Twilio::Values.of({
90
+ 'PageToken' => page_token,
91
+ 'Page' => page_number,
92
+ 'PageSize' => page_size,
93
+ })
94
+
95
+ response = @version.page('GET', @uri, params: params)
96
+
97
+ EventPage.new(@version, response, @solution)
98
+ end
99
+
100
+ ##
101
+ # Retrieve a single page of EventInstance records from the API.
102
+ # Request is executed immediately.
103
+ # @param [String] target_url API-generated URL for the requested results page
104
+ # @return [Page] Page of EventInstance
105
+ def get_page(target_url)
106
+ response = @version.domain.request(
107
+ 'GET',
108
+ target_url
109
+ )
110
+ EventPage.new(@version, response, @solution)
111
+ end
112
+
113
+ ##
114
+ # Provide a user friendly representation
115
+ def to_s
116
+ '#<Twilio.Api.V2010.EventList>'
117
+ end
118
+ end
119
+
120
+ class EventPage < Page
121
+ ##
122
+ # Initialize the EventPage
123
+ # @param [Version] version Version that contains the resource
124
+ # @param [Response] response Response from the API
125
+ # @param [Hash] solution Path solution for the resource
126
+ # @return [EventPage] EventPage
127
+ def initialize(version, response, solution)
128
+ super(version, response)
129
+
130
+ # Path Solution
131
+ @solution = solution
132
+ end
133
+
134
+ ##
135
+ # Build an instance of EventInstance
136
+ # @param [Hash] payload Payload response from the API
137
+ # @return [EventInstance] EventInstance
138
+ def get_instance(payload)
139
+ EventInstance.new(
140
+ @version,
141
+ payload,
142
+ account_sid: @solution[:account_sid],
143
+ call_sid: @solution[:call_sid],
144
+ )
145
+ end
146
+
147
+ ##
148
+ # Provide a user friendly representation
149
+ def to_s
150
+ '<Twilio.Api.V2010.EventPage>'
151
+ end
152
+ end
153
+
154
+ class EventInstance < InstanceResource
155
+ ##
156
+ # Initialize the EventInstance
157
+ # @param [Version] version Version that contains the resource
158
+ # @param [Hash] payload payload that contains response from Twilio
159
+ # @param [String] account_sid The SID of the
160
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call
161
+ # resource.
162
+ # @param [String] call_sid The unique string that that we created to identify this
163
+ # Call resource.
164
+ # @return [EventInstance] EventInstance
165
+ def initialize(version, payload, account_sid: nil, call_sid: nil)
166
+ super(version)
167
+
168
+ # Marshaled Properties
169
+ @properties = {'request' => payload['request'], 'response' => payload['response'], }
170
+ end
171
+
172
+ ##
173
+ # @return [Hash] Call Request.
174
+ def request
175
+ @properties['request']
176
+ end
177
+
178
+ ##
179
+ # @return [Hash] Call Response with Events.
180
+ def response
181
+ @properties['response']
182
+ end
183
+
184
+ ##
185
+ # Provide a user friendly representation
186
+ def to_s
187
+ "<Twilio.Api.V2010.EventInstance>"
188
+ end
189
+
190
+ ##
191
+ # Provide a detailed, user friendly representation
192
+ def inspect
193
+ "<Twilio.Api.V2010.EventInstance>"
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
199
+ end
200
+ end
201
+ end
@@ -13,11 +13,11 @@ module Twilio
13
13
  class Client
14
14
  @@default_region = 'us1'
15
15
 
16
- attr_accessor :http_client, :username, :password, :account_sid, :auth_token, :region, :edge
16
+ attr_accessor :http_client, :username, :password, :account_sid, :auth_token, :region, :edge, :logger
17
17
 
18
18
  ##
19
19
  # Initializes the Twilio Client
20
- def initialize(username=nil, password=nil, account_sid=nil, region=nil, http_client=nil)
20
+ def initialize(username=nil, password=nil, account_sid=nil, region=nil, http_client=nil, logger=nil)
21
21
  @username = username || Twilio.account_sid
22
22
  @password = password || Twilio.auth_token
23
23
  @region = region || Twilio.region
@@ -26,6 +26,7 @@ module Twilio
26
26
  @auth_token = @password
27
27
  @auth = [@username, @password]
28
28
  @http_client = http_client || Twilio.http_client || Twilio::HTTP::Client.new
29
+ @logger = logger || Twilio.logger
29
30
 
30
31
  # Domains
31
32
  @accounts = nil
@@ -80,7 +81,24 @@ module Twilio
80
81
 
81
82
  uri = build_uri(uri)
82
83
 
83
- @http_client.request(
84
+ if @logger
85
+ @logger.debug("--BEGIN Twilio API Request--")
86
+ @logger.debug("Request Method: <#{method}>")
87
+
88
+ headers.each do |key, value|
89
+ unless key.downcase == 'authorization'
90
+ @logger.debug("#{key}:#{value}")
91
+ end
92
+ end
93
+
94
+ url = URI(uri)
95
+ @logger.debug("Host:#{url.host}")
96
+ @logger.debug("Path:#{url.path}")
97
+ @logger.debug("Query:#{url.query}")
98
+ @logger.debug("Request Params:#{params}")
99
+ end
100
+
101
+ response = @http_client.request(
84
102
  host,
85
103
  port,
86
104
  method,
@@ -91,6 +109,14 @@ module Twilio
91
109
  auth,
92
110
  timeout
93
111
  )
112
+
113
+ if @logger
114
+ @logger.debug("Response Status Code:#{response.status_code}")
115
+ @logger.debug("Response Headers:#{response.headers}")
116
+ @logger.debug("--END TWILIO API REQUEST--")
117
+ end
118
+
119
+ response
94
120
  end
95
121
 
96
122
  ##
@@ -29,6 +29,8 @@ module Twilio
29
29
  # Lists SubscriptionInstance records from the API as a list.
30
30
  # Unlike stream(), this operation is eager and will load `limit` records into
31
31
  # memory before returning.
32
+ # @param [String] sink_sid The SID of the sink that the list of Subscriptions
33
+ # should be filtered by.
32
34
  # @param [Integer] limit Upper limit for the number of records to return. stream()
33
35
  # guarantees to never return more than limit. Default is no limit
34
36
  # @param [Integer] page_size Number of records to fetch per request, when
@@ -36,14 +38,16 @@ module Twilio
36
38
  # but a limit is defined, stream() will attempt to read the limit with the most
37
39
  # efficient page size, i.e. min(limit, 1000)
38
40
  # @return [Array] Array of up to limit results
39
- def list(limit: nil, page_size: nil)
40
- self.stream(limit: limit, page_size: page_size).entries
41
+ def list(sink_sid: :unset, limit: nil, page_size: nil)
42
+ self.stream(sink_sid: sink_sid, limit: limit, page_size: page_size).entries
41
43
  end
42
44
 
43
45
  ##
44
46
  # Streams SubscriptionInstance records from the API as an Enumerable.
45
47
  # This operation lazily loads records as efficiently as possible until the limit
46
48
  # is reached.
49
+ # @param [String] sink_sid The SID of the sink that the list of Subscriptions
50
+ # should be filtered by.
47
51
  # @param [Integer] limit Upper limit for the number of records to return. stream()
48
52
  # guarantees to never return more than limit. Default is no limit.
49
53
  # @param [Integer] page_size Number of records to fetch per request, when
@@ -51,10 +55,10 @@ module Twilio
51
55
  # but a limit is defined, stream() will attempt to read the limit with the most
52
56
  # efficient page size, i.e. min(limit, 1000)
53
57
  # @return [Enumerable] Enumerable that will yield up to limit results
54
- def stream(limit: nil, page_size: nil)
58
+ def stream(sink_sid: :unset, limit: nil, page_size: nil)
55
59
  limits = @version.read_limits(limit, page_size)
56
60
 
57
- page = self.page(page_size: limits[:page_size], )
61
+ page = self.page(sink_sid: sink_sid, page_size: limits[:page_size], )
58
62
 
59
63
  @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
60
64
  end
@@ -76,12 +80,15 @@ module Twilio
76
80
  ##
77
81
  # Retrieve a single page of SubscriptionInstance records from the API.
78
82
  # Request is executed immediately.
83
+ # @param [String] sink_sid The SID of the sink that the list of Subscriptions
84
+ # should be filtered by.
79
85
  # @param [String] page_token PageToken provided by the API
80
86
  # @param [Integer] page_number Page Number, this value is simply for client state
81
87
  # @param [Integer] page_size Number of records to return, defaults to 50
82
88
  # @return [Page] Page of SubscriptionInstance
83
- def page(page_token: :unset, page_number: :unset, page_size: :unset)
89
+ def page(sink_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
84
90
  params = Twilio::Values.of({
91
+ 'SinkSid' => sink_sid,
85
92
  'PageToken' => page_token,
86
93
  'Page' => page_number,
87
94
  'PageSize' => page_size,