Class: Amex::CardAccount
- Inherits:
-
Object
- Object
- Amex::CardAccount
- Defined in:
- lib/amex/card_account.rb
Instance Attribute Summary collapse
-
#cancelled ⇒ Object
Returns the value of attribute cancelled.
-
#card_art ⇒ Object
Returns the value of attribute card_art.
-
#card_index ⇒ Object
Returns the value of attribute card_index.
-
#card_member_name ⇒ Object
Returns the value of attribute card_member_name.
-
#card_number_suffix ⇒ Object
Returns the value of attribute card_number_suffix.
-
#card_product ⇒ Object
Returns the value of attribute card_product.
-
#client ⇒ Object
Returns the value of attribute client.
-
#is_basic ⇒ Object
Returns the value of attribute is_basic.
-
#is_centurion ⇒ Object
Returns the value of attribute is_centurion.
-
#is_platinum ⇒ Object
Returns the value of attribute is_platinum.
-
#is_premium ⇒ Object
Returns the value of attribute is_premium.
-
#lending_type ⇒ Object
Returns the value of attribute lending_type.
-
#loyalty_indicator ⇒ Object
Returns the value of attribute loyalty_indicator.
-
#loyalty_programmes ⇒ Object
Returns the value of attribute loyalty_programmes.
-
#market ⇒ Object
Returns the value of attribute market.
-
#past_due ⇒ Object
Returns the value of attribute past_due.
-
#payment_credits ⇒ Object
Returns the value of attribute payment_credits.
-
#payment_due ⇒ Object
Returns the value of attribute payment_due.
-
#payment_due_date ⇒ DateTime
Returns the date that the next payment on the card is due.
-
#recent_charges ⇒ Object
Returns the value of attribute recent_charges.
-
#stmt_balance ⇒ Object
Returns the value of attribute stmt_balance.
-
#total_balance ⇒ Object
Returns the value of attribute total_balance.
Instance Method Summary collapse
-
#cancelled? ⇒ Boolean
Returns whether the card account is cancelled.
-
#due? ⇒ Boolean
Returns whether this account has a due payment (i.e. whether you need to pay American Express anything) (see #overdue?).
-
#initialize(options) ⇒ Amex::CardAccount
constructor
Generates a CardAccount object from XML properties grabbed by the client.
-
#is_charge_card? ⇒ Boolean
Returns whether this account is a charge card.
-
#is_credit_card? ⇒ Boolean
Returns whether this account is a credit card.
-
#loyalty_balances ⇒ Hash{String => String}
Returns a hash of loyalty scheme balances for this account.
-
#loyalty_enabled? ⇒ Boolean
Returns whether this account has any kind of loyalty scheme attached.
-
#overdue? ⇒ Boolean
Returns whether payment on this account is overdue.
-
#product ⇒ String
Returns the name of the card product that your card conforms to (e.g. “American Express Preferred Rewards Gold”).
-
#statement_balance ⇒ Float
Returns the balance of the most recent statement.
-
#transactions(billing_period = 0) ⇒ Array<Amex::Transaction>
Fetches transactions on an American Express card.
-
#type ⇒ :basic, ...
Returns the type of account this card conforms to (generally not useful, probably largely used internally by American Express.
Constructor Details
#initialize(options) ⇒ Amex::CardAccount
Generates a CardAccount object from XML properties grabbed by the client
17 18 19 20 21 22 23 |
# File 'lib/amex/card_account.rb', line 17 def initialize() .each do |key, value| method = key.to_s.underscore + "=" send(key.to_s.underscore + "=", value) if respond_to? method.to_sym end @loyalty_programmes = [] end |
Instance Attribute Details
#cancelled ⇒ Object
Returns the value of attribute cancelled.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def cancelled @cancelled end |
#card_art ⇒ Object
Returns the value of attribute card_art.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def card_art @card_art end |
#card_index ⇒ Object
Returns the value of attribute card_index.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def card_index @card_index end |
#card_member_name ⇒ Object
Returns the value of attribute card_member_name.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def card_member_name @card_member_name end |
#card_number_suffix ⇒ Object
Returns the value of attribute card_number_suffix.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def card_number_suffix @card_number_suffix end |
#card_product ⇒ Object
Returns the value of attribute card_product.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def card_product @card_product end |
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def client @client end |
#is_basic ⇒ Object
Returns the value of attribute is_basic.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def is_basic @is_basic end |
#is_centurion ⇒ Object
Returns the value of attribute is_centurion.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def is_centurion @is_centurion end |
#is_platinum ⇒ Object
Returns the value of attribute is_platinum.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def is_platinum @is_platinum end |
#is_premium ⇒ Object
Returns the value of attribute is_premium.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def is_premium @is_premium end |
#lending_type ⇒ Object
Returns the value of attribute lending_type.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def lending_type @lending_type end |
#loyalty_indicator ⇒ Object
Returns the value of attribute loyalty_indicator.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def loyalty_indicator @loyalty_indicator end |
#loyalty_programmes ⇒ Object
Returns the value of attribute loyalty_programmes.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def loyalty_programmes @loyalty_programmes end |
#market ⇒ Object
Returns the value of attribute market.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def market @market end |
#past_due ⇒ Object
Returns the value of attribute past_due.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def past_due @past_due end |
#payment_credits ⇒ Object
Returns the value of attribute payment_credits.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def payment_credits @payment_credits end |
#payment_due ⇒ Object
Returns the value of attribute payment_due.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def payment_due @payment_due end |
#payment_due_date ⇒ DateTime
Returns the date that the next payment on the card is due
99 100 101 |
# File 'lib/amex/card_account.rb', line 99 def payment_due_date @payment_due_date end |
#recent_charges ⇒ Object
Returns the value of attribute recent_charges.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def recent_charges @recent_charges end |
#stmt_balance ⇒ Object
Returns the value of attribute stmt_balance.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def stmt_balance @stmt_balance end |
#total_balance ⇒ Object
Returns the value of attribute total_balance.
3 4 5 |
# File 'lib/amex/card_account.rb', line 3 def total_balance @total_balance end |
Instance Method Details
#cancelled? ⇒ Boolean
Returns whether the card account is cancelled
91 92 93 |
# File 'lib/amex/card_account.rb', line 91 def cancelled? @cancelled end |
#due? ⇒ Boolean
Returns whether this account has a due payment (i.e. whether you need to pay American Express anything) (see #overdue?)
150 151 152 153 |
# File 'lib/amex/card_account.rb', line 150 def due? return true if @payment_due.to_f > 0 false end |
#is_charge_card? ⇒ Boolean
Returns whether this account is a charge card
131 132 133 134 |
# File 'lib/amex/card_account.rb', line 131 def is_charge_card? return true if @lending_type == "Charge" false end |
#is_credit_card? ⇒ Boolean
Returns whether this account is a credit card
122 123 124 125 |
# File 'lib/amex/card_account.rb', line 122 def is_credit_card? return true if @lending_type == "Credit" false end |
#loyalty_balances ⇒ Hash{String => String}
Returns a hash of loyalty scheme balances for this account
171 172 173 174 175 176 177 |
# File 'lib/amex/card_account.rb', line 171 def loyalty_balances result = {} @loyalty_programmes.each do |programme| result[programme.name] = programme.balance end result end |
#loyalty_enabled? ⇒ Boolean
Returns whether this account has any kind of loyalty scheme attached
160 161 162 |
# File 'lib/amex/card_account.rb', line 160 def loyalty_enabled? @loyalty_indicator end |
#overdue? ⇒ Boolean
Returns whether payment on this account is overdue
140 141 142 143 |
# File 'lib/amex/card_account.rb', line 140 def overdue? return true if @past_due false end |
#product ⇒ String
Returns the name of the card product that your card conforms to (e.g. “American Express Preferred Rewards Gold”)
83 84 85 |
# File 'lib/amex/card_account.rb', line 83 def product @card_product end |
#statement_balance ⇒ Float
Returns the balance of the most recent statement
74 75 76 |
# File 'lib/amex/card_account.rb', line 74 def statement_balance @stmt_balance end |
#transactions(billing_period = 0) ⇒ Array<Amex::Transaction>
This can fetch either a single billing period or a range of billing periods, e.g:
> account.transaction(0)
fetches transactions since the last statement (default)
> account.transaction(0..5)
fetches transactions between now and five statements ago
Fetches transactions on an American Express card
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/amex/card_account.rb', line 38 def transactions(billing_period=0) result = [] # Build an array of billing periods we need to fetch - this is almost # certainly woefully inefficient code. billing_periods = [] if billing_period.class == Fixnum billing_periods << billing_period elsif billing_period.class == Range billing_period.each { |n| billing_periods << n } else raise "The passed in billing period option must be a number or a range" end billing_periods.each do |n| = { :body => { "PayLoadText" => @client.statement_request_xml(@card_index, n) }} response = @client.class.post( '/myca/intl/moblclient/emea/ws.do?Face=en_GB', ) xml = Nokogiri::XML(response.body) xml = xml.css("XMLResponse") xml.css('Transaction').each do |transaction| result << Amex::Transaction.new(transaction) end end result end |
#type ⇒ :basic, ...
Returns the type of account this card conforms to (generally not useful,
probably largely used internally by American Express
110 111 112 113 114 115 116 |
# File 'lib/amex/card_account.rb', line 110 def type return :basic if @is_basic return :platinum if @is_platinum return :centurion if @is_centurion return :premium if @is_premium :unknown end |