transferzero-sdk 1.9.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +94 -0
  3. data/README.md +12 -4
  4. data/docs/AccountValidationRequest.md +2 -0
  5. data/docs/Document.md +4 -0
  6. data/docs/PayoutMethod.md +1 -1
  7. data/docs/PayoutMethodCashProviderEnum.md +16 -0
  8. data/docs/PayoutMethodCountryEnum.md +16 -0
  9. data/docs/PayoutMethodDetails.md +4 -0
  10. data/docs/PayoutMethodDetailsGHSCash.md +21 -0
  11. data/docs/PayoutMethodDetailsXOFCash.md +25 -0
  12. data/docs/PayoutMethodDetailsXOFMobile.md +3 -1
  13. data/docs/ProofOfPayment.md +23 -0
  14. data/docs/ProofOfPaymentListResponse.md +17 -0
  15. data/docs/Recipient.md +4 -0
  16. data/docs/RecipientStateReasonDetails.md +23 -0
  17. data/docs/RecipientsApi.md +62 -0
  18. data/docs/Sender.md +3 -1
  19. data/lib/transferzero-sdk.rb +7 -0
  20. data/lib/transferzero-sdk/api/recipients_api.rb +54 -0
  21. data/lib/transferzero-sdk/api_client.rb +1 -1
  22. data/lib/transferzero-sdk/models/account_validation_request.rb +10 -1
  23. data/lib/transferzero-sdk/models/document.rb +21 -1
  24. data/lib/transferzero-sdk/models/payout_method.rb +1 -1
  25. data/lib/transferzero-sdk/models/payout_method_cash_provider_enum.rb +31 -0
  26. data/lib/transferzero-sdk/models/payout_method_country_enum.rb +43 -0
  27. data/lib/transferzero-sdk/models/payout_method_details.rb +21 -1
  28. data/lib/transferzero-sdk/models/payout_method_details_ghs_cash.rb +236 -0
  29. data/lib/transferzero-sdk/models/payout_method_details_mad_cash.rb +1 -1
  30. data/lib/transferzero-sdk/models/payout_method_details_xof_bank.rb +1 -1
  31. data/lib/transferzero-sdk/models/payout_method_details_xof_cash.rb +254 -0
  32. data/lib/transferzero-sdk/models/payout_method_details_xof_mobile.rb +14 -5
  33. data/lib/transferzero-sdk/models/payout_method_identity_card_type_enum.rb +1 -1
  34. data/lib/transferzero-sdk/models/payout_method_mobile_provider_enum.rb +1 -0
  35. data/lib/transferzero-sdk/models/proof_of_payment.rb +233 -0
  36. data/lib/transferzero-sdk/models/proof_of_payment_list_response.rb +204 -0
  37. data/lib/transferzero-sdk/models/recipient.rb +20 -1
  38. data/lib/transferzero-sdk/models/recipient_state_reason_details.rb +235 -0
  39. data/lib/transferzero-sdk/models/sender.rb +12 -2
  40. data/lib/transferzero-sdk/version.rb +1 -1
  41. data/spec/models/payout_method_cash_provider_enum_spec.rb +35 -0
  42. data/spec/models/payout_method_country_enum_spec.rb +35 -0
  43. data/spec/models/payout_method_details_ghs_cash_spec.rb +53 -0
  44. data/spec/models/payout_method_details_xof_cash_spec.rb +71 -0
  45. data/spec/models/proof_of_payment_list_response_spec.rb +41 -0
  46. data/spec/models/proof_of_payment_spec.rb +59 -0
  47. data/spec/models/recipient_state_reason_details_spec.rb +59 -0
  48. metadata +32 -3
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.0.0-beta3
13
13
  require 'date'
14
14
 
15
15
  module TransferZero
16
- # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"212537718685\" # Mandatory; International format preferred \"sender_identity_card_type\" => \"O\", # Mandatory; Values: \"O\": Other, \"PP\": Passport, \"NI\": National ID \"sender_identity_card_id\" => 'AB12345678', # Mandatory \"sender_city_of_birth\" => \"London\", # Mandatory \"sender_country_of_birth\" => \"GB\", # Mandatory; ISO 2-letter format \"sender_gender\" => \"M\", # Mandatory; Values: \"M\": Male, \"F\": Female \"reason\" => \"Remittance payment\", # Optional; Default value is 'Remittance payment' \"identity_card_type\" => \"NI\", # Optional; Values: \"PP\": Passport, \"NI\": National ID \"identity_card_id\" => 'AB12345678' # Optional } ``` Please note when sending MAD::Cash payments you should subscribe to the recipient.pending webhook, as that will broadcast the payment reference ID the customer need to use to obtain the funds. Example webhook response excerpt - ```JSON { (...) \"state\":\"pending\", \"metadata\": { \"payment_reference\":\"9M5GJRJUBCY\" }, (...) } ``` The reference can also be provided optionally for MAD::Cash, but if you want to use this functionality please contact us for more details.
16
+ # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"212537718685\" # Mandatory; International format preferred \"sender_identity_card_type\" => \"O\", # Mandatory; Values: \"O\": Other, \"PP\": Passport, \"ID\": National ID \"sender_identity_card_id\" => 'AB12345678', # Mandatory \"sender_city_of_birth\" => \"London\", # Mandatory \"sender_country_of_birth\" => \"GB\", # Mandatory; ISO 2-letter format \"sender_gender\" => \"M\", # Mandatory; Values: \"M\": Male, \"F\": Female \"reason\" => \"Remittance payment\", # Optional; Default value is 'Remittance payment' \"identity_card_type\" => \"ID\", # Optional; Values: \"PP\": Passport, \"ID\": National ID \"identity_card_id\" => 'AB12345678' # Optional } ``` Please note when sending MAD::Cash payments you should subscribe to the recipient.pending webhook, as that will broadcast the payment reference ID the customer need to use to obtain the funds. Example webhook response excerpt - ```JSON { (...) \"state\":\"pending\", \"metadata\": { \"payment_reference\":\"9M5GJRJUBCY\" }, (...) } ``` The reference can also be provided optionally for MAD::Cash, but if you want to use this functionality please contact us for more details.
17
17
  class PayoutMethodDetailsMADCash
18
18
  attr_accessor :first_name
19
19
 
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.0.0-beta3
13
13
  require 'date'
14
14
 
15
15
  module TransferZero
16
- # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"iban\": \"SN08SN0000000000000000000000\", \"bank_name\": \"BRM\", \"bank_country\": \"SN\" # ISO country code for Senegal } ``` *** Currently in Beta phase ***
16
+ # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"iban\": \"SN08SN0000000000000000000000\", \"bank_name\": \"BRM\", \"bank_country\": \"SN\" # ISO country code for Senegal } ```
17
17
  class PayoutMethodDetailsXOFBank
18
18
  attr_accessor :first_name
19
19
 
@@ -0,0 +1,254 @@
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
+ # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"221774044436\", // local or international format \"cash_provider\": \"wizall\" // Optional; Values: \"wizall\"; Default value is \"wizall\"; \"country\": \"SN\" // Optional; Values: \"CI\", \"ML\" or \"SN\"; Default value is \"SN\"; } ``` Please note all senders trying to create Wizall cash pickup requests must have `identity_type` and `identity_number` present. The fields above are generally considered optional for senders for other payment corridors. If you wish to use an existing sender who has some of these fields missing you can provide them alongside the `id` or `external_id` field in the sender details. For example - ```JSON { \"transaction\": { \"sender\": { \"external_id\": \"<id of sender>\", \"identity_type\": \"ID\", \"identity_number\": \"AB12345678\", (...) }, (...) } } ```
17
+ class PayoutMethodDetailsXOFCash
18
+ attr_accessor :first_name
19
+
20
+ attr_accessor :last_name
21
+
22
+ attr_accessor :phone_number
23
+
24
+ attr_accessor :cash_provider
25
+
26
+ attr_accessor :country
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'first_name' => :'first_name',
32
+ :'last_name' => :'last_name',
33
+ :'phone_number' => :'phone_number',
34
+ :'cash_provider' => :'cash_provider',
35
+ :'country' => :'country'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'first_name' => :'String',
43
+ :'last_name' => :'String',
44
+ :'phone_number' => :'String',
45
+ :'cash_provider' => :'PayoutMethodCashProviderEnum',
46
+ :'country' => :'PayoutMethodCountryEnum'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayoutMethodDetailsXOFCash` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayoutMethodDetailsXOFCash`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'first_name')
66
+ self.first_name = attributes[:'first_name']
67
+ end
68
+
69
+ if attributes.key?(:'last_name')
70
+ self.last_name = attributes[:'last_name']
71
+ end
72
+
73
+ if attributes.key?(:'phone_number')
74
+ self.phone_number = attributes[:'phone_number']
75
+ end
76
+
77
+ if attributes.key?(:'cash_provider')
78
+ self.cash_provider = attributes[:'cash_provider']
79
+ end
80
+
81
+ if attributes.key?(:'country')
82
+ self.country = attributes[:'country']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ if @first_name.nil?
91
+ invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
92
+ end
93
+
94
+ if @last_name.nil?
95
+ invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
96
+ end
97
+
98
+ if @phone_number.nil?
99
+ invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
100
+ end
101
+
102
+ invalid_properties
103
+ end
104
+
105
+ # Check to see if the all the properties in the model are valid
106
+ # @return true if the model is valid
107
+ def valid?
108
+ return false if @first_name.nil?
109
+ return false if @last_name.nil?
110
+ return false if @phone_number.nil?
111
+ true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ first_name == o.first_name &&
120
+ last_name == o.last_name &&
121
+ phone_number == o.phone_number &&
122
+ cash_provider == o.cash_provider &&
123
+ country == o.country
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Integer] Hash code
134
+ def hash
135
+ [first_name, last_name, phone_number, cash_provider, country].hash
136
+ end
137
+
138
+ require 'active_support/core_ext/hash'
139
+ require 'active_support/hash_with_indifferent_access.rb'
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def build_from_hash(attributes)
144
+ return nil unless attributes.is_a?(Hash)
145
+ self.class.openapi_types.each_pair do |key, type|
146
+ if type =~ /\AArray<(.*)>/i
147
+ # check to ensure the input is an array given that the the attribute
148
+ # is documented as an array but the input is not
149
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
150
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
151
+ end
152
+ elsif !attributes[self.class.attribute_map[key]].nil?
153
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
154
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
155
+ end
156
+
157
+ self
158
+ end
159
+
160
+ # Deserializes the data based on type
161
+ # @param string type Data type
162
+ # @param string value Value to be deserialized
163
+ # @return [Object] Deserialized data
164
+ def _deserialize(type, value)
165
+ case type.to_sym
166
+ when :DateTime
167
+ DateTime.parse(value)
168
+ when :Date
169
+ Date.parse(value)
170
+ when :String
171
+ value.to_s
172
+ when :Integer
173
+ value.to_i
174
+ when :Float
175
+ value.to_f
176
+ when :Boolean
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ else # model
197
+ temp_model = TransferZero.const_get(type).new
198
+ temp_model.build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ next if value.nil?
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ ::ActiveSupport::HashWithIndifferentAccess.new(hash)
224
+ end
225
+
226
+ def [](key)
227
+ to_hash[key]
228
+ end
229
+
230
+ def dig(*args)
231
+ to_hash.dig(*args)
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.compact.map { |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to? :to_hash
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+
252
+ end
253
+
254
+ end
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.0.0-beta3
13
13
  require 'date'
14
14
 
15
15
  module TransferZero
16
- # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"774044436\" # local or international Senegalese format \"mobile_provider\": \"orange\", # \"orange\" or \"tigo\" }
16
+ # ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"774044436\", # local or international Senegalese or Ivory Coast format \"mobile_provider\": \"orange\", # \"orange\" or \"tigo\" for Senegal; \"orange\", \"mtn\" or \"moov\" for Ivory Coast \"country\" # Optional; Values: \"SN\" for Senegal or \"CI\" for Ivory Coast; Default value is \"SN\" } ```
17
17
  class PayoutMethodDetailsXOFMobile
18
18
  attr_accessor :first_name
19
19
 
@@ -23,13 +23,16 @@ class PayoutMethodDetailsXOFMobile
23
23
 
24
24
  attr_accessor :mobile_provider
25
25
 
26
+ attr_accessor :country
27
+
26
28
  # Attribute mapping from ruby-style variable name to JSON key.
27
29
  def self.attribute_map
28
30
  {
29
31
  :'first_name' => :'first_name',
30
32
  :'last_name' => :'last_name',
31
33
  :'phone_number' => :'phone_number',
32
- :'mobile_provider' => :'mobile_provider'
34
+ :'mobile_provider' => :'mobile_provider',
35
+ :'country' => :'country'
33
36
  }
34
37
  end
35
38
 
@@ -39,7 +42,8 @@ class PayoutMethodDetailsXOFMobile
39
42
  :'first_name' => :'String',
40
43
  :'last_name' => :'String',
41
44
  :'phone_number' => :'String',
42
- :'mobile_provider' => :'PayoutMethodMobileProviderEnum'
45
+ :'mobile_provider' => :'PayoutMethodMobileProviderEnum',
46
+ :'country' => :'PayoutMethodCountryEnum'
43
47
  }
44
48
  end
45
49
 
@@ -73,6 +77,10 @@ class PayoutMethodDetailsXOFMobile
73
77
  if attributes.key?(:'mobile_provider')
74
78
  self.mobile_provider = attributes[:'mobile_provider']
75
79
  end
80
+
81
+ if attributes.key?(:'country')
82
+ self.country = attributes[:'country']
83
+ end
76
84
  end
77
85
 
78
86
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -116,7 +124,8 @@ class PayoutMethodDetailsXOFMobile
116
124
  first_name == o.first_name &&
117
125
  last_name == o.last_name &&
118
126
  phone_number == o.phone_number &&
119
- mobile_provider == o.mobile_provider
127
+ mobile_provider == o.mobile_provider &&
128
+ country == o.country
120
129
  end
121
130
 
122
131
  # @see the `==` method
@@ -128,7 +137,7 @@ class PayoutMethodDetailsXOFMobile
128
137
  # Calculates hash code according to all attributes.
129
138
  # @return [Integer] Hash code
130
139
  def hash
131
- [first_name, last_name, phone_number, mobile_provider].hash
140
+ [first_name, last_name, phone_number, mobile_provider, country].hash
132
141
  end
133
142
 
134
143
  require 'active_support/core_ext/hash'
@@ -17,7 +17,7 @@ class PayoutMethodIdentityCardTypeEnum
17
17
 
18
18
  O = "O".freeze
19
19
  PP = "PP".freeze
20
- NI = "NI".freeze
20
+ ID = "ID".freeze
21
21
 
22
22
  # Builds the enum from string
23
23
  # @param [String] The enum value in the form of the string
@@ -17,6 +17,7 @@ class PayoutMethodMobileProviderEnum
17
17
 
18
18
  ORANGE = "orange".freeze
19
19
  TIGO = "tigo".freeze
20
+ MOOV = "moov".freeze
20
21
  MTN = "mtn".freeze
21
22
  AIRTEL = "airtel".freeze
22
23
  VODAFONE = "vodafone".freeze
@@ -0,0 +1,233 @@
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 ProofOfPayment
17
+ # UUID of the uploaded document
18
+ attr_accessor :id
19
+
20
+ # Name of the uploaded file
21
+ attr_accessor :file_name
22
+
23
+ # URL to thumbnail image of the uploaded file
24
+ attr_accessor :thumbnail
25
+
26
+ # URL to uploaded file
27
+ attr_accessor :url
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'id' => :'id',
33
+ :'file_name' => :'file_name',
34
+ :'thumbnail' => :'thumbnail',
35
+ :'url' => :'url'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'id' => :'String',
43
+ :'file_name' => :'String',
44
+ :'thumbnail' => :'String',
45
+ :'url' => :'String'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::ProofOfPayment` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::ProofOfPayment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'id')
65
+ self.id = attributes[:'id']
66
+ end
67
+
68
+ if attributes.key?(:'file_name')
69
+ self.file_name = attributes[:'file_name']
70
+ end
71
+
72
+ if attributes.key?(:'thumbnail')
73
+ self.thumbnail = attributes[:'thumbnail']
74
+ end
75
+
76
+ if attributes.key?(:'url')
77
+ self.url = attributes[:'url']
78
+ end
79
+ end
80
+
81
+ # Show invalid properties with the reasons. Usually used together with valid?
82
+ # @return Array for valid properties with the reasons
83
+ def list_invalid_properties
84
+ invalid_properties = Array.new
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ id == o.id &&
100
+ file_name == o.file_name &&
101
+ thumbnail == o.thumbnail &&
102
+ url == o.url
103
+ end
104
+
105
+ # @see the `==` method
106
+ # @param [Object] Object to be compared
107
+ def eql?(o)
108
+ self == o
109
+ end
110
+
111
+ # Calculates hash code according to all attributes.
112
+ # @return [Integer] Hash code
113
+ def hash
114
+ [id, file_name, thumbnail, url].hash
115
+ end
116
+
117
+ require 'active_support/core_ext/hash'
118
+ require 'active_support/hash_with_indifferent_access.rb'
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ self.class.openapi_types.each_pair do |key, type|
125
+ if type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
129
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
130
+ end
131
+ elsif !attributes[self.class.attribute_map[key]].nil?
132
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
133
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
134
+ end
135
+
136
+ self
137
+ end
138
+
139
+ # Deserializes the data based on type
140
+ # @param string type Data type
141
+ # @param string value Value to be deserialized
142
+ # @return [Object] Deserialized data
143
+ def _deserialize(type, value)
144
+ case type.to_sym
145
+ when :DateTime
146
+ DateTime.parse(value)
147
+ when :Date
148
+ Date.parse(value)
149
+ when :String
150
+ value.to_s
151
+ when :Integer
152
+ value.to_i
153
+ when :Float
154
+ value.to_f
155
+ when :Boolean
156
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
157
+ true
158
+ else
159
+ false
160
+ end
161
+ when :Object
162
+ # generic object (usually a Hash), return directly
163
+ value
164
+ when /\AArray<(?<inner_type>.+)>\z/
165
+ inner_type = Regexp.last_match[:inner_type]
166
+ value.map { |v| _deserialize(inner_type, v) }
167
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
168
+ k_type = Regexp.last_match[:k_type]
169
+ v_type = Regexp.last_match[:v_type]
170
+ {}.tap do |hash|
171
+ value.each do |k, v|
172
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
173
+ end
174
+ end
175
+ else # model
176
+ temp_model = TransferZero.const_get(type).new
177
+ temp_model.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ next if value.nil?
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ ::ActiveSupport::HashWithIndifferentAccess.new(hash)
203
+ end
204
+
205
+ def [](key)
206
+ to_hash[key]
207
+ end
208
+
209
+ def dig(*args)
210
+ to_hash.dig(*args)
211
+ end
212
+
213
+ # Outputs non-array value in the form of hash
214
+ # For object, use to_hash. Otherwise, just return the value
215
+ # @param [Object] value Any valid value
216
+ # @return [Hash] Returns the value in the form of hash
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map { |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+ end
232
+
233
+ end