Class: Asdawqw::TransportYield
- Defined in:
- lib/asdawqw/models/transport_yield.rb
Overview
TransportYield Model.
Instance Attribute Summary collapse
-
#date_range ⇒ List of Yield
Set a specific date range in which you would like to manipulate the basic price per night.
-
#length_of_stay ⇒ List of Yield
Automatically applies price modifications to inquiries based on the number of nights the inquiries are for.
-
#product_id ⇒ Integer
ID of the product.
-
#weekend ⇒ List of Yield
Set a specific date range in which you would like to manipulate the basic price per night on weekends.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(product_id = nil, weekend = nil, length_of_stay = nil, date_range = nil) ⇒ TransportYield
constructor
A new instance of TransportYield.
Methods inherited from BaseModel
Constructor Details
#initialize(product_id = nil, weekend = nil, length_of_stay = nil, date_range = nil) ⇒ TransportYield
Returns a new instance of TransportYield.
49 50 51 52 53 54 55 56 57 |
# File 'lib/asdawqw/models/transport_yield.rb', line 49 def initialize(product_id = nil, weekend = nil, length_of_stay = nil, date_range = nil) @product_id = product_id @weekend = weekend @length_of_stay = length_of_stay @date_range = date_range end |
Instance Attribute Details
#date_range ⇒ List of Yield
Set a specific date range in which you would like to manipulate the basic price per night. For example you will set the YMR date range from 01.07.2016-31.07.2016 yield amount = 20 modifier - Increase Percent Price per night in the period from 01.07.2016 to 31.07.2016 will be 100 + 20% = 120 USD
37 38 39 |
# File 'lib/asdawqw/models/transport_yield.rb', line 37 def date_range @date_range end |
#length_of_stay ⇒ List of Yield
Automatically applies price modifications to inquiries based on the number of nights the inquiries are for. For example you will set the YMR date range from 01.07.2016-31.07.2017 param - of Stay. Let’s say you set 15 days. yield amount = 5 modifier - Decrease Percent Price per night if you made a reservation for 15 or more days will be 100 - 5% = 95 USD
29 30 31 |
# File 'lib/asdawqw/models/transport_yield.rb', line 29 def length_of_stay @length_of_stay end |
#product_id ⇒ Integer
ID of the product
11 12 13 |
# File 'lib/asdawqw/models/transport_yield.rb', line 11 def product_id @product_id end |
#weekend ⇒ List of Yield
Set a specific date range in which you would like to manipulate the basic price per night on weekends. For example you will set the YMR date range from 01.07.2016-31.07.2016 param - (Friday, Saturday=0; Saturday, Sunday=1) yield amount = 20 modifier - Increase Percent Price per night in the period from 01.07.2016 to 31.07.2016 will be 100 USD in working days and 100 + 20% = 120 USD in weekends (Friday, Saturday or Saturday, Sunday, depending on what was selected).
21 22 23 |
# File 'lib/asdawqw/models/transport_yield.rb', line 21 def weekend @weekend end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/asdawqw/models/transport_yield.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. product_id = hash['productId'] # Parameter is an array, so we need to iterate through it weekend = nil unless hash['weekend'].nil? weekend = [] hash['weekend'].each do |structure| weekend << (Yield.from_hash(structure) if structure) end end # Parameter is an array, so we need to iterate through it length_of_stay = nil unless hash['lengthOfStay'].nil? length_of_stay = [] hash['lengthOfStay'].each do |structure| length_of_stay << (Yield.from_hash(structure) if structure) end end # Parameter is an array, so we need to iterate through it date_range = nil unless hash['dateRange'].nil? date_range = [] hash['dateRange'].each do |structure| date_range << (Yield.from_hash(structure) if structure) end end # Create object from extracted values. TransportYield.new(product_id, weekend, length_of_stay, date_range) end |
.names ⇒ Object
A mapping from model property names to API property names.
40 41 42 43 44 45 46 47 |
# File 'lib/asdawqw/models/transport_yield.rb', line 40 def self.names @_hash = {} if @_hash.nil? @_hash['product_id'] = 'productId' @_hash['weekend'] = 'weekend' @_hash['length_of_stay'] = 'lengthOfStay' @_hash['date_range'] = 'dateRange' @_hash end |