Class: TaobaoApi::User
- Inherits:
-
Object
- Object
- TaobaoApi::User
- Includes:
- BaseApi
- Defined in:
- lib/taobao_api/user.rb
Constant Summary collapse
- @@configurable_attrs =
[:address, :level, :praise_rate, :type, :seller_credit, :nick, :location]
Class Method Summary collapse
- .<<(item) ⇒ Object
-
.get_buyer_users_level(*nicks) ⇒ Object
获得买家用户等级 返回Hash { ‘tumayun’ => 10, ‘jcw’ => 12 } get_buyer_users_level(‘tumayun’, ‘jcw’).
Instance Method Summary collapse
-
#initialize(nick) ⇒ User
constructor
A new instance of User.
Methods included from BaseApi
included, init_config, valid_config
Constructor Details
#initialize(nick) ⇒ User
Returns a new instance of User.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/taobao_api/user.rb', line 18 def initialize(nick) return if ( = self.class.get_result(nick)).blank? @@configurable_attrs.each do |attr_name| instance_variable_set("@#{attr_name}", .search(attr_name.to_s)) end @level = @level.to_i @praise_rate = count_praise_rate() @address = get_address() end |
Class Method Details
.<<(item) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/taobao_api/user.rb', line 11 def @@configurable_attrs.<<(item) return self if item.blank? super(item.to_sym).uniq! TaobaoApi::User.send :attr_reader, item.to_sym self end |
.get_buyer_users_level(*nicks) ⇒ Object
获得买家用户等级 返回Hash { ‘tumayun’ => 10, ‘jcw’ => 12 } get_buyer_users_level(‘tumayun’, ‘jcw’)
33 34 35 36 37 |
# File 'lib/taobao_api/user.rb', line 33 def self.get_buyer_users_level(*nicks) = { :method => 'taobao.users.get', :timestamp => Time.now.to_s(:db), :fields => 'nick, buyer_credit', :nicks => nicks.join(',') } users = taobao_api_get().search('user') || [] users.inject({}){ |h, user| h[user['nick']] = user['buyer_credit'].try(:[], 'level'); h } end |