Class: Nineflats::User

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

base_url, 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
# File 'lib/nineflats-api/user.rb', line 6

def initialize(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

#favoritesObject

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

.api_call(slug) ⇒ Object



40
41
42
# File 'lib/nineflats-api/user.rb', line 40

def self.api_call(slug)
  base_url + "/users/#{slug}?client_id=#{Nineflats::Base.client_app_key}"
end

.bookings(user_id) ⇒ Object



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

def self.bookings(user_id)
  Client.bookings(user_id)
end

.fetch(slug) ⇒ Object



36
37
38
# File 'lib/nineflats-api/user.rb', line 36

def self.fetch(slug)
  User.new(Helpers.get_data(User.api_call(slug)))
end