Class: Nineflats::Booking

Inherits:
Base
  • Object
show all
Defined in:
lib/nineflats-api/booking.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#raw_data

Instance Method Summary collapse

Methods inherited from Base

client_app_key, client_app_key=, object_link

Constructor Details

#initialize(json) ⇒ Booking

Returns a new instance of Booking.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/nineflats-api/booking.rb', line 7

def initialize(json)
  @raw_data = json
  booking = json.first[1]

  @checkin_date     = booking["checkin_date"]
  @checkout_date    = booking["checkout_date"]
  @nights           = booking["nights"]
  @number_of_guests = booking["number_of_guests"]
  @status           = booking["status"]

  @host   = User.new({"user" => booking["host"]})
  @place  = Place.new({"place" => booking["place"]})

  @links = {}
  booking['links'].each do |link|
    @links[link['rel']] = link['href']
  end
end

Instance Attribute Details

#checkin_dateObject

Returns the value of attribute checkin_date.



4
5
6
# File 'lib/nineflats-api/booking.rb', line 4

def checkin_date
  @checkin_date
end

#checkout_dateObject

Returns the value of attribute checkout_date.



4
5
6
# File 'lib/nineflats-api/booking.rb', line 4

def checkout_date
  @checkout_date
end

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/nineflats-api/booking.rb', line 5

def host
  @host
end

Returns the value of attribute links.



5
6
7
# File 'lib/nineflats-api/booking.rb', line 5

def links
  @links
end

#nightsObject

Returns the value of attribute nights.



4
5
6
# File 'lib/nineflats-api/booking.rb', line 4

def nights
  @nights
end

#number_of_guestsObject

Returns the value of attribute number_of_guests.



4
5
6
# File 'lib/nineflats-api/booking.rb', line 4

def number_of_guests
  @number_of_guests
end

#placeObject

Returns the value of attribute place.



5
6
7
# File 'lib/nineflats-api/booking.rb', line 5

def place
  @place
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/nineflats-api/booking.rb', line 4

def status
  @status
end