Class: TransferZero::Recipient
- Inherits:
-
Object
- Object
- TransferZero::Recipient
- Defined in:
- lib/transferzero-sdk/models/recipient.rb
Overview
The recipient describes the amount, the currency and the destination where the money should be sent.
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Date and time that the recipient was created.
-
#editable ⇒ Object
Shows whether the recipient can be edited using the PATCH /v1/recipients/#id endpoint or not.
-
#errors ⇒ Object
The fields that have some problems and don’t pass validation.
-
#exchange_rate ⇒ Object
The exchange rate used in this payment.
-
#fee_fractional ⇒ Object
The fee for this payment in fractional units (for example cents for USD transactions).
-
#id ⇒ Object
Returns the value of attribute id.
-
#input_amount ⇒ Object
The amount that had to be paid in for this payment to proceed.
-
#input_currency ⇒ Object
The currency this payment was paid in.
-
#input_usd_amount ⇒ Object
Shows how much this payment is worth in USD.
-
#may_cancel ⇒ Object
If true it shows that the payment can be cancelled immediately using the DELETE /v1/recipients/#id endpoint.
-
#metadata ⇒ Object
Additional metadata that can be added to a recipient.
-
#output_amount ⇒ Object
The amount that will be paid to the recipient.
-
#output_currency ⇒ Object
The currency the payment will be delivered in.
-
#payout_method ⇒ Object
Returns the value of attribute payout_method.
-
#requested_amount ⇒ Object
the amount that should be paid to the recipient.
-
#requested_currency ⇒ Object
the currency of the amount in 3-character alpha ISO 4217 currency format.
-
#retriable ⇒ Object
Shows whether the transaction made to the recipient can be retried or not.
-
#state ⇒ Object
Returns the value of attribute state.
-
#state_reason ⇒ Object
In case the payment is unsuccessful it holds the error message associated with the last unsuccessful payout.
-
#state_reason_details ⇒ Object
Returns the value of attribute state_reason_details.
-
#transaction_external_id ⇒ Object
Optional ID that is supplied by partner linking it to the partner’s own Transaction ID.
-
#transaction_id ⇒ Object
The ID of the transaction that is related to this recipient.
-
#transaction_state ⇒ Object
Returns the value of attribute transaction_state.
-
#type ⇒ Object
Type of recipient to create - either person or business (defaults to person).
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #[](key) ⇒ Object
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Returns the model itself.
- #dig(*args) ⇒ Object
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Recipient
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Recipient
Initializes the object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 169 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::Recipient` 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 `TransferZero::Recipient`. 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?(:'requested_amount') self.requested_amount = attributes[:'requested_amount'] end if attributes.key?(:'requested_currency') self.requested_currency = attributes[:'requested_currency'] end if attributes.key?(:'payout_method') self.payout_method = attributes[:'payout_method'] end if attributes.key?(:'metadata') self. = attributes[:'metadata'] end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.key?(:'editable') self.editable = attributes[:'editable'] end if attributes.key?(:'retriable') self.retriable = attributes[:'retriable'] end if attributes.key?(:'input_usd_amount') self.input_usd_amount = attributes[:'input_usd_amount'] end if attributes.key?(:'may_cancel') self.may_cancel = attributes[:'may_cancel'] end if attributes.key?(:'state_reason') self.state_reason = attributes[:'state_reason'] end if attributes.key?(:'state_reason_details') self.state_reason_details = attributes[:'state_reason_details'] end if attributes.key?(:'state') self.state = attributes[:'state'] end if attributes.key?(:'transaction_id') self.transaction_id = attributes[:'transaction_id'] end if attributes.key?(:'transaction_external_id') self.transaction_external_id = attributes[:'transaction_external_id'] end if attributes.key?(:'transaction_state') self.transaction_state = attributes[:'transaction_state'] end if attributes.key?(:'exchange_rate') self.exchange_rate = attributes[:'exchange_rate'] end if attributes.key?(:'fee_fractional') self.fee_fractional = attributes[:'fee_fractional'] end if attributes.key?(:'input_amount') self.input_amount = attributes[:'input_amount'] end if attributes.key?(:'input_currency') self.input_currency = attributes[:'input_currency'] end if attributes.key?(:'output_amount') self.output_amount = attributes[:'output_amount'] end if attributes.key?(:'output_currency') self.output_currency = attributes[:'output_currency'] end if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'type') self.type = attributes[:'type'] end if attributes.key?(:'errors') if (value = attributes[:'errors']).is_a?(Hash) self.errors = value end end end |
Instance Attribute Details
#created_at ⇒ Object
Date and time that the recipient was created.
30 31 32 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 30 def created_at @created_at end |
#editable ⇒ Object
Shows whether the recipient can be edited using the PATCH /v1/recipients/#id endpoint or not
33 34 35 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 33 def editable @editable end |
#errors ⇒ Object
The fields that have some problems and don’t pass validation
83 84 85 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 83 def errors @errors end |
#exchange_rate ⇒ Object
The exchange rate used in this payment
60 61 62 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 60 def exchange_rate @exchange_rate end |
#fee_fractional ⇒ Object
The fee for this payment in fractional units (for example cents for USD transactions)
63 64 65 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 63 def fee_fractional @fee_fractional end |
#id ⇒ Object
Returns the value of attribute id.
77 78 79 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 77 def id @id end |
#input_amount ⇒ Object
The amount that had to be paid in for this payment to proceed
66 67 68 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 66 def input_amount @input_amount end |
#input_currency ⇒ Object
The currency this payment was paid in
69 70 71 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 69 def input_currency @input_currency end |
#input_usd_amount ⇒ Object
Shows how much this payment is worth in USD
39 40 41 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 39 def input_usd_amount @input_usd_amount end |
#may_cancel ⇒ Object
If true it shows that the payment can be cancelled immediately using the DELETE /v1/recipients/#id endpoint. If false you can still try to cancel it, however it will only gets cancelled once we have confirmation from our partner that the payment has failed.
42 43 44 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 42 def may_cancel @may_cancel end |
#metadata ⇒ Object
Additional metadata that can be added to a recipient. These values will be returned on request
27 28 29 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 27 def end |
#output_amount ⇒ Object
The amount that will be paid to the recipient
72 73 74 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 72 def output_amount @output_amount end |
#output_currency ⇒ Object
The currency the payment will be delivered in
75 76 77 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 75 def output_currency @output_currency end |
#payout_method ⇒ Object
Returns the value of attribute payout_method.
24 25 26 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 24 def payout_method @payout_method end |
#requested_amount ⇒ Object
the amount that should be paid to the recipient. This can be in any currency, usually either the input or the output currency. If the value here is not the output currency we will calculate how much the recipient is going to get using the exchange rates active when the transaction was created.
19 20 21 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 19 def requested_amount @requested_amount end |
#requested_currency ⇒ Object
the currency of the amount in 3-character alpha ISO 4217 currency format
22 23 24 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 22 def requested_currency @requested_currency end |
#retriable ⇒ Object
Shows whether the transaction made to the recipient can be retried or not
36 37 38 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 36 def retriable @retriable end |
#state ⇒ Object
Returns the value of attribute state.
49 50 51 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 49 def state @state end |
#state_reason ⇒ Object
In case the payment is unsuccessful it holds the error message associated with the last unsuccessful payout.
45 46 47 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 45 def state_reason @state_reason end |
#state_reason_details ⇒ Object
Returns the value of attribute state_reason_details.
47 48 49 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 47 def state_reason_details @state_reason_details end |
#transaction_external_id ⇒ Object
Optional ID that is supplied by partner linking it to the partner’s own Transaction ID.
55 56 57 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 55 def transaction_external_id @transaction_external_id end |
#transaction_id ⇒ Object
The ID of the transaction that is related to this recipient
52 53 54 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 52 def transaction_id @transaction_id end |
#transaction_state ⇒ Object
Returns the value of attribute transaction_state.
57 58 59 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 57 def transaction_state @transaction_state end |
#type ⇒ Object
Type of recipient to create - either person or business (defaults to person)
80 81 82 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 80 def type @type end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 108 def self.attribute_map { :'requested_amount' => :'requested_amount', :'requested_currency' => :'requested_currency', :'payout_method' => :'payout_method', :'metadata' => :'metadata', :'created_at' => :'created_at', :'editable' => :'editable', :'retriable' => :'retriable', :'input_usd_amount' => :'input_usd_amount', :'may_cancel' => :'may_cancel', :'state_reason' => :'state_reason', :'state_reason_details' => :'state_reason_details', :'state' => :'state', :'transaction_id' => :'transaction_id', :'transaction_external_id' => :'transaction_external_id', :'transaction_state' => :'transaction_state', :'exchange_rate' => :'exchange_rate', :'fee_fractional' => :'fee_fractional', :'input_amount' => :'input_amount', :'input_currency' => :'input_currency', :'output_amount' => :'output_amount', :'output_currency' => :'output_currency', :'id' => :'id', :'type' => :'type', :'errors' => :'errors' } end |
.openapi_types ⇒ Object
Attribute type mapping.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 138 def self.openapi_types { :'requested_amount' => :'Float', :'requested_currency' => :'String', :'payout_method' => :'PayoutMethod', :'metadata' => :'Object', :'created_at' => :'DateTime', :'editable' => :'Boolean', :'retriable' => :'Boolean', :'input_usd_amount' => :'Float', :'may_cancel' => :'Boolean', :'state_reason' => :'String', :'state_reason_details' => :'RecipientStateReasonDetails', :'state' => :'RecipientState', :'transaction_id' => :'String', :'transaction_external_id' => :'String', :'transaction_state' => :'TransactionState', :'exchange_rate' => :'Float', :'fee_fractional' => :'Float', :'input_amount' => :'Float', :'input_currency' => :'String', :'output_amount' => :'Float', :'output_currency' => :'String', :'id' => :'String', :'type' => :'String', :'errors' => :'Hash<String, Array<ValidationErrorDescription>>' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 323 def ==(o) return true if self.equal?(o) self.class == o.class && requested_amount == o.requested_amount && requested_currency == o.requested_currency && payout_method == o.payout_method && == o. && created_at == o.created_at && editable == o.editable && retriable == o.retriable && input_usd_amount == o.input_usd_amount && may_cancel == o.may_cancel && state_reason == o.state_reason && state_reason_details == o.state_reason_details && state == o.state && transaction_id == o.transaction_id && transaction_external_id == o.transaction_external_id && transaction_state == o.transaction_state && exchange_rate == o.exchange_rate && fee_fractional == o.fee_fractional && input_amount == o.input_amount && input_currency == o.input_currency && output_amount == o.output_amount && output_currency == o.output_currency && id == o.id && type == o.type && errors == o.errors end |
#[](key) ⇒ Object
452 453 454 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 452 def [](key) to_hash[key] end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 390 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = TransferZero.const_get(type).new temp_model.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
464 465 466 467 468 469 470 471 472 473 474 475 476 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 464 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Returns the model itself
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 369 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#dig(*args) ⇒ Object
456 457 458 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 456 def dig(*args) to_hash.dig(*args) end |
#eql?(o) ⇒ Boolean
354 355 356 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 354 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
360 361 362 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 360 def hash [requested_amount, requested_currency, payout_method, , created_at, editable, retriable, input_usd_amount, may_cancel, state_reason, state_reason_details, state, transaction_id, transaction_external_id, transaction_state, exchange_rate, fee_fractional, input_amount, input_currency, output_amount, output_currency, id, type, errors].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 283 def list_invalid_properties invalid_properties = Array.new if @requested_amount.nil? invalid_properties.push('invalid value for "requested_amount", requested_amount cannot be nil.') end if @requested_currency.nil? invalid_properties.push('invalid value for "requested_currency", requested_currency cannot be nil.') end if @payout_method.nil? invalid_properties.push('invalid value for "payout_method", payout_method cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
436 437 438 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 436 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
442 443 444 445 446 447 448 449 450 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 442 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end ::ActiveSupport::HashWithIndifferentAccess.new(hash) end |
#to_s ⇒ String
Returns the string representation of the object
430 431 432 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 430 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
302 303 304 305 306 307 308 309 |
# File 'lib/transferzero-sdk/models/recipient.rb', line 302 def valid? return false if @requested_amount.nil? return false if @requested_currency.nil? return false if @payout_method.nil? type_validator = EnumAttributeValidator.new('String', ["person", "business"]) return false unless type_validator.valid?(@type) true end |