=begin #Mailchimp Marketing API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 3.0.2 Contact: apihelp@mailchimp.com Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.12 =end require 'uri' module MailchimpMarketing class ConversationsApi attr_accessor :api_client def initialize(api_client) @api_client = api_client end # Get a list of conversations # Get a list of conversations for the account. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. # @option opts [Array<String>] :exclude_fields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. # @option opts [Integer] :count The number of records to return. [Default value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is **10**. [Maximum value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is **1000** (default to 10) # @option opts [Integer] :offset The number of records from a collection to skip. Iterating over large collections with this parameter can be slow. [Default value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is **0**. (default to 0) # @option opts [String] :has_unread_messages Whether the conversation has any unread messages. # @option opts [String] :list_id The unique id for the list. # @option opts [String] :campaign_id The unique id for the campaign. # @return [TrackedConversations] def list(opts = {}) data, _status_code, _headers = list_with_http_info(opts) data end # Get a list of conversations # Get a list of conversations for the account. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. # @option opts [Array<String>] :exclude_fields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. # @option opts [Integer] :count The number of records to return. [Default value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is **10**. [Maximum value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is **1000** # @option opts [Integer] :offset The number of records from a collection to skip. Iterating over large collections with this parameter can be slow. [Default value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is **0**. # @option opts [String] :has_unread_messages Whether the conversation has any unread messages. # @option opts [String] :list_id The unique id for the list. # @option opts [String] :campaign_id The unique id for the campaign. # @return [Array<(TrackedConversations, Fixnum, Hash)>] TrackedConversations data, response status code and response headers def list_with_http_info(opts = {}) # resource path local_var_path = '/conversations' # query parameters query_params = {} query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil? query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil? query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil? query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil? query_params[:'has_unread_messages'] = opts[:'has_unread_messages'] if !opts[:'has_unread_messages'].nil? query_params[:'list_id'] = opts[:'list_id'] if !opts[:'list_id'].nil? query_params[:'campaign_id'] = opts[:'campaign_id'] if !opts[:'campaign_id'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['basicAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TrackedConversations') return data, status_code, headers end # Get information about a conversation # Get details about an individual conversation. # @param conversation_id The unique id for the conversation. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. # @option opts [Array<String>] :exclude_fields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. # @return [Conversation] def get(conversation_id = {}, opts = {}) data, _status_code, _headers = get_with_http_info(conversation_id, opts) data end # Get information about a conversation # Get details about an individual conversation. # @param conversation_id The unique id for the conversation. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. # @option opts [Array<String>] :exclude_fields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. # @return [Array<(Conversation, Fixnum, Hash)>] Conversation data, response status code and response headers def get_with_http_info(conversation_id, opts = {}) # resource path local_var_path = '/conversations/{conversation_id}'.sub('{' + 'conversation_id' + '}', conversation_id.to_s) # query parameters query_params = {} query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil? query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['basicAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Conversation') return data, status_code, headers end # Get conversation messages # Get messages from a specific conversation. # @param conversation_id The unique id for the conversation. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. # @option opts [Array<String>] :exclude_fields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. # @option opts [String] :is_read Whether a conversation message has been marked as read. # @option opts [DateTime] :before_timestamp Restrict the response to messages created before the set time. We recommend [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time format: 2015-10-21T15:41:36+00:00. # @option opts [DateTime] :since_timestamp Restrict the response to messages created after the set time. We recommend [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time format: 2015-10-21T15:41:36+00:00. # @return [CollectionOfConversationMessages] def get_conversation_messages(conversation_id = {}, opts = {}) data, _status_code, _headers = get_conversation_messages_with_http_info(conversation_id, opts) data end # Get conversation messages # Get messages from a specific conversation. # @param conversation_id The unique id for the conversation. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. # @option opts [Array<String>] :exclude_fields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. # @option opts [String] :is_read Whether a conversation message has been marked as read. # @option opts [DateTime] :before_timestamp Restrict the response to messages created before the set time. We recommend [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time format: 2015-10-21T15:41:36+00:00. # @option opts [DateTime] :since_timestamp Restrict the response to messages created after the set time. We recommend [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time format: 2015-10-21T15:41:36+00:00. # @return [Array<(CollectionOfConversationMessages, Fixnum, Hash)>] CollectionOfConversationMessages data, response status code and response headers def get_conversation_messages_with_http_info(conversation_id, opts = {}) # resource path local_var_path = '/conversations/{conversation_id}/messages'.sub('{' + 'conversation_id' + '}', conversation_id.to_s) # query parameters query_params = {} query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil? query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil? query_params[:'is_read'] = opts[:'is_read'] if !opts[:'is_read'].nil? query_params[:'before_timestamp'] = opts[:'before_timestamp'] if !opts[:'before_timestamp'].nil? query_params[:'since_timestamp'] = opts[:'since_timestamp'] if !opts[:'since_timestamp'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['basicAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'CollectionOfConversationMessages') return data, status_code, headers end # Get a specific conversation message # Get an individual message in a conversation. # @param conversation_id The unique id for the conversation. # @param message_id The unique id for the conversation message. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. # @option opts [Array<String>] :exclude_fields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. # @return [ConversationMessage] def get_conversation_message(conversation_id = {}, message_id = {}, opts = {}) data, _status_code, _headers = get_conversation_message_with_http_info(conversation_id, message_id, opts) data end # Get a specific conversation message # Get an individual message in a conversation. # @param conversation_id The unique id for the conversation. # @param message_id The unique id for the conversation message. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. # @option opts [Array<String>] :exclude_fields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. # @return [Array<(ConversationMessage, Fixnum, Hash)>] ConversationMessage data, response status code and response headers def get_conversation_message_with_http_info(conversation_id, message_id, opts = {}) # resource path local_var_path = '/conversations/{conversation_id}/messages/{message_id}'.sub('{' + 'conversation_id' + '}', conversation_id.to_s).sub('{' + 'message_id' + '}', message_id.to_s) # query parameters query_params = {} query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil? query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['basicAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ConversationMessage') return data, status_code, headers end # Post a new conversation message # Post a new message to a conversation. # @param conversation_id The unique id for the conversation. # @param body # @param [Hash] opts the optional parameters # @return [ConversationMessage] def create_conversation_message(conversation_id = {}, body = {}, opts = {}) data, _status_code, _headers = create_conversation_message_with_http_info(conversation_id, body, opts) data end # Post a new conversation message # Post a new message to a conversation. # @param conversation_id The unique id for the conversation. # @param body # @param [Hash] opts the optional parameters # @return [Array<(ConversationMessage, Fixnum, Hash)>] ConversationMessage data, response status code and response headers def create_conversation_message_with_http_info(conversation_id, body, opts = {}) # resource path local_var_path = '/conversations/{conversation_id}/messages'.sub('{' + 'conversation_id' + '}', conversation_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['basicAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ConversationMessage') return data, status_code, headers end end end