=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 EcommerceApi 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 # Create orders in batch # Create multiple orders at one time instead of one order at a time # @param order_batch # @param [Hash] opts the optional parameters # @return [nil] def create_batch_order(order_batch, opts = {}) create_batch_order_with_http_info(order_batch, opts) nil end # Create orders in batch # Create multiple orders at one time instead of one order at a time # @param order_batch # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_batch_order_with_http_info(order_batch, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.create_batch_order ...' end # verify the required parameter 'order_batch' is set if @api_client.config.client_side_validation && order_batch.nil? fail ArgumentError, "Missing the required parameter 'order_batch' when calling EcommerceApi.create_batch_order" end # resource path local_var_path = '/orders/status/batch' # 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(order_batch) 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: EcommerceApi#create_batch_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Managing the status of the order # Manages the transactional status of the order # @param order # @param [Hash] opts the optional parameters # @return [nil] def create_order(order, opts = {}) create_order_with_http_info(order, opts) nil end # Managing the status of the order # Manages the transactional status of the order # @param order # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_order_with_http_info(order, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.create_order ...' end # verify the required parameter 'order' is set if @api_client.config.client_side_validation && order.nil? fail ArgumentError, "Missing the required parameter 'order' when calling EcommerceApi.create_order" end # resource path local_var_path = '/orders/status' # 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(order) 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: EcommerceApi#create_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create categories in batch # @param create_update_batch_category Values to create a batch of categories # @param [Hash] opts the optional parameters # @return [CreateUpdateBatchCategoryModel] def create_update_batch_category(create_update_batch_category, opts = {}) data, _status_code, _headers = create_update_batch_category_with_http_info(create_update_batch_category, opts) data end # Create categories in batch # @param create_update_batch_category Values to create a batch of categories # @param [Hash] opts the optional parameters # @return [Array<(CreateUpdateBatchCategoryModel, Fixnum, Hash)>] CreateUpdateBatchCategoryModel data, response status code and response headers def create_update_batch_category_with_http_info(create_update_batch_category, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.create_update_batch_category ...' end # verify the required parameter 'create_update_batch_category' is set if @api_client.config.client_side_validation && create_update_batch_category.nil? fail ArgumentError, "Missing the required parameter 'create_update_batch_category' when calling EcommerceApi.create_update_batch_category" end # resource path local_var_path = '/categories/batch' # 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(create_update_batch_category) 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 => 'CreateUpdateBatchCategoryModel') if @api_client.config.debugging @api_client.config.logger.debug "API called: EcommerceApi#create_update_batch_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create products in batch # @param create_update_batch_products Values to create a batch of products # @param [Hash] opts the optional parameters # @return [CreateUpdateBatchProductsModel] def create_update_batch_products(create_update_batch_products, opts = {}) data, _status_code, _headers = create_update_batch_products_with_http_info(create_update_batch_products, opts) data end # Create products in batch # @param create_update_batch_products Values to create a batch of products # @param [Hash] opts the optional parameters # @return [Array<(CreateUpdateBatchProductsModel, Fixnum, Hash)>] CreateUpdateBatchProductsModel data, response status code and response headers def create_update_batch_products_with_http_info(create_update_batch_products, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.create_update_batch_products ...' end # verify the required parameter 'create_update_batch_products' is set if @api_client.config.client_side_validation && create_update_batch_products.nil? fail ArgumentError, "Missing the required parameter 'create_update_batch_products' when calling EcommerceApi.create_update_batch_products" end # resource path local_var_path = '/products/batch' # 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(create_update_batch_products) 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 => 'CreateUpdateBatchProductsModel') if @api_client.config.debugging @api_client.config.logger.debug "API called: EcommerceApi#create_update_batch_products\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create/Update a category # @param create_update_category Values to create/update a category # @param [Hash] opts the optional parameters # @return [CreateCategoryModel] def create_update_category(create_update_category, opts = {}) data, _status_code, _headers = create_update_category_with_http_info(create_update_category, opts) data end # Create/Update a category # @param create_update_category Values to create/update a category # @param [Hash] opts the optional parameters # @return [Array<(CreateCategoryModel, Fixnum, Hash)>] CreateCategoryModel data, response status code and response headers def create_update_category_with_http_info(create_update_category, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.create_update_category ...' end # verify the required parameter 'create_update_category' is set if @api_client.config.client_side_validation && create_update_category.nil? fail ArgumentError, "Missing the required parameter 'create_update_category' when calling EcommerceApi.create_update_category" end # resource path local_var_path = '/categories' # 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(create_update_category) 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 => 'CreateCategoryModel') if @api_client.config.debugging @api_client.config.logger.debug "API called: EcommerceApi#create_update_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create/Update a product # @param create_update_product Values to create/update a product # @param [Hash] opts the optional parameters # @return [CreateProductModel] def create_update_product(create_update_product, opts = {}) data, _status_code, _headers = create_update_product_with_http_info(create_update_product, opts) data end # Create/Update a product # @param create_update_product Values to create/update a product # @param [Hash] opts the optional parameters # @return [Array<(CreateProductModel, Fixnum, Hash)>] CreateProductModel data, response status code and response headers def create_update_product_with_http_info(create_update_product, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.create_update_product ...' end # verify the required parameter 'create_update_product' is set if @api_client.config.client_side_validation && create_update_product.nil? fail ArgumentError, "Missing the required parameter 'create_update_product' when calling EcommerceApi.create_update_product" end # resource path local_var_path = '/products' # 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(create_update_product) 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 => 'CreateProductModel') if @api_client.config.debugging @api_client.config.logger.debug "API called: EcommerceApi#create_update_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Activate the eCommerce app # Getting access to Brevo eCommerce. # @param [Hash] opts the optional parameters # @return [nil] def ecommerce_activate_post(opts = {}) ecommerce_activate_post_with_http_info(opts) nil end # Activate the eCommerce app # Getting access to Brevo eCommerce. # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def ecommerce_activate_post_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.ecommerce_activate_post ...' end # resource path local_var_path = '/ecommerce/activate' # 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(: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: EcommerceApi#ecommerce_activate_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Return all your categories # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Number of documents per page (default to 50) # @option opts [Integer] :offset Index of the first document in the page (default to 0) # @option opts [String] :sort Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed (default to desc) # @option opts [Array] :ids Filter by category ids # @option opts [String] :name Filter by category name # @return [GetCategories] def get_categories(opts = {}) data, _status_code, _headers = get_categories_with_http_info(opts) data end # Return all your categories # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Number of documents per page # @option opts [Integer] :offset Index of the first document in the page # @option opts [String] :sort Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed # @option opts [Array] :ids Filter by category ids # @option opts [String] :name Filter by category name # @return [Array<(GetCategories, Fixnum, Hash)>] GetCategories data, response status code and response headers def get_categories_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.get_categories ...' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling EcommerceApi.get_categories, must be smaller than or equal to 100.' end if @api_client.config.client_side_validation && opts[:'sort'] && !['asc', 'desc'].include?(opts[:'sort']) fail ArgumentError, 'invalid value for "sort", must be one of asc, desc' end # resource path local_var_path = '/categories' # query parameters query_params = {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil? query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? query_params[:'ids'] = @api_client.build_collection_param(opts[:'ids'], :csv) if !opts[:'ids'].nil? query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil? # 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 => 'GetCategories') if @api_client.config.debugging @api_client.config.logger.debug "API called: EcommerceApi#get_categories\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a category details # @param id Category ID # @param [Hash] opts the optional parameters # @return [GetCategoryDetails] def get_category_info(id, opts = {}) data, _status_code, _headers = get_category_info_with_http_info(id, opts) data end # Get a category details # @param id Category ID # @param [Hash] opts the optional parameters # @return [Array<(GetCategoryDetails, Fixnum, Hash)>] GetCategoryDetails data, response status code and response headers def get_category_info_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.get_category_info ...' 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 EcommerceApi.get_category_info" end # resource path local_var_path = '/categories/{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 => 'GetCategoryDetails') if @api_client.config.debugging @api_client.config.logger.debug "API called: EcommerceApi#get_category_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a product's details # @param id Product ID # @param [Hash] opts the optional parameters # @return [GetProductDetails] def get_product_info(id, opts = {}) data, _status_code, _headers = get_product_info_with_http_info(id, opts) data end # Get a product's details # @param id Product ID # @param [Hash] opts the optional parameters # @return [Array<(GetProductDetails, Fixnum, Hash)>] GetProductDetails data, response status code and response headers def get_product_info_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.get_product_info ...' 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 EcommerceApi.get_product_info" end # resource path local_var_path = '/products/{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 => 'GetProductDetails') if @api_client.config.debugging @api_client.config.logger.debug "API called: EcommerceApi#get_product_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Return all your products # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Number of documents per page (default to 50) # @option opts [Integer] :offset Index of the first document in the page (default to 0) # @option opts [String] :sort Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed (default to desc) # @option opts [Array] :ids Filter by product ids # @option opts [String] :name Filter by product name, minimum 3 characters should be present for search # @option opts [Float] :price_lte Price filter for products less than and equals to particular amount # @option opts [Float] :price_gte Price filter for products greater than and equals to particular amount # @option opts [Float] :price_lt Price filter for products less than particular amount # @option opts [Float] :price_gt Price filter for products greater than particular amount # @option opts [Float] :price_eq Price filter for products equals to particular amount # @option opts [Float] :price_ne Price filter for products not equals to particular amount # @option opts [Array] :categories Filter by category ids # @return [GetProducts] def get_products(opts = {}) data, _status_code, _headers = get_products_with_http_info(opts) data end # Return all your products # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Number of documents per page # @option opts [Integer] :offset Index of the first document in the page # @option opts [String] :sort Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed # @option opts [Array] :ids Filter by product ids # @option opts [String] :name Filter by product name, minimum 3 characters should be present for search # @option opts [Float] :price_lte Price filter for products less than and equals to particular amount # @option opts [Float] :price_gte Price filter for products greater than and equals to particular amount # @option opts [Float] :price_lt Price filter for products less than particular amount # @option opts [Float] :price_gt Price filter for products greater than particular amount # @option opts [Float] :price_eq Price filter for products equals to particular amount # @option opts [Float] :price_ne Price filter for products not equals to particular amount # @option opts [Array] :categories Filter by category ids # @return [Array<(GetProducts, Fixnum, Hash)>] GetProducts data, response status code and response headers def get_products_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EcommerceApi.get_products ...' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling EcommerceApi.get_products, must be smaller than or equal to 1000.' end if @api_client.config.client_side_validation && opts[:'sort'] && !['asc', 'desc'].include?(opts[:'sort']) fail ArgumentError, 'invalid value for "sort", must be one of asc, desc' end # resource path local_var_path = '/products' # query parameters query_params = {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil? query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? query_params[:'ids'] = @api_client.build_collection_param(opts[:'ids'], :csv) if !opts[:'ids'].nil? query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil? query_params[:'price[lte]'] = opts[:'price_lte'] if !opts[:'price_lte'].nil? query_params[:'price[gte]'] = opts[:'price_gte'] if !opts[:'price_gte'].nil? query_params[:'price[lt]'] = opts[:'price_lt'] if !opts[:'price_lt'].nil? query_params[:'price[gt]'] = opts[:'price_gt'] if !opts[:'price_gt'].nil? query_params[:'price[eq]'] = opts[:'price_eq'] if !opts[:'price_eq'].nil? query_params[:'price[ne]'] = opts[:'price_ne'] if !opts[:'price_ne'].nil? query_params[:'categories'] = @api_client.build_collection_param(opts[:'categories'], :csv) if !opts[:'categories'].nil? # 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 => 'GetProducts') if @api_client.config.debugging @api_client.config.logger.debug "API called: EcommerceApi#get_products\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end