=begin #Brevo API #Brevo provide a RESTFul API that can be used with any languages. With this API, you will be able to : - Manage your campaigns and get the statistics - Manage your contacts - Send transactional Emails and SMS - and much more... You can download our wrappers at https://github.com/orgs/brevo **Possible responses** | Code | Message | | :-------------: | ------------- | | 200 | OK. Successful Request | | 201 | OK. Successful Creation | | 202 | OK. Request accepted | | 204 | OK. Successful Update/Deletion | | 400 | Error. Bad Request | | 401 | Error. Authentication Needed | | 402 | Error. Not enough credit, plan upgrade needed | | 403 | Error. Permission denied | | 404 | Error. Object does not exist | | 405 | Error. Method not allowed | | 406 | Error. Not Acceptable | OpenAPI spec version: 3.0.0 Contact: contact@brevo.com Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.19 =end require 'uri' module Brevo class ConversationsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Set custom user_agent if explicitly passed in api # default will still remain Swagger-Codegen/#{VERSION}/ruby def setUserAgent(user_agent) @user_agent = user_agent if user_agent.is_a?(String) && user_agent.downcase.start_with?('brevo_') @api_client.default_headers['User-Agent'] = @user_agent end end # Sets agent’s status to online for 2-3 minutes # We recommend pinging this endpoint every minute for as long as the agent has to be considered online. # @param body Agent fields. # @param [Hash] opts the optional parameters # @return [nil] def conversations_agent_online_ping_post(body, opts = {}) conversations_agent_online_ping_post_with_http_info(body, opts) nil end # Sets agent’s status to online for 2-3 minutes # We recommend pinging this endpoint every minute for as long as the agent has to be considered online. # @param body Agent fields. # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def conversations_agent_online_ping_post_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_agent_online_ping_post ...' end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling ConversationsApi.conversations_agent_online_ping_post" end # resource path local_var_path = '/conversations/agentOnlinePing' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/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 = ['api-key', 'partner-key'] 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) if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_agent_online_ping_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete a message sent by an agent # Only agents’ messages can be deleted. # @param id ID of the message # @param [Hash] opts the optional parameters # @return [nil] def conversations_messages_id_delete(id, opts = {}) conversations_messages_id_delete_with_http_info(id, opts) nil end # Delete a message sent by an agent # Only agents’ messages can be deleted. # @param id ID of the message # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def conversations_messages_id_delete_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_messages_id_delete ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ConversationsApi.conversations_messages_id_delete" end # resource path local_var_path = '/conversations/messages/{id}'.sub('{' + 'id' + '}', 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']) # 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 = ['api-key', 'partner-key'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_messages_id_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a message # @param id ID of the message # @param [Hash] opts the optional parameters # @return [ConversationsMessage] def conversations_messages_id_get(id, opts = {}) data, _status_code, _headers = conversations_messages_id_get_with_http_info(id, opts) data end # Get a message # @param id ID of the message # @param [Hash] opts the optional parameters # @return [Array<(ConversationsMessage, Fixnum, Hash)>] ConversationsMessage data, response status code and response headers def conversations_messages_id_get_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_messages_id_get ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ConversationsApi.conversations_messages_id_get" end # resource path local_var_path = '/conversations/messages/{id}'.sub('{' + 'id' + '}', 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']) # 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 = ['api-key', 'partner-key'] 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 => 'ConversationsMessage') if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_messages_id_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update a message sent by an agent # Only agents’ messages can be edited. # @param id ID of the message # @param [Hash] opts the optional parameters # @option opts [Body9] :body # @return [ConversationsMessage] def conversations_messages_id_put(id, opts = {}) data, _status_code, _headers = conversations_messages_id_put_with_http_info(id, opts) data end # Update a message sent by an agent # Only agents’ messages can be edited. # @param id ID of the message # @param [Hash] opts the optional parameters # @option opts [Body9] :body # @return [Array<(ConversationsMessage, Fixnum, Hash)>] ConversationsMessage data, response status code and response headers def conversations_messages_id_put_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_messages_id_put ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ConversationsApi.conversations_messages_id_put" end # resource path local_var_path = '/conversations/messages/{id}'.sub('{' + 'id' + '}', 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']) # 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(opts[:'body']) auth_names = ['api-key', 'partner-key'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ConversationsMessage') if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_messages_id_put\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Send a message as an agent # @param body Message fields. # @param [Hash] opts the optional parameters # @return [ConversationsMessage] def conversations_messages_post(body, opts = {}) data, _status_code, _headers = conversations_messages_post_with_http_info(body, opts) data end # Send a message as an agent # @param body Message fields. # @param [Hash] opts the optional parameters # @return [Array<(ConversationsMessage, Fixnum, Hash)>] ConversationsMessage data, response status code and response headers def conversations_messages_post_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_messages_post ...' end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling ConversationsApi.conversations_messages_post" end # resource path local_var_path = '/conversations/messages' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/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 = ['api-key', 'partner-key'] 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 => 'ConversationsMessage') if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_messages_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete an automated message # @param id ID of the message # @param [Hash] opts the optional parameters # @return [nil] def conversations_pushed_messages_id_delete(id, opts = {}) conversations_pushed_messages_id_delete_with_http_info(id, opts) nil end # Delete an automated message # @param id ID of the message # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def conversations_pushed_messages_id_delete_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_pushed_messages_id_delete ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ConversationsApi.conversations_pushed_messages_id_delete" end # resource path local_var_path = '/conversations/pushedMessages/{id}'.sub('{' + 'id' + '}', 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']) # 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 = ['api-key', 'partner-key'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_pushed_messages_id_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get an automated message # @param id ID of the message sent previously # @param [Hash] opts the optional parameters # @return [ConversationsMessage] def conversations_pushed_messages_id_get(id, opts = {}) data, _status_code, _headers = conversations_pushed_messages_id_get_with_http_info(id, opts) data end # Get an automated message # @param id ID of the message sent previously # @param [Hash] opts the optional parameters # @return [Array<(ConversationsMessage, Fixnum, Hash)>] ConversationsMessage data, response status code and response headers def conversations_pushed_messages_id_get_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_pushed_messages_id_get ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ConversationsApi.conversations_pushed_messages_id_get" end # resource path local_var_path = '/conversations/pushedMessages/{id}'.sub('{' + 'id' + '}', 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']) # 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 = ['api-key', 'partner-key'] 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 => 'ConversationsMessage') if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_pushed_messages_id_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update an automated message # @param id ID of the message # @param body # @param [Hash] opts the optional parameters # @return [ConversationsMessage] def conversations_pushed_messages_id_put(id, body, opts = {}) data, _status_code, _headers = conversations_pushed_messages_id_put_with_http_info(id, body, opts) data end # Update an automated message # @param id ID of the message # @param body # @param [Hash] opts the optional parameters # @return [Array<(ConversationsMessage, Fixnum, Hash)>] ConversationsMessage data, response status code and response headers def conversations_pushed_messages_id_put_with_http_info(id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_pushed_messages_id_put ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ConversationsApi.conversations_pushed_messages_id_put" end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling ConversationsApi.conversations_pushed_messages_id_put" end # resource path local_var_path = '/conversations/pushedMessages/{id}'.sub('{' + 'id' + '}', 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']) # 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 = ['api-key', 'partner-key'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ConversationsMessage') if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_pushed_messages_id_put\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Send an automated message to a visitor # Example of automated messages: order status, announce new features in your web app, etc. # @param body # @param [Hash] opts the optional parameters # @return [ConversationsMessage] def conversations_pushed_messages_post(body, opts = {}) data, _status_code, _headers = conversations_pushed_messages_post_with_http_info(body, opts) data end # Send an automated message to a visitor # Example of automated messages: order status, announce new features in your web app, etc. # @param body # @param [Hash] opts the optional parameters # @return [Array<(ConversationsMessage, Fixnum, Hash)>] ConversationsMessage data, response status code and response headers def conversations_pushed_messages_post_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ConversationsApi.conversations_pushed_messages_post ...' end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling ConversationsApi.conversations_pushed_messages_post" end # resource path local_var_path = '/conversations/pushedMessages' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/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 = ['api-key', 'partner-key'] 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 => 'ConversationsMessage') if @api_client.config.debugging @api_client.config.logger.debug "API called: ConversationsApi#conversations_pushed_messages_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end