class Bfwd::Refund

Refund

Attributes

account_id[RW]

{ "description" : "Identifier of account to refund.", "verbs":["GET"] }

actual_refunded_value[RW]

{ "description" : "Refunded amount", "verbs":[] }

actual_value[RW]

{ "description" : "", "verbs":[] }

changed_by[RW]

{ "description" : "ID of the user who last updated the entity.", "verbs":[] }

created[RW]

{ "description" : "The UTC DateTime when the object was created.", "verbs":[] }

created_by[RW]

{ "description" : "Refund requested by this account", "verbs":["GET"] }

currency[RW]

{ "description" : "Currency of the refund specified by a three character ISO 4217 currency code.", "verbs":["GET"] }

id[RW]

{ "description" : "", "verbs":["GET", "PUT"] }

invoice_id[RW]

{ "description" : "Invoice to refund.", "verbs":["POST","GET"] }

invoice_payment_id[RW]

{ "description" : "Invoice payment to refund", "verbs":["POST", "GET"] }

nominal_refunded_value[RW]

{ "description" : "Nominal value refunded.", "verbs":[] }

nominal_value[RW]

{ "description" : "", "verbs":[] }

organization_id[RW]

{ "description" : "", "verbs":[] }

original_gateway_payment_reference[RW]

{ "description" : "Reference in the gateway to the payment being refunded.", "verbs":["GET"] }

original_payment_id[RW]

{ "description" : "Original payment being refunded.", "verbs":["GET"] }

original_receipt_id[RW]

{ "description" : "ID of the receipt for the successful payment that this entity refunds.", "verbs":["POST","GET"] }

payment_method_id[RW]

{ "description" : "Payment method to refund from", "verbs":["GET"] }

reason[RW]

{ "description" : "The reason for the refund.", "verbs":["GET"] }

receipt_id[RW]

{ "description" : "ID of the receipt for this refund.", "verbs":["POST","GET"] }

refund_completed[RW]

{ "description" : "When the refund was completed", "verbs":["GET"] }

refund_invoice_payment_id[RW]

{ "description" : "", "verbs":[] }

refund_nature[RW]

{"default":"<span class=\"label label-default\">SingleAttempt</span>","description":The mechanism by which credit is returned to the customer:
<span class=\"label label-default\">Void</span> &mdash; The original authorized payment is voided before capture.
<span class=\"label label-default\">Refund</span> &mdash; A refund is issued against an already-captured payment.","verbs":}

refund_payment_id[RW]

{ "description" : "Identifier for the payment used to refund", "verbs":["GET"] }

refund_state[RW]

{ "default" : "AwaitingRefund", "PUT_description" : "<span class=\"label label-default\">Pending</span> refunds can be set to <span class=\"label label-default\">AwaitingRefund</span> to initiate the refund or <span class=\"label label-default\">Cancelled</span> to stop the refund.", "description" : "Initially a refund is in the <span class=\"label label-default\">AwaitingRefund</span> state. Once the funds are successfully returned the state is <span class=\"label label-default\">Refunded</span>. If the refund fails or is rejected is it set as <span class=\"label label-default\">Failed</span>. Refunds can be set to a <span class=\"label label-default\">Pending</span> state to support authorization flows, and will leave the refund pending until updated to <span class=\"label label-default\">AwaitingRefund</span>. <span class=\"label label-default\">Cancelled</span> is when a refund will not be executed.", "verbs":["GET", "POST", "PUT"] }

refund_type[RW]

{ "description" : "This is the type of refund. Refunds are associated with either an invoice and payment, a payment or unreferenced.", "verbs":[] }

refunded[RW]

{ "description" : "Value refunded", "verbs":["GET"] }

updated[RW]

{ "description" : "The UTC DateTime when the object was last updated.", "verbs":[] }

value[RW]

{ "description" : "Positive decimal representing the total value to refund. This is at most the amount un-refunded on the payment. If amount is the total payment amount is refunded.", "verbs":["POST","GET"] }

Public Class Methods

attribute_map() click to toggle source

Attribute mapping from ruby-style variable name to JSON key.

# File lib/bf_ruby2/models/refund.rb, line 125
def self.attribute_map
  {
    :'created' => :'created',
    :'changed_by' => :'changedBy',
    :'updated' => :'updated',
    :'id' => :'id',
    :'organization_id' => :'organizationID',
    :'account_id' => :'accountID',
    :'reason' => :'reason',
    :'nominal_value' => :'nominalValue',
    :'value' => :'value',
    :'refunded' => :'refunded',
    :'actual_value' => :'actualValue',
    :'nominal_refunded_value' => :'nominalRefundedValue',
    :'actual_refunded_value' => :'actualRefundedValue',
    :'refund_state' => :'refundState',
    :'refund_type' => :'refundType',
    :'refund_nature' => :'refundNature',
    :'refund_completed' => :'refundCompleted',
    :'currency' => :'currency',
    :'payment_method_id' => :'paymentMethodID',
    :'invoice_payment_id' => :'invoicePaymentID',
    :'refund_invoice_payment_id' => :'refundInvoicePaymentID',
    :'original_payment_id' => :'originalPaymentID',
    :'original_gateway_payment_reference' => :'originalGatewayPaymentReference',
    :'refund_payment_id' => :'refundPaymentID',
    :'invoice_id' => :'invoiceID',
    :'receipt_id' => :'receiptID',
    :'original_receipt_id' => :'originalReceiptID',
    :'created_by' => :'createdBy'
  }
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# File lib/bf_ruby2/models/refund.rb, line 194
def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'created')
    self.created = attributes[:'created']
  end

  if attributes.has_key?(:'changedBy')
    self.changed_by = attributes[:'changedBy']
  end

  if attributes.has_key?(:'updated')
    self.updated = attributes[:'updated']
  end

  if attributes.has_key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'organizationID')
    self.organization_id = attributes[:'organizationID']
  end

  if attributes.has_key?(:'accountID')
    self.account_id = attributes[:'accountID']
  end

  if attributes.has_key?(:'reason')
    self.reason = attributes[:'reason']
  end

  if attributes.has_key?(:'nominalValue')
    self.nominal_value = attributes[:'nominalValue']
  end

  if attributes.has_key?(:'value')
    self.value = attributes[:'value']
  end

  if attributes.has_key?(:'refunded')
    self.refunded = attributes[:'refunded']
  end

  if attributes.has_key?(:'actualValue')
    self.actual_value = attributes[:'actualValue']
  end

  if attributes.has_key?(:'nominalRefundedValue')
    self.nominal_refunded_value = attributes[:'nominalRefundedValue']
  end

  if attributes.has_key?(:'actualRefundedValue')
    self.actual_refunded_value = attributes[:'actualRefundedValue']
  end

  if attributes.has_key?(:'refundState')
    self.refund_state = attributes[:'refundState']
  end

  if attributes.has_key?(:'refundType')
    self.refund_type = attributes[:'refundType']
  end

  if attributes.has_key?(:'refundNature')
    self.refund_nature = attributes[:'refundNature']
  end

  if attributes.has_key?(:'refundCompleted')
    self.refund_completed = attributes[:'refundCompleted']
  end

  if attributes.has_key?(:'currency')
    self.currency = attributes[:'currency']
  end

  if attributes.has_key?(:'paymentMethodID')
    self.payment_method_id = attributes[:'paymentMethodID']
  end

  if attributes.has_key?(:'invoicePaymentID')
    self.invoice_payment_id = attributes[:'invoicePaymentID']
  end

  if attributes.has_key?(:'refundInvoicePaymentID')
    self.refund_invoice_payment_id = attributes[:'refundInvoicePaymentID']
  end

  if attributes.has_key?(:'originalPaymentID')
    self.original_payment_id = attributes[:'originalPaymentID']
  end

  if attributes.has_key?(:'originalGatewayPaymentReference')
    self.original_gateway_payment_reference = attributes[:'originalGatewayPaymentReference']
  end

  if attributes.has_key?(:'refundPaymentID')
    self.refund_payment_id = attributes[:'refundPaymentID']
  end

  if attributes.has_key?(:'invoiceID')
    self.invoice_id = attributes[:'invoiceID']
  end

  if attributes.has_key?(:'receiptID')
    self.receipt_id = attributes[:'receiptID']
  end

  if attributes.has_key?(:'originalReceiptID')
    self.original_receipt_id = attributes[:'originalReceiptID']
  end

  if attributes.has_key?(:'createdBy')
    self.created_by = attributes[:'createdBy']
  end

end
swagger_types() click to toggle source

Attribute type mapping.

# File lib/bf_ruby2/models/refund.rb, line 159
def self.swagger_types
  {
    :'created' => :'DateTime',
    :'changed_by' => :'String',
    :'updated' => :'DateTime',
    :'id' => :'String',
    :'organization_id' => :'String',
    :'account_id' => :'String',
    :'reason' => :'String',
    :'nominal_value' => :'Float',
    :'value' => :'Float',
    :'refunded' => :'Float',
    :'actual_value' => :'Float',
    :'nominal_refunded_value' => :'Float',
    :'actual_refunded_value' => :'Float',
    :'refund_state' => :'String',
    :'refund_type' => :'String',
    :'refund_nature' => :'String',
    :'refund_completed' => :'DateTime',
    :'currency' => :'String',
    :'payment_method_id' => :'String',
    :'invoice_payment_id' => :'String',
    :'refund_invoice_payment_id' => :'String',
    :'original_payment_id' => :'String',
    :'original_gateway_payment_reference' => :'String',
    :'refund_payment_id' => :'String',
    :'invoice_id' => :'String',
    :'receipt_id' => :'String',
    :'original_receipt_id' => :'String',
    :'created_by' => :'String'
  }
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# File lib/bf_ruby2/models/refund.rb, line 405
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created == o.created &&
      changed_by == o.changed_by &&
      updated == o.updated &&
      id == o.id &&
      organization_id == o.organization_id &&
      account_id == o.account_id &&
      reason == o.reason &&
      nominal_value == o.nominal_value &&
      value == o.value &&
      refunded == o.refunded &&
      actual_value == o.actual_value &&
      nominal_refunded_value == o.nominal_refunded_value &&
      actual_refunded_value == o.actual_refunded_value &&
      refund_state == o.refund_state &&
      refund_type == o.refund_type &&
      refund_nature == o.refund_nature &&
      refund_completed == o.refund_completed &&
      currency == o.currency &&
      payment_method_id == o.payment_method_id &&
      invoice_payment_id == o.invoice_payment_id &&
      refund_invoice_payment_id == o.refund_invoice_payment_id &&
      original_payment_id == o.original_payment_id &&
      original_gateway_payment_reference == o.original_gateway_payment_reference &&
      refund_payment_id == o.refund_payment_id &&
      invoice_id == o.invoice_id &&
      receipt_id == o.receipt_id &&
      original_receipt_id == o.original_receipt_id &&
      created_by == o.created_by
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# File lib/bf_ruby2/models/refund.rb, line 474
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 = Bfwd.const_get(type).new
    temp_model.build_from_hash(value)
  end
end
_to_hash(value) click to toggle source

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/bf_ruby2/models/refund.rb, line 540
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) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/bf_ruby2/models/refund.rb, line 453
def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_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
eql?(o) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/bf_ruby2/models/refund.rb, line 440
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Fixnum] Hash code

# File lib/bf_ruby2/models/refund.rb, line 446
def hash
  [created, changed_by, updated, id, organization_id, account_id, reason, nominal_value, value, refunded, actual_value, nominal_refunded_value, actual_refunded_value, refund_state, refund_type, refund_nature, refund_completed, currency, payment_method_id, invoice_payment_id, refund_invoice_payment_id, original_payment_id, original_gateway_payment_reference, refund_payment_id, invoice_id, receipt_id, original_receipt_id, created_by].hash
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properies with the reasons

# File lib/bf_ruby2/models/refund.rb, line 316
def list_invalid_properties
  invalid_properties = Array.new
  if @nominal_value.nil?
    invalid_properties.push("invalid value for 'nominal_value', nominal_value cannot be nil.")
  end

  if @actual_value.nil?
    invalid_properties.push("invalid value for 'actual_value', actual_value cannot be nil.")
  end

  if @nominal_refunded_value.nil?
    invalid_properties.push("invalid value for 'nominal_refunded_value', nominal_refunded_value cannot be nil.")
  end

  if @actual_refunded_value.nil?
    invalid_properties.push("invalid value for 'actual_refunded_value', actual_refunded_value cannot be nil.")
  end

  if @refund_state.nil?
    invalid_properties.push("invalid value for 'refund_state', refund_state cannot be nil.")
  end

  if @refund_type.nil?
    invalid_properties.push("invalid value for 'refund_type', refund_type cannot be nil.")
  end

  if @refund_nature.nil?
    invalid_properties.push("invalid value for 'refund_nature', refund_nature cannot be nil.")
  end

  if @currency.nil?
    invalid_properties.push("invalid value for 'currency', currency cannot be nil.")
  end

  return invalid_properties
end
refund_nature=(refund_nature) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] refund_nature Object to be assigned

# File lib/bf_ruby2/models/refund.rb, line 395
def refund_nature=(refund_nature)
  validator = EnumAttributeValidator.new('String', ["Refund", "Void"])
  unless validator.valid?(refund_nature)
    fail ArgumentError, "invalid value for 'refund_nature', must be one of #{validator.allowable_values}."
  end
  @refund_nature = refund_nature
end
refund_state=(refund_state) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] refund_state Object to be assigned

# File lib/bf_ruby2/models/refund.rb, line 375
def refund_state=(refund_state)
  validator = EnumAttributeValidator.new('String', ["Pending", "AwaitingRefund", "Refunded", "Cancelled", "Failed"])
  unless validator.valid?(refund_state)
    fail ArgumentError, "invalid value for 'refund_state', must be one of #{validator.allowable_values}."
  end
  @refund_state = refund_state
end
refund_type=(refund_type) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] refund_type Object to be assigned

# File lib/bf_ruby2/models/refund.rb, line 385
def refund_type=(refund_type)
  validator = EnumAttributeValidator.new('String', ["InvoicePayment", "Payment"])
  unless validator.valid?(refund_type)
    fail ArgumentError, "invalid value for 'refund_type', must be one of #{validator.allowable_values}."
  end
  @refund_type = refund_type
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/bf_ruby2/models/refund.rb, line 520
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/bf_ruby2/models/refund.rb, line 526
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
  hash
end
to_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/bf_ruby2/models/refund.rb, line 514
def to_s
  to_hash.to_s
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/bf_ruby2/models/refund.rb, line 355
def valid?
  return false if @nominal_value.nil?
  return false if @actual_value.nil?
  return false if @nominal_refunded_value.nil?
  return false if @actual_refunded_value.nil?
  return false if @refund_state.nil?
  refund_state_validator = EnumAttributeValidator.new('String', ["Pending", "AwaitingRefund", "Refunded", "Cancelled", "Failed"])
  return false unless refund_state_validator.valid?(@refund_state)
  return false if @refund_type.nil?
  refund_type_validator = EnumAttributeValidator.new('String', ["InvoicePayment", "Payment"])
  return false unless refund_type_validator.valid?(@refund_type)
  return false if @refund_nature.nil?
  refund_nature_validator = EnumAttributeValidator.new('String', ["Refund", "Void"])
  return false unless refund_nature_validator.valid?(@refund_nature)
  return false if @currency.nil?
  return true
end