Class: Twilio::REST::Conversations::V2::ConversationList
- Inherits:
-
ListResource
- Object
- ListResource
- Twilio::REST::Conversations::V2::ConversationList
- Defined in:
- lib/twilio-ruby/rest/conversations/v2/conversation.rb
Defined Under Namespace
Classes: ConversationWorkflow, ConversationsV2Address, ConversationsV2CaptureRule, ConversationsV2StatusTimeouts, CreateConversationWithConfigRequest, CreateConversationWithConfigRequestConfiguration, CreateConversationWithConfigRequestConfigurationChannelSettingsValue, CreateConversationWithConfigRequestConfigurationChannelSettingsValueStatusTimeouts, CreateConversationWithConfigRequestConfigurationStatusCallbacks, CreateConversationWithConfigRequestParticipants, CreateConversationWithConfigRequestParticipantsAddresses, PatchConversationByIdRequest, PatchConversationByIdRequestConfiguration, UpdateConversationByIdRequest
Instance Method Summary collapse
-
#create(create_conversation_with_config_request: :unset) ⇒ ConversationInstance
Create the ConversationInstance.
-
#create_with_metadata(create_conversation_with_config_request: :unset) ⇒ ConversationInstance
Create the ConversationInstanceMetadata.
-
#each ⇒ Object
When passed a block, yields ConversationInstance records from the API.
-
#get_page(target_url) ⇒ Page
Retrieve a single page of ConversationInstance records from the API.
-
#initialize(version) ⇒ ConversationList
constructor
Initialize the ConversationList.
-
#list(status: :unset, channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Lists ConversationInstance records from the API as a list.
-
#list_with_metadata(status: :unset, channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Array of up to limit results.
-
#page(status: :unset, channel_id: :unset, page_token: :unset, page_size: :unset) ⇒ Page
Page of ConversationInstance.
-
#stream(status: :unset, 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) ⇒ ConversationList
Initialize the ConversationList
836 837 838 839 840 841 842 843 844 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 836 def initialize(version) apiV1Version = ApiV1Version.new version.domain, version super(apiV1Version) # Path Solution @solution = { } @uri = "/Conversations" end |
Instance Method Details
#create(create_conversation_with_config_request: :unset) ⇒ ConversationInstance
Create the ConversationInstance
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 849 def create(create_conversation_with_config_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_conversation_with_config_request.to_json) ConversationInstance.new( @version, payload, ) end |
#create_with_metadata(create_conversation_with_config_request: :unset) ⇒ ConversationInstance
Create the ConversationInstanceMetadata
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 869 def (create_conversation_with_config_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_conversation_with_config_request.to_json) conversation_instance = ConversationInstance.new( @version, response.body, ) ConversationInstanceMetadata.new( @version, conversation_instance, response.headers, response.status_code ) end |
#each ⇒ Object
When passed a block, yields ConversationInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
979 980 981 982 983 984 985 986 987 988 989 990 991 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 979 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 ConversationInstance records from the API. Request is executed immediately.
1023 1024 1025 1026 1027 1028 1029 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 1023 def get_page(target_url) response = @version.domain.request( 'GET', target_url ) ConversationPage.new(@version, response, @solution) end |
#list(status: :unset, channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Lists ConversationInstance records from the API as a list.
Unlike stream(), this operation is eager and will load limit records into
memory before returning.
906 907 908 909 910 911 912 913 914 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 906 def list(status: :unset, channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) self.stream( status: status, channel_id: channel_id, page_token: page_token, limit: limit, page_size: page_size ).entries end |
#list_with_metadata(status: :unset, channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Returns Array of up to limit results.
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 958 def (status: :unset, channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) params = Twilio::Values.of({ 'status' => Twilio.serialize_list(status) { |e| e }, 'channelId' => channel_id, 'pageToken' => page_token, 'PageSize' => limits[:page_size], }); headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) ConversationPageMetadata.new(@version, response, @solution, limits[:limit]) end |
#page(status: :unset, channel_id: :unset, page_token: :unset, page_size: :unset) ⇒ Page
Returns Page of ConversationInstance.
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 1001 def page(status: :unset, channel_id: :unset, page_token: :unset, page_size: :unset) params = Twilio::Values.of({ 'status' => Twilio.serialize_list(status) { |e| e }, 'channelId' => channel_id, 'pageToken' => page_token, 'PageSize' => page_size, }) headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) ConversationPage.new(@version, response, @solution) end |
#stream(status: :unset, 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.
930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 930 def stream(status: :unset, channel_id: :unset, page_token: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( status: status, 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
1034 1035 1036 |
# File 'lib/twilio-ruby/rest/conversations/v2/conversation.rb', line 1034 def to_s '#<Twilio.Conversations.V2.ConversationList>' end |