=begin #MailSlurp API #MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository The version of the OpenAPI document: d1659dc1567a5b62f65d0612107a50aace03e085 Generated by: https://openapi-generator.tech OpenAPI Generator version: 4.2.3 =end require 'cgi' module MailSlurpClient class ContactControllerApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create a contact # @param create_contact_options [CreateContactOptions] createContactOptions # @param [Hash] opts the optional parameters # @return [ContactDto] def create_contact(create_contact_options, opts = {}) data, _status_code, _headers = create_contact_with_http_info(create_contact_options, opts) data end # Create a contact # @param create_contact_options [CreateContactOptions] createContactOptions # @param [Hash] opts the optional parameters # @return [Array<(ContactDto, Integer, Hash)>] ContactDto data, response status code and response headers def create_contact_with_http_info(create_contact_options, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ContactControllerApi.create_contact ...' end # verify the required parameter 'create_contact_options' is set if @api_client.config.client_side_validation && create_contact_options.nil? fail ArgumentError, "Missing the required parameter 'create_contact_options' when calling ContactControllerApi.create_contact" end # resource path local_var_path = '/contacts' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[: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 = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(create_contact_options) # return_type return_type = opts[:return_type] || 'ContactDto' # auth_names auth_names = opts[:auth_names] || ['API_KEY'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ContactControllerApi#create_contact\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete contact # @param contact_id [String] contactId # @param [Hash] opts the optional parameters # @return [nil] def delete_contact(contact_id, opts = {}) delete_contact_with_http_info(contact_id, opts) nil end # Delete contact # @param contact_id [String] contactId # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_contact_with_http_info(contact_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ContactControllerApi.delete_contact ...' end # verify the required parameter 'contact_id' is set if @api_client.config.client_side_validation && contact_id.nil? fail ArgumentError, "Missing the required parameter 'contact_id' when calling ContactControllerApi.delete_contact" end # resource path local_var_path = '/contacts/{contactId}'.sub('{' + 'contactId' + '}', CGI.escape(contact_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] # auth_names auth_names = opts[:auth_names] || ['API_KEY'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ContactControllerApi#delete_contact\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all contacts # @param [Hash] opts the optional parameters # @option opts [Integer] :page Optional page index in inbox list pagination (default to 0) # @option opts [Integer] :size Optional page size in inbox list pagination (default to 20) # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC') # @return [PageContactProjection] def get_all_contacts(opts = {}) data, _status_code, _headers = get_all_contacts_with_http_info(opts) data end # Get all contacts # @param [Hash] opts the optional parameters # @option opts [Integer] :page Optional page index in inbox list pagination # @option opts [Integer] :size Optional page size in inbox list pagination # @option opts [String] :sort Optional createdAt sort direction ASC or DESC # @return [Array<(PageContactProjection, Integer, Hash)>] PageContactProjection data, response status code and response headers def get_all_contacts_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ContactControllerApi.get_all_contacts ...' end allowable_values = ["ASC", "DESC"] if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort']) fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}" end # resource path local_var_path = '/contacts/paginated' # query parameters query_params = opts[:query_params] || {} query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil? query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'PageContactProjection' # auth_names auth_names = opts[:auth_names] || ['API_KEY'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ContactControllerApi#get_all_contacts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get contact # @param contact_id [String] contactId # @param [Hash] opts the optional parameters # @return [ContactDto] def get_contact(contact_id, opts = {}) data, _status_code, _headers = get_contact_with_http_info(contact_id, opts) data end # Get contact # @param contact_id [String] contactId # @param [Hash] opts the optional parameters # @return [Array<(ContactDto, Integer, Hash)>] ContactDto data, response status code and response headers def get_contact_with_http_info(contact_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ContactControllerApi.get_contact ...' end # verify the required parameter 'contact_id' is set if @api_client.config.client_side_validation && contact_id.nil? fail ArgumentError, "Missing the required parameter 'contact_id' when calling ContactControllerApi.get_contact" end # resource path local_var_path = '/contacts/{contactId}'.sub('{' + 'contactId' + '}', CGI.escape(contact_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'ContactDto' # auth_names auth_names = opts[:auth_names] || ['API_KEY'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ContactControllerApi#get_contact\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all contacts # @param [Hash] opts the optional parameters # @return [Array] def get_contacts(opts = {}) data, _status_code, _headers = get_contacts_with_http_info(opts) data end # Get all contacts # @param [Hash] opts the optional parameters # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers def get_contacts_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ContactControllerApi.get_contacts ...' end # resource path local_var_path = '/contacts' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'Array' # auth_names auth_names = opts[:auth_names] || ['API_KEY'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ContactControllerApi#get_contacts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end