=begin #Voucherify API #Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. The version of the OpenAPI document: v2018-08-01 Contact: support@voucherify.io Generated by: https://openapi-generator.tech OpenAPI Generator version: 7.0.1 =end require 'cgi' module VoucherifySdk class ProductCollectionsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create Product Collection # This method creates a new product collection. # @param [Hash] opts the optional parameters # @option opts [ProductCollectionsCreateRequestBody] :product_collections_create_request_body # @return [ProductCollectionsCreateResponseBody] def create_product_collection(opts = {}) data, _status_code, _headers = create_product_collection_with_http_info(opts) data end # Create Product Collection # This method creates a new product collection. # @param [Hash] opts the optional parameters # @option opts [ProductCollectionsCreateRequestBody] :product_collections_create_request_body # @return [Array<(ProductCollectionsCreateResponseBody, Integer, Hash)>] ProductCollectionsCreateResponseBody data, response status code and response headers private def create_product_collection_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.create_product_collection ...' end # resource path local_var_path = '/v1/product-collections' # 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' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'product_collections_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'ProductCollectionsCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ProductCollectionsApi.create_product_collection", :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: ProductCollectionsApi#create_product_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Product Collection # This method deletes a product collection. # @param product_collection_id [String] A unique product collection ID. # @param [Hash] opts the optional parameters # @return [nil] def delete_product_collection(product_collection_id, opts = {}) delete_product_collection_with_http_info(product_collection_id, opts) nil end # Delete Product Collection # This method deletes a product collection. # @param product_collection_id [String] A unique product collection ID. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers private def delete_product_collection_with_http_info(product_collection_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.delete_product_collection ...' end # verify the required parameter 'product_collection_id' is set if @api_client.config.client_side_validation && product_collection_id.nil? fail ArgumentError, "Missing the required parameter 'product_collection_id' when calling ProductCollectionsApi.delete_product_collection" end # resource path local_var_path = '/v1/product-collections/{productCollectionId}'.sub('{' + 'productCollectionId' + '}', CGI.escape(product_collection_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[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ProductCollectionsApi.delete_product_collection", :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: ProductCollectionsApi#delete_product_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Product Collection # Retrieves the product collection. # @param product_collection_id [String] A unique product collection ID. # @param [Hash] opts the optional parameters # @return [ProductCollectionsGetResponseBody] def get_product_collection(product_collection_id, opts = {}) data, _status_code, _headers = get_product_collection_with_http_info(product_collection_id, opts) data end # Get Product Collection # Retrieves the product collection. # @param product_collection_id [String] A unique product collection ID. # @param [Hash] opts the optional parameters # @return [Array<(ProductCollectionsGetResponseBody, Integer, Hash)>] ProductCollectionsGetResponseBody data, response status code and response headers private def get_product_collection_with_http_info(product_collection_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.get_product_collection ...' end # verify the required parameter 'product_collection_id' is set if @api_client.config.client_side_validation && product_collection_id.nil? fail ArgumentError, "Missing the required parameter 'product_collection_id' when calling ProductCollectionsApi.get_product_collection" end # resource path local_var_path = '/v1/product-collections/{productCollectionId}'.sub('{' + 'productCollectionId' + '}', CGI.escape(product_collection_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[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ProductCollectionsGetResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ProductCollectionsApi.get_product_collection", :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: ProductCollectionsApi#get_product_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Product Collections # This method returns a list of product collections. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [ProductCollectionsListResponseBody] def list_product_collections(opts = {}) data, _status_code, _headers = list_product_collections_with_http_info(opts) data end # List Product Collections # This method returns a list of product collections. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [Array<(ProductCollectionsListResponseBody, Integer, Hash)>] ProductCollectionsListResponseBody data, response status code and response headers private def list_product_collections_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.list_product_collections ...' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductCollectionsApi.list_product_collections, must be smaller than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductCollectionsApi.list_product_collections, must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ProductCollectionsApi.list_product_collections, must be smaller than or equal to 100.' end # resource path local_var_path = '/v1/product-collections' # query parameters query_params = opts[:query_params] || {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].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[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ProductCollectionsListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ProductCollectionsApi.list_product_collections", :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: ProductCollectionsApi#list_product_collections\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Products in Collection # Retrieves list of products from a product collection; works for both dynamic and static product collections. # @param product_collection_id [String] Unique product collection ID. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @option opts [Time] :starting_after Timestamp representing the date and time to use in starting_after cursor to get more data. Represented in ISO 8601 format. # @return [ProductCollectionsProductsListResponseBody] def list_products_in_collection(product_collection_id, opts = {}) data, _status_code, _headers = list_products_in_collection_with_http_info(product_collection_id, opts) data end # List Products in Collection # Retrieves list of products from a product collection; works for both dynamic and static product collections. # @param product_collection_id [String] Unique product collection ID. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @option opts [Time] :starting_after Timestamp representing the date and time to use in starting_after cursor to get more data. Represented in ISO 8601 format. # @return [Array<(ProductCollectionsProductsListResponseBody, Integer, Hash)>] ProductCollectionsProductsListResponseBody data, response status code and response headers private def list_products_in_collection_with_http_info(product_collection_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.list_products_in_collection ...' end # verify the required parameter 'product_collection_id' is set if @api_client.config.client_side_validation && product_collection_id.nil? fail ArgumentError, "Missing the required parameter 'product_collection_id' when calling ProductCollectionsApi.list_products_in_collection" end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductCollectionsApi.list_products_in_collection, must be smaller than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductCollectionsApi.list_products_in_collection, must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ProductCollectionsApi.list_products_in_collection, must be smaller than or equal to 100.' end # resource path local_var_path = '/v1/product-collections/{productCollectionId}/products'.sub('{' + 'productCollectionId' + '}', CGI.escape(product_collection_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? query_params[:'starting_after'] = opts[:'starting_after'] if !opts[:'starting_after'].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[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ProductCollectionsProductsListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ProductCollectionsApi.list_products_in_collection", :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: ProductCollectionsApi#list_products_in_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end