Module: DeviantArt::Client::User
- Included in:
- DeviantArt::Client
- Defined in:
- lib/deviantart/client/user.rb
Instance Method Summary collapse
-
#damntoken ⇒ Object
Retrieve the dAmn auth token required to connect to the dAmn servers.
-
#get_friends(username, offset: 0, limit: 10) ⇒ Object
Get the users list of friends.
-
#get_profile(username, ext_collections: false, ext_galleries: false) ⇒ Object
Get user profile information.
-
#get_status(statusid, mature_content: true) ⇒ Object
Fetch the status.
-
#get_statuses(username, offset: 0, limit: 10, mature_content: true) ⇒ Object
User Statuses.
-
#get_watchers(username: nil, offset: 0, limit: 10) ⇒ Object
Get the user’s list of watchers.
-
#search_friends(query, username: nil) ⇒ Object
Search friends by username.
-
#unwatch(username) ⇒ Object
Unwatch a user.
-
#watch(username, watch = {}) ⇒ Object
Watch a user.
-
#watch_status(username) ⇒ Object
Check if user is being watched by the given user.
-
#whoami ⇒ Object
Fetch user info of authenticated user.
-
#whois(users) ⇒ Object
Fetch user info for given usernames.
Instance Method Details
#damntoken ⇒ Object
Retrieve the dAmn auth token required to connect to the dAmn servers
101 102 103 |
# File 'lib/deviantart/client/user.rb', line 101 def damntoken perform(DeviantArt::User::DamnToken, :get, '/api/v1/oauth2/user/damntoken?') end |
#get_friends(username, offset: 0, limit: 10) ⇒ Object
Get the users list of friends
25 26 27 28 29 30 |
# File 'lib/deviantart/client/user.rb', line 25 def get_friends(username, offset: 0, limit: 10) params = {} params['offset'] = offset if offset != 0 params['limit'] = limit if limit != 10 perform(DeviantArt::User::Friends, :get, "/api/v1/oauth2/user/friends/#{username.nil? ? '' : username}", params) end |
#get_profile(username, ext_collections: false, ext_galleries: false) ⇒ Object
Get user profile information
17 18 19 20 21 22 |
# File 'lib/deviantart/client/user.rb', line 17 def get_profile(username, ext_collections: false, ext_galleries: false) params = {} params['ext_collections'] = ext_collections if ext_collections params['ext_galleries'] = ext_galleries if ext_galleries perform(DeviantArt::User::Profile, :get, "/api/v1/oauth2/user/profile/#{username.nil? ? '' : username}", params) end |
#get_status(statusid, mature_content: true) ⇒ Object
Fetch the status
62 63 64 65 66 |
# File 'lib/deviantart/client/user.rb', line 62 def get_status(statusid, mature_content: true) params = {} params['mature_content'] = mature_content perform(DeviantArt::Status, :get, "/api/v1/oauth2/user/statuses/#{statusid}", params) end |
#get_statuses(username, offset: 0, limit: 10, mature_content: true) ⇒ Object
User Statuses
52 53 54 55 56 57 58 59 |
# File 'lib/deviantart/client/user.rb', line 52 def get_statuses(username, offset: 0, limit: 10, mature_content: true) params = {} params['username'] = username params['mature_content'] = mature_content params['offset'] = offset if offset != 0 params['limit'] = limit if limit != 10 perform(DeviantArt::User::Statuses, :get, '/api/v1/oauth2/user/statuses/', params) end |
#get_watchers(username: nil, offset: 0, limit: 10) ⇒ Object
Get the user’s list of watchers
69 70 71 72 73 74 |
# File 'lib/deviantart/client/user.rb', line 69 def get_watchers(username: nil, offset: 0, limit: 10) params = {} params['offset'] = offset if offset != 0 params['limit'] = limit if limit != 10 perform(DeviantArt::User::Watchers, :get, "/api/v1/oauth2/user/watchers/#{username.nil? ? '' : username}", params) end |
#search_friends(query, username: nil) ⇒ Object
Search friends by username
44 45 46 47 48 49 |
# File 'lib/deviantart/client/user.rb', line 44 def search_friends(query, username: nil) params = {} params['query'] = query params['username'] = username unless username.nil? perform(DeviantArt::User::Friends::Search, :get, '/api/v1/oauth2/user/friends/search', params) end |
#unwatch(username) ⇒ Object
Unwatch a user
96 97 98 |
# File 'lib/deviantart/client/user.rb', line 96 def unwatch(username) perform(DeviantArt::User::Friends::Unwatch, :get, "/api/v1/oauth2/user/friends/unwatch/#{username.nil? ? '' : username}") end |
#watch(username, watch = {}) ⇒ Object
Watch a user
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/deviantart/client/user.rb', line 82 def watch(username, watch = {}) watch_params = {} %w(friend deviations journals forum_threads critiques scraps activity collections).each do |p| if watch[p] watch_params[p] = true else watch_params[p] = false end end params = { watch: watch_params } perform(DeviantArt::User::Friends::Watch, :post, "/api/v1/oauth2/user/friends/watch/#{username.nil? ? '' : username}", params) end |
#watch_status(username) ⇒ Object
Check if user is being watched by the given user
77 78 79 |
# File 'lib/deviantart/client/user.rb', line 77 def watch_status(username) perform(DeviantArt::User::Friends::Watching, :get, "/api/v1/oauth2/user/friends/watching/#{username.nil? ? '' : username}") end |
#whoami ⇒ Object
Fetch user info of authenticated user
39 40 41 |
# File 'lib/deviantart/client/user.rb', line 39 def whoami perform(DeviantArt::User, :get, '/api/v1/oauth2/user/whoami?') end |
#whois(users) ⇒ Object
Fetch user info for given usernames
33 34 35 36 |
# File 'lib/deviantart/client/user.rb', line 33 def whois(users) params = { usernames: users.is_a?(Enumerable) ? users : [users] } perform(DeviantArt::User::Whois, :post, '/api/v1/oauth2/user/whois', params) end |