Class: Svpply::User

Inherits:
Object
  • Object
show all
Defined in:
lib/svpply/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ User

Returns a new instance of User.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/svpply/user.rb', line 18

def initialize(hash)
  @id = hash["id"]
  @name = hash["name"]
  @username = hash["username"]
  @url = hash["url"]
  @description = hash["description"]
  @location = hash["location"]
  @display_name = hash["display_name"]
  @avatar = hash["avatar"]
  @gender_preference = hash["gender_preference"]
  @products_count = hash["products_count"]
  @owns_count = hash["owns_count"]
  @users_following_count = hash["users_following_count"]
  @users_followers_count = hash["users_followers_count"]
  @stores_following_count = hash["stores_following_count"]
  @searches_following_count = hash["searches_following_count"]
  @date_created = hash["date_created"]
  @date_updated = hash["date_updated"]
  @svpply_url = "https://svpply.com/#{@username}"
end

Instance Attribute Details

#avatarObject (readonly)

Returns the value of attribute avatar.



3
4
5
# File 'lib/svpply/user.rb', line 3

def avatar
  @avatar
end

#date_createdObject (readonly)

Returns the value of attribute date_created.



3
4
5
# File 'lib/svpply/user.rb', line 3

def date_created
  @date_created
end

#date_updatedObject (readonly)

Returns the value of attribute date_updated.



3
4
5
# File 'lib/svpply/user.rb', line 3

def date_updated
  @date_updated
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/svpply/user.rb', line 3

def description
  @description
end

#display_nameObject (readonly)

Returns the value of attribute display_name.



3
4
5
# File 'lib/svpply/user.rb', line 3

def display_name
  @display_name
end

#gender_preferenceObject (readonly)

Returns the value of attribute gender_preference.



3
4
5
# File 'lib/svpply/user.rb', line 3

def gender_preference
  @gender_preference
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/svpply/user.rb', line 3

def id
  @id
end

#locationObject (readonly)

Returns the value of attribute location.



3
4
5
# File 'lib/svpply/user.rb', line 3

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/svpply/user.rb', line 3

def name
  @name
end

#owns_countObject (readonly)

Returns the value of attribute owns_count.



3
4
5
# File 'lib/svpply/user.rb', line 3

def owns_count
  @owns_count
end

#products_countObject (readonly)

Returns the value of attribute products_count.



3
4
5
# File 'lib/svpply/user.rb', line 3

def products_count
  @products_count
end

#searches_following_countObject (readonly)

Returns the value of attribute searches_following_count.



3
4
5
# File 'lib/svpply/user.rb', line 3

def searches_following_count
  @searches_following_count
end

#stores_following_countObject (readonly)

Returns the value of attribute stores_following_count.



3
4
5
# File 'lib/svpply/user.rb', line 3

def stores_following_count
  @stores_following_count
end

#svpply_urlObject (readonly)

Returns the value of attribute svpply_url.



3
4
5
# File 'lib/svpply/user.rb', line 3

def svpply_url
  @svpply_url
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/svpply/user.rb', line 3

def url
  @url
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/svpply/user.rb', line 3

def username
  @username
end

#users_followers_countObject (readonly)

Returns the value of attribute users_followers_count.



3
4
5
# File 'lib/svpply/user.rb', line 3

def users_followers_count
  @users_followers_count
end

#users_following_countObject (readonly)

Returns the value of attribute users_following_count.



3
4
5
# File 'lib/svpply/user.rb', line 3

def users_following_count
  @users_following_count
end

Class Method Details

.find(id) ⇒ Object



10
11
12
# File 'lib/svpply/user.rb', line 10

def self.find(id)
  new(Client.get_response("/users/#{id}.json")["user"])
end

.products(id, attrs = nil) ⇒ Object



14
15
16
# File 'lib/svpply/user.rb', line 14

def self.products(id, attrs=nil)
  ProductCollection.new(Client.get_response("/users/#{id}/wants/products.json", attrs)).products
end