twilio-ruby 5.0.0.rc4 → 5.0.0.rc5

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.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +8 -1
  3. data/Makefile +3 -0
  4. data/lib/twilio-ruby.rb +0 -1
  5. data/lib/twilio-ruby/framework/version.rb +4 -4
  6. data/lib/twilio-ruby/rest/api/v2010/account.rb +0 -13
  7. data/lib/twilio-ruby/rest/api/v2010/account/address.rb +0 -13
  8. data/lib/twilio-ruby/rest/api/v2010/account/application.rb +0 -14
  9. data/lib/twilio-ruby/rest/api/v2010/account/authorized_connect_app.rb +0 -13
  10. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number.rb +0 -13
  11. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +0 -13
  12. data/lib/twilio-ruby/rest/api/v2010/account/call/feedback.rb +0 -11
  13. data/lib/twilio-ruby/rest/api/v2010/account/call/feedback_summary.rb +0 -13
  14. data/lib/twilio-ruby/rest/api/v2010/account/call/notification.rb +0 -14
  15. data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +0 -14
  16. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +0 -13
  17. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +0 -14
  18. data/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb +0 -13
  19. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +0 -14
  20. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +0 -13
  21. data/lib/twilio-ruby/rest/api/v2010/account/message/media.rb +0 -14
  22. data/lib/twilio-ruby/rest/api/v2010/account/notification.rb +0 -13
  23. data/lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb +0 -14
  24. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +0 -13
  25. data/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb +0 -14
  26. data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +0 -13
  27. data/lib/twilio-ruby/rest/api/v2010/account/recording/transcription.rb +0 -14
  28. data/lib/twilio-ruby/rest/api/v2010/account/sandbox.rb +0 -10
  29. data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb +0 -13
  30. data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +0 -14
  31. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +0 -13
  32. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb +0 -14
  33. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb +0 -14
  34. data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb +0 -14
  35. data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb +0 -14
  36. data/lib/twilio-ruby/rest/api/v2010/account/sms/short_code.rb +0 -13
  37. data/lib/twilio-ruby/rest/api/v2010/account/sms/sms_message.rb +0 -13
  38. data/lib/twilio-ruby/rest/api/v2010/account/transcription.rb +0 -13
  39. data/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb +0 -13
  40. data/lib/twilio-ruby/rest/client.rb +7 -7
  41. data/lib/twilio-ruby/rest/ip_messaging/v1/credential.rb +0 -12
  42. data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +0 -12
  43. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +0 -13
  44. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/member.rb +0 -14
  45. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +0 -14
  46. data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +0 -13
  47. data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +0 -18
  48. data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +0 -12
  49. data/lib/twilio-ruby/rest/monitor/v1/alert.rb +0 -12
  50. data/lib/twilio-ruby/rest/monitor/v1/event.rb +0 -12
  51. data/lib/twilio-ruby/rest/notifications.rb +4 -0
  52. data/lib/twilio-ruby/rest/notifications/v1.rb +9 -0
  53. data/lib/twilio-ruby/rest/notifications/v1/credential.rb +390 -0
  54. data/lib/twilio-ruby/rest/notifications/v1/service.rb +0 -12
  55. data/lib/twilio-ruby/rest/notifications/v1/service/binding.rb +0 -13
  56. data/lib/twilio-ruby/rest/preview.rb +47 -0
  57. data/lib/twilio-ruby/rest/preview/wireless.rb +53 -0
  58. data/lib/twilio-ruby/rest/preview/wireless/command.rb +345 -0
  59. data/lib/twilio-ruby/rest/preview/wireless/device.rb +456 -0
  60. data/lib/twilio-ruby/rest/preview/wireless/device/usage.rb +227 -0
  61. data/lib/twilio-ruby/rest/preview/wireless/rate_plan.rb +325 -0
  62. data/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb +0 -12
  63. data/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb +0 -12
  64. data/lib/twilio-ruby/rest/pricing/v1/voice/country.rb +0 -12
  65. data/lib/twilio-ruby/rest/pricing/v1/voice/number.rb +0 -12
  66. data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +0 -12
  67. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +0 -13
  68. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb +0 -13
  69. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +0 -13
  70. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +0 -14
  71. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +0 -13
  72. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb +0 -11
  73. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +0 -13
  74. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb +0 -11
  75. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb +0 -10
  76. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb +0 -13
  77. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb +0 -11
  78. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb +0 -10
  79. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +0 -12
  80. data/lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb +0 -13
  81. data/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb +0 -13
  82. data/lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb +0 -13
  83. data/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb +0 -13
  84. data/lib/twilio-ruby/version.rb +1 -1
  85. data/spec/integration/api/v2010/account/usage/trigger_spec.rb +3 -3
  86. data/spec/integration/ip_messaging/v1/credential_spec.rb +1 -1
  87. data/spec/integration/ip_messaging/v1/service/role_spec.rb +1 -1
  88. data/spec/integration/notifications/v1/credential_spec.rb +228 -0
  89. data/spec/integration/notifications/v1/service/binding_spec.rb +2 -2
  90. data/spec/integration/preview/wireless/command_spec.rb +58 -0
  91. data/spec/integration/preview/wireless/device/usage_spec.rb +25 -0
  92. data/spec/integration/preview/wireless/device_spec.rb +72 -0
  93. data/spec/integration/preview/wireless/rate_plan_spec.rb +39 -0
  94. metadata +19 -16
  95. data/lib/twilio-ruby/rest/conversations.rb +0 -40
  96. data/lib/twilio-ruby/rest/conversations/v1.rb +0 -35
  97. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +0 -270
  98. data/lib/twilio-ruby/rest/conversations/v1/conversation/completed.rb +0 -217
  99. data/lib/twilio-ruby/rest/conversations/v1/conversation/in_progress.rb +0 -217
  100. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +0 -352
  101. data/spec/integration/conversations/v1/conversation/completed_spec.rb +0 -89
  102. data/spec/integration/conversations/v1/conversation/in_progress_spec.rb +0 -89
  103. data/spec/integration/conversations/v1/conversation/participant_spec.rb +0 -174
  104. data/spec/integration/conversations/v1/conversation_spec.rb +0 -49
@@ -1,217 +0,0 @@
1
- ##
2
- # This code was generated by
3
- # \ / _ _ _| _ _
4
- # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
- # / /
6
-
7
- module Twilio
8
- module REST
9
- class Conversations < Domain
10
- class V1 < Version
11
- class ConversationList < ListResource
12
- class CompletedList < ListResource
13
- ##
14
- # Initialize the CompletedList
15
- # @param [Version] version Version that contains the resource
16
-
17
- # @return [CompletedList] CompletedList
18
- def initialize(version)
19
- super(version)
20
-
21
- # Path Solution
22
- @solution = {}
23
- @uri = "/Conversations/Completed"
24
- end
25
-
26
- ##
27
- # Lists CompletedInstance records from the API as a list.
28
- # Unlike stream(), this operation is eager and will load `limit` records into
29
- # memory before returning.
30
- # @param [Integer] limit Upper limit for the number of records to return. stream()
31
- # guarantees to never return more than limit. Default is no limit
32
- # @param [Integer] page_size Number of records to fetch per request, when not set will use
33
- # the default value of 50 records. If no page_size is defined
34
- # but a limit is defined, stream() will attempt to read the
35
- # limit with the most efficient page size, i.e. min(limit, 1000)
36
-
37
- # @return [Array] Array of up to limit results
38
- def list(limit: nil, page_size: nil)
39
- self.stream(
40
- limit: limit,
41
- page_size: page_size
42
- ).entries
43
- end
44
-
45
- ##
46
- # Streams CompletedInstance records from the API as an Enumerable.
47
- # This operation lazily loads records as efficiently as possible until the limit
48
- # is reached.
49
- # @param [Integer] limit Upper limit for the number of records to return. stream()
50
- # guarantees to never return more than limit. Default is no limit
51
- # @param [Integer] page_size Number of records to fetch per request, when not set will use
52
- # the default value of 50 records. If no page_size is defined
53
- # but a limit is defined, stream() will attempt to read the
54
- # limit with the most efficient page size, i.e. min(limit, 1000)
55
-
56
- # @return [Enumerable] Enumerable that will yield up to limit results
57
- def stream(limit: nil, page_size: nil)
58
- limits = @version.read_limits(limit, page_size)
59
-
60
- page = self.page(
61
- page_size: limits['page_size'],
62
- )
63
-
64
- @version.stream(page, limit: limits['limit'], page_limit: limits['page_limit'])
65
- end
66
-
67
- ##
68
- # When passed a block, yields CompletedInstance records from the API.
69
- # This operation lazily loads records as efficiently as possible until the limit
70
- # is reached.
71
- # @param [Integer] limit Upper limit for the number of records to return. stream()
72
- # guarantees to never return more than limit. Default is no limit
73
- # @param [Integer] page_size Number of records to fetch per request, when not set will use
74
- # the default value of 50 records. If no page_size is defined
75
- # but a limit is defined, stream() will attempt to read the
76
- # limit with the most efficient page size, i.e. min(limit, 1000)
77
- def each
78
- limits = @version.read_limits
79
-
80
- page = self.page(
81
- page_size: limits['page_size'],
82
- )
83
-
84
- @version.stream(page,
85
- limit: limits['limit'],
86
- page_limit: limits['page_limit']).each {|x| yield x}
87
- end
88
-
89
- ##
90
- # Retrieve a single page of CompletedInstance records from the API.
91
- # Request is executed immediately.
92
- # @param [String] page_token PageToken provided by the API
93
- # @param [Integer] page_number Page Number, this value is simply for client state
94
- # @param [Integer] page_size Number of records to return, defaults to 50
95
-
96
- # @return [Page] Page of CompletedInstance
97
- def page(page_token: nil, page_number: nil, page_size: nil)
98
- params = {
99
- 'PageToken' => page_token,
100
- 'Page' => page_number,
101
- 'PageSize' => page_size,
102
- }
103
- response = @version.page(
104
- 'GET',
105
- @uri,
106
- params
107
- )
108
- return CompletedPage.new(@version, response, @solution)
109
- end
110
-
111
- ##
112
- # Provide a user friendly representation
113
- def to_s
114
- '#<Twilio.Conversations.V1.CompletedList>'
115
- end
116
- end
117
-
118
- class CompletedPage < Page
119
- ##
120
- # Initialize the CompletedPage
121
- # @param [Version] version Version that contains the resource
122
- # @param [Response] response Response from the API
123
- # @param [Hash] solution Path solution for the resource
124
-
125
- # @return [CompletedPage] CompletedPage
126
- def initialize(version, response, solution)
127
- super(version, response)
128
-
129
- # Path Solution
130
- @solution = solution
131
- end
132
-
133
- ##
134
- # Build an instance of CompletedInstance
135
- # @param [Hash] payload Payload response from the API
136
-
137
- # @return [CompletedInstance] CompletedInstance
138
- def get_instance(payload)
139
- return CompletedInstance.new(
140
- @version,
141
- payload,
142
- )
143
- end
144
-
145
- ##
146
- # Provide a user friendly representation
147
- def to_s
148
- '<Twilio.Conversations.V1.CompletedPage>'
149
- end
150
- end
151
-
152
- class CompletedInstance < InstanceResource
153
- ##
154
- # Initialize the CompletedInstance
155
- # @param [Version] version Version that contains the resource
156
- # @param [Hash] payload payload that contains response from Twilio
157
-
158
- # @return [CompletedInstance] CompletedInstance
159
- def initialize(version, payload)
160
- super(version)
161
-
162
- # Marshaled Properties
163
- @properties = {
164
- 'sid' => payload['sid'],
165
- 'status' => payload['status'],
166
- 'duration' => payload['duration'].to_i,
167
- 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
168
- 'start_time' => Twilio.deserialize_iso8601(payload['start_time']),
169
- 'end_time' => Twilio.deserialize_iso8601(payload['end_time']),
170
- 'account_sid' => payload['account_sid'],
171
- 'url' => payload['url'],
172
- }
173
- end
174
-
175
- def sid
176
- @properties['sid']
177
- end
178
-
179
- def status
180
- @properties['status']
181
- end
182
-
183
- def duration
184
- @properties['duration']
185
- end
186
-
187
- def date_created
188
- @properties['date_created']
189
- end
190
-
191
- def start_time
192
- @properties['start_time']
193
- end
194
-
195
- def end_time
196
- @properties['end_time']
197
- end
198
-
199
- def account_sid
200
- @properties['account_sid']
201
- end
202
-
203
- def url
204
- @properties['url']
205
- end
206
-
207
- ##
208
- # Provide a user friendly representation
209
- def to_s
210
- "<Twilio.Conversations.V1.CompletedInstance>"
211
- end
212
- end
213
- end
214
- end
215
- end
216
- end
217
- end
@@ -1,217 +0,0 @@
1
- ##
2
- # This code was generated by
3
- # \ / _ _ _| _ _
4
- # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
- # / /
6
-
7
- module Twilio
8
- module REST
9
- class Conversations < Domain
10
- class V1 < Version
11
- class ConversationList < ListResource
12
- class InProgressList < ListResource
13
- ##
14
- # Initialize the InProgressList
15
- # @param [Version] version Version that contains the resource
16
-
17
- # @return [InProgressList] InProgressList
18
- def initialize(version)
19
- super(version)
20
-
21
- # Path Solution
22
- @solution = {}
23
- @uri = "/Conversations/InProgress"
24
- end
25
-
26
- ##
27
- # Lists InProgressInstance records from the API as a list.
28
- # Unlike stream(), this operation is eager and will load `limit` records into
29
- # memory before returning.
30
- # @param [Integer] limit Upper limit for the number of records to return. stream()
31
- # guarantees to never return more than limit. Default is no limit
32
- # @param [Integer] page_size Number of records to fetch per request, when not set will use
33
- # the default value of 50 records. If no page_size is defined
34
- # but a limit is defined, stream() will attempt to read the
35
- # limit with the most efficient page size, i.e. min(limit, 1000)
36
-
37
- # @return [Array] Array of up to limit results
38
- def list(limit: nil, page_size: nil)
39
- self.stream(
40
- limit: limit,
41
- page_size: page_size
42
- ).entries
43
- end
44
-
45
- ##
46
- # Streams InProgressInstance records from the API as an Enumerable.
47
- # This operation lazily loads records as efficiently as possible until the limit
48
- # is reached.
49
- # @param [Integer] limit Upper limit for the number of records to return. stream()
50
- # guarantees to never return more than limit. Default is no limit
51
- # @param [Integer] page_size Number of records to fetch per request, when not set will use
52
- # the default value of 50 records. If no page_size is defined
53
- # but a limit is defined, stream() will attempt to read the
54
- # limit with the most efficient page size, i.e. min(limit, 1000)
55
-
56
- # @return [Enumerable] Enumerable that will yield up to limit results
57
- def stream(limit: nil, page_size: nil)
58
- limits = @version.read_limits(limit, page_size)
59
-
60
- page = self.page(
61
- page_size: limits['page_size'],
62
- )
63
-
64
- @version.stream(page, limit: limits['limit'], page_limit: limits['page_limit'])
65
- end
66
-
67
- ##
68
- # When passed a block, yields InProgressInstance records from the API.
69
- # This operation lazily loads records as efficiently as possible until the limit
70
- # is reached.
71
- # @param [Integer] limit Upper limit for the number of records to return. stream()
72
- # guarantees to never return more than limit. Default is no limit
73
- # @param [Integer] page_size Number of records to fetch per request, when not set will use
74
- # the default value of 50 records. If no page_size is defined
75
- # but a limit is defined, stream() will attempt to read the
76
- # limit with the most efficient page size, i.e. min(limit, 1000)
77
- def each
78
- limits = @version.read_limits
79
-
80
- page = self.page(
81
- page_size: limits['page_size'],
82
- )
83
-
84
- @version.stream(page,
85
- limit: limits['limit'],
86
- page_limit: limits['page_limit']).each {|x| yield x}
87
- end
88
-
89
- ##
90
- # Retrieve a single page of InProgressInstance records from the API.
91
- # Request is executed immediately.
92
- # @param [String] page_token PageToken provided by the API
93
- # @param [Integer] page_number Page Number, this value is simply for client state
94
- # @param [Integer] page_size Number of records to return, defaults to 50
95
-
96
- # @return [Page] Page of InProgressInstance
97
- def page(page_token: nil, page_number: nil, page_size: nil)
98
- params = {
99
- 'PageToken' => page_token,
100
- 'Page' => page_number,
101
- 'PageSize' => page_size,
102
- }
103
- response = @version.page(
104
- 'GET',
105
- @uri,
106
- params
107
- )
108
- return InProgressPage.new(@version, response, @solution)
109
- end
110
-
111
- ##
112
- # Provide a user friendly representation
113
- def to_s
114
- '#<Twilio.Conversations.V1.InProgressList>'
115
- end
116
- end
117
-
118
- class InProgressPage < Page
119
- ##
120
- # Initialize the InProgressPage
121
- # @param [Version] version Version that contains the resource
122
- # @param [Response] response Response from the API
123
- # @param [Hash] solution Path solution for the resource
124
-
125
- # @return [InProgressPage] InProgressPage
126
- def initialize(version, response, solution)
127
- super(version, response)
128
-
129
- # Path Solution
130
- @solution = solution
131
- end
132
-
133
- ##
134
- # Build an instance of InProgressInstance
135
- # @param [Hash] payload Payload response from the API
136
-
137
- # @return [InProgressInstance] InProgressInstance
138
- def get_instance(payload)
139
- return InProgressInstance.new(
140
- @version,
141
- payload,
142
- )
143
- end
144
-
145
- ##
146
- # Provide a user friendly representation
147
- def to_s
148
- '<Twilio.Conversations.V1.InProgressPage>'
149
- end
150
- end
151
-
152
- class InProgressInstance < InstanceResource
153
- ##
154
- # Initialize the InProgressInstance
155
- # @param [Version] version Version that contains the resource
156
- # @param [Hash] payload payload that contains response from Twilio
157
-
158
- # @return [InProgressInstance] InProgressInstance
159
- def initialize(version, payload)
160
- super(version)
161
-
162
- # Marshaled Properties
163
- @properties = {
164
- 'sid' => payload['sid'],
165
- 'status' => payload['status'],
166
- 'duration' => payload['duration'].to_i,
167
- 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
168
- 'start_time' => Twilio.deserialize_iso8601(payload['start_time']),
169
- 'end_time' => Twilio.deserialize_iso8601(payload['end_time']),
170
- 'account_sid' => payload['account_sid'],
171
- 'url' => payload['url'],
172
- }
173
- end
174
-
175
- def sid
176
- @properties['sid']
177
- end
178
-
179
- def status
180
- @properties['status']
181
- end
182
-
183
- def duration
184
- @properties['duration']
185
- end
186
-
187
- def date_created
188
- @properties['date_created']
189
- end
190
-
191
- def start_time
192
- @properties['start_time']
193
- end
194
-
195
- def end_time
196
- @properties['end_time']
197
- end
198
-
199
- def account_sid
200
- @properties['account_sid']
201
- end
202
-
203
- def url
204
- @properties['url']
205
- end
206
-
207
- ##
208
- # Provide a user friendly representation
209
- def to_s
210
- "<Twilio.Conversations.V1.InProgressInstance>"
211
- end
212
- end
213
- end
214
- end
215
- end
216
- end
217
- end
@@ -1,352 +0,0 @@
1
- ##
2
- # This code was generated by
3
- # \ / _ _ _| _ _
4
- # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
- # / /
6
-
7
- module Twilio
8
- module REST
9
- class Conversations < Domain
10
- class V1 < Version
11
- class ConversationContext < InstanceContext
12
- class ParticipantList < ListResource
13
- ##
14
- # Initialize the ParticipantList
15
- # @param [Version] version Version that contains the resource
16
- # @param [String] conversation_sid The conversation_sid
17
-
18
- # @return [ParticipantList] ParticipantList
19
- def initialize(version, conversation_sid: nil)
20
- super(version)
21
-
22
- # Path Solution
23
- @solution = {
24
- conversation_sid: conversation_sid
25
- }
26
- @uri = "/Conversations/#{@solution[:conversation_sid]}/Participants"
27
- end
28
-
29
- ##
30
- # Lists ParticipantInstance records from the API as a list.
31
- # Unlike stream(), this operation is eager and will load `limit` records into
32
- # memory before returning.
33
- # @param [Integer] limit Upper limit for the number of records to return. stream()
34
- # guarantees to never return more than limit. Default is no limit
35
- # @param [Integer] page_size Number of records to fetch per request, when not set will use
36
- # the default value of 50 records. If no page_size is defined
37
- # but a limit is defined, stream() will attempt to read the
38
- # limit with the most efficient page size, i.e. min(limit, 1000)
39
-
40
- # @return [Array] Array of up to limit results
41
- def list(limit: nil, page_size: nil)
42
- self.stream(
43
- limit: limit,
44
- page_size: page_size
45
- ).entries
46
- end
47
-
48
- ##
49
- # Streams ParticipantInstance 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 not set will use
55
- # the default value of 50 records. If no page_size is defined
56
- # but a limit is defined, stream() will attempt to read the
57
- # limit with the most efficient page size, i.e. min(limit, 1000)
58
-
59
- # @return [Enumerable] Enumerable that will yield up to limit results
60
- def stream(limit: nil, page_size: nil)
61
- limits = @version.read_limits(limit, page_size)
62
-
63
- page = self.page(
64
- page_size: limits['page_size'],
65
- )
66
-
67
- @version.stream(page, limit: limits['limit'], page_limit: limits['page_limit'])
68
- end
69
-
70
- ##
71
- # When passed a block, yields ParticipantInstance records from the API.
72
- # This operation lazily loads records as efficiently as possible until the limit
73
- # is reached.
74
- # @param [Integer] limit Upper limit for the number of records to return. stream()
75
- # guarantees to never return more than limit. Default is no limit
76
- # @param [Integer] page_size Number of records to fetch per request, when not set will use
77
- # the default value of 50 records. If no page_size is defined
78
- # but a limit is defined, stream() will attempt to read the
79
- # limit with the most efficient page size, i.e. min(limit, 1000)
80
- def each
81
- limits = @version.read_limits
82
-
83
- page = self.page(
84
- page_size: limits['page_size'],
85
- )
86
-
87
- @version.stream(page,
88
- limit: limits['limit'],
89
- page_limit: limits['page_limit']).each {|x| yield x}
90
- end
91
-
92
- ##
93
- # Retrieve a single page of ParticipantInstance records from the API.
94
- # Request is executed immediately.
95
- # @param [String] page_token PageToken provided by the API
96
- # @param [Integer] page_number Page Number, this value is simply for client state
97
- # @param [Integer] page_size Number of records to return, defaults to 50
98
-
99
- # @return [Page] Page of ParticipantInstance
100
- def page(page_token: nil, page_number: nil, page_size: nil)
101
- params = {
102
- 'PageToken' => page_token,
103
- 'Page' => page_number,
104
- 'PageSize' => page_size,
105
- }
106
- response = @version.page(
107
- 'GET',
108
- @uri,
109
- params
110
- )
111
- return ParticipantPage.new(@version, response, @solution)
112
- end
113
-
114
- ##
115
- # Retrieve a single page of ParticipantInstance records from the API.
116
- # Request is executed immediately.
117
- # @param [String] to The to
118
- # @param [String] from The from
119
-
120
- # @return [ParticipantInstance] Newly created ParticipantInstance
121
- def create(to: nil, from: nil)
122
- data = {
123
- 'To' => to,
124
- 'From' => from,
125
- }
126
-
127
- payload = @version.create(
128
- 'POST',
129
- @uri,
130
- data: data
131
- )
132
-
133
- return ParticipantInstance.new(
134
- @version,
135
- payload,
136
- conversation_sid: @solution['conversation_sid'],
137
- )
138
- end
139
-
140
- ##
141
- # Constructs a ParticipantContext
142
- # @param [String] sid The sid
143
-
144
- # @return [ParticipantContext] ParticipantContext
145
- def get(sid)
146
- ParticipantContext.new(
147
- @version,
148
- conversation_sid: @solution[:conversation_sid],
149
- sid: sid,
150
- )
151
- end
152
-
153
- ##
154
- # Provide a user friendly representation
155
- def to_s
156
- '#<Twilio.Conversations.V1.ParticipantList>'
157
- end
158
- end
159
-
160
- class ParticipantPage < Page
161
- ##
162
- # Initialize the ParticipantPage
163
- # @param [Version] version Version that contains the resource
164
- # @param [Response] response Response from the API
165
- # @param [Hash] solution Path solution for the resource
166
- # @param [String] conversation_sid The conversation_sid
167
-
168
- # @return [ParticipantPage] ParticipantPage
169
- def initialize(version, response, solution)
170
- super(version, response)
171
-
172
- # Path Solution
173
- @solution = solution
174
- end
175
-
176
- ##
177
- # Build an instance of ParticipantInstance
178
- # @param [Hash] payload Payload response from the API
179
-
180
- # @return [ParticipantInstance] ParticipantInstance
181
- def get_instance(payload)
182
- return ParticipantInstance.new(
183
- @version,
184
- payload,
185
- conversation_sid: @solution['conversation_sid'],
186
- )
187
- end
188
-
189
- ##
190
- # Provide a user friendly representation
191
- def to_s
192
- '<Twilio.Conversations.V1.ParticipantPage>'
193
- end
194
- end
195
-
196
- class ParticipantContext < InstanceContext
197
- ##
198
- # Initialize the ParticipantContext
199
- # @param [Version] version Version that contains the resource
200
- # @param [String] conversation_sid The conversation_sid
201
- # @param [String] sid The sid
202
-
203
- # @return [ParticipantContext] ParticipantContext
204
- def initialize(version, conversation_sid, sid)
205
- super(version)
206
-
207
- # Path Solution
208
- @solution = {
209
- conversation_sid: conversation_sid,
210
- sid: sid,
211
- }
212
- @uri = "/Conversations/#{@solution[:conversation_sid]}/Participants/#{@solution[:sid]}"
213
- end
214
-
215
- ##
216
- # Fetch a ParticipantInstance
217
- # @return [ParticipantInstance] Fetched ParticipantInstance
218
- def fetch
219
- params = {}
220
-
221
- payload = @version.fetch(
222
- 'GET',
223
- @uri,
224
- params,
225
- )
226
-
227
- return ParticipantInstance.new(
228
- @version,
229
- payload,
230
- conversation_sid: @solution['conversation_sid'],
231
- sid: @solution['sid'],
232
- )
233
- end
234
-
235
- ##
236
- # Provide a user friendly representation
237
- def to_s
238
- context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
239
- "#<Twilio.Conversations.V1.ParticipantContext #{context}>"
240
- end
241
- end
242
-
243
- class ParticipantInstance < InstanceResource
244
- ##
245
- # Initialize the ParticipantInstance
246
- # @param [Version] version Version that contains the resource
247
- # @param [Hash] payload payload that contains response from Twilio
248
- # @param [String] conversation_sid The conversation_sid
249
- # @param [String] sid The sid
250
-
251
- # @return [ParticipantInstance] ParticipantInstance
252
- def initialize(version, payload, conversation_sid: nil, sid: nil)
253
- super(version)
254
-
255
- # Marshaled Properties
256
- @properties = {
257
- 'sid' => payload['sid'],
258
- 'address' => payload['address'],
259
- 'status' => payload['status'],
260
- 'conversation_sid' => payload['conversation_sid'],
261
- 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
262
- 'start_time' => Twilio.deserialize_iso8601(payload['start_time']),
263
- 'end_time' => Twilio.deserialize_iso8601(payload['end_time']),
264
- 'duration' => payload['duration'].to_i,
265
- 'account_sid' => payload['account_sid'],
266
- 'url' => payload['url'],
267
- }
268
-
269
- # Context
270
- @instance_context = nil
271
- @params = {
272
- 'conversation_sid' => conversation_sid,
273
- 'sid' => sid || @properties['sid'],
274
- }
275
- end
276
-
277
- ##
278
- # Generate an instance context for the instance, the context is capable of
279
- # performing various actions. All instance actions are proxied to the context
280
- # @param [Version] version Version that contains the resource
281
-
282
- # @return [ParticipantContext] ParticipantContext for this ParticipantInstance
283
- def context
284
- unless @instance_context
285
- @instance_context = ParticipantContext.new(
286
- @version,
287
- @params['conversation_sid'],
288
- @params['sid'],
289
- )
290
- end
291
- @instance_context
292
- end
293
-
294
- def sid
295
- @properties['sid']
296
- end
297
-
298
- def address
299
- @properties['address']
300
- end
301
-
302
- def status
303
- @properties['status']
304
- end
305
-
306
- def conversation_sid
307
- @properties['conversation_sid']
308
- end
309
-
310
- def date_created
311
- @properties['date_created']
312
- end
313
-
314
- def start_time
315
- @properties['start_time']
316
- end
317
-
318
- def end_time
319
- @properties['end_time']
320
- end
321
-
322
- def duration
323
- @properties['duration']
324
- end
325
-
326
- def account_sid
327
- @properties['account_sid']
328
- end
329
-
330
- def url
331
- @properties['url']
332
- end
333
-
334
- ##
335
- # Fetch a ParticipantInstance
336
- # @return [ParticipantInstance] Fetched ParticipantInstance
337
- def fetch
338
- @context.fetch()
339
- end
340
-
341
- ##
342
- # Provide a user friendly representation
343
- def to_s
344
- context = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
345
- "<Twilio.Conversations.V1.ParticipantInstance #{context}>"
346
- end
347
- end
348
- end
349
- end
350
- end
351
- end
352
- end