From cc6a76a2c21a288ec790aab9e10b56d476953912 Mon Sep 17 00:00:00 2001 From: dvacca-onfido <134616519+dvacca-onfido@users.noreply.github.com> Date: Fri, 17 May 2024 12:49:23 +0000 Subject: [PATCH] Upgrade after onfido-openapi-spec change 3370037 --- lib/onfido.rb | 10 +- lib/onfido/api/default_api.rb | 104 +++---- lib/onfido/api_client.rb | 2 +- ...sk_request.rb => complete_task_builder.rb} | 16 +- .../models/complete_task_builder_data.rb | 106 +++++++ lib/onfido/models/watchlist_monitor.rb | 91 +++--- .../models/watchlist_monitor_builder.rb | 292 ++++++++++++++++++ lib/onfido/models/watchlist_monitor_match.rb | 14 +- .../models/watchlist_monitor_matches_list.rb | 223 +++++++++++++ ...b => watchlist_monitor_matches_updater.rb} | 6 +- .../models/watchlist_monitor_response.rb | 254 +++++++++++++++ lib/onfido/models/watchlist_monitor_shared.rb | 285 +++++++++++++++++ lib/onfido/models/watchlist_monitors_list.rb | 223 +++++++++++++ 13 files changed, 1518 insertions(+), 108 deletions(-) rename lib/onfido/models/{complete_task_request.rb => complete_task_builder.rb} (94%) create mode 100644 lib/onfido/models/complete_task_builder_data.rb create mode 100644 lib/onfido/models/watchlist_monitor_builder.rb create mode 100644 lib/onfido/models/watchlist_monitor_matches_list.rb rename lib/onfido/models/{update_monitor_match_request.rb => watchlist_monitor_matches_updater.rb} (96%) create mode 100644 lib/onfido/models/watchlist_monitor_response.rb create mode 100644 lib/onfido/models/watchlist_monitor_shared.rb create mode 100644 lib/onfido/models/watchlist_monitors_list.rb diff --git a/lib/onfido.rb b/lib/onfido.rb index c1a5fa2..0cbd0cb 100644 --- a/lib/onfido.rb +++ b/lib/onfido.rb @@ -36,7 +36,8 @@ require 'onfido/models/check_response' require 'onfido/models/check_shared' require 'onfido/models/checks_list' -require 'onfido/models/complete_task_request' +require 'onfido/models/complete_task_builder' +require 'onfido/models/complete_task_builder_data' require 'onfido/models/consent_item' require 'onfido/models/consents_builder' require 'onfido/models/country_codes' @@ -230,7 +231,6 @@ require 'onfido/models/sdk_token_request' require 'onfido/models/sdk_token_response' require 'onfido/models/task' -require 'onfido/models/update_monitor_match_request' require 'onfido/models/us_driving_licence_breakdown' require 'onfido/models/us_driving_licence_breakdown_address' require 'onfido/models/us_driving_licence_breakdown_address_breakdown' @@ -253,7 +253,13 @@ require 'onfido/models/watchlist_enhanced_properties' require 'onfido/models/watchlist_enhanced_report' require 'onfido/models/watchlist_monitor' +require 'onfido/models/watchlist_monitor_builder' require 'onfido/models/watchlist_monitor_match' +require 'onfido/models/watchlist_monitor_matches_list' +require 'onfido/models/watchlist_monitor_matches_updater' +require 'onfido/models/watchlist_monitor_response' +require 'onfido/models/watchlist_monitor_shared' +require 'onfido/models/watchlist_monitors_list' require 'onfido/models/watchlist_peps_only_report' require 'onfido/models/watchlist_sanctions_only_report' require 'onfido/models/watchlist_standard_breakdown' diff --git a/lib/onfido/api/default_api.rb b/lib/onfido/api/default_api.rb index c115fa7..362e9b6 100644 --- a/lib/onfido/api/default_api.rb +++ b/lib/onfido/api/default_api.rb @@ -86,11 +86,11 @@ def cancel_report_with_http_info(report_id, opts = {}) # Completes a Send / Receive Data Task. # @param workflow_run_id [String] The unique identifier of the Workflow Run to which the Task belongs. # @param task_id [String] The identifier of the Task you want to complete. - # @param complete_task_request [CompleteTaskRequest] + # @param complete_task_builder [CompleteTaskBuilder] # @param [Hash] opts the optional parameters # @return [nil] - def complete_task(workflow_run_id, task_id, complete_task_request, opts = {}) - complete_task_with_http_info(workflow_run_id, task_id, complete_task_request, opts) + def complete_task(workflow_run_id, task_id, complete_task_builder, opts = {}) + complete_task_with_http_info(workflow_run_id, task_id, complete_task_builder, opts) nil end @@ -98,10 +98,10 @@ def complete_task(workflow_run_id, task_id, complete_task_request, opts = {}) # Completes a Send / Receive Data Task. # @param workflow_run_id [String] The unique identifier of the Workflow Run to which the Task belongs. # @param task_id [String] The identifier of the Task you want to complete. - # @param complete_task_request [CompleteTaskRequest] + # @param complete_task_builder [CompleteTaskBuilder] # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers - def complete_task_with_http_info(workflow_run_id, task_id, complete_task_request, opts = {}) + def complete_task_with_http_info(workflow_run_id, task_id, complete_task_builder, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefaultApi.complete_task ...' end @@ -113,9 +113,9 @@ def complete_task_with_http_info(workflow_run_id, task_id, complete_task_request if @api_client.config.client_side_validation && task_id.nil? fail ArgumentError, "Missing the required parameter 'task_id' when calling DefaultApi.complete_task" end - # verify the required parameter 'complete_task_request' is set - if @api_client.config.client_side_validation && complete_task_request.nil? - fail ArgumentError, "Missing the required parameter 'complete_task_request' when calling DefaultApi.complete_task" + # verify the required parameter 'complete_task_builder' is set + if @api_client.config.client_side_validation && complete_task_builder.nil? + fail ArgumentError, "Missing the required parameter 'complete_task_builder' when calling DefaultApi.complete_task" end # resource path local_var_path = '/workflow_runs/{workflow_run_id}/tasks/{task_id}/complete'.sub('{' + 'workflow_run_id' + '}', CGI.escape(workflow_run_id.to_s)).sub('{' + 'task_id' + '}', CGI.escape(task_id.to_s)) @@ -137,7 +137,7 @@ def complete_task_with_http_info(workflow_run_id, task_id, complete_task_request form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:debug_body] || @api_client.object_to_http_body(complete_task_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(complete_task_builder) # return_type return_type = opts[:debug_return_type] @@ -300,26 +300,26 @@ def create_check_with_http_info(check_builder, opts = {}) # Create monitor # Creates a new monitor for the applicant - # @param watchlist_monitor [WatchlistMonitor] + # @param watchlist_monitor_builder [WatchlistMonitorBuilder] # @param [Hash] opts the optional parameters # @return [WatchlistMonitor] - def create_watchlist_monitor(watchlist_monitor, opts = {}) - data, _status_code, _headers = create_watchlist_monitor_with_http_info(watchlist_monitor, opts) + def create_watchlist_monitor(watchlist_monitor_builder, opts = {}) + data, _status_code, _headers = create_watchlist_monitor_with_http_info(watchlist_monitor_builder, opts) data end # Create monitor # Creates a new monitor for the applicant - # @param watchlist_monitor [WatchlistMonitor] + # @param watchlist_monitor_builder [WatchlistMonitorBuilder] # @param [Hash] opts the optional parameters # @return [Array<(WatchlistMonitor, Integer, Hash)>] WatchlistMonitor data, response status code and response headers - def create_watchlist_monitor_with_http_info(watchlist_monitor, opts = {}) + def create_watchlist_monitor_with_http_info(watchlist_monitor_builder, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefaultApi.create_watchlist_monitor ...' end - # verify the required parameter 'watchlist_monitor' is set - if @api_client.config.client_side_validation && watchlist_monitor.nil? - fail ArgumentError, "Missing the required parameter 'watchlist_monitor' when calling DefaultApi.create_watchlist_monitor" + # verify the required parameter 'watchlist_monitor_builder' is set + if @api_client.config.client_side_validation && watchlist_monitor_builder.nil? + fail ArgumentError, "Missing the required parameter 'watchlist_monitor_builder' when calling DefaultApi.create_watchlist_monitor" end # resource path local_var_path = '/watchlist_monitors' @@ -341,7 +341,7 @@ def create_watchlist_monitor_with_http_info(watchlist_monitor, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:debug_body] || @api_client.object_to_http_body(watchlist_monitor) + post_body = opts[:debug_body] || @api_client.object_to_http_body(watchlist_monitor_builder) # return_type return_type = opts[:debug_return_type] || 'WatchlistMonitor' @@ -2219,24 +2219,24 @@ def find_workflow_run_with_http_info(workflow_run_id, opts = {}) # Triggers a new check with an updated report to be generated by the monitor, as if the monitor had received an update. # @param monitor_id [String] # @param [Hash] opts the optional parameters - # @return [Applicant] - def force_new_record_creation(monitor_id, opts = {}) - data, _status_code, _headers = force_new_record_creation_with_http_info(monitor_id, opts) - data + # @return [nil] + def force_report_creation_from_watchlist_monitor(monitor_id, opts = {}) + force_report_creation_from_watchlist_monitor_with_http_info(monitor_id, opts) + nil end # Force new report creation (BETA) # Triggers a new check with an updated report to be generated by the monitor, as if the monitor had received an update. # @param monitor_id [String] # @param [Hash] opts the optional parameters - # @return [Array<(Applicant, Integer, Hash)>] Applicant data, response status code and response headers - def force_new_record_creation_with_http_info(monitor_id, opts = {}) + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def force_report_creation_from_watchlist_monitor_with_http_info(monitor_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: DefaultApi.force_new_record_creation ...' + @api_client.config.logger.debug 'Calling API: DefaultApi.force_report_creation_from_watchlist_monitor ...' end # verify the required parameter 'monitor_id' is set if @api_client.config.client_side_validation && monitor_id.nil? - fail ArgumentError, "Missing the required parameter 'monitor_id' when calling DefaultApi.force_new_record_creation" + fail ArgumentError, "Missing the required parameter 'monitor_id' when calling DefaultApi.force_report_creation_from_watchlist_monitor" end # resource path local_var_path = '/watchlist_monitors/{monitor_id}/new_report'.sub('{' + 'monitor_id' + '}', CGI.escape(monitor_id.to_s)) @@ -2256,13 +2256,13 @@ def force_new_record_creation_with_http_info(monitor_id, opts = {}) post_body = opts[:debug_body] # return_type - return_type = opts[:debug_return_type] || 'Applicant' + return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['Token'] new_options = opts.merge( - :operation => :"DefaultApi.force_new_record_creation", + :operation => :"DefaultApi.force_report_creation_from_watchlist_monitor", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -2273,7 +2273,7 @@ def force_new_record_creation_with_http_info(monitor_id, opts = {}) 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: DefaultApi#force_new_record_creation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + @api_client.config.logger.debug "API called: DefaultApi#force_report_creation_from_watchlist_monitor\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end @@ -2990,7 +2990,7 @@ def list_tasks_with_http_info(workflow_run_id, opts = {}) # List match IDs on this monitor, as well as their enabled/disabled status # @param monitor_id [String] # @param [Hash] opts the optional parameters - # @return [Array] + # @return [WatchlistMonitorMatchesList] def list_watchlist_monitor_matches(monitor_id, opts = {}) data, _status_code, _headers = list_watchlist_monitor_matches_with_http_info(monitor_id, opts) data @@ -3000,7 +3000,7 @@ def list_watchlist_monitor_matches(monitor_id, opts = {}) # List match IDs on this monitor, as well as their enabled/disabled status # @param monitor_id [String] # @param [Hash] opts the optional parameters - # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers + # @return [Array<(WatchlistMonitorMatchesList, Integer, Hash)>] WatchlistMonitorMatchesList data, response status code and response headers def list_watchlist_monitor_matches_with_http_info(monitor_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefaultApi.list_watchlist_monitor_matches ...' @@ -3027,7 +3027,7 @@ def list_watchlist_monitor_matches_with_http_info(monitor_id, opts = {}) post_body = opts[:debug_body] # return_type - return_type = opts[:debug_return_type] || 'Array' + return_type = opts[:debug_return_type] || 'WatchlistMonitorMatchesList' # auth_names auth_names = opts[:debug_auth_names] || ['Token'] @@ -3054,7 +3054,7 @@ def list_watchlist_monitor_matches_with_http_info(monitor_id, opts = {}) # @param applicant_id [String] The id of the applicant the watchlist monitors belong to. If omitted, all monitors for the account will be listed. # @param [Hash] opts the optional parameters # @option opts [Boolean] :include_deleted Whether to also include deleted (inactive) monitors. (default to false) - # @return [Array] + # @return [WatchlistMonitorsList] def list_watchlist_monitors(applicant_id, opts = {}) data, _status_code, _headers = list_watchlist_monitors_with_http_info(applicant_id, opts) data @@ -3065,7 +3065,7 @@ def list_watchlist_monitors(applicant_id, opts = {}) # @param applicant_id [String] The id of the applicant the watchlist monitors belong to. If omitted, all monitors for the account will be listed. # @param [Hash] opts the optional parameters # @option opts [Boolean] :include_deleted Whether to also include deleted (inactive) monitors. (default to false) - # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers + # @return [Array<(WatchlistMonitorsList, Integer, Hash)>] WatchlistMonitorsList data, response status code and response headers def list_watchlist_monitors_with_http_info(applicant_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DefaultApi.list_watchlist_monitors ...' @@ -3094,7 +3094,7 @@ def list_watchlist_monitors_with_http_info(applicant_id, opts = {}) post_body = opts[:debug_body] # return_type - return_type = opts[:debug_return_type] || 'Array' + return_type = opts[:debug_return_type] || 'WatchlistMonitorsList' # auth_names auth_names = opts[:debug_auth_names] || ['Token'] @@ -3708,31 +3708,31 @@ def update_applicant_with_http_info(applicant_id, applicant_updater, opts = {}) # Set match status (BETA) # Update the status of the given matches # @param monitor_id [String] - # @param update_monitor_match_request [UpdateMonitorMatchRequest] + # @param watchlist_monitor_matches_updater [WatchlistMonitorMatchesUpdater] # @param [Hash] opts the optional parameters - # @return [nil] - def update_monitor_match(monitor_id, update_monitor_match_request, opts = {}) - update_monitor_match_with_http_info(monitor_id, update_monitor_match_request, opts) - nil + # @return [WatchlistMonitorMatchesList] + def update_watchlist_monitor_match(monitor_id, watchlist_monitor_matches_updater, opts = {}) + data, _status_code, _headers = update_watchlist_monitor_match_with_http_info(monitor_id, watchlist_monitor_matches_updater, opts) + data end # Set match status (BETA) # Update the status of the given matches # @param monitor_id [String] - # @param update_monitor_match_request [UpdateMonitorMatchRequest] + # @param watchlist_monitor_matches_updater [WatchlistMonitorMatchesUpdater] # @param [Hash] opts the optional parameters - # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers - def update_monitor_match_with_http_info(monitor_id, update_monitor_match_request, opts = {}) + # @return [Array<(WatchlistMonitorMatchesList, Integer, Hash)>] WatchlistMonitorMatchesList data, response status code and response headers + def update_watchlist_monitor_match_with_http_info(monitor_id, watchlist_monitor_matches_updater, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: DefaultApi.update_monitor_match ...' + @api_client.config.logger.debug 'Calling API: DefaultApi.update_watchlist_monitor_match ...' end # verify the required parameter 'monitor_id' is set if @api_client.config.client_side_validation && monitor_id.nil? - fail ArgumentError, "Missing the required parameter 'monitor_id' when calling DefaultApi.update_monitor_match" + fail ArgumentError, "Missing the required parameter 'monitor_id' when calling DefaultApi.update_watchlist_monitor_match" end - # verify the required parameter 'update_monitor_match_request' is set - if @api_client.config.client_side_validation && update_monitor_match_request.nil? - fail ArgumentError, "Missing the required parameter 'update_monitor_match_request' when calling DefaultApi.update_monitor_match" + # verify the required parameter 'watchlist_monitor_matches_updater' is set + if @api_client.config.client_side_validation && watchlist_monitor_matches_updater.nil? + fail ArgumentError, "Missing the required parameter 'watchlist_monitor_matches_updater' when calling DefaultApi.update_watchlist_monitor_match" end # resource path local_var_path = '/watchlist_monitors/{monitor_id}/matches'.sub('{' + 'monitor_id' + '}', CGI.escape(monitor_id.to_s)) @@ -3754,16 +3754,16 @@ def update_monitor_match_with_http_info(monitor_id, update_monitor_match_request form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:debug_body] || @api_client.object_to_http_body(update_monitor_match_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(watchlist_monitor_matches_updater) # return_type - return_type = opts[:debug_return_type] + return_type = opts[:debug_return_type] || 'WatchlistMonitorMatchesList' # auth_names auth_names = opts[:debug_auth_names] || ['Token'] new_options = opts.merge( - :operation => :"DefaultApi.update_monitor_match", + :operation => :"DefaultApi.update_watchlist_monitor_match", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -3774,7 +3774,7 @@ def update_monitor_match_with_http_info(monitor_id, update_monitor_match_request data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options) if @api_client.config.debugging - @api_client.config.logger.debug "API called: DefaultApi#update_monitor_match\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + @api_client.config.logger.debug "API called: DefaultApi#update_watchlist_monitor_match\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end diff --git a/lib/onfido/api_client.rb b/lib/onfido/api_client.rb index 6febeb4..c11aba4 100644 --- a/lib/onfido/api_client.rb +++ b/lib/onfido/api_client.rb @@ -34,7 +34,7 @@ class ApiClient # @option config [Configuration] Configuration for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @config = config - @user_agent = "onfido-ruby/3.0.0" + @user_agent = "onfido-ruby/2.9.0" @default_headers = { 'Content-Type' => 'application/json', 'User-Agent' => @user_agent diff --git a/lib/onfido/models/complete_task_request.rb b/lib/onfido/models/complete_task_builder.rb similarity index 94% rename from lib/onfido/models/complete_task_request.rb rename to lib/onfido/models/complete_task_builder.rb index 860ad19..76f155e 100644 --- a/lib/onfido/models/complete_task_request.rb +++ b/lib/onfido/models/complete_task_builder.rb @@ -14,8 +14,7 @@ require 'time' module Onfido - class CompleteTaskRequest - # The Task completion payload. + class CompleteTaskBuilder attr_accessor :data # Attribute mapping from ruby-style variable name to JSON key. @@ -33,7 +32,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'data' => :'Object' + :'data' => :'CompleteTaskBuilderData' } end @@ -47,19 +46,21 @@ def self.openapi_nullable # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::CompleteTaskRequest` initialize method" + fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::CompleteTaskBuilder` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::CompleteTaskRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::CompleteTaskBuilder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'data') self.data = attributes[:'data'] + else + self.data = nil end end @@ -68,6 +69,10 @@ def initialize(attributes = {}) def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + invalid_properties end @@ -75,6 +80,7 @@ def list_invalid_properties # @return true if the model is valid def valid? warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @data.nil? true end diff --git a/lib/onfido/models/complete_task_builder_data.rb b/lib/onfido/models/complete_task_builder_data.rb new file mode 100644 index 0000000..c52208b --- /dev/null +++ b/lib/onfido/models/complete_task_builder_data.rb @@ -0,0 +1,106 @@ +=begin +#Onfido API v3.6 + +#The Onfido API (v3.6) + +The version of the OpenAPI document: v3.6 + +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Onfido + # The Task completion payload. + module CompleteTaskBuilderData + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'Array', + :'Object' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = Onfido.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/onfido/models/watchlist_monitor.rb b/lib/onfido/models/watchlist_monitor.rb index 3a746b4..3274edd 100644 --- a/lib/onfido/models/watchlist_monitor.rb +++ b/lib/onfido/models/watchlist_monitor.rb @@ -15,6 +15,15 @@ module Onfido class WatchlistMonitor + # The ID for the applicant associated with the monitor. + attr_accessor :applicant_id + + # The name of the report type the monitor creates. + attr_accessor :report_name + + # A list of tags associated with this monitor. These tags will be applied to each check this monitor creates. + attr_accessor :tags + # The unique identifier for the monitor. attr_accessor :id @@ -24,17 +33,8 @@ class WatchlistMonitor # The date and time at which the monitor was deleted. If the monitor is still active, this field will be null. attr_accessor :deleted_at - # The ID for the applicant associated with the monitor. - attr_accessor :applicant_id - - # The name of the report type the monitor creates. Can be either \"watchlist_standard\" or \"watchlist_aml\". - attr_accessor :report_name - - # A list of tags associated with this monitor. These tags will be applied to each check this monitor creates. - attr_accessor :tags - # Indicates whether the object was created in the sandbox or not. - attr_accessor :sandbox + attr_accessor :is_sandbox class EnumAttributeValidator attr_reader :datatype @@ -61,13 +61,13 @@ def valid?(value) # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'id' => :'id', - :'created_at' => :'created_at', - :'deleted_at' => :'deleted_at', :'applicant_id' => :'applicant_id', :'report_name' => :'report_name', :'tags' => :'tags', - :'sandbox' => :'sandbox' + :'id' => :'id', + :'created_at' => :'created_at', + :'deleted_at' => :'deleted_at', + :'is_sandbox' => :'is_sandbox' } end @@ -79,13 +79,13 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'id' => :'String', - :'created_at' => :'Time', - :'deleted_at' => :'Time', :'applicant_id' => :'String', :'report_name' => :'String', :'tags' => :'Array', - :'sandbox' => :'Boolean' + :'id' => :'String', + :'created_at' => :'Time', + :'deleted_at' => :'Time', + :'is_sandbox' => :'Boolean' } end @@ -95,6 +95,14 @@ def self.openapi_nullable ]) end + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'WatchlistMonitorResponse', + :'WatchlistMonitorShared' + ] + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -110,18 +118,6 @@ def initialize(attributes = {}) h[k.to_sym] = v } - if attributes.key?(:'id') - self.id = attributes[:'id'] - end - - if attributes.key?(:'created_at') - self.created_at = attributes[:'created_at'] - end - - if attributes.key?(:'deleted_at') - self.deleted_at = attributes[:'deleted_at'] - end - if attributes.key?(:'applicant_id') self.applicant_id = attributes[:'applicant_id'] else @@ -140,10 +136,24 @@ def initialize(attributes = {}) end end - if attributes.key?(:'sandbox') - self.sandbox = attributes[:'sandbox'] + if attributes.key?(:'id') + self.id = attributes[:'id'] else - self.sandbox = false + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'deleted_at') + self.deleted_at = attributes[:'deleted_at'] + end + + if attributes.key?(:'is_sandbox') + self.is_sandbox = attributes[:'is_sandbox'] + else + self.is_sandbox = false end end @@ -160,6 +170,10 @@ def list_invalid_properties invalid_properties.push('invalid value for "report_name", report_name cannot be nil.') end + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + invalid_properties end @@ -171,6 +185,7 @@ def valid? return false if @report_name.nil? report_name_validator = EnumAttributeValidator.new('String', ["watchlist_standard", "watchlist_aml", "unknown_default_open_api"]) return false unless report_name_validator.valid?(@report_name) + return false if @id.nil? true end @@ -189,13 +204,13 @@ def report_name=(report_name) def ==(o) return true if self.equal?(o) self.class == o.class && - id == o.id && - created_at == o.created_at && - deleted_at == o.deleted_at && applicant_id == o.applicant_id && report_name == o.report_name && tags == o.tags && - sandbox == o.sandbox + id == o.id && + created_at == o.created_at && + deleted_at == o.deleted_at && + is_sandbox == o.is_sandbox end # @see the `==` method @@ -207,7 +222,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, created_at, deleted_at, applicant_id, report_name, tags, sandbox].hash + [applicant_id, report_name, tags, id, created_at, deleted_at, is_sandbox].hash end # Builds the object from hash diff --git a/lib/onfido/models/watchlist_monitor_builder.rb b/lib/onfido/models/watchlist_monitor_builder.rb new file mode 100644 index 0000000..0245de5 --- /dev/null +++ b/lib/onfido/models/watchlist_monitor_builder.rb @@ -0,0 +1,292 @@ +=begin +#Onfido API v3.6 + +#The Onfido API (v3.6) + +The version of the OpenAPI document: v3.6 + +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Onfido + class WatchlistMonitorBuilder + # The ID for the applicant associated with the monitor. + attr_accessor :applicant_id + + # The name of the report type the monitor creates. + attr_accessor :report_name + + # A list of tags associated with this monitor. These tags will be applied to each check this monitor creates. + attr_accessor :tags + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'applicant_id' => :'applicant_id', + :'report_name' => :'report_name', + :'tags' => :'tags' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'applicant_id' => :'String', + :'report_name' => :'String', + :'tags' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'WatchlistMonitorShared' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::WatchlistMonitorBuilder` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::WatchlistMonitorBuilder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'applicant_id') + self.applicant_id = attributes[:'applicant_id'] + else + self.applicant_id = nil + end + + if attributes.key?(:'report_name') + self.report_name = attributes[:'report_name'] + else + self.report_name = nil + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @applicant_id.nil? + invalid_properties.push('invalid value for "applicant_id", applicant_id cannot be nil.') + end + + if @report_name.nil? + invalid_properties.push('invalid value for "report_name", report_name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @applicant_id.nil? + return false if @report_name.nil? + report_name_validator = EnumAttributeValidator.new('String', ["watchlist_standard", "watchlist_aml", "unknown_default_open_api"]) + return false unless report_name_validator.valid?(@report_name) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] report_name Object to be assigned + def report_name=(report_name) + validator = EnumAttributeValidator.new('String', ["watchlist_standard", "watchlist_aml", "unknown_default_open_api"]) + unless validator.valid?(report_name) + fail ArgumentError, "invalid value for \"report_name\", must be one of #{validator.allowable_values}." + end + @report_name = report_name + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + applicant_id == o.applicant_id && + report_name == o.report_name && + tags == o.tags + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [applicant_id, report_name, tags].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Onfido.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/onfido/models/watchlist_monitor_match.rb b/lib/onfido/models/watchlist_monitor_match.rb index 2e9f9b9..c21fd7d 100644 --- a/lib/onfido/models/watchlist_monitor_match.rb +++ b/lib/onfido/models/watchlist_monitor_match.rb @@ -19,13 +19,13 @@ class WatchlistMonitorMatch attr_accessor :id # Monitor status - attr_accessor :status + attr_accessor :enabled # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'id' => :'id', - :'status' => :'status' + :'enabled' => :'enabled' } end @@ -38,7 +38,7 @@ def self.acceptable_attributes def self.openapi_types { :'id' => :'String', - :'status' => :'Boolean' + :'enabled' => :'Boolean' } end @@ -67,8 +67,8 @@ def initialize(attributes = {}) self.id = attributes[:'id'] end - if attributes.key?(:'status') - self.status = attributes[:'status'] + if attributes.key?(:'enabled') + self.enabled = attributes[:'enabled'] end end @@ -93,7 +93,7 @@ def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && - status == o.status + enabled == o.enabled end # @see the `==` method @@ -105,7 +105,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, status].hash + [id, enabled].hash end # Builds the object from hash diff --git a/lib/onfido/models/watchlist_monitor_matches_list.rb b/lib/onfido/models/watchlist_monitor_matches_list.rb new file mode 100644 index 0000000..4ca3239 --- /dev/null +++ b/lib/onfido/models/watchlist_monitor_matches_list.rb @@ -0,0 +1,223 @@ +=begin +#Onfido API v3.6 + +#The Onfido API (v3.6) + +The version of the OpenAPI document: v3.6 + +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Onfido + class WatchlistMonitorMatchesList + attr_accessor :matches + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'matches' => :'matches' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'matches' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::WatchlistMonitorMatchesList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::WatchlistMonitorMatchesList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'matches') + if (value = attributes[:'matches']).is_a?(Array) + self.matches = value + end + else + self.matches = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @matches.nil? + invalid_properties.push('invalid value for "matches", matches cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @matches.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + matches == o.matches + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [matches].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Onfido.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/onfido/models/update_monitor_match_request.rb b/lib/onfido/models/watchlist_monitor_matches_updater.rb similarity index 96% rename from lib/onfido/models/update_monitor_match_request.rb rename to lib/onfido/models/watchlist_monitor_matches_updater.rb index fc81404..7ebcade 100644 --- a/lib/onfido/models/update_monitor_match_request.rb +++ b/lib/onfido/models/watchlist_monitor_matches_updater.rb @@ -14,7 +14,7 @@ require 'time' module Onfido - class UpdateMonitorMatchRequest + class WatchlistMonitorMatchesUpdater attr_accessor :enable attr_accessor :disable @@ -50,13 +50,13 @@ def self.openapi_nullable # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::UpdateMonitorMatchRequest` initialize method" + fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::WatchlistMonitorMatchesUpdater` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::UpdateMonitorMatchRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::WatchlistMonitorMatchesUpdater`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } diff --git a/lib/onfido/models/watchlist_monitor_response.rb b/lib/onfido/models/watchlist_monitor_response.rb new file mode 100644 index 0000000..79de8c6 --- /dev/null +++ b/lib/onfido/models/watchlist_monitor_response.rb @@ -0,0 +1,254 @@ +=begin +#Onfido API v3.6 + +#The Onfido API (v3.6) + +The version of the OpenAPI document: v3.6 + +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Onfido + class WatchlistMonitorResponse + # The unique identifier for the monitor. + attr_accessor :id + + # The date and time at which the monitor was created. + attr_accessor :created_at + + # The date and time at which the monitor was deleted. If the monitor is still active, this field will be null. + attr_accessor :deleted_at + + # Indicates whether the object was created in the sandbox or not. + attr_accessor :is_sandbox + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'deleted_at' => :'deleted_at', + :'is_sandbox' => :'is_sandbox' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'deleted_at' => :'Time', + :'is_sandbox' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::WatchlistMonitorResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::WatchlistMonitorResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'deleted_at') + self.deleted_at = attributes[:'deleted_at'] + end + + if attributes.key?(:'is_sandbox') + self.is_sandbox = attributes[:'is_sandbox'] + else + self.is_sandbox = false + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + deleted_at == o.deleted_at && + is_sandbox == o.is_sandbox + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, deleted_at, is_sandbox].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Onfido.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/onfido/models/watchlist_monitor_shared.rb b/lib/onfido/models/watchlist_monitor_shared.rb new file mode 100644 index 0000000..6548486 --- /dev/null +++ b/lib/onfido/models/watchlist_monitor_shared.rb @@ -0,0 +1,285 @@ +=begin +#Onfido API v3.6 + +#The Onfido API (v3.6) + +The version of the OpenAPI document: v3.6 + +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Onfido + class WatchlistMonitorShared + # The ID for the applicant associated with the monitor. + attr_accessor :applicant_id + + # The name of the report type the monitor creates. + attr_accessor :report_name + + # A list of tags associated with this monitor. These tags will be applied to each check this monitor creates. + attr_accessor :tags + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'applicant_id' => :'applicant_id', + :'report_name' => :'report_name', + :'tags' => :'tags' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'applicant_id' => :'String', + :'report_name' => :'String', + :'tags' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::WatchlistMonitorShared` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::WatchlistMonitorShared`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'applicant_id') + self.applicant_id = attributes[:'applicant_id'] + else + self.applicant_id = nil + end + + if attributes.key?(:'report_name') + self.report_name = attributes[:'report_name'] + else + self.report_name = nil + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @applicant_id.nil? + invalid_properties.push('invalid value for "applicant_id", applicant_id cannot be nil.') + end + + if @report_name.nil? + invalid_properties.push('invalid value for "report_name", report_name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @applicant_id.nil? + return false if @report_name.nil? + report_name_validator = EnumAttributeValidator.new('String', ["watchlist_standard", "watchlist_aml", "unknown_default_open_api"]) + return false unless report_name_validator.valid?(@report_name) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] report_name Object to be assigned + def report_name=(report_name) + validator = EnumAttributeValidator.new('String', ["watchlist_standard", "watchlist_aml", "unknown_default_open_api"]) + unless validator.valid?(report_name) + fail ArgumentError, "invalid value for \"report_name\", must be one of #{validator.allowable_values}." + end + @report_name = report_name + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + applicant_id == o.applicant_id && + report_name == o.report_name && + tags == o.tags + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [applicant_id, report_name, tags].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Onfido.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/onfido/models/watchlist_monitors_list.rb b/lib/onfido/models/watchlist_monitors_list.rb new file mode 100644 index 0000000..ee4c3ca --- /dev/null +++ b/lib/onfido/models/watchlist_monitors_list.rb @@ -0,0 +1,223 @@ +=begin +#Onfido API v3.6 + +#The Onfido API (v3.6) + +The version of the OpenAPI document: v3.6 + +Generated by: https://openapi-generator.tech +Generator version: 7.5.0 + +=end + +require 'date' +require 'time' + +module Onfido + class WatchlistMonitorsList + attr_accessor :monitors + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'monitors' => :'monitors' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'monitors' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Onfido::WatchlistMonitorsList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Onfido::WatchlistMonitorsList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'monitors') + if (value = attributes[:'monitors']).is_a?(Array) + self.monitors = value + end + else + self.monitors = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @monitors.nil? + invalid_properties.push('invalid value for "monitors", monitors cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @monitors.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + monitors == o.monitors + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [monitors].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Onfido.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end