-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
186 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
moneykit (0.1.9) | ||
moneykit (0.1.10) | ||
faraday (>= 1.0.1, < 3.0) | ||
faraday-multipart | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# MoneyKit::Response401GetAccountNumbers | ||
|
||
## Properties | ||
|
||
| Name | Type | Description | Notes | | ||
| ---- | ---- | ----------- | ----- | | ||
| **error_code** | **Object** | | [optional] | | ||
| **error_message** | **Object** | | | | ||
| **documentation_url** | **Object** | | [optional] | | ||
|
||
## Example | ||
|
||
```ruby | ||
require 'moneykit' | ||
|
||
instance = MoneyKit::Response401GetAccountNumbers.new( | ||
error_code: null, | ||
error_message: null, | ||
documentation_url: null | ||
) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
=begin | ||
#MoneyKit API | ||
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
The version of the OpenAPI document: 2023-02-18 | ||
Generated by: https://openapi-generator.tech | ||
OpenAPI Generator version: 7.1.0 | ||
=end | ||
|
||
require 'date' | ||
require 'time' | ||
|
||
module MoneyKit | ||
module Response401GetAccountNumbers | ||
class << self | ||
# List of class defined in anyOf (OpenAPI v3) | ||
def openapi_any_of | ||
[ | ||
:'APIErrorAuthExpiredAccessTokenResponse', | ||
:'APIErrorAuthUnauthorizedResponse', | ||
:'LinkErrorUnauthorizedAccessResponse' | ||
] | ||
end | ||
|
||
# Builds the object | ||
# @param [Mixed] Data to be matched against the list of anyOf items | ||
# @return [Object] Returns the model or the data itself | ||
def build(data) | ||
# Go through the list of anyOf items and attempt to identify the appropriate one. | ||
# Note: | ||
# - 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_any_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_any_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 = MoneyKit.const_get(klass) | ||
if const | ||
if const.respond_to?(:openapi_any_of) # nested anyOf model | ||
model = const.build(data) | ||
return model if model | ||
else | ||
# raise if data contains keys that are not known to the model | ||
raise unless (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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ | |
=end | ||
|
||
module MoneyKit | ||
VERSION = '0.1.9' | ||
VERSION = '0.1.10' | ||
end |
Oops, something went wrong.