Class: Starling::Resources::PaymentResource

Inherits:
BaseResource show all
Defined in:
lib/starling/resources/payment_resource.rb

Overview

A resource representing a Payment returned from the Payment API

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from Starling::Resources::BaseResource

Instance Method Details

#amountFloat

Returns the amount of the payment.

Returns:

  • (Float)

    the amount of the payment



17
18
19
# File 'lib/starling/resources/payment_resource.rb', line 17

def amount
  present_float(parsed_data['amount'])
end

#cancelled_atTime?

Returns the time when the payment was cancelled, or nil if it has not been cancelled.

Returns:

  • (Time, nil)

    the time when the payment was cancelled, or nil if it has not been cancelled



67
68
69
# File 'lib/starling/resources/payment_resource.rb', line 67

def cancelled_at
  present_datetime(parsed_data['cancelledAt'])
end

#currencyString

Returns the currency of the payment.

Returns:

  • (String)

    the currency of the payment



12
13
14
# File 'lib/starling/resources/payment_resource.rb', line 12

def currency
  parsed_data['currency']
end

#immediatetrue, false

Returns where the payment is immediate or scheduled for the future.

Returns:

  • (true, false)

    where the payment is immediate or scheduled for the future



38
39
40
# File 'lib/starling/resources/payment_resource.rb', line 38

def immediate
  parsed_data['immediate']
end

#next_dateDate

Returns the date of the next payment in the series.

Returns:

  • (Date)

    the date of the next payment in the series



61
62
63
# File 'lib/starling/resources/payment_resource.rb', line 61

def next_date
  present_date(parsed_data['nextDate'])
end

#payment_order_idString Also known as: id

Returns the Starling internal ID of the payment.

Returns:

  • (String)

    the Starling internal ID of the payment



6
7
8
# File 'lib/starling/resources/payment_resource.rb', line 6

def payment_order_id
  parsed_data['paymentOrderId']
end

#payment_typeSymbol

Returns the type of the payment (e.g. ‘:standing_order`) (these values do not seem to be accurate!).

Returns:

  • (Symbol)

    the type of the payment (e.g. ‘:standing_order`) (these values do not seem to be accurate!)



73
74
75
# File 'lib/starling/resources/payment_resource.rb', line 73

def payment_type
  present_enum(parsed_data['paymentType'])
end

#receiving_contact_account_idString

Returns the Starling internal ID of the contact account the payment is/was sent to.

Returns:

  • (String)

    the Starling internal ID of the contact account the payment is/was sent to



28
29
30
# File 'lib/starling/resources/payment_resource.rb', line 28

def 
  parsed_data['receivingContactAccountId']
end

#recipient_nameString

Returns the name of the recipient of the payment.

Returns:

  • (String)

    the name of the recipient of the payment



33
34
35
# File 'lib/starling/resources/payment_resource.rb', line 33

def recipient_name
  parsed_data['recipientName']
end

#recurrence_ruleHash?

Returns a Hash describing the recurrence behaviour of the payment, or nil if the payment is not recurring. The values in the Hash will be parsed directly from JSON (e.g. dates will appear as strings).

TODO: Consider replacing this with its own resource

Returns:

  • (Hash, nil)

    a Hash describing the recurrence behaviour of the payment, with values parsed directly from JSON, or nil if the payment is not recurring



51
52
53
# File 'lib/starling/resources/payment_resource.rb', line 51

def recurrence_rule
  parsed_data['recurrenceRule']
end

#referenceString

Returns the reference of the payment.

Returns:

  • (String)

    the reference of the payment



22
23
24
# File 'lib/starling/resources/payment_resource.rb', line 22

def reference
  parsed_data['reference']
end

#start_dateDate

Returns the start date of the payment.

Returns:

  • (Date)

    the start date of the payment



56
57
58
# File 'lib/starling/resources/payment_resource.rb', line 56

def start_date
  present_date(parsed_data['startDate'])
end