Class: Twilio::REST::Conversations::V2::CommunicationList
- Inherits:
-
ListResource
- Object
- ListResource
- Twilio::REST::Conversations::V2::CommunicationList
- Defined in:
- lib/twilio-ruby/rest/conversations/v2/communication.rb
Defined Under Namespace
Classes: ContentTranscriptionTranscription, ConversationsV2ContentTranscriptionTranscription, ConversationsV2ContentTranscriptionTranscriptionWords, CreateCommunicationInConversationRequest, CreateCommunicationInConversationRequestAuthor, CreateCommunicationInConversationRequestContent
Instance Method Summary collapse
-
#create(create_communication_in_conversation_request: :unset) ⇒ CommunicationInstance
Create the CommunicationInstance.
-
#create_with_metadata(create_communication_in_conversation_request: :unset) ⇒ CommunicationInstance
Create the CommunicationInstanceMetadata.
-
#each ⇒ Object
When passed a block, yields CommunicationInstance records from the API.
-
#get_page(target_url) ⇒ Page
Retrieve a single page of CommunicationInstance records from the API.
-
#initialize(version, conversation_sid: nil) ⇒ CommunicationList
constructor
Initialize the CommunicationList.
-
#list(channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Lists CommunicationInstance records from the API as a list.
-
#list_with_metadata(channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Array of up to limit results.
-
#page(channel_id: :unset, page_token: :unset, page_size: :unset) ⇒ Page
Page of CommunicationInstance.
-
#stream(channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Enumerable
Streams Instance records from the API as an Enumerable.
-
#to_s ⇒ Object
Provide a user friendly representation.
Constructor Details
#initialize(version, conversation_sid: nil) ⇒ CommunicationList
Initialize the CommunicationList
147 148 149 150 151 152 153 154 155 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 147 def initialize(version, conversation_sid: nil) apiV1Version = ApiV1Version.new version.domain, version super(apiV1Version) # Path Solution @solution = { conversation_sid: conversation_sid } @uri = "/Conversations/#{@solution[:conversation_sid]}/Communications" end |
Instance Method Details
#create(create_communication_in_conversation_request: :unset) ⇒ CommunicationInstance
Create the CommunicationInstance
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 160 def create(create_communication_in_conversation_request: :unset ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) headers['Content-Type'] = 'application/json' payload = @version.create('POST', @uri, headers: headers, data: create_communication_in_conversation_request.to_json) CommunicationInstance.new( @version, payload, conversation_sid: @solution[:conversation_sid], ) end |
#create_with_metadata(create_communication_in_conversation_request: :unset) ⇒ CommunicationInstance
Create the CommunicationInstanceMetadata
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 181 def (create_communication_in_conversation_request: :unset ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) headers['Content-Type'] = 'application/json' response = @version.('POST', @uri, headers: headers, data: create_communication_in_conversation_request.to_json) communication_instance = CommunicationInstance.new( @version, response.body, conversation_sid: @solution[:conversation_sid], ) CommunicationInstanceMetadata.new( @version, communication_instance, response.headers, response.status_code ) end |
#each ⇒ Object
When passed a block, yields CommunicationInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 285 def each limits = @version.read_limits page = self.page(page_size: limits[:page_size], ) return [].each if page.nil? result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) return [].each if result.nil? result.each {|x| yield x} end |
#get_page(target_url) ⇒ Page
Retrieve a single page of CommunicationInstance records from the API. Request is executed immediately.
326 327 328 329 330 331 332 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 326 def get_page(target_url) response = @version.domain.request( 'GET', target_url ) CommunicationPage.new(@version, response, @solution) end |
#list(channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Lists CommunicationInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.
218 219 220 221 222 223 224 225 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 218 def list(channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) self.stream( channel_id: channel_id, page_token: page_token, limit: limit, page_size: page_size ).entries end |
#list_with_metadata(channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Returns Array of up to limit results.
266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 266 def (channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) params = Twilio::Values.of({ 'channelId' => channel_id, 'pageToken' => page_token, 'PageSize' => limits[:page_size], }); headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) CommunicationPageMetadata.new(@version, response, @solution, limits[:limit]) end |
#page(channel_id: :unset, page_token: :unset, page_size: :unset) ⇒ Page
Returns Page of CommunicationInstance.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 306 def page(channel_id: :unset, page_token: :unset, page_size: :unset) params = Twilio::Values.of({ 'channelId' => channel_id, 'pageToken' => page_token, 'PageSize' => page_size, }) headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) CommunicationPage.new(@version, response, @solution) end |
#stream(channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Enumerable
Streams Instance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.
240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 240 def stream(channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( channel_id: channel_id, page_token: page_token, page_size: limits[:page_size], ) return [].each if page.nil? result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) return [].each if result.nil? result end |
#to_s ⇒ Object
Provide a user friendly representation
337 338 339 |
# File 'lib/twilio-ruby/rest/conversations/v2/communication.rb', line 337 def to_s '#<Twilio.Conversations.V2.CommunicationList>' end |