Class: Nineflats::User

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

Instance Attribute Summary collapse

Attributes inherited from Base

#raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client_app_key, client_app_key=, object_link

Constructor Details

#initialize(json) ⇒ User

Returns a new instance of User.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nineflats-api/user.rb', line 6

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

  @name           = user["name"]
  @slug           = user["slug"]
  @user_photo_url = user["user_photo_url"]

  if user["links"]
    @self_url      = Nineflats::Base.object_link("self", user["links"])
    @full_url      = Nineflats::Base.object_link("full", user["links"])
    @favorites_url = Nineflats::Base.object_link("favorites", user["links"])
  end
end

Instance Attribute Details

#favorites(options = {}) ⇒ Object

Returns the value of attribute favorites.



3
4
5
# File 'lib/nineflats-api/user.rb', line 3

def favorites
  @favorites
end

#favorites_urlObject

Returns the value of attribute favorites_url.



3
4
5
# File 'lib/nineflats-api/user.rb', line 3

def favorites_url
  @favorites_url
end

#full_urlObject

Returns the value of attribute full_url.



3
4
5
# File 'lib/nineflats-api/user.rb', line 3

def full_url
  @full_url
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/nineflats-api/user.rb', line 3

def name
  @name
end

#self_urlObject

Returns the value of attribute self_url.



3
4
5
# File 'lib/nineflats-api/user.rb', line 3

def self_url
  @self_url
end

#slugObject

Returns the value of attribute slug.



3
4
5
# File 'lib/nineflats-api/user.rb', line 3

def slug
  @slug
end

#user_photo_urlObject

Returns the value of attribute user_photo_url.



3
4
5
# File 'lib/nineflats-api/user.rb', line 3

def user_photo_url
  @user_photo_url
end

Class Method Details

.find_by_slug(slug) ⇒ Object



32
33
34
# File 'lib/nineflats-api/user.rb', line 32

def self.find_by_slug(slug)
  Client.user(slug)
end

Instance Method Details

#bookingsObject



21
22
23
# File 'lib/nineflats-api/user.rb', line 21

def bookings
  Client.user_bookings(self.slug)
end