Skip to content

Commit

Permalink
Upgrade after onfido-openapi-spec change 3370037
Browse files Browse the repository at this point in the history
  • Loading branch information
dvacca-onfido authored and github-actions[bot] committed May 17, 2024
1 parent 470a341 commit cc6a76a
Show file tree
Hide file tree
Showing 13 changed files with 1,518 additions and 108 deletions.
10 changes: 8 additions & 2 deletions lib/onfido.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down
104 changes: 52 additions & 52 deletions lib/onfido/api/default_api.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/onfido/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -33,7 +32,7 @@ def self.acceptable_attributes
# Attribute type mapping.
def self.openapi_types
{
:'data' => :'Object'
:'data' => :'CompleteTaskBuilderData'
}
end

Expand All @@ -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

Expand All @@ -68,13 +69,18 @@ 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

# 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 @data.nil?
true
end

Expand Down
106 changes: 106 additions & 0 deletions lib/onfido/models/complete_task_builder_data.rb
Original file line number Diff line number Diff line change
@@ -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>',
:'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<(?<sub_type>.+)>\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<String, (?<sub_type>.+)>\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
91 changes: 53 additions & 38 deletions lib/onfido/models/watchlist_monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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<String>',
:'sandbox' => :'Boolean'
:'id' => :'String',
:'created_at' => :'Time',
:'deleted_at' => :'Time',
:'is_sandbox' => :'Boolean'
}
end

Expand All @@ -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 = {})
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit cc6a76a

Please sign in to comment.