Class: Etsy::User
Overview
User
Represents a single Etsy user - has the following attributes:
- id
-
The unique identifier for this user
- username
-
This user’s username
-
This user’s email address (authenticated calls only)
Class Method Summary collapse
-
.find(*identifiers_and_options) ⇒ Object
Retrieve one or more users by name or ID:.
-
.myself(token, secret, options = {}) ⇒ Object
Retrieve the currently authenticated user.
Instance Method Summary collapse
-
#addresses ⇒ Object
The addresses associated with this user.
-
#bought_listings ⇒ Object
Return a set of listings that have been bought.
-
#created_at ⇒ Object
Time that this user was created.
-
#favorites ⇒ Object
Retrieve list of favorited items for this user.
-
#profile ⇒ Object
The profile associated with this user.
-
#shop ⇒ Object
The shop associated with this user.
- #shops ⇒ Object
Methods included from Model
included, #initialize, #result, #secret, #token
Class Method Details
.find(*identifiers_and_options) ⇒ Object
31 32 33 |
# File 'lib/etsy/user.rb', line 31 def self.find(*) find_one_or_more('users', ) end |
.myself(token, secret, options = {}) ⇒ Object
Retrieve the currently authenticated user.
37 38 39 |
# File 'lib/etsy/user.rb', line 37 def self.myself(token, secret, = {}) find('__SELF__', {:access_token => token, :access_secret => secret}.merge()) end |
Instance Method Details
#addresses ⇒ Object
The addresses associated with this user.
49 50 51 52 |
# File 'lib/etsy/user.rb', line 49 def addresses = (token && secret) ? {:access_token => token, :access_secret => secret} : {} @addresses ||= Address.find(username, ) end |
#bought_listings ⇒ Object
Return a set of listings that have been bought
101 102 103 104 105 106 |
# File 'lib/etsy/user.rb', line 101 def bought_listings unless @bought_listings @bought_listings = Listing.bought_listings(id, {:access_token => token, :access_secret => secret}) end @bought_listings end |
#created_at ⇒ Object
Time that this user was created
86 87 88 |
# File 'lib/etsy/user.rb', line 86 def created_at Time.at(created) end |
#favorites ⇒ Object
Retrieve list of favorited items for this user
92 93 94 95 96 97 |
# File 'lib/etsy/user.rb', line 92 def favorites unless @favorites @favorites = Listing.find_all_user_favorite_listings(id, {:access_token => token, :access_secret => secret}) end @favorites end |
#profile ⇒ Object
The profile associated with this user.
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/etsy/user.rb', line 56 def profile unless @profile if associated_profile @profile = Profile.new(associated_profile) else = {:fields => 'user_id', :includes => 'Profile'} = .merge(:access_token => token, :access_secret => secret) if (token && secret) tmp = User.find(username, ) @profile = Profile.new(tmp.associated_profile) end end @profile end |
#shop ⇒ Object
The shop associated with this user.
43 44 45 |
# File 'lib/etsy/user.rb', line 43 def shop @shop ||= shops.first end |
#shops ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/etsy/user.rb', line 70 def shops unless @shops if associated_shops @shops = associated_shops.map { |shop| Shop.new(shop) } else = {:fields => 'user_id', :includes => 'Shops'} = .merge(:access_token => token, :access_secret => secret) if (token && secret) tmp = User.find(username, ) @shops = tmp.associated_shops.map { |shop| Shop.new(shop) } end end @shops end |