class Etsy::User
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)
Public Class Methods
find(*identifiers_and_options)
click to toggle source
Retrieve one or more users by name or ID:
Etsy::User.find('reagent')
You can find multiple users by passing an array of identifiers:
Etsy::User.find(['reagent', 'littletjane'])
# File lib/etsy/user.rb, line 33 def self.find(*identifiers_and_options) find_one_or_more('users', identifiers_and_options) end
myself(token, secret, options = {})
click to toggle source
Retrieve the currently authenticated user.
# File lib/etsy/user.rb, line 39 def self.myself(token, secret, options = {}) find('__SELF__', {:access_token => token, :access_secret => secret}.merge(options)) end
Public Instance Methods
addresses()
click to toggle source
The addresses associated with this user.
# File lib/etsy/user.rb, line 51 def addresses options = (token && secret) ? {:access_token => token, :access_secret => secret} : {} @addresses ||= Address.find(username, options) end
bill_charges()
click to toggle source
# 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 options = {:fields => 'user_id', :includes => 'BillCharges'} options = options.merge(:access_token => token, :access_secret => secret) if (token && secret) tmp = User.find(username, options) @bill_charges = tmp.associated_bill_charges.map { |bill_charge| BillCharge.new(bill_charge) } end end @bill_charges end
bill_payments()
click to toggle source
# 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 options = {:fields => 'user_id', :includes => 'BillPayments'} options = options.merge(:access_token => token, :access_secret => secret) if (token && secret) tmp = User.find(username, options) @bill_payments = tmp.associated_bill_payments.map { |bill_payment| BillPayment.new(bill_payment) } end end @bill_payments end
bought_listings()
click to toggle source
Return a set of listings that have been bought
# 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()
click to toggle source
Time that this user was created
# File lib/etsy/user.rb, line 116 def created_at Time.at(created) end
favorites()
click to toggle source
Retrieve list of favorited items for this user
# 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()
click to toggle source
The profile associated with this user.
# File lib/etsy/user.rb, line 58 def profile unless @profile if associated_profile @profile = Profile.new(associated_profile) else options = {:fields => 'user_id', :includes => 'Profile'} options = options.merge(:access_token => token, :access_secret => secret) if (token && secret) tmp = User.find(username, options) @profile = Profile.new(tmp.associated_profile) end end @profile end
shop()
click to toggle source
The shop associated with this user.
# File lib/etsy/user.rb, line 45 def shop @shop ||= shops.first end
shops()
click to toggle source
# File lib/etsy/user.rb, line 72 def shops unless @shops if associated_shops @shops = associated_shops.map { |shop| Shop.new(shop) } else options = {:fields => 'user_id', :includes => 'Shops'} options = options.merge(:access_token => token, :access_secret => secret) if (token && secret) tmp = User.find(username, options) @shops = tmp.associated_shops.map { |shop| Shop.new(shop) } end end @shops end