Class: Asdawqw::Rate

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/rate.rb

Overview

Rate Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(begin_date = nil, end_date = nil, amount = nil) ⇒ Rate

Returns a new instance of Rate.



33
34
35
36
37
38
39
# File 'lib/asdawqw/models/rate.rb', line 33

def initialize(begin_date = nil,
               end_date = nil,
               amount = nil)
  @begin_date = begin_date
  @end_date = end_date
  @amount = amount
end

Instance Attribute Details

#amountFloat

Value of rate, needs to be higher than 0, otherwise it will not be imported

Returns:

  • (Float)


22
23
24
# File 'lib/asdawqw/models/rate.rb', line 22

def amount
  @amount
end

#begin_dateDate

Beginning date of date range for which rate is applied. Date should be in format “yyyy-MM-dd”

Returns:

  • (Date)


12
13
14
# File 'lib/asdawqw/models/rate.rb', line 12

def begin_date
  @begin_date
end

#end_dateDate

End date of date range for which rate is applied. Date should be in format “yyyy-MM-dd”

Returns:

  • (Date)


17
18
19
# File 'lib/asdawqw/models/rate.rb', line 17

def end_date
  @end_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/asdawqw/models/rate.rb', line 42

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  begin_date = hash['beginDate']
  end_date = hash['endDate']
  amount = hash['amount']

  # Create object from extracted values.
  Rate.new(begin_date,
           end_date,
           amount)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/asdawqw/models/rate.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['begin_date'] = 'beginDate'
  @_hash['end_date'] = 'endDate'
  @_hash['amount'] = 'amount'
  @_hash
end