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.
-
#created_at ⇒ Object
Time that this user was created.
-
#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 |
#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 |
#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 |