transferzero-sdk 1.3.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -18
  3. data/docs/AccountMeta.md +1 -1
  4. data/docs/AccountValidationApi.md +4 -4
  5. data/docs/AccountValidationRequest.md +6 -4
  6. data/docs/Currency.md +1 -1
  7. data/docs/CurrencyExchange.md +1 -1
  8. data/docs/CurrencyOpposite.md +1 -1
  9. data/docs/Document.md +5 -1
  10. data/docs/DocumentsApi.md +74 -2
  11. data/docs/FieldSelectValidation.md +1 -1
  12. data/docs/FieldValidation.md +1 -1
  13. data/docs/PayinMethod.md +4 -4
  14. data/docs/PayinMethodDetails.md +5 -3
  15. data/docs/PayinMethodDetailsMobile.md +1 -1
  16. data/docs/PayinMethodDetailsNGNBank.md +4 -2
  17. data/docs/PaymentMethod.md +2 -2
  18. data/docs/PaymentMethodOpposite.md +2 -2
  19. data/docs/PayoutMethod.md +1 -1
  20. data/docs/PayoutMethodDetails.md +5 -3
  21. data/docs/PayoutMethodDetailsNGNBank.md +1 -1
  22. data/docs/PayoutMethodDetailsXOFBank.md +25 -0
  23. data/docs/PoliticallyExposedPerson.md +31 -0
  24. data/docs/Recipient.md +3 -3
  25. data/docs/RecipientsApi.md +2 -2
  26. data/docs/Sender.md +2 -0
  27. data/docs/Transaction.md +5 -5
  28. data/docs/TransactionTraits.md +2 -2
  29. data/docs/TransactionsApi.md +64 -0
  30. data/example/client.rb +14 -14
  31. data/git_push.sh +1 -1
  32. data/lib/transferzero-sdk.rb +2 -7
  33. data/lib/transferzero-sdk/api/account_validation_api.rb +4 -4
  34. data/lib/transferzero-sdk/api/documents_api.rb +63 -0
  35. data/lib/transferzero-sdk/api/recipients_api.rb +2 -2
  36. data/lib/transferzero-sdk/api/transactions_api.rb +59 -0
  37. data/lib/transferzero-sdk/api_client.rb +1 -1
  38. data/lib/transferzero-sdk/models/account_validation_request.rb +15 -15
  39. data/lib/transferzero-sdk/models/currency_exchange.rb +1 -2
  40. data/lib/transferzero-sdk/models/currency_opposite.rb +1 -2
  41. data/lib/transferzero-sdk/models/document.rb +20 -1
  42. data/lib/transferzero-sdk/models/document_webhook.rb +0 -1
  43. data/lib/transferzero-sdk/models/payin_method.rb +4 -4
  44. data/lib/transferzero-sdk/models/payin_method_details.rb +12 -7
  45. data/lib/transferzero-sdk/models/payin_method_details_ngn_bank.rb +11 -6
  46. data/lib/transferzero-sdk/models/payout_method.rb +1 -1
  47. data/lib/transferzero-sdk/models/payout_method_details.rb +25 -15
  48. data/lib/transferzero-sdk/models/payout_method_details_ngn_bank.rb +0 -5
  49. data/lib/transferzero-sdk/models/{currency_opposite_all_of.rb → payout_method_details_xof_bank.rb} +69 -18
  50. data/lib/transferzero-sdk/models/payout_method_webhook.rb +0 -1
  51. data/lib/transferzero-sdk/models/{payout_method_webhook_all_of.rb → politically_exposed_person.rb} +81 -10
  52. data/lib/transferzero-sdk/models/recipient_webhook.rb +0 -1
  53. data/lib/transferzero-sdk/models/sender.rb +14 -2
  54. data/lib/transferzero-sdk/models/sender_state.rb +1 -0
  55. data/lib/transferzero-sdk/models/sender_webhook.rb +0 -1
  56. data/lib/transferzero-sdk/models/transaction.rb +2 -2
  57. data/lib/transferzero-sdk/models/transaction_state.rb +1 -0
  58. data/lib/transferzero-sdk/models/transaction_traits.rb +3 -3
  59. data/lib/transferzero-sdk/models/transaction_webhook.rb +0 -1
  60. data/lib/transferzero-sdk/models/webhook.rb +1 -1
  61. data/lib/transferzero-sdk/version.rb +1 -1
  62. data/spec/api/account_validation_api_spec.rb +2 -2
  63. data/spec/api/currency_info_api_spec.rb +2 -0
  64. data/spec/api/documents_api_spec.rb +15 -0
  65. data/spec/api/recipients_api_spec.rb +1 -1
  66. data/spec/api/transactions_api_spec.rb +13 -0
  67. data/spec/models/account_validation_request_spec.rb +7 -1
  68. data/spec/models/currency_opposite_spec.rb +6 -0
  69. data/spec/models/document_spec.rb +12 -0
  70. data/spec/models/payin_method_details_ngn_bank_spec.rb +6 -0
  71. data/spec/models/payin_method_details_spec.rb +6 -0
  72. data/spec/models/payout_method_details_spec.rb +7 -1
  73. data/spec/models/payout_method_details_xof_bank_spec.rb +65 -0
  74. data/spec/models/politically_exposed_person_spec.rb +83 -0
  75. data/spec/models/recipient_spec.rb +6 -0
  76. data/spec/models/sender_spec.rb +16 -0
  77. data/transferzero-sdk.gemspec +2 -2
  78. metadata +17 -46
  79. data/Gemfile.lock +0 -93
  80. data/docs/CurrencyExchangeAllOf.md +0 -17
  81. data/docs/CurrencyOppositeAllOf.md +0 -19
  82. data/docs/DocumentWebhookAllOf.md +0 -17
  83. data/docs/PayoutMethodWebhookAllOf.md +0 -17
  84. data/docs/RecipientWebhookAllOf.md +0 -17
  85. data/docs/SenderWebhookAllOf.md +0 -17
  86. data/docs/TransactionWebhookAllOf.md +0 -17
  87. data/lib/transferzero-sdk/models/currency_exchange_all_of.rb +0 -204
  88. data/lib/transferzero-sdk/models/document_webhook_all_of.rb +0 -201
  89. data/lib/transferzero-sdk/models/recipient_webhook_all_of.rb +0 -201
  90. data/lib/transferzero-sdk/models/sender_webhook_all_of.rb +0 -201
  91. data/lib/transferzero-sdk/models/transaction_webhook_all_of.rb +0 -201
  92. data/spec/api_client_spec.rb +0 -189
  93. data/spec/models/currency_exchange_all_of_spec.rb +0 -41
  94. data/spec/models/currency_opposite_all_of_spec.rb +0 -41
  95. data/spec/models/document_webhook_all_of_spec.rb +0 -41
  96. data/spec/models/payout_method_webhook_all_of_spec.rb +0 -41
  97. data/spec/models/recipient_webhook_all_of_spec.rb +0 -41
  98. data/spec/models/sender_webhook_all_of_spec.rb +0 -41
  99. data/spec/models/transaction_webhook_all_of_spec.rb +0 -41
@@ -1,93 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- transferzero-sdk (1.2.0)
5
- activesupport (~> 5)
6
- json (~> 2.1, >= 2.1.0)
7
- typhoeus (~> 1.0, >= 1.0.1)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- ZenTest (4.11.2)
13
- activesupport (5.2.3)
14
- concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 0.7, < 2)
16
- minitest (~> 5.1)
17
- tzinfo (~> 1.1)
18
- addressable (2.6.0)
19
- public_suffix (>= 2.0.2, < 4.0)
20
- autotest (4.4.6)
21
- ZenTest (>= 4.4.1)
22
- autotest-fsevent (0.2.14)
23
- sys-uname
24
- autotest-growl (0.2.16)
25
- autotest-rails-pure (4.1.2)
26
- byebug (11.0.1)
27
- coderay (1.1.2)
28
- concurrent-ruby (1.1.5)
29
- crack (0.4.3)
30
- safe_yaml (~> 1.0.0)
31
- diff-lcs (1.3)
32
- ethon (0.12.0)
33
- ffi (>= 1.3.0)
34
- ffi (1.11.1)
35
- hashdiff (1.0.0)
36
- i18n (1.6.0)
37
- concurrent-ruby (~> 1.0)
38
- json (2.2.0)
39
- method_source (0.9.2)
40
- minitest (5.11.3)
41
- pry (0.12.2)
42
- coderay (~> 1.1.0)
43
- method_source (~> 0.9.0)
44
- pry-byebug (3.7.0)
45
- byebug (~> 11.0)
46
- pry (~> 0.10)
47
- public_suffix (3.1.1)
48
- rake (12.0.0)
49
- rspec (3.8.0)
50
- rspec-core (~> 3.8.0)
51
- rspec-expectations (~> 3.8.0)
52
- rspec-mocks (~> 3.8.0)
53
- rspec-core (3.8.2)
54
- rspec-support (~> 3.8.0)
55
- rspec-expectations (3.8.4)
56
- diff-lcs (>= 1.2.0, < 2.0)
57
- rspec-support (~> 3.8.0)
58
- rspec-mocks (3.8.1)
59
- diff-lcs (>= 1.2.0, < 2.0)
60
- rspec-support (~> 3.8.0)
61
- rspec-support (3.8.2)
62
- safe_yaml (1.0.5)
63
- sys-uname (1.0.4)
64
- ffi (>= 1.0.0)
65
- thread_safe (0.3.6)
66
- typhoeus (1.3.1)
67
- ethon (>= 0.9.0)
68
- tzinfo (1.2.5)
69
- thread_safe (~> 0.1)
70
- vcr (3.0.3)
71
- webmock (1.24.6)
72
- addressable (>= 2.3.6)
73
- crack (>= 0.3.2)
74
- hashdiff
75
-
76
- PLATFORMS
77
- ruby
78
-
79
- DEPENDENCIES
80
- ZenTest (~> 4.11, >= 4.11.2)
81
- autotest (~> 4.4, >= 4.4.6)
82
- autotest-fsevent (~> 0.2, >= 0.2.12)
83
- autotest-growl (~> 0.2, >= 0.2.16)
84
- autotest-rails-pure (~> 4.1, >= 4.1.2)
85
- pry-byebug
86
- rake (~> 12.0.0)
87
- rspec (~> 3.6, >= 3.6.0)
88
- transferzero-sdk!
89
- vcr (~> 3.0, >= 3.0.1)
90
- webmock (~> 1.24, >= 1.24.3)
91
-
92
- BUNDLED WITH
93
- 1.17.3
@@ -1,17 +0,0 @@
1
- # TransferZero::CurrencyExchangeAllOf
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **opposites** | [**Array&lt;CurrencyOpposite&gt;**](CurrencyOpposite.md) | Lists the currencies where you can exchange from this one | [optional]
8
-
9
- ## Code Sample
10
-
11
- ```ruby
12
- require 'TransferZero'
13
-
14
- instance = TransferZero::CurrencyExchangeAllOf.new(opposites: null)
15
- ```
16
-
17
-
@@ -1,19 +0,0 @@
1
- # TransferZero::CurrencyOppositeAllOf
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **rate** | **Float** | The rate of this particular currency with the base one | [optional]
8
- **mtm_rate** | **Float** | Mark to market rate of this particular currency against the base one with the margin factored in | [optional]
9
-
10
- ## Code Sample
11
-
12
- ```ruby
13
- require 'TransferZero'
14
-
15
- instance = TransferZero::CurrencyOppositeAllOf.new(rate: null,
16
- mtm_rate: null)
17
- ```
18
-
19
-
@@ -1,17 +0,0 @@
1
- # TransferZero::DocumentWebhookAllOf
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **object** | [**Document**](Document.md) | | [optional]
8
-
9
- ## Code Sample
10
-
11
- ```ruby
12
- require 'TransferZero'
13
-
14
- instance = TransferZero::DocumentWebhookAllOf.new(object: null)
15
- ```
16
-
17
-
@@ -1,17 +0,0 @@
1
- # TransferZero::PayoutMethodWebhookAllOf
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **object** | [**PayoutMethod**](PayoutMethod.md) | | [optional]
8
-
9
- ## Code Sample
10
-
11
- ```ruby
12
- require 'TransferZero'
13
-
14
- instance = TransferZero::PayoutMethodWebhookAllOf.new(object: null)
15
- ```
16
-
17
-
@@ -1,17 +0,0 @@
1
- # TransferZero::RecipientWebhookAllOf
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **object** | [**Recipient**](Recipient.md) | | [optional]
8
-
9
- ## Code Sample
10
-
11
- ```ruby
12
- require 'TransferZero'
13
-
14
- instance = TransferZero::RecipientWebhookAllOf.new(object: null)
15
- ```
16
-
17
-
@@ -1,17 +0,0 @@
1
- # TransferZero::SenderWebhookAllOf
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **object** | [**Sender**](Sender.md) | | [optional]
8
-
9
- ## Code Sample
10
-
11
- ```ruby
12
- require 'TransferZero'
13
-
14
- instance = TransferZero::SenderWebhookAllOf.new(object: null)
15
- ```
16
-
17
-
@@ -1,17 +0,0 @@
1
- # TransferZero::TransactionWebhookAllOf
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **object** | [**Transaction**](Transaction.md) | | [optional]
8
-
9
- ## Code Sample
10
-
11
- ```ruby
12
- require 'TransferZero'
13
-
14
- instance = TransferZero::TransactionWebhookAllOf.new(object: null)
15
- ```
16
-
17
-
@@ -1,204 +0,0 @@
1
- =begin
2
- #TransferZero API
3
-
4
- #Reference documentation for the TransferZero API V1
5
-
6
- OpenAPI spec version: 1.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.0.0-beta3
10
-
11
- =end
12
-
13
- require 'date'
14
-
15
- module TransferZero
16
- class CurrencyExchangeAllOf
17
- # Lists the currencies where you can exchange from this one
18
- attr_accessor :opposites
19
-
20
- # Attribute mapping from ruby-style variable name to JSON key.
21
- def self.attribute_map
22
- {
23
- :'opposites' => :'opposites'
24
- }
25
- end
26
-
27
- # Attribute type mapping.
28
- def self.openapi_types
29
- {
30
- :'opposites' => :'Array<CurrencyOpposite>'
31
- }
32
- end
33
-
34
- # Initializes the object
35
- # @param [Hash] attributes Model attributes in the form of hash
36
- def initialize(attributes = {})
37
- if (!attributes.is_a?(Hash))
38
- fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::CurrencyExchangeAllOf` initialize method"
39
- end
40
-
41
- # check to see if the attribute exists and convert string to symbol for hash key
42
- attributes = attributes.each_with_object({}) { |(k, v), h|
43
- if (!self.class.attribute_map.key?(k.to_sym))
44
- fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::CurrencyExchangeAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
45
- end
46
- h[k.to_sym] = v
47
- }
48
-
49
- if attributes.key?(:'opposites')
50
- if (value = attributes[:'opposites']).is_a?(Array)
51
- self.opposites = value
52
- end
53
- end
54
- end
55
-
56
- # Show invalid properties with the reasons. Usually used together with valid?
57
- # @return Array for valid properties with the reasons
58
- def list_invalid_properties
59
- invalid_properties = Array.new
60
- invalid_properties
61
- end
62
-
63
- # Check to see if the all the properties in the model are valid
64
- # @return true if the model is valid
65
- def valid?
66
- true
67
- end
68
-
69
- # Checks equality by comparing each attribute.
70
- # @param [Object] Object to be compared
71
- def ==(o)
72
- return true if self.equal?(o)
73
- self.class == o.class &&
74
- opposites == o.opposites
75
- end
76
-
77
- # @see the `==` method
78
- # @param [Object] Object to be compared
79
- def eql?(o)
80
- self == o
81
- end
82
-
83
- # Calculates hash code according to all attributes.
84
- # @return [Integer] Hash code
85
- def hash
86
- [opposites].hash
87
- end
88
-
89
- require 'active_support/core_ext/hash'
90
- require 'active_support/hash_with_indifferent_access.rb'
91
- # Builds the object from hash
92
- # @param [Hash] attributes Model attributes in the form of hash
93
- # @return [Object] Returns the model itself
94
- def build_from_hash(attributes)
95
- return nil unless attributes.is_a?(Hash)
96
- self.class.openapi_types.each_pair do |key, type|
97
- if type =~ /\AArray<(.*)>/i
98
- # check to ensure the input is an array given that the the attribute
99
- # is documented as an array but the input is not
100
- if attributes[self.class.attribute_map[key]].is_a?(Array)
101
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
102
- end
103
- elsif !attributes[self.class.attribute_map[key]].nil?
104
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
105
- end # or else data not found in attributes(hash), not an issue as the data can be optional
106
- end
107
-
108
- self
109
- end
110
-
111
- # Deserializes the data based on type
112
- # @param string type Data type
113
- # @param string value Value to be deserialized
114
- # @return [Object] Deserialized data
115
- def _deserialize(type, value)
116
- case type.to_sym
117
- when :DateTime
118
- DateTime.parse(value)
119
- when :Date
120
- Date.parse(value)
121
- when :String
122
- value.to_s
123
- when :Integer
124
- value.to_i
125
- when :Float
126
- value.to_f
127
- when :Boolean
128
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
129
- true
130
- else
131
- false
132
- end
133
- when :Object
134
- # generic object (usually a Hash), return directly
135
- value
136
- when /\AArray<(?<inner_type>.+)>\z/
137
- inner_type = Regexp.last_match[:inner_type]
138
- value.map { |v| _deserialize(inner_type, v) }
139
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
140
- k_type = Regexp.last_match[:k_type]
141
- v_type = Regexp.last_match[:v_type]
142
- {}.tap do |hash|
143
- value.each do |k, v|
144
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
145
- end
146
- end
147
- else # model
148
- temp_model = TransferZero.const_get(type).new
149
- temp_model.build_from_hash(value)
150
- end
151
- end
152
-
153
- # Returns the string representation of the object
154
- # @return [String] String presentation of the object
155
- def to_s
156
- to_hash.to_s
157
- end
158
-
159
- # to_body is an alias to to_hash (backward compatibility)
160
- # @return [Hash] Returns the object in the form of hash
161
- def to_body
162
- to_hash
163
- end
164
-
165
- # Returns the object in the form of hash
166
- # @return [Hash] Returns the object in the form of hash
167
- def to_hash
168
- hash = {}
169
- self.class.attribute_map.each_pair do |attr, param|
170
- value = self.send(attr)
171
- next if value.nil?
172
- hash[param] = _to_hash(value)
173
- end
174
- ::ActiveSupport::HashWithIndifferentAccess.new(hash)
175
- end
176
-
177
- def [](key)
178
- to_hash[key]
179
- end
180
-
181
- def dig(*args)
182
- to_hash.dig(*args)
183
- end
184
-
185
- # Outputs non-array value in the form of hash
186
- # For object, use to_hash. Otherwise, just return the value
187
- # @param [Object] value Any valid value
188
- # @return [Hash] Returns the value in the form of hash
189
- def _to_hash(value)
190
- if value.is_a?(Array)
191
- value.compact.map { |v| _to_hash(v) }
192
- elsif value.is_a?(Hash)
193
- {}.tap do |hash|
194
- value.each { |k, v| hash[k] = _to_hash(v) }
195
- end
196
- elsif value.respond_to? :to_hash
197
- value.to_hash
198
- else
199
- value
200
- end
201
- end
202
-
203
- end
204
- end
@@ -1,201 +0,0 @@
1
- =begin
2
- #TransferZero API
3
-
4
- #Reference documentation for the TransferZero API V1
5
-
6
- OpenAPI spec version: 1.0
7
-
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.0.0-beta3
10
-
11
- =end
12
-
13
- require 'date'
14
-
15
- module TransferZero
16
- class DocumentWebhookAllOf
17
- attr_accessor :object
18
-
19
- # Attribute mapping from ruby-style variable name to JSON key.
20
- def self.attribute_map
21
- {
22
- :'object' => :'object'
23
- }
24
- end
25
-
26
- # Attribute type mapping.
27
- def self.openapi_types
28
- {
29
- :'object' => :'Document'
30
- }
31
- end
32
-
33
- # Initializes the object
34
- # @param [Hash] attributes Model attributes in the form of hash
35
- def initialize(attributes = {})
36
- if (!attributes.is_a?(Hash))
37
- fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::DocumentWebhookAllOf` initialize method"
38
- end
39
-
40
- # check to see if the attribute exists and convert string to symbol for hash key
41
- attributes = attributes.each_with_object({}) { |(k, v), h|
42
- if (!self.class.attribute_map.key?(k.to_sym))
43
- fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::DocumentWebhookAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
44
- end
45
- h[k.to_sym] = v
46
- }
47
-
48
- if attributes.key?(:'object')
49
- self.object = attributes[:'object']
50
- end
51
- end
52
-
53
- # Show invalid properties with the reasons. Usually used together with valid?
54
- # @return Array for valid properties with the reasons
55
- def list_invalid_properties
56
- invalid_properties = Array.new
57
- invalid_properties
58
- end
59
-
60
- # Check to see if the all the properties in the model are valid
61
- # @return true if the model is valid
62
- def valid?
63
- true
64
- end
65
-
66
- # Checks equality by comparing each attribute.
67
- # @param [Object] Object to be compared
68
- def ==(o)
69
- return true if self.equal?(o)
70
- self.class == o.class &&
71
- object == o.object
72
- end
73
-
74
- # @see the `==` method
75
- # @param [Object] Object to be compared
76
- def eql?(o)
77
- self == o
78
- end
79
-
80
- # Calculates hash code according to all attributes.
81
- # @return [Integer] Hash code
82
- def hash
83
- [object].hash
84
- end
85
-
86
- require 'active_support/core_ext/hash'
87
- require 'active_support/hash_with_indifferent_access.rb'
88
- # Builds the object from hash
89
- # @param [Hash] attributes Model attributes in the form of hash
90
- # @return [Object] Returns the model itself
91
- def build_from_hash(attributes)
92
- return nil unless attributes.is_a?(Hash)
93
- self.class.openapi_types.each_pair do |key, type|
94
- if type =~ /\AArray<(.*)>/i
95
- # check to ensure the input is an array given that the the attribute
96
- # is documented as an array but the input is not
97
- if attributes[self.class.attribute_map[key]].is_a?(Array)
98
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
- end
100
- elsif !attributes[self.class.attribute_map[key]].nil?
101
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
- end # or else data not found in attributes(hash), not an issue as the data can be optional
103
- end
104
-
105
- self
106
- end
107
-
108
- # Deserializes the data based on type
109
- # @param string type Data type
110
- # @param string value Value to be deserialized
111
- # @return [Object] Deserialized data
112
- def _deserialize(type, value)
113
- case type.to_sym
114
- when :DateTime
115
- DateTime.parse(value)
116
- when :Date
117
- Date.parse(value)
118
- when :String
119
- value.to_s
120
- when :Integer
121
- value.to_i
122
- when :Float
123
- value.to_f
124
- when :Boolean
125
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
- true
127
- else
128
- false
129
- end
130
- when :Object
131
- # generic object (usually a Hash), return directly
132
- value
133
- when /\AArray<(?<inner_type>.+)>\z/
134
- inner_type = Regexp.last_match[:inner_type]
135
- value.map { |v| _deserialize(inner_type, v) }
136
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
- k_type = Regexp.last_match[:k_type]
138
- v_type = Regexp.last_match[:v_type]
139
- {}.tap do |hash|
140
- value.each do |k, v|
141
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
- end
143
- end
144
- else # model
145
- temp_model = TransferZero.const_get(type).new
146
- temp_model.build_from_hash(value)
147
- end
148
- end
149
-
150
- # Returns the string representation of the object
151
- # @return [String] String presentation of the object
152
- def to_s
153
- to_hash.to_s
154
- end
155
-
156
- # to_body is an alias to to_hash (backward compatibility)
157
- # @return [Hash] Returns the object in the form of hash
158
- def to_body
159
- to_hash
160
- end
161
-
162
- # Returns the object in the form of hash
163
- # @return [Hash] Returns the object in the form of hash
164
- def to_hash
165
- hash = {}
166
- self.class.attribute_map.each_pair do |attr, param|
167
- value = self.send(attr)
168
- next if value.nil?
169
- hash[param] = _to_hash(value)
170
- end
171
- ::ActiveSupport::HashWithIndifferentAccess.new(hash)
172
- end
173
-
174
- def [](key)
175
- to_hash[key]
176
- end
177
-
178
- def dig(*args)
179
- to_hash.dig(*args)
180
- end
181
-
182
- # Outputs non-array value in the form of hash
183
- # For object, use to_hash. Otherwise, just return the value
184
- # @param [Object] value Any valid value
185
- # @return [Hash] Returns the value in the form of hash
186
- def _to_hash(value)
187
- if value.is_a?(Array)
188
- value.compact.map { |v| _to_hash(v) }
189
- elsif value.is_a?(Hash)
190
- {}.tap do |hash|
191
- value.each { |k, v| hash[k] = _to_hash(v) }
192
- end
193
- elsif value.respond_to? :to_hash
194
- value.to_hash
195
- else
196
- value
197
- end
198
- end
199
-
200
- end
201
- end