=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 ValidationRulesApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create Validation Rules Assignments # Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution. # @param validation_rule_id [String] Unique validation rule ID. # @param [Hash] opts the optional parameters # @option opts [Boolean] :force If this flag is set to true, the previous assignment with the same data will be deleted and a new one will be added. # @option opts [ValidationRulesAssignmentsCreateRequestBody] :validation_rules_assignments_create_request_body Specify the resource that you would like to assign the validation rule to. # @return [ValidationRulesAssignmentsCreateResponseBody] def create_validation_rule_assignment(validation_rule_id, opts = {}) data, _status_code, _headers = create_validation_rule_assignment_with_http_info(validation_rule_id, opts) data end # Create Validation Rules Assignments # Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution. # @param validation_rule_id [String] Unique validation rule ID. # @param [Hash] opts the optional parameters # @option opts [Boolean] :force If this flag is set to true, the previous assignment with the same data will be deleted and a new one will be added. # @option opts [ValidationRulesAssignmentsCreateRequestBody] :validation_rules_assignments_create_request_body Specify the resource that you would like to assign the validation rule to. # @return [Array<(ValidationRulesAssignmentsCreateResponseBody, Integer, Hash)>] ValidationRulesAssignmentsCreateResponseBody data, response status code and response headers private def create_validation_rule_assignment_with_http_info(validation_rule_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.create_validation_rule_assignment ...' end # resource path local_var_path = '/v1/validation-rules/{validationRuleId}/assignments'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'force'] = opts[:'force'] if !opts[:'force'].nil? # 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[:'validation_rules_assignments_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'ValidationRulesAssignmentsCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ValidationRulesApi.create_validation_rule_assignment", :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: ValidationRulesApi#create_validation_rule_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Validation Rules # Create validation rules. # @param [Hash] opts the optional parameters # @option opts [ValidationRulesCreateRequestBody] :validation_rules_create_request_body Specify the validation rules parameters. # @return [ValidationRulesCreateResponseBody] def create_validation_rules(opts = {}) data, _status_code, _headers = create_validation_rules_with_http_info(opts) data end # Create Validation Rules # Create validation rules. # @param [Hash] opts the optional parameters # @option opts [ValidationRulesCreateRequestBody] :validation_rules_create_request_body Specify the validation rules parameters. # @return [Array<(ValidationRulesCreateResponseBody, Integer, Hash)>] ValidationRulesCreateResponseBody data, response status code and response headers private def create_validation_rules_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.create_validation_rules ...' end # resource path local_var_path = '/v1/validation-rules' # 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[:'validation_rules_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'ValidationRulesCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ValidationRulesApi.create_validation_rules", :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: ValidationRulesApi#create_validation_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Validation Rule Assignment # This method deletes a validation rule assignment. # @param validation_rule_id [String] A unique validation rule ID. # @param assignment_id [String] A unique validation rule assignment ID. # @param [Hash] opts the optional parameters # @return [nil] def delete_validation_rule_assignment(validation_rule_id, assignment_id, opts = {}) delete_validation_rule_assignment_with_http_info(validation_rule_id, assignment_id, opts) nil end # Delete Validation Rule Assignment # This method deletes a validation rule assignment. # @param validation_rule_id [String] A unique validation rule ID. # @param assignment_id [String] A unique validation rule assignment ID. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers private def delete_validation_rule_assignment_with_http_info(validation_rule_id, assignment_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.delete_validation_rule_assignment ...' end # resource path local_var_path = '/v1/validation-rules/{validationRuleId}/assignments/{assignmentId}'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_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 => :"ValidationRulesApi.delete_validation_rule_assignment", :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: ValidationRulesApi#delete_validation_rule_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Validation Rule # This method deletes a validation rule. # @param validation_rule_id [String] A unique validation rule ID. # @param [Hash] opts the optional parameters # @return [nil] def delete_validation_rules(validation_rule_id, opts = {}) delete_validation_rules_with_http_info(validation_rule_id, opts) nil end # Delete Validation Rule # This method deletes a validation rule. # @param validation_rule_id [String] A unique validation rule ID. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers private def delete_validation_rules_with_http_info(validation_rule_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.delete_validation_rules ...' end # resource path local_var_path = '/v1/validation-rules/{validationRuleId}'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_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 => :"ValidationRulesApi.delete_validation_rules", :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: ValidationRulesApi#delete_validation_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Validation Rule # Retrieve the details of a validation rule. # @param validation_rule_id [String] A unique validation rule ID. # @param [Hash] opts the optional parameters # @return [ValidationRulesGetResponseBody] def get_validation_rule(validation_rule_id, opts = {}) data, _status_code, _headers = get_validation_rule_with_http_info(validation_rule_id, opts) data end # Get Validation Rule # Retrieve the details of a validation rule. # @param validation_rule_id [String] A unique validation rule ID. # @param [Hash] opts the optional parameters # @return [Array<(ValidationRulesGetResponseBody, Integer, Hash)>] ValidationRulesGetResponseBody data, response status code and response headers private def get_validation_rule_with_http_info(validation_rule_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.get_validation_rule ...' end # resource path local_var_path = '/v1/validation-rules/{validationRuleId}'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_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] || 'ValidationRulesGetResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ValidationRulesApi.get_validation_rule", :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: ValidationRulesApi#get_validation_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Validation Rule Assignments # Retrieve validation rule assignments for a specific validation rule. # @param validation_rule_id [String] Unique validation rule ID. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [ParameterOrderListValidationRuleAssignments] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [ValidationRulesAssignmentsListResponseBody] def list_validation_rule_assignments(validation_rule_id, opts = {}) data, _status_code, _headers = list_validation_rule_assignments_with_http_info(validation_rule_id, opts) data end # List Validation Rule Assignments # Retrieve validation rule assignments for a specific validation rule. # @param validation_rule_id [String] Unique validation rule ID. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [ParameterOrderListValidationRuleAssignments] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [Array<(ValidationRulesAssignmentsListResponseBody, Integer, Hash)>] ValidationRulesAssignmentsListResponseBody data, response status code and response headers private def list_validation_rule_assignments_with_http_info(validation_rule_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.list_validation_rule_assignments ...' end # resource path local_var_path = '/v1/validation-rules/{validationRuleId}/assignments'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_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? # 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] || 'ValidationRulesAssignmentsListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ValidationRulesApi.list_validation_rule_assignments", :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: ValidationRulesApi#list_validation_rule_assignments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Validation Rules # Retrieve validation rules. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [ParameterOrderListValidationRules] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @option opts [Time] :start_date Timestamp representing the date and time which results must start on. Represented in ISO 8601 format. # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. # @return [ValidationRulesListResponseBody] def list_validation_rules(opts = {}) data, _status_code, _headers = list_validation_rules_with_http_info(opts) data end # List Validation Rules # Retrieve validation rules. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [ParameterOrderListValidationRules] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @option opts [Time] :start_date Timestamp representing the date and time which results must start on. Represented in ISO 8601 format. # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. # @return [Array<(ValidationRulesListResponseBody, Integer, Hash)>] ValidationRulesListResponseBody data, response status code and response headers private def list_validation_rules_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.list_validation_rules ...' end # resource path local_var_path = '/v1/validation-rules' # 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[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil? query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].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] || 'ValidationRulesListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ValidationRulesApi.list_validation_rules", :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: ValidationRulesApi#list_validation_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Validation Rules' Assignment(s) # List all validation rules assignments or filter the results using the related object ID or the validation rule ID query parameters. # How to retrieve specific validation rule assignments(s) ## Related object ID To find an assignment for a particular resource, you can use the ID of the object to which the validation rule was assigned. This could be, for example, an ID of a: voucher, campaign, distribution, reward assignment, earning rule, promotion tier. ## Validation rule ID You can use the validation rule ID to find assignment(s) for a specific validation rule. # @param [Hash] opts the optional parameters # @option opts [String] :related_object_id The resource ID to which the validation rule was assigned; this could be, for example, a resource ID of a voucher, campaign, earning rule, reward assignment, promotion tier, or distribution. # @option opts [String] :rule Validation rule ID. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. # @option opts [String] :order Sorts the results using one of the filtering options: -created_at, created_at, where the dash - preceding a sorting option means sorting in a descending order. # @return [ValidationRulesAssignmentsListResponseBody] def list_validation_rules_assignments(opts = {}) data, _status_code, _headers = list_validation_rules_assignments_with_http_info(opts) data end # List Validation Rules' Assignment(s) # List all validation rules assignments or filter the results using the related object ID or the validation rule ID query parameters. # How to retrieve specific validation rule assignments(s) ## Related object ID To find an assignment for a particular resource, you can use the ID of the object to which the validation rule was assigned. This could be, for example, an ID of a: voucher, campaign, distribution, reward assignment, earning rule, promotion tier. ## Validation rule ID You can use the validation rule ID to find assignment(s) for a specific validation rule. # @param [Hash] opts the optional parameters # @option opts [String] :related_object_id The resource ID to which the validation rule was assigned; this could be, for example, a resource ID of a voucher, campaign, earning rule, reward assignment, promotion tier, or distribution. # @option opts [String] :rule Validation rule ID. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. # @option opts [String] :order Sorts the results using one of the filtering options: -created_at, created_at, where the dash - preceding a sorting option means sorting in a descending order. # @return [Array<(ValidationRulesAssignmentsListResponseBody, Integer, Hash)>] ValidationRulesAssignmentsListResponseBody data, response status code and response headers private def list_validation_rules_assignments_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.list_validation_rules_assignments ...' end # resource path local_var_path = '/v1/validation-rules-assignments' # query parameters query_params = opts[:query_params] || {} query_params[:'related_object_id'] = opts[:'related_object_id'] if !opts[:'related_object_id'].nil? query_params[:'rule'] = opts[:'rule'] if !opts[:'rule'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].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] || 'ValidationRulesAssignmentsListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ValidationRulesApi.list_validation_rules_assignments", :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: ValidationRulesApi#list_validation_rules_assignments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Validation Rule # Update validation rule parameters. # @param validation_rule_id [String] A unique validation rule ID. # @param [Hash] opts the optional parameters # @option opts [ValidationRulesUpdateRequestBody] :validation_rules_update_request_body Specify the parameters to be updated. # @return [ValidationRulesUpdateResponseBody] def update_validation_rule(validation_rule_id, opts = {}) data, _status_code, _headers = update_validation_rule_with_http_info(validation_rule_id, opts) data end # Update Validation Rule # Update validation rule parameters. # @param validation_rule_id [String] A unique validation rule ID. # @param [Hash] opts the optional parameters # @option opts [ValidationRulesUpdateRequestBody] :validation_rules_update_request_body Specify the parameters to be updated. # @return [Array<(ValidationRulesUpdateResponseBody, Integer, Hash)>] ValidationRulesUpdateResponseBody data, response status code and response headers private def update_validation_rule_with_http_info(validation_rule_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ValidationRulesApi.update_validation_rule ...' end # resource path local_var_path = '/v1/validation-rules/{validationRuleId}'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_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']) # 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[:'validation_rules_update_request_body']) # return_type return_type = opts[:debug_return_type] || 'ValidationRulesUpdateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ValidationRulesApi.update_validation_rule", :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(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ValidationRulesApi#update_validation_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end