Module: DeviantArt::Client::User

Included in:
DeviantArt::Client
Defined in:
lib/deviantart/client/user.rb

Instance Method Summary collapse

Instance Method Details

#damntokenObject

Retrieve the dAmn auth token required to connect to the dAmn servers



118
119
120
# File 'lib/deviantart/client/user.rb', line 118

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



42
43
44
45
46
47
# File 'lib/deviantart/client/user.rb', line 42

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



20
21
22
23
24
25
# File 'lib/deviantart/client/user.rb', line 20

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



79
80
81
82
83
# File 'lib/deviantart/client/user.rb', line 79

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



69
70
71
72
73
74
75
76
# File 'lib/deviantart/client/user.rb', line 69

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



86
87
88
89
90
91
# File 'lib/deviantart/client/user.rb', line 86

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



61
62
63
64
65
66
# File 'lib/deviantart/client/user.rb', line 61

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



113
114
115
# File 'lib/deviantart/client/user.rb', line 113

def unwatch(username)
  perform(DeviantArt::User::Friends::Unwatch, :get, "/api/v1/oauth2/user/friends/unwatch/#{username.nil? ? '' : username}")
end

#update_profile(user_is_artist: nil, artist_level: nil, artist_specialty: nil, real_name: nil, tagline: nil, countryid: nil, website: nil, bio: nil) ⇒ Object

Update the users profile information



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/deviantart/client/user.rb', line 28

def update_profile(user_is_artist: nil, artist_level: nil, artist_specialty: nil, real_name: nil,  tagline: nil, countryid: nil, website: nil, bio: nil)
  params = {}
  params['user_is_artist'] = user_is_artist if user_is_artist
  params['artist_level'] = artist_level if artist_level
  params['artist_specialty'] = artist_specialty if artist_specialty
  params['real_name'] = real_name if real_name
  params['tagline'] = tagline if tagline
  params['countryid'] = countryid if countryid
  params['website'] = website if website
  params['bio'] = bio if bio
  perform(DeviantArt::User::UpdateProfile, :post, '/api/v1/oauth2/user/profile/update', params)
end

#watch(username, watch = {}) ⇒ Object

Watch a user



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/deviantart/client/user.rb', line 99

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



94
95
96
# File 'lib/deviantart/client/user.rb', line 94

def watch_status(username)
  perform(DeviantArt::User::Friends::Watching, :get, "/api/v1/oauth2/user/friends/watching/#{username.nil? ? '' : username}")
end

#whoamiObject

Fetch user info of authenticated user



56
57
58
# File 'lib/deviantart/client/user.rb', line 56

def whoami
  perform(DeviantArt::User, :get, '/api/v1/oauth2/user/whoami?')
end

#whois(users) ⇒ Object

Fetch user info for given usernames



50
51
52
53
# File 'lib/deviantart/client/user.rb', line 50

def whois(users)
  params = { usernames: users.is_a?(Enumerable) ? users : [users] }
  perform(DeviantArt::User::Whois, :post, '/api/v1/oauth2/user/whois', params)
end