deviantart 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +3 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/Rakefile +83 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/deviantart.gemspec +25 -0
- data/lib/deviantart.rb +8 -0
- data/lib/deviantart/client.rb +144 -0
- data/lib/deviantart/collections.rb +24 -0
- data/lib/deviantart/data.rb +24 -0
- data/lib/deviantart/deviation.rb +28 -0
- data/lib/deviantart/feed.rb +12 -0
- data/lib/deviantart/gallery.rb +39 -0
- data/lib/deviantart/user.rb +31 -0
- data/lib/deviantart/version.rb +3 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3fdd663a915e28c0444e53eb3f732b93281a6524
|
4
|
+
data.tar.gz: a93893796b12f74c8a39c0a1c74092313c85c115
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 10e554efc6cee88812149878b94cd1de27e0f26d1fd278fe9202e5f24d42d604f99525a0cc63c17249527f854a86a748e05d2dbb18af5e0de3792aa47515bdd4
|
7
|
+
data.tar.gz: 5f3bdb693bd1be7f1b0e0d48821067b5ee60a85ee2ae5ecfe3d77785c6fb4835f3d52a606812797820b8dcfadfd35d3c9315d23d088aa1ae91dcfaa51229a24b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem 'webmock'
|
5
|
+
gem 'minitest'
|
6
|
+
gem 'json'
|
7
|
+
gem 'sinatra'
|
8
|
+
gem 'omniauth'
|
9
|
+
gem 'omniauth-oauth2', '~> 1.3.1'
|
10
|
+
gem 'omniauth-deviantart'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Specify your gem's dependencies in deviantart.gemspec
|
14
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Code Ass
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# deviantART API library
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
$ gem install deviantart
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
da = DeviantArt.new do |config|
|
11
|
+
config.client_id = 9999
|
12
|
+
config.client_secret = 'LMNOPQRSTUVWXYZZZZZZZZ9999999999'
|
13
|
+
# auto refresh access_token with Client Credentials Grant when expired
|
14
|
+
config.grant_type = :client_credentials
|
15
|
+
config.access_token_auto_refresh = true
|
16
|
+
end
|
17
|
+
# da is DeviantArt::Client object
|
18
|
+
|
19
|
+
deviation = da.get_deviation('F98C2XXX-C6A8-XXXX-08F9-57CCXXXXX187')
|
20
|
+
deviation['title'] # => deviation's title
|
21
|
+
```
|
22
|
+
|
23
|
+
## How to Test
|
24
|
+
|
25
|
+
At the first, install gems:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
$ bundle install
|
29
|
+
```
|
30
|
+
|
31
|
+
And you will run test with stub APIs:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
$ bundle exec rake test
|
35
|
+
```
|
36
|
+
|
37
|
+
If you want to use *real* API in test, run this one:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
$ bundle exec rake real
|
41
|
+
Input your browser command>
|
42
|
+
```
|
43
|
+
|
44
|
+
This prompt demands browser command for OAuth 2 authorization of deviantART.
|
45
|
+
After this, Rake task performs some steps:
|
46
|
+
|
47
|
+
- creates named pipe
|
48
|
+
- OAuth consumer server launches internal
|
49
|
+
- opens the browser with authorization page
|
50
|
+
|
51
|
+
```bash
|
52
|
+
$ bundle exec rake real
|
53
|
+
Input your browser command> firefox
|
54
|
+
Wrote "firefox" to test/browser_command
|
55
|
+
Boot Sinatra OAuth consumer...
|
56
|
+
Open browser for authorization
|
57
|
+
```
|
58
|
+
|
59
|
+
The OAuth consumer server writes access token to named pipe and terminates after you permit it on browser.
|
60
|
+
Rake task takes access token via named pipe.
|
61
|
+
The tests run with the access token.
|
62
|
+
|
63
|
+
```bash
|
64
|
+
--snip--
|
65
|
+
Open browser for authorization
|
66
|
+
Got access token!
|
67
|
+
# Running:
|
68
|
+
|
69
|
+
..............
|
70
|
+
|
71
|
+
Finished in 4.44s, 3.14159 runs/s, 11.4478 assertions/s.
|
72
|
+
|
73
|
+
14 runs, 51 assertions, 0 failures, 0 errors, 0 skips
|
74
|
+
```
|
75
|
+
|
76
|
+
The browser command is cached at `test/browser_command`, the access token is cached at `test/fixtures/authorization_code.json`.
|
77
|
+
|
78
|
+
## API
|
79
|
+
|
80
|
+
## Official API Document
|
81
|
+
|
82
|
+
[Developers - DeviantArt](https://www.deviantart.com/developers/)
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
87
|
+
|
88
|
+
## Badges
|
89
|
+
|
90
|
+
[![Build Status](https://travis-ci.org/aycabta/deviantart.svg)](https://travis-ci.org/aycabta/deviantart)
|
91
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
require "readline"
|
4
|
+
|
5
|
+
test_pettern = FileList['test/**/*_test.rb']
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
8
|
+
t.libs << "test"
|
9
|
+
t.libs << "lib"
|
10
|
+
t.test_files = test_pettern
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_browser_command
|
14
|
+
browser_command_file = 'test/browser_command'
|
15
|
+
if !File.exists?(browser_command_file)
|
16
|
+
browser_command = Readline.readline('Input your browser command> ')
|
17
|
+
open(browser_command_file, 'w') do |f|
|
18
|
+
f.write(browser_command)
|
19
|
+
end
|
20
|
+
puts "Wrote \"#{browser_command}\" to #{browser_command_file}"
|
21
|
+
browser_command
|
22
|
+
else
|
23
|
+
open(browser_command_file, 'r').read
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_access_token
|
28
|
+
cv = ConditionVariable.new
|
29
|
+
mutex = Mutex.new
|
30
|
+
is_pinged = false
|
31
|
+
Thread.new {
|
32
|
+
mutex.synchronize {
|
33
|
+
puts 'Boot Sinatra OAuth consumer...'
|
34
|
+
system('bundle exec ruby test/oauth_consumer.rb > /dev/null 2>&1 &')
|
35
|
+
open(OUTPUT_PIPE).read # block to get 'ping'
|
36
|
+
is_pinged = true
|
37
|
+
cv.signal
|
38
|
+
}
|
39
|
+
}
|
40
|
+
is_browsed = false
|
41
|
+
Thread.new {
|
42
|
+
mutex.synchronize {
|
43
|
+
until is_pinged
|
44
|
+
cv.wait(mutex)
|
45
|
+
end
|
46
|
+
puts 'Open browser for authorization'
|
47
|
+
system("#{get_browser_command} http://localhost:4567/auth/deviantart &")
|
48
|
+
is_browsed = true
|
49
|
+
cv.signal
|
50
|
+
}
|
51
|
+
}
|
52
|
+
result = nil
|
53
|
+
mutex.synchronize {
|
54
|
+
until is_browsed
|
55
|
+
cv.wait(mutex)
|
56
|
+
end
|
57
|
+
result = open(OUTPUT_PIPE).read # block to get authorization code
|
58
|
+
}
|
59
|
+
puts 'Got access token!'
|
60
|
+
open(AUTHORIZATION_CODE_FILE, 'w') do |f|
|
61
|
+
f.write(result)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Rake::TestTask.new(:real) do |t|
|
66
|
+
AUTHORIZATION_CODE_FILE = 'test/fixtures/authorization_code.json'
|
67
|
+
if !File.exists?(AUTHORIZATION_CODE_FILE)
|
68
|
+
OUTPUT_PIPE = 'test/output_pipe'
|
69
|
+
if File.exists?(OUTPUT_PIPE)
|
70
|
+
File.unlink(OUTPUT_PIPE)
|
71
|
+
end
|
72
|
+
File.mkfifo(OUTPUT_PIPE)
|
73
|
+
get_access_token
|
74
|
+
File.unlink(OUTPUT_PIPE)
|
75
|
+
end
|
76
|
+
t.ruby_opts << '-I. -e "ENV[\'REAL\']=\'1\'"'
|
77
|
+
t.loader = :direct
|
78
|
+
t.libs << "test"
|
79
|
+
t.libs << "lib"
|
80
|
+
t.test_files = test_pettern
|
81
|
+
end
|
82
|
+
|
83
|
+
task :default => :test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "deviantart"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/deviantart.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'deviantart/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "deviantart"
|
8
|
+
spec.version = DeviantArt::VERSION
|
9
|
+
spec.authors = ["Code Ass"]
|
10
|
+
spec.email = ["aycabta@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{deviantART API library}
|
13
|
+
spec.description = %q{deviantART API library}
|
14
|
+
spec.homepage = "https://github.com/aycabta/deviantart"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 11.2"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.9"
|
25
|
+
end
|
data/lib/deviantart.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'deviantart/deviation'
|
2
|
+
require 'deviantart/gallery'
|
3
|
+
require 'deviantart/collections'
|
4
|
+
require 'deviantart/user'
|
5
|
+
require 'deviantart/data'
|
6
|
+
require 'deviantart/feed'
|
7
|
+
require 'net/http'
|
8
|
+
require 'uri'
|
9
|
+
require 'json'
|
10
|
+
|
11
|
+
class Net::HTTPResponse
|
12
|
+
attr_accessor :json
|
13
|
+
end
|
14
|
+
|
15
|
+
module DeviantArt
|
16
|
+
class Client
|
17
|
+
include DeviantArt::Deviation
|
18
|
+
include DeviantArt::Gallery
|
19
|
+
include DeviantArt::Collections
|
20
|
+
include DeviantArt::User
|
21
|
+
include DeviantArt::Data
|
22
|
+
include DeviantArt::Feed
|
23
|
+
attr_accessor :access_token, :client_id, :client_secret, :code, :redirect_uri, :grant_type, :access_token_auto_refresh, :refresh_token
|
24
|
+
attr_writer :user_agent
|
25
|
+
@@host = 'www.deviantart.com'
|
26
|
+
|
27
|
+
def initialize(options = {})
|
28
|
+
@access_token = nil
|
29
|
+
options.each do |key, value|
|
30
|
+
instance_variable_set("@#{key}", value)
|
31
|
+
end
|
32
|
+
yield(self) if block_given?
|
33
|
+
@http = Net::HTTP.new(@@host, 443)
|
34
|
+
@http.use_ssl = true
|
35
|
+
@on_refreshed_access_token = nil
|
36
|
+
@on_refreshed_authorization_code = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.host
|
40
|
+
@@host
|
41
|
+
end
|
42
|
+
|
43
|
+
def user_agent
|
44
|
+
@user_agent ||= "DeviantArtRubyGem/#{DeviantArt::VERSION}/#{RUBY_DESCRIPTION}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def access_token_auto_refresh?
|
48
|
+
@access_token_auto_refresh
|
49
|
+
end
|
50
|
+
|
51
|
+
def perform(method, path, params = {})
|
52
|
+
if @access_token.nil? && access_token_auto_refresh?
|
53
|
+
refresh_access_token
|
54
|
+
end
|
55
|
+
response = request(method, path, params)
|
56
|
+
if response.code == '401' && access_token_auto_refresh?
|
57
|
+
refresh_access_token
|
58
|
+
response = request(method, path, params)
|
59
|
+
end
|
60
|
+
response.json
|
61
|
+
end
|
62
|
+
|
63
|
+
def on_refreshed_authorization_code(&block)
|
64
|
+
@on_refreshed_authorization_code = block
|
65
|
+
end
|
66
|
+
|
67
|
+
def on_refreshed_access_token(&block)
|
68
|
+
@on_refreshed_access_token = block
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def request(method, path, params = {})
|
74
|
+
uri = URI.parse("https://#{@@host}#{path}")
|
75
|
+
case method
|
76
|
+
when :get
|
77
|
+
uri.query = URI.encode_www_form(params)
|
78
|
+
request = Net::HTTP::Get.new(uri)
|
79
|
+
when :post
|
80
|
+
request = Net::HTTP::Post.new(uri.path)
|
81
|
+
if params.any?{ |key, value| value.is_a?(Enumerable) }
|
82
|
+
converted_params = []
|
83
|
+
params.each do |key, value|
|
84
|
+
if value.is_a?(Enumerable)
|
85
|
+
value.each_index do |i|
|
86
|
+
converted_params << ["#{key}[#{i}]", value[i]]
|
87
|
+
end
|
88
|
+
else
|
89
|
+
converted_params << [key, value]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
request.body = URI.encode_www_form(converted_params)
|
93
|
+
else
|
94
|
+
request.set_form_data(params)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
request['Content-Type'] = 'application/x-www-form-urlencoded'
|
98
|
+
request['User-Agent'] = user_agent
|
99
|
+
if not @access_token.nil?
|
100
|
+
request["Authorization"] = "Bearer #{@access_token}"
|
101
|
+
end
|
102
|
+
response = @http.request(request)
|
103
|
+
response.json = JSON.parse(response.body)
|
104
|
+
response
|
105
|
+
end
|
106
|
+
|
107
|
+
def refresh_client_credentials
|
108
|
+
response = request(
|
109
|
+
:post, '/oauth2/token',
|
110
|
+
{ grant_type: 'client_credentials', client_id: @client_id, client_secret: @client_secret }
|
111
|
+
)
|
112
|
+
if response.code == '200'
|
113
|
+
@access_token = response.json['access_token']
|
114
|
+
@on_refreshed_access_token.call(@access_token) if @on_refreshed_access_token
|
115
|
+
else
|
116
|
+
@access_token = nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def refresh_authorization_code
|
121
|
+
response = request(
|
122
|
+
:post, '/oauth2/token',
|
123
|
+
{ grant_type: 'refresh_token', client_id: @client_id, client_secret: @client_secret, refresh_token: @refresh_token }
|
124
|
+
)
|
125
|
+
if response.code == '200'
|
126
|
+
@access_token = response.json['access_token']
|
127
|
+
@on_refreshed_access_token.call(@access_token) if @on_refreshed_access_token
|
128
|
+
@on_refreshed_authorization_code.call(@access_token, response.json['refresh_token']) if @on_refreshed_authorization_code
|
129
|
+
else
|
130
|
+
@access_token = nil
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def refresh_access_token
|
135
|
+
case @grant_type.to_sym
|
136
|
+
when :authorization_code
|
137
|
+
refresh_authorization_code
|
138
|
+
when :client_credentials
|
139
|
+
refresh_client_credentials
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DeviantArt
|
2
|
+
module Collections
|
3
|
+
# Fetch collection folders
|
4
|
+
def get_collections_folders(username: nil, calculate_size: false, ext_preload: false, offset: 0, limit: 10)
|
5
|
+
params = {}
|
6
|
+
params['username'] = username unless username.nil?
|
7
|
+
params['calculate_size'] = calculate_size if calculate_size
|
8
|
+
params['ext_preload'] = ext_preload if ext_preload
|
9
|
+
params['offset'] = offset if offset != 0
|
10
|
+
params['limit'] = limit if limit != 10
|
11
|
+
perform(:get, '/api/v1/oauth2/collections/folders', params)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Fetch collection folder contents
|
15
|
+
def get_collections(folderid, username: nil, offset: 0, limit: 10)
|
16
|
+
params = {}
|
17
|
+
params['username'] = username unless username.nil?
|
18
|
+
params['offset'] = offset if offset != 0
|
19
|
+
params['limit'] = limit if limit != 10
|
20
|
+
perform(:get, "/api/v1/oauth2/collections/#{folderid}", params)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DeviantArt
|
2
|
+
module Data
|
3
|
+
# Get a list of countries
|
4
|
+
def get_countries
|
5
|
+
perform(:get, '/api/v1/oauth2/data/countries')
|
6
|
+
end
|
7
|
+
|
8
|
+
# Returns the DeviantArt Privacy Policy
|
9
|
+
def get_privacy
|
10
|
+
perform(:get, '/api/v1/oauth2/data/privacy')
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns the DeviantArt Submission Policy
|
14
|
+
def get_submission
|
15
|
+
perform(:get, '/api/v1/oauth2/data/submission')
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns the DeviantArt Terms of Service
|
19
|
+
def get_tos
|
20
|
+
perform(:get, '/api/v1/oauth2/data/tos')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module DeviantArt
|
2
|
+
module Deviation
|
3
|
+
# Fetch a deviation details
|
4
|
+
def get_deviation(deviationid)
|
5
|
+
perform(:get, "/api/v1/oauth2/deviation/#{deviationid}")
|
6
|
+
end
|
7
|
+
|
8
|
+
# Fetch full data that is not included in the main devaition details
|
9
|
+
def get_deviation_content(deviationid)
|
10
|
+
perform(:get, '/api/v1/oauth2/deviation/content', { deviationid: deviationid })
|
11
|
+
end
|
12
|
+
|
13
|
+
# Fetch a list of users who faved the deviation
|
14
|
+
def get_deviation_whofaved(deviationid, offset: 0, limit: 10)
|
15
|
+
params = {}
|
16
|
+
params['deviationid'] = deviationid
|
17
|
+
params['offset'] = offset if offset != 0
|
18
|
+
params['limit'] = limit if limit != 10
|
19
|
+
perform(:get, '/api/v1/oauth2/deviation/whofaved', params)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get the original file download (if allowed)
|
23
|
+
def download_deviation(deviationid)
|
24
|
+
perform(:get, "/api/v1/oauth2/deviation/download/#{deviationid}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module DeviantArt
|
2
|
+
module Feed
|
3
|
+
# Fetch Watch Feed
|
4
|
+
def get_feed(mature_content: false, cursor: nil)
|
5
|
+
params = {}
|
6
|
+
params['cursor'] = cursor unless cursor.nil?
|
7
|
+
params['mature_content'] = mature_content
|
8
|
+
perform(:get, '/api/v1/oauth2/feed/home', params)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module DeviantArt
|
2
|
+
module Gallery
|
3
|
+
# Get the "all" view of a users gallery
|
4
|
+
def get_gallery_all(username: nil, offset: 0, limit: 10)
|
5
|
+
params = {}
|
6
|
+
params['username'] = username unless username.nil?
|
7
|
+
params['offset'] = offset if offset != 0
|
8
|
+
params['limit'] = limit if limit != 10
|
9
|
+
perform(:get, '/api/v1/oauth2/gallery/all', params)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Fetch gallery folders
|
13
|
+
def get_gallery_folders(username: nil, calculate_size: false, ext_preload: false, offset: 0, limit: 10)
|
14
|
+
params = {}
|
15
|
+
params['username'] = username unless username.nil?
|
16
|
+
params['calculate_size'] = calculate_size if calculate_size
|
17
|
+
params['ext_preload'] = ext_preload if ext_preload
|
18
|
+
params['offset'] = offset if offset != 0
|
19
|
+
params['limit'] = limit if limit != 10
|
20
|
+
perform(:get, '/api/v1/oauth2/gallery/folders', params)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Fetch gallery folder contents
|
24
|
+
def get_gallery(username: nil, folderid: nil, mode: nil, offset: 0, limit: 10)
|
25
|
+
params = {}
|
26
|
+
params['username'] = username unless username.nil?
|
27
|
+
params['mode'] = mode unless mode.nil?
|
28
|
+
params['offset'] = offset if offset != 0
|
29
|
+
params['limit'] = limit if limit != 10
|
30
|
+
unless folderid.nil?
|
31
|
+
path = "/api/v1/oauth2/gallery/#{folderid}"
|
32
|
+
else
|
33
|
+
path = '/api/v1/oauth2/gallery/'
|
34
|
+
end
|
35
|
+
perform(:get, path, params)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module DeviantArt
|
2
|
+
module User
|
3
|
+
# Get user profile information
|
4
|
+
def get_profile(username: nil, ext_collections: false, ext_galleries: false)
|
5
|
+
params = {}
|
6
|
+
params['ext_collections'] = ext_collections if ext_collections
|
7
|
+
params['ext_galleries'] = ext_galleries if ext_galleries
|
8
|
+
perform(:get, "/api/v1/oauth2/user/profile/#{username.nil? ? '' : username}", params)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Get the users list of friends
|
12
|
+
def get_friends(username: nil, offset: 0, limit: 10)
|
13
|
+
params = {}
|
14
|
+
params['offset'] = offset if offset != 0
|
15
|
+
params['limit'] = limit if limit != 10
|
16
|
+
perform(:get, "/api/v1/oauth2/user/friends/#{username.nil? ? '' : username}", params)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Fetch user info for given usernames
|
20
|
+
def whois(users)
|
21
|
+
params = { usernames: users.is_a?(Enumerable) ? users : [users] }
|
22
|
+
perform(:post, '/api/v1/oauth2/user/whois', params)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Fetch user info of authenticated user
|
26
|
+
def whoami
|
27
|
+
perform(:get, '/api/v1/oauth2/user/whoami?')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deviantart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Code Ass
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.9'
|
55
|
+
description: deviantART API library
|
56
|
+
email:
|
57
|
+
- aycabta@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- deviantart.gemspec
|
71
|
+
- lib/deviantart.rb
|
72
|
+
- lib/deviantart/client.rb
|
73
|
+
- lib/deviantart/collections.rb
|
74
|
+
- lib/deviantart/data.rb
|
75
|
+
- lib/deviantart/deviation.rb
|
76
|
+
- lib/deviantart/feed.rb
|
77
|
+
- lib/deviantart/gallery.rb
|
78
|
+
- lib/deviantart/user.rb
|
79
|
+
- lib/deviantart/version.rb
|
80
|
+
homepage: https://github.com/aycabta/deviantart
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.6.6
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: deviantART API library
|
104
|
+
test_files: []
|