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.
- #bill_charges ⇒ Object
- #bill_payments ⇒ Object
-
#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
33 34 35 |
# File 'lib/etsy/user.rb', line 33 def self.find(*) find_one_or_more('users', ) end |
.myself(token, secret, options = {}) ⇒ Object
Retrieve the currently authenticated user.
39 40 41 |
# File 'lib/etsy/user.rb', line 39 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.
51 52 53 54 |
# File 'lib/etsy/user.rb', line 51 def addresses = (token && secret) ? {:access_token => token, :access_secret => secret} : {} @addresses ||= Address.find(username, ) end |
#bill_charges ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/etsy/user.rb', line 86 def bill_charges unless @bill_charges if associated_bill_charges @bill_charges = associated_bill_charges.map { |bill_charge| BillCharge.new(bill_charge) } else = {:fields => 'user_id', :includes => 'BillCharges'} = .merge(:access_token => token, :access_secret => secret) if (token && secret) tmp = User.find(username, ) @bill_charges = tmp.associated_bill_charges.map { |bill_charge| BillCharge.new(bill_charge) } end end @bill_charges end |
#bill_payments ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/etsy/user.rb', line 100 def bill_payments unless @bill_payments if associated_bill_payments @bill_payments = associated_bill_payments.map { |bill_payment| BillPayment.new(bill_payment) } else = {:fields => 'user_id', :includes => 'BillPayments'} = .merge(:access_token => token, :access_secret => secret) if (token && secret) tmp = User.find(username, ) @bill_payments = tmp.associated_bill_payments.map { |bill_payment| BillPayment.new(bill_payment) } end end @bill_payments end |
#bought_listings ⇒ Object
Return a set of listings that have been bought
131 132 133 134 135 136 |
# File 'lib/etsy/user.rb', line 131 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
116 117 118 |
# File 'lib/etsy/user.rb', line 116 def created_at Time.at(created) end |
#favorites ⇒ Object
Retrieve list of favorited items for this user
122 123 124 125 126 127 |
# File 'lib/etsy/user.rb', line 122 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.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/etsy/user.rb', line 58 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.
45 46 47 |
# File 'lib/etsy/user.rb', line 45 def shop @shop ||= shops.first end |
#shops ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/etsy/user.rb', line 72 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 |