class TransferZero::Recipient
The recipient describes the amount, the currency and the destination where the money should be sent.
Attributes
Date and time that the recipient was created.
Shows whether the recipient can be edited using the PATCH /v1/recipients/{id} endpoint or not
The fields that have some problems and don't pass validation
The exchange rate used in this payment
The fee for this payment in fractional units (for example cents for USD transactions)
The amount that had to be paid in for this payment to proceed
The currency this payment was paid in
Shows how much this payment is worth in USD
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.
Additional metadata that can be added to a recipient. These values will be returned on request
The amount that will be paid to the recipient
The currency the payment will be delivered in
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.
the currency of the amount in 3-character alpha ISO 4217 currency format
Shows whether the transaction made to the recipient can be retried or not
In case the payment is unsuccessful it holds the error message associated with the last unsuccessful payout.
Optional ID that is supplied by partner linking it to the partner's own Transaction
ID.
The ID of the transaction that is related to this recipient
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/transferzero-sdk/models/recipient.rb, line 83 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', :'errors' => :'errors' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/transferzero-sdk/models/recipient.rb, line 142 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.metadata = 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?(:'errors') if (value = attributes[:'errors']).is_a?(Hash) self.errors = value end end end
Attribute type mapping.
# File lib/transferzero-sdk/models/recipient.rb, line 112 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', :'errors' => :'Hash<String, Array<ValidationErrorDescription>>' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/transferzero-sdk/models/recipient.rb, line 280 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 && metadata == o.metadata && 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 && errors == o.errors end
# File lib/transferzero-sdk/models/recipient.rb, line 408 def [](key) to_hash[key] end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/transferzero-sdk/models/recipient.rb, line 346 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
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/transferzero-sdk/models/recipient.rb, line 420 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/transferzero-sdk/models/recipient.rb, line 325 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
# File lib/transferzero-sdk/models/recipient.rb, line 412 def dig(*args) to_hash.dig(*args) end
@see the `==` method @param [Object] Object to be compared
# File lib/transferzero-sdk/models/recipient.rb, line 310 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Integer] Hash code
# File lib/transferzero-sdk/models/recipient.rb, line 316 def hash [requested_amount, requested_currency, payout_method, metadata, 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, errors].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/transferzero-sdk/models/recipient.rb, line 252 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
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/transferzero-sdk/models/recipient.rb, line 398 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
Returns the string representation of the object @return [String] String presentation of the object
# File lib/transferzero-sdk/models/recipient.rb, line 386 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/transferzero-sdk/models/recipient.rb, line 271 def valid? return false if @requested_amount.nil? return false if @requested_currency.nil? return false if @payout_method.nil? true end