Class: Smartfm::User
Defined Under Namespace
Constant Summary collapse
- ATTRIBUTES =
[:username, :profile]
Class Method Summary collapse
- .current(auth, params = {}) ⇒ Object
- .find(username, params = {}) ⇒ Object
- .followers(auth, params = {}) ⇒ Object
- .friends(auth, params = {}) ⇒ Object
- .matching(keyword, params = {}) ⇒ Object
- .rest_client ⇒ Object
Instance Method Summary collapse
- #follow!(auth, params = {}) ⇒ Object
- #followers(params = {}) ⇒ Object
- #followers_of_current(auth, params = {}) ⇒ Object
- #friends(params = {}) ⇒ Object
- #friends_of_current(auth, params = {}) ⇒ Object
-
#initialize(params) ⇒ User
constructor
A new instance of User.
- #items(params = {}) ⇒ Object
- #likes(params = {}) ⇒ Object
- #lists(params = {}) ⇒ Object
- #notifications(params = {}) ⇒ Object
- #rest_client ⇒ Object
- #study(params = {}) ⇒ Object
- #unfollow!(auth, params = {}) ⇒ Object
Methods inherited from Base
Constructor Details
Class Method Details
.current(auth, params = {}) ⇒ Object
83 84 85 |
# File 'lib/smartfm/models/user.rb', line 83 def self.current(auth, params = {}) self.rest_client.current(auth, params) end |
.find(username, params = {}) ⇒ Object
71 72 73 74 75 |
# File 'lib/smartfm/models/user.rb', line 71 def self.find(username, params = {}) params[:username] = username hash = self.rest_client.find(params) self.deserialize(hash) end |
.followers(auth, params = {}) ⇒ Object
91 92 93 |
# File 'lib/smartfm/models/user.rb', line 91 def self.followers(auth, params = {}) self.rest_client.followers_of_current(auth, params) end |
.friends(auth, params = {}) ⇒ Object
87 88 89 |
# File 'lib/smartfm/models/user.rb', line 87 def self.friends(auth, params = {}) self.rest_client.friends_of_current(auth, params) end |
.matching(keyword, params = {}) ⇒ Object
77 78 79 80 81 |
# File 'lib/smartfm/models/user.rb', line 77 def self.matching(keyword, params = {}) params[:keyword] = keyword hash = self.rest_client.matching(params) self.deserialize(hash) || [] end |
.rest_client ⇒ Object
5 |
# File 'lib/smartfm/models/user.rb', line 5 def self.rest_client; Smartfm::RestClient::User; end |
Instance Method Details
#follow!(auth, params = {}) ⇒ Object
115 116 117 |
# File 'lib/smartfm/models/user.rb', line 115 def follow!(auth, params = {}) self.rest_client.follow!(auth, params.merge(:username => self.username)) end |
#followers(params = {}) ⇒ Object
100 101 102 103 |
# File 'lib/smartfm/models/user.rb', line 100 def followers(params = {}) hash = self.rest_client.followers(params.merge(:username => self.username)) self.deserialize(hash) || [] end |
#followers_of_current(auth, params = {}) ⇒ Object
110 111 112 113 |
# File 'lib/smartfm/models/user.rb', line 110 def followers_of_current(auth, params = {}) hash = self.rest_client.followers_of_current(auth, params) self.deserialize(hash) || [] end |
#friends(params = {}) ⇒ Object
95 96 97 98 |
# File 'lib/smartfm/models/user.rb', line 95 def friends(params = {}) hash = self.rest_client.friends(params.merge(:username => self.username)) self.deserialize(hash) || [] end |
#friends_of_current(auth, params = {}) ⇒ Object
105 106 107 108 |
# File 'lib/smartfm/models/user.rb', line 105 def friends_of_current(auth, params = {}) hash = self.rest_client.friends_of_current(auth, params) self.deserialize(hash) || [] end |
#items(params = {}) ⇒ Object
123 124 125 126 |
# File 'lib/smartfm/models/user.rb', line 123 def items(params = {}) hash = self.rest_client.items(params.merge(:username => self.username)) self.deserialize(hash, :as => Smartfm::Item) || [] end |
#likes(params = {}) ⇒ Object
133 134 135 136 |
# File 'lib/smartfm/models/user.rb', line 133 def likes(params = {}) hash = self.rest_client.likes(params.merge(:username => self.username)) self.deserialize(hash, :as => Smartfm::Like) || [] end |
#lists(params = {}) ⇒ Object
128 129 130 131 |
# File 'lib/smartfm/models/user.rb', line 128 def lists(params = {}) hash = self.rest_client.lists(params.merge(:username => self.username)) self.deserialize(hash, :as => Smartfm::List) || [] end |
#notifications(params = {}) ⇒ Object
138 139 140 141 |
# File 'lib/smartfm/models/user.rb', line 138 def notifications(params = {}) hash = self.rest_client.notifications(params.merge(:username => self.username)) self.deserialize(hash, :as => Smartfm::Notification) || [] end |
#rest_client ⇒ Object
6 |
# File 'lib/smartfm/models/user.rb', line 6 def rest_client; self.class.rest_client; end |
#study(params = {}) ⇒ Object
143 144 145 146 147 148 |
# File 'lib/smartfm/models/user.rb', line 143 def study(params = {}) params[:application] ||= 'iknow' return nil unless ['iknow', 'dictation', 'brainspeed', ].include?(params[:application]) hash = self.rest_client.study_results(params.merge(:username => self.username)) self.deserialize(hash, :as => Smartfm::User::Study) end |
#unfollow!(auth, params = {}) ⇒ Object
119 120 121 |
# File 'lib/smartfm/models/user.rb', line 119 def unfollow!(auth, params = {}) self.rest_client.unfollow!(auth, params.merge(:username => self.username)) end |