lib/VoucherifySdk/api/validation_rules_api.rb in voucherify-5.0.0 vs lib/VoucherifySdk/api/validation_rules_api.rb in voucherify-6.0.0
- old
+ new
@@ -17,10 +17,79 @@
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]
@@ -102,18 +171,10 @@
# @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
- # verify the required parameter 'validation_rule_id' is set
- if @api_client.config.client_side_validation && validation_rule_id.nil?
- fail ArgumentError, "Missing the required parameter 'validation_rule_id' when calling ValidationRulesApi.delete_validation_rule_assignment"
- end
- # verify the required parameter 'assignment_id' is set
- if @api_client.config.client_side_validation && assignment_id.nil?
- fail ArgumentError, "Missing the required parameter 'assignment_id' when calling 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] || {}
@@ -167,14 +228,10 @@
# @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
- # verify the required parameter 'validation_rule_id' is set
- if @api_client.config.client_side_validation && validation_rule_id.nil?
- fail ArgumentError, "Missing the required parameter 'validation_rule_id' when calling 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] || {}
@@ -228,14 +285,10 @@
# @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
- # verify the required parameter 'validation_rule_id' is set
- if @api_client.config.client_side_validation && validation_rule_id.nil?
- fail ArgumentError, "Missing the required parameter 'validation_rule_id' when calling 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] || {}
@@ -276,12 +329,12 @@
# 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 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 [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
@@ -289,34 +342,18 @@
# 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 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 [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
- # verify the required parameter 'validation_rule_id' is set
- if @api_client.config.client_side_validation && validation_rule_id.nil?
- fail ArgumentError, "Missing the required parameter 'validation_rule_id' when calling ValidationRulesApi.list_validation_rule_assignments"
- end
- if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
- fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rule_assignments, 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 ValidationRulesApi.list_validation_rule_assignments, 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 ValidationRulesApi.list_validation_rule_assignments, must be smaller than or equal to 100.'
- 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] || {}
@@ -359,12 +396,12 @@
end
# List Validation Rules
# Retrieve validation rules.
# @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 [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 = {})
@@ -373,32 +410,20 @@
end
# List Validation Rules
# Retrieve validation rules.
# @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 [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
- if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
- fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rules, 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 ValidationRulesApi.list_validation_rules, 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 ValidationRulesApi.list_validation_rules, must be smaller than or equal to 100.'
- end
-
# resource path
local_var_path = '/v1/validation-rules'
# query parameters
query_params = opts[:query_params] || {}
@@ -445,12 +470,12 @@
# 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.
- # @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. 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
@@ -459,30 +484,18 @@
# 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.
- # @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. 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
- if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100
- fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ValidationRulesApi.list_validation_rules_assignments, must be smaller than or equal to 100.'
- end
-
- if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
- fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rules_assignments, 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 ValidationRulesApi.list_validation_rules_assignments, must be greater than or equal to 1.'
- end
-
# resource path
local_var_path = '/v1/validation-rules-assignments'
# query parameters
query_params = opts[:query_params] || {}
@@ -544,13 +557,9 @@
# @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
- # verify the required parameter 'validation_rule_id' is set
- if @api_client.config.client_side_validation && validation_rule_id.nil?
- fail ArgumentError, "Missing the required parameter 'validation_rule_id' when calling 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