class Revolut::Api::Response::Card

Attributes

address[RW]
auto_topup[RW]
brand[RW]
confirmation_attempts[RW]
confirmed[RW]
created_date[RW]
currency[RW]
current_topup[RW]
expired[RW]
expiry_date[RW]
id[RW]
issuer[RW]
last_four[RW]
last_used_date[RW]
owner_id[RW]
three_d_verified[RW]
topup_limit[RW]
updated_date[RW]

Public Class Methods

new(hash = {}) click to toggle source
# File lib/revolut/api/response/card.rb, line 13
def initialize(hash = {})
  self.id                       =   hash.fetch("id", nil)
  self.owner_id                 =   hash.fetch("ownerId", nil)
  self.last_four                =   hash.fetch("lastFour", nil)&.to_i
  self.brand                    =   hash.fetch("brand", nil)

  self.expiry_date              =   {
    month: hash.fetch("expiryDate", {}).fetch("month", nil),
    year:  hash.fetch("expiryDate", {}).fetch("year", nil),
  }

  self.three_d_verified         =   hash.fetch("threeDVerified", false)

  address_data                  =   hash.fetch("address", {})
  self.address                  =   ::Revolut::Api::Response::Address.new(address_data)

  issuer_data                   =   hash.fetch("issuer", {})
  self.issuer                   =   ::Revolut::Api::Response::CardIssuer.new(issuer_data)

  self.currency                 =   hash.fetch("currency", nil)
  self.confirmed                =   hash.fetch("confirmed", false)
  self.confirmation_attempts    =   hash.fetch("confirmationAttempts", 0)
  self.auto_topup               =   hash.fetch("autoTopup", nil)

  self.created_date             =   hash.fetch("createdDate", nil)
  self.created_date             =   ::Revolut::Api::Utilities.epoch_to_utc(self.created_date) unless self.created_date.nil?
  self.updated_date             =   hash.fetch("updatedDate", nil)
  self.updated_date             =   ::Revolut::Api::Utilities.epoch_to_utc(self.updated_date) unless self.updated_date.nil?
  self.last_used_date           =   hash.fetch("lastUsedDate", nil)
  self.last_used_date           =   ::Revolut::Api::Utilities.epoch_to_utc(self.last_used_date) unless self.last_used_date.nil?

  self.topup_limit              =   hash.fetch("topupLimit", nil)
  self.topup_limit              =   ::Revolut::Api::Utilities.convert_from_integer_amount(self.currency, self.topup_limit) if !self.currency.to_s.empty? && !self.topup_limit.nil?

  self.current_topup            =   hash.fetch("currentTopup", nil)
  self.current_topup            =   ::Revolut::Api::Utilities.convert_from_integer_amount(self.currency, self.current_topup) if !self.currency.to_s.empty? && !self.current_topup.nil?
end