Class: Asdawqw::AvailabilityModel
- Defined in:
- lib/asdawqw/models/availability_model.rb
Overview
AvailabilityModel Model.
Instance Attribute Summary collapse
-
#availability ⇒ Boolean
Determines if the dates are available or not.
-
#begin_date ⇒ Date
Beginning date of date range for which availability is applied.
-
#end_date ⇒ Date
End date of date range for which availability is applied.
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(begin_date = nil, end_date = nil, availability = nil) ⇒ AvailabilityModel
constructor
A new instance of AvailabilityModel.
Methods inherited from BaseModel
Constructor Details
#initialize(begin_date = nil, end_date = nil, availability = nil) ⇒ AvailabilityModel
Returns a new instance of AvailabilityModel.
38 39 40 41 42 43 44 |
# File 'lib/asdawqw/models/availability_model.rb', line 38 def initialize(begin_date = nil, end_date = nil, availability = nil) @begin_date = begin_date @end_date = end_date @availability = availability end |
Instance Attribute Details
#availability ⇒ Boolean
Determines if the dates are available or not. Our system saves only not available dates, so it is enough that you sent only not available dates. But if you want to open dates that you previously sent that are not available, you need to send that these dates are available over API.
27 28 29 |
# File 'lib/asdawqw/models/availability_model.rb', line 27 def availability @availability end |
#begin_date ⇒ Date
Beginning date of date range for which availability is applied. Date should be in format “yyyy-MM-dd”
12 13 14 |
# File 'lib/asdawqw/models/availability_model.rb', line 12 def begin_date @begin_date end |
#end_date ⇒ Date
End date of date range for which availability is applied. Additional clarification: If you have reservation from 2020/08/05 - 2020/08/09, so checkout is on 2020/08/09 - you should send end date 2020/08/08, since 2020/08/09 is actually open for new reservation. Date should be in format “yyyy-MM-dd”
20 21 22 |
# File 'lib/asdawqw/models/availability_model.rb', line 20 def end_date @end_date end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/asdawqw/models/availability_model.rb', line 47 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. begin_date = hash['beginDate'] end_date = hash['endDate'] availability = hash['availability'] # Create object from extracted values. AvailabilityModel.new(begin_date, end_date, availability) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 |
# File 'lib/asdawqw/models/availability_model.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['begin_date'] = 'beginDate' @_hash['end_date'] = 'endDate' @_hash['availability'] = 'availability' @_hash end |