=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 CouponsApi 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 а coupon collection # @param create_coupon_collection Values to create a coupon collection # @param [Hash] opts the optional parameters # @return [InlineResponse2013] def create_coupon_collection(create_coupon_collection, opts = {}) data, _status_code, _headers = create_coupon_collection_with_http_info(create_coupon_collection, opts) data end # Create а coupon collection # @param create_coupon_collection Values to create a coupon collection # @param [Hash] opts the optional parameters # @return [Array<(InlineResponse2013, Fixnum, Hash)>] InlineResponse2013 data, response status code and response headers def create_coupon_collection_with_http_info(create_coupon_collection, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CouponsApi.create_coupon_collection ...' end # verify the required parameter 'create_coupon_collection' is set if @api_client.config.client_side_validation && create_coupon_collection.nil? fail ArgumentError, "Missing the required parameter 'create_coupon_collection' when calling CouponsApi.create_coupon_collection" end # resource path local_var_path = '/couponCollections' # 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_coupon_collection) 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 => 'InlineResponse2013') if @api_client.config.debugging @api_client.config.logger.debug "API called: CouponsApi#create_coupon_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create coupons for a coupon collection # @param create_coupons Values to create coupons # @param [Hash] opts the optional parameters # @return [nil] def create_coupons(create_coupons, opts = {}) create_coupons_with_http_info(create_coupons, opts) nil end # Create coupons for a coupon collection # @param create_coupons Values to create coupons # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_coupons_with_http_info(create_coupons, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CouponsApi.create_coupons ...' end # verify the required parameter 'create_coupons' is set if @api_client.config.client_side_validation && create_coupons.nil? fail ArgumentError, "Missing the required parameter 'create_coupons' when calling CouponsApi.create_coupons" end # resource path local_var_path = '/coupons' # 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_coupons) 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: CouponsApi#create_coupons\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a coupon collection by id # @param id Id of the collection to return # @param [Hash] opts the optional parameters # @return [GetCouponCollection] def get_coupon_collection(id, opts = {}) data, _status_code, _headers = get_coupon_collection_with_http_info(id, opts) data end # Get a coupon collection by id # @param id Id of the collection to return # @param [Hash] opts the optional parameters # @return [Array<(GetCouponCollection, Fixnum, Hash)>] GetCouponCollection data, response status code and response headers def get_coupon_collection_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_collection ...' 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 CouponsApi.get_coupon_collection" end # resource path local_var_path = '/couponCollections/{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 => 'GetCouponCollection') if @api_client.config.debugging @api_client.config.logger.debug "API called: CouponsApi#get_coupon_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all your coupon collections # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Number of documents returned per page (default to 50) # @option opts [Integer] :offset Index of the first document on the page (default to 0) # @option opts [String] :sort Sort the results by creation time in ascending/descending order (default to desc) # @option opts [Object] :sort_by The field used to sort coupon collections # @return [GetCouponCollection] def get_coupon_collections(opts = {}) data, _status_code, _headers = get_coupon_collections_with_http_info(opts) data end # Get all your coupon collections # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Number of documents returned per page # @option opts [Integer] :offset Index of the first document on the page # @option opts [String] :sort Sort the results by creation time in ascending/descending order # @option opts [Object] :sort_by The field used to sort coupon collections # @return [Array<(GetCouponCollection, Fixnum, Hash)>] GetCouponCollection data, response status code and response headers def get_coupon_collections_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_collections ...' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CouponsApi.get_coupon_collections, must be smaller than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 0 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CouponsApi.get_coupon_collections, must be greater than or equal to 0.' end if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0 fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling CouponsApi.get_coupon_collections, must be greater than or equal to 0.' 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 = '/couponCollections' # 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[:'sortBy'] = opts[:'sort_by'] if !opts[:'sort_by'].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 => 'GetCouponCollection') if @api_client.config.debugging @api_client.config.logger.debug "API called: CouponsApi#get_coupon_collections\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update a coupon collection by id # @param id Id of the collection to update # @param [Hash] opts the optional parameters # @option opts [UpdateCouponCollection] :update_coupon_collection Values to update the coupon collection # @return [InlineResponse2003] def update_coupon_collection(id, opts = {}) data, _status_code, _headers = update_coupon_collection_with_http_info(id, opts) data end # Update a coupon collection by id # @param id Id of the collection to update # @param [Hash] opts the optional parameters # @option opts [UpdateCouponCollection] :update_coupon_collection Values to update the coupon collection # @return [Array<(InlineResponse2003, Fixnum, Hash)>] InlineResponse2003 data, response status code and response headers def update_coupon_collection_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CouponsApi.update_coupon_collection ...' 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 CouponsApi.update_coupon_collection" end # resource path local_var_path = '/couponCollections/{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[:'update_coupon_collection']) auth_names = ['api-key', 'partner-key'] data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'InlineResponse2003') if @api_client.config.debugging @api_client.config.logger.debug "API called: CouponsApi#update_coupon_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end