Class: PaymentsApi::Quote

Inherits:
BaseModel show all
Defined in:
lib/payments_api/models/quote.rb

Overview

Quote Information Object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(beneficiary_currency = nil, id = nil, beneficiary_amount = nil, originator_amount = nil, originator_amount_is_fixed = nil, exchange_rate = nil, locked = nil, revision = nil) ⇒ Quote

Returns a new instance of Quote.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/payments_api/models/quote.rb', line 61

def initialize(beneficiary_currency = nil,
               id = nil,
               beneficiary_amount = nil,
               originator_amount = nil,
               originator_amount_is_fixed = nil,
               exchange_rate = nil,
               locked = nil,
               revision = nil)
  @id = id
  @beneficiary_amount = beneficiary_amount
  @beneficiary_currency = beneficiary_currency
  @originator_amount = originator_amount
  @originator_amount_is_fixed = originator_amount_is_fixed
  @exchange_rate = exchange_rate
  @locked = locked
  @revision = revision
end

Instance Attribute Details

#beneficiary_amountFloat

Amount to send in beneficiary currency. Not required if originatorAmount is provided.

Returns:

  • (Float)


16
17
18
# File 'lib/payments_api/models/quote.rb', line 16

def beneficiary_amount
  @beneficiary_amount
end

#beneficiary_currencyString

Beneficiary currency code in ISO 4217 format

Returns:

  • (String)


20
21
22
# File 'lib/payments_api/models/quote.rb', line 20

def beneficiary_currency
  @beneficiary_currency
end

#exchange_rateFloat

The exchange rate for the quote

Returns:

  • (Float)


36
37
38
# File 'lib/payments_api/models/quote.rb', line 36

def exchange_rate
  @exchange_rate
end

#idInteger

Quote ID

Returns:

  • (Integer)


11
12
13
# File 'lib/payments_api/models/quote.rb', line 11

def id
  @id
end

#lockedBoolean

Set to true if the quote rate is locked

Returns:

  • (Boolean)


40
41
42
# File 'lib/payments_api/models/quote.rb', line 40

def locked
  @locked
end

#originator_amountFloat

Amount to send in originator currency. Not required if beneficiaryAmount is provided

Returns:

  • (Float)


25
26
27
# File 'lib/payments_api/models/quote.rb', line 25

def originator_amount
  @originator_amount
end

#originator_amount_is_fixedBoolean

If true, then the originator amount is fixed to the provided value. If false, then the beneficiary amount is fixed to the provided value. This field is automatically set based on whether the originator or beneficary amount was provided.

Returns:

  • (Boolean)


32
33
34
# File 'lib/payments_api/models/quote.rb', line 32

def originator_amount_is_fixed
  @originator_amount_is_fixed
end

#revisionInteger

Quote revision number. This is automatically incremented each time the quote is refreshed or updated, and starts from 1

Returns:

  • (Integer)


45
46
47
# File 'lib/payments_api/models/quote.rb', line 45

def revision
  @revision
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/payments_api/models/quote.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  beneficiary_currency = hash['beneficiaryCurrency']
  id = hash['id']
  beneficiary_amount = hash['beneficiaryAmount']
  originator_amount = hash['originatorAmount']
  originator_amount_is_fixed = hash['originatorAmountIsFixed']
  exchange_rate = hash['exchangeRate']
  locked = hash['locked']
  revision = hash['revision']

  # Create object from extracted values.
  Quote.new(beneficiary_currency,
            id,
            beneficiary_amount,
            originator_amount,
            originator_amount_is_fixed,
            exchange_rate,
            locked,
            revision)
end

.namesObject

A mapping from model property names to API property names.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/payments_api/models/quote.rb', line 48

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['beneficiary_amount'] = 'beneficiaryAmount'
  @_hash['beneficiary_currency'] = 'beneficiaryCurrency'
  @_hash['originator_amount'] = 'originatorAmount'
  @_hash['originator_amount_is_fixed'] = 'originatorAmountIsFixed'
  @_hash['exchange_rate'] = 'exchangeRate'
  @_hash['locked'] = 'locked'
  @_hash['revision'] = 'revision'
  @_hash
end