Skip to content

Commit

Permalink
Upgrade after onfido-openapi-spec change e518034
Browse files Browse the repository at this point in the history
  • Loading branch information
dvacca-onfido authored and github-actions[bot] committed May 16, 2024
1 parent 470a341 commit f7daaa5
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 23 deletions.
3 changes: 2 additions & 1 deletion 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
32 changes: 16 additions & 16 deletions lib/onfido/api/default_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ 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

# Complete Task
# 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
Expand All @@ -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))
Expand All @@ -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]
Expand Down Expand Up @@ -2220,8 +2220,8 @@ def find_workflow_run_with_http_info(workflow_run_id, opts = {})
# @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)
def force_report_creation_from_watchlist_monitor(monitor_id, opts = {})
data, _status_code, _headers = force_report_creation_from_watchlist_monitor_with_http_info(monitor_id, opts)
data
end

Expand All @@ -2230,13 +2230,13 @@ def force_new_record_creation(monitor_id, opts = {})
# @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 = {})
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))
Expand All @@ -2262,7 +2262,7 @@ def force_new_record_creation_with_http_info(monitor_id, opts = {})
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,
Expand All @@ -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
Expand Down
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

0 comments on commit f7daaa5

Please sign in to comment.