lagotto-rb 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 +38 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +3 -0
- data/CONDUCT.md +25 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +53 -0
- data/LICENSE +7 -0
- data/README.md +136 -0
- data/Rakefile +41 -0
- data/bin/lagotto +91 -0
- data/examples/alerts.rb +25 -0
- data/examples/alm.rb +20 -0
- data/examples/events.rb +20 -0
- data/examples/requests.rb +5 -0
- data/examples/sources.rb +10 -0
- data/examples/status.rb +5 -0
- data/ignore/alerts.rb +24 -0
- data/ignore/other_methods.rb +23 -0
- data/lagotto-rb.gemspec +35 -0
- data/lib/lagotto-rb.rb +340 -0
- data/lib/lagotto-rb/helpers.rb +103 -0
- data/lib/lagotto-rb/req.rb +49 -0
- data/lib/lagotto-rb/request.rb +66 -0
- data/lib/lagotto-rb/version.rb +3 -0
- metadata +218 -0
data/examples/alm.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'alm'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
# Get altmetrics by DOI
|
5
|
+
## swap out the key and instance to change provider
|
6
|
+
Alm.alm(ids: '10.1371/journal.pone.0029797', key: ENV['CROSSREF_API_KEY'], instance: "crossref")
|
7
|
+
Alm.alm(ids: ['10.1371/journal.pone.0029797','10.1016/j.dsr2.2010.10.029'], key: ENV['CROSSREF_API_KEY'], instance: "crossref")
|
8
|
+
Alm.alm(ids: '10.4081/audiores.2013.e1', key: ENV['PKP_API_KEY'], instance: "pkp")
|
9
|
+
Alm.alm(ids: '10.1371/journal.pone.0025110', key: ENV['PLOS_API_KEY'], instance: "plos")
|
10
|
+
ids = ["10.1371/journal.pone.0029797","10.1371/journal.pone.0029798"]
|
11
|
+
Alm.alm(ids: ids, key: ENV['PLOS_API_KEY'], instance: "plos")
|
12
|
+
|
13
|
+
# Search by source
|
14
|
+
Alm.alm(source: 'twitter', key: ENV['CROSSREF_API_KEY'], instance: "crossref")
|
15
|
+
Alm.alm(instance: "crossref", per_page: 5, key: ENV['CROSSREF_API_KEY'])
|
16
|
+
|
17
|
+
# Get data by publisher
|
18
|
+
ids = HTTParty.get("http://api.crossref.org/members")
|
19
|
+
ids = ids['message']['items'].collect { |p| p['id'] }
|
20
|
+
Alm.alm(publisher: ids[0], info: "summary")
|
data/examples/events.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'alm'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
# Get events by DOI
|
5
|
+
## swap out the key and instance to change provider
|
6
|
+
Lagotto.events(ids: '10.1371/journal.pone.0029797', instance: "crossref")
|
7
|
+
Lagotto.events(ids: ['10.1371/journal.pone.0029797','10.1016/j.dsr2.2010.10.029'], instance: "crossref")
|
8
|
+
Lagotto.events(ids: '10.4081/audiores.2013.e1', instance: "pkp")
|
9
|
+
Lagotto.events(ids: "10.1371/journal.pone.0029797")
|
10
|
+
ids = ["10.1371/journal.pone.0029797","10.1371/journal.pone.0029798"]
|
11
|
+
Lagotto.events(ids: ids)
|
12
|
+
|
13
|
+
# Search by source
|
14
|
+
Lagotto.events(source: 'twitter', instance: "crossref")
|
15
|
+
Lagotto.events(instance: "crossref", per_page: 5)
|
16
|
+
|
17
|
+
# Get data by publisher
|
18
|
+
ids = HTTParty.get("http://api.crossref.org/members")
|
19
|
+
ids = ids['message']['items'].collect { |p| p['id'] }
|
20
|
+
Lagotto.events(publisher: ids[0], info: "summary")
|
data/examples/sources.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'alm'
|
2
|
+
|
3
|
+
# a single source
|
4
|
+
Lagotto.sources(source: 'twitter', per_page: 2)
|
5
|
+
Lagotto.sources(source: 'mendeley', per_page: 3)
|
6
|
+
Lagotto.sources(source: 'facebook', per_page: 1, info: "detail")
|
7
|
+
|
8
|
+
# many sources
|
9
|
+
sources = ['facebook','twitter','mendeley']
|
10
|
+
sources.collect { |x| Lagotto.sources(source: x, per_page: 1) }
|
data/examples/status.rb
ADDED
data/ignore/alerts.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
def self.alerts(source: nil, ids: nil, class_name: nil, level: nil, q: nil,
|
2
|
+
unresolved: nil, per_page: 50, page: 1, user: nil, pwd: nil,
|
3
|
+
instance: 'plos', options: {})
|
4
|
+
|
5
|
+
url = pick_url_alerts(instance)
|
6
|
+
# userpwd = getuserinfo(user, pwd)
|
7
|
+
options = {
|
8
|
+
query: {
|
9
|
+
q: q,
|
10
|
+
class_name: class_name,
|
11
|
+
source: source,
|
12
|
+
level: level,
|
13
|
+
unresolved: unresolved,
|
14
|
+
ids: ids,
|
15
|
+
rows: per_page,
|
16
|
+
page: page
|
17
|
+
},
|
18
|
+
basic_auth: { username: user, password: pwd }
|
19
|
+
}
|
20
|
+
options[:query] = options[:query].reject{ |i,j| j == nil }
|
21
|
+
res = HTTParty.get(url, options)
|
22
|
+
response_ok(res.code)
|
23
|
+
return res
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
##
|
2
|
+
# Make a `/requests` route request
|
3
|
+
#
|
4
|
+
# @!macro lagotto_params
|
5
|
+
# @!macro lagotto_options
|
6
|
+
# @return [Hash] A hash
|
7
|
+
#
|
8
|
+
# @example:
|
9
|
+
# require 'lagotto-rb'
|
10
|
+
# Lagotto.requests(key: ENV['PLOS_API_KEY'])
|
11
|
+
def self.requests(key: nil, instance: 'plos', options: nil, verbose: false)
|
12
|
+
url = pick_url(instance)
|
13
|
+
BasicRequest.new(url, 'api_requests', key, options, verbose).perform
|
14
|
+
# options = {
|
15
|
+
# query: {
|
16
|
+
# api_key: key
|
17
|
+
# },
|
18
|
+
# headers: {"Accept" => 'application/json'}
|
19
|
+
# }
|
20
|
+
# res = HTTParty.get(url+'/api_requests', options)
|
21
|
+
# response_ok(res.code)
|
22
|
+
# return res
|
23
|
+
end
|
data/lagotto-rb.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lagotto-rb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'lagotto-rb'
|
8
|
+
s.version = Lagotto::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.required_ruby_version = '>= 2.0'
|
11
|
+
s.date = '2016-01-08'
|
12
|
+
s.summary = "Lagotto client for Ruby"
|
13
|
+
s.description = "Lagotto client for Ruby - get altmetrics from any Lagotto installation."
|
14
|
+
s.authors = ["Scott Chamberlain"]
|
15
|
+
s.email = 'myrmecocystus@gmail.com'
|
16
|
+
s.homepage = 'http://github.com/lagotto/lagotto-rb'
|
17
|
+
s.licenses = 'MIT'
|
18
|
+
|
19
|
+
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.bindir = 'bin'
|
22
|
+
s.executables = ['lagotto']
|
23
|
+
|
24
|
+
s.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
s.add_development_dependency "rake", '~> 0'
|
26
|
+
s.add_development_dependency "test-unit", '~> 3.1'
|
27
|
+
s.add_development_dependency "simplecov", '~> 0.10'
|
28
|
+
s.add_development_dependency "codecov", '~> 0.1'
|
29
|
+
|
30
|
+
s.add_runtime_dependency 'thor', '~> 0.18'
|
31
|
+
s.add_runtime_dependency 'launchy', '~> 2.4', '>= 2.4.2'
|
32
|
+
s.add_runtime_dependency 'faraday', '~> 0.9.1'
|
33
|
+
s.add_runtime_dependency 'faraday_middleware', '~> 0.10.0'
|
34
|
+
s.add_runtime_dependency 'multi_json', '~> 1.0'
|
35
|
+
end
|
data/lib/lagotto-rb.rb
ADDED
@@ -0,0 +1,340 @@
|
|
1
|
+
require "multi_json"
|
2
|
+
|
3
|
+
require "lagotto-rb/version"
|
4
|
+
require "lagotto-rb/request"
|
5
|
+
require "lagotto-rb/req"
|
6
|
+
require "lagotto-rb/helpers"
|
7
|
+
|
8
|
+
# @!macro lagotto_params
|
9
|
+
# @param ids [String] one or more work identifier
|
10
|
+
# @param type [String] One of doi, pmid, pmcid, or mendeley_uuid
|
11
|
+
# @param source [String] One source. To get many sources, make many calls.
|
12
|
+
# @param publisher [String] Filter articles to a given publisher, using a crossref_id.
|
13
|
+
# @param order [String] Results are sorted by descending event count when given the source name, e.g. `&order=wikipedia`. Otherwise (the default) results are sorted by date descending. When using `&source=x`, we can only sort by data or that source, not a different source.
|
14
|
+
# @param per_page [String] Items per page
|
15
|
+
# @param page [String] Page to retrieve
|
16
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
17
|
+
# @param key [String] API key
|
18
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
19
|
+
|
20
|
+
# @!macro lagotto_options
|
21
|
+
# @param options [Hash] Hash of options for configuring the request, passed on to Faraday.new
|
22
|
+
# :timeout - [Fixnum] open/read timeout Integer in seconds
|
23
|
+
# :open_timeout - [Fixnum] read timeout Integer in seconds
|
24
|
+
# :proxy - [Hash] hash of proxy options
|
25
|
+
# :uri - [String] Proxy Server URI
|
26
|
+
# :user - [String] Proxy server username
|
27
|
+
# :password - [String] Proxy server password
|
28
|
+
# :params_encoder - [Hash] not sure what this is
|
29
|
+
# :bind - [Hash] A hash with host and port values
|
30
|
+
# :boundary - [String] of the boundary value
|
31
|
+
# :oauth - [Hash] A hash with OAuth details
|
32
|
+
|
33
|
+
##
|
34
|
+
# Lagotto - The top level module for using methods
|
35
|
+
# to access a Lagotto instance API
|
36
|
+
#
|
37
|
+
# The following methods, matching the main Crossref API routes, are available:
|
38
|
+
# * `Lagotto.works` - Use the /works endpoint
|
39
|
+
# * `Lagotto.status` - Get instance status, requires authentication
|
40
|
+
# * `Lagotto.requests` - Search requests, requires authentication
|
41
|
+
# * `Lagotto.alerts` - Search alerts, requires authentication
|
42
|
+
# * `Lagotto.events` - Get events back
|
43
|
+
# * `Lagotto.sources` - Search /works routes by source
|
44
|
+
module Lagotto
|
45
|
+
##
|
46
|
+
# Make a `/works` route request
|
47
|
+
#
|
48
|
+
# @!macro lagotto_params
|
49
|
+
# @!macro lagotto_options
|
50
|
+
# @return [Hash] A hash
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# require 'lagotto-rb'
|
54
|
+
# Lagotto.works(ids: 'http://doi.org/10.15468/DL.SQNY5P', instance: "crossref")
|
55
|
+
# Lagotto.works(ids: ['http://doi.org/10.1371/journal.pone.0029797','http://doi.org/10.1016/j.dsr2.2010.10.029'], instance: "crossref")
|
56
|
+
# Lagotto.works(ids: 'http://doi.org/10.1371/journal.pone.0025110', instance: "plos")
|
57
|
+
# ids = ["http://doi.org/10.1371/journal.pone.0029797","http://doi.org/10.1371/journal.pone.0029798"]
|
58
|
+
# Lagotto.works(ids: ids, instance: "plos")
|
59
|
+
# Lagotto.works(ids: '10.4081/audiores.2013.e1', key: ENV['PKP_API_KEY'], instance: "pkp")
|
60
|
+
#
|
61
|
+
# # Search by source
|
62
|
+
# Lagotto.works(source: 'twitter', instance: "crossref")
|
63
|
+
# Lagotto.works(instance: "crossref", per_page: 5)
|
64
|
+
#
|
65
|
+
# # get by publisher
|
66
|
+
# Lagotto.works(publisher: 311)
|
67
|
+
def self.works(ids: nil, type: nil, source: nil, publisher: nil,
|
68
|
+
order: nil, per_page: 50, page: 1, instance: 'plos', key: nil,
|
69
|
+
options: nil, verbose: false)
|
70
|
+
|
71
|
+
test_length(source)
|
72
|
+
type_check(page, Fixnum)
|
73
|
+
type_check(per_page, Fixnum)
|
74
|
+
# test_values('id_type', id_type, ['doi','pmid','pmcid','mendeley_uuid'])
|
75
|
+
# test_values('instance', instance, ['plos','crossref','copernicus','elife','pensoft','pkp'])
|
76
|
+
|
77
|
+
url = pick_url(instance)
|
78
|
+
ids = join_ids(ids)
|
79
|
+
Request.new(url, 'works', ids, type, source,
|
80
|
+
publisher, order, per_page, page, key, options, verbose).perform
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Make a `/works` route request by source
|
85
|
+
#
|
86
|
+
# @param source [String] One source. To get many sources, make many calls.
|
87
|
+
# @param per_page [String] Items per page
|
88
|
+
# @param page [String] Page to retrieve
|
89
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
90
|
+
# @param key [String] API key
|
91
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
92
|
+
# @!macro lagotto_options
|
93
|
+
# @return [Hash] A hash
|
94
|
+
#
|
95
|
+
# @example
|
96
|
+
# # a single source
|
97
|
+
# Lagotto.works_sources(source: 'twitter', per_page: 2)
|
98
|
+
# Lagotto.works_sources(source: 'mendeley', per_page: 3)
|
99
|
+
# Lagotto.works_sources(source: 'facebook', per_page: 1)
|
100
|
+
|
101
|
+
# # many sources
|
102
|
+
# sources = ['facebook','twitter','mendeley']
|
103
|
+
# sources.collect { |x| Lagotto.works_sources(source: x, per_page: 1) }
|
104
|
+
def self.works_sources(source: nil, per_page: 50, page: 1, instance: 'plos', key: nil,
|
105
|
+
options: nil, verbose: false)
|
106
|
+
|
107
|
+
url = pick_url(instance)
|
108
|
+
Request.new(url, 'works', nil, nil, source,
|
109
|
+
nil, nil, per_page, page, key, options, verbose).perform
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Make a `/events` route request
|
114
|
+
#
|
115
|
+
# @!macro lagotto_params
|
116
|
+
# @!macro lagotto_options
|
117
|
+
# @return [Hash] A hash
|
118
|
+
#
|
119
|
+
# @example
|
120
|
+
# # Get events by DOI
|
121
|
+
# ## swap out the key and instance to change provider
|
122
|
+
# Lagotto.events(ids: '10.1371/journal.pone.0029797', instance: "crossref")
|
123
|
+
# Lagotto.events(ids: ['10.1371/journal.pone.0029797','10.1016/j.dsr2.2010.10.029'], instance: "crossref")
|
124
|
+
# Lagotto.events(ids: '10.4081/audiores.2013.e1', instance: "pkp")
|
125
|
+
# Lagotto.events(ids: "10.1371/journal.pone.0029797")
|
126
|
+
# ids = ["10.1371/journal.pone.0029797","10.1371/journal.pone.0029798"]
|
127
|
+
# Lagotto.events(ids: ids)
|
128
|
+
#
|
129
|
+
# # Search by source
|
130
|
+
# Lagotto.events(source: 'twitter', instance: "crossref")
|
131
|
+
# Lagotto.events(instance: "crossref", per_page: 5)
|
132
|
+
#
|
133
|
+
# # Get data by publisher
|
134
|
+
# ids = Faraday.new(:url => "http://api.crossref.org/members").get
|
135
|
+
# json = MultiJson.load(ids.body)
|
136
|
+
# ids = json['message']['items'].collect { |p| p['id'] }
|
137
|
+
# Lagotto.events(publisher: ids[0])
|
138
|
+
def self.events(ids: nil, type: nil, source: nil, publisher: nil,
|
139
|
+
order: nil, per_page: 50, page: 1, instance: 'plos', key: nil,
|
140
|
+
options: nil, verbose: false)
|
141
|
+
|
142
|
+
test_length(source)
|
143
|
+
type_check(page, Fixnum)
|
144
|
+
type_check(per_page, Fixnum)
|
145
|
+
url = pick_url(instance)
|
146
|
+
ids = join_ids(ids)
|
147
|
+
Request.new(url, 'events', ids, type, source,
|
148
|
+
publisher, order, per_page, page, key, options, verbose).perform
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# Make a `/publishers` route request
|
153
|
+
#
|
154
|
+
# @param id [Fixnum] Publisher id
|
155
|
+
# @param page [String] Page to retrieve
|
156
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
157
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
158
|
+
# @!macro lagotto_options
|
159
|
+
# @return [Hash] A hash
|
160
|
+
#
|
161
|
+
# @example
|
162
|
+
# Lagotto.publishers()
|
163
|
+
# Lagotto.publishers(id: 340)
|
164
|
+
# Lagotto.publishers(instance: 'crossref')
|
165
|
+
def self.publishers(id: nil, page: 1, instance: 'plos', options: nil, verbose: false)
|
166
|
+
url = pick_url(instance) + '/publishers'
|
167
|
+
if !id.nil?
|
168
|
+
url = url + '/' + id.to_s
|
169
|
+
end
|
170
|
+
BasicRequest.new(url, '', nil, options, verbose, {}).perform
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# Make a `/groups` route request
|
175
|
+
#
|
176
|
+
# @param id [Fixnum] Group id
|
177
|
+
# @param page [String] Page to retrieve
|
178
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
179
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
180
|
+
# @!macro lagotto_options
|
181
|
+
# @return [Hash] A hash
|
182
|
+
#
|
183
|
+
# @example
|
184
|
+
# Lagotto.groups()
|
185
|
+
# Lagotto.groups(instance: 'crossref')
|
186
|
+
# Lagotto.groups(id: 'recommended', instance: 'crossref')
|
187
|
+
def self.groups(id: nil, page: 1, instance: 'plos', options: nil, verbose: false)
|
188
|
+
url = pick_url(instance) + '/groups'
|
189
|
+
if !id.nil?
|
190
|
+
url = url + '/' + id.to_s
|
191
|
+
end
|
192
|
+
BasicRequest.new(url, '', nil, options, verbose, {}).perform
|
193
|
+
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# Make a `/references` route request
|
197
|
+
#
|
198
|
+
# Returns list of references for a particular work, source and/or relation_type
|
199
|
+
#
|
200
|
+
# @param work_id [String] Work ID
|
201
|
+
# @param work_ids [String] Work IDs
|
202
|
+
# @param q [String] Query for ids
|
203
|
+
# @param relation_type_id [String] Relation_type ID
|
204
|
+
# @param source_id [String] Source ID
|
205
|
+
# @param page [String] Page number
|
206
|
+
# @param per_page [String] Results per page (0-1000), Default: 1000
|
207
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
208
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
209
|
+
# @!macro lagotto_options
|
210
|
+
# @return [Hash] A hash
|
211
|
+
#
|
212
|
+
# @example
|
213
|
+
# Lagotto.references(per_page: 5, instance: 'crossref')
|
214
|
+
# Lagotto.references(work_id: 'http://doi.org/10.6084/M9.FIGSHARE.1598061', instance: 'crossref')
|
215
|
+
def self.references(work_id: nil, work_ids: nil, q: nil, relation_type_id: nil,
|
216
|
+
source_id: nil, page: 1, per_page: 1000,
|
217
|
+
instance: 'plos', options: nil, verbose: false)
|
218
|
+
|
219
|
+
url = pick_url(instance)
|
220
|
+
args = { work_id: work_id, work_ids: work_ids, q: q,
|
221
|
+
relation_type_id: relation_type_id, source_id: source_id,
|
222
|
+
page: page, per_page: per_page }
|
223
|
+
BasicRequest.new(url, 'references', nil, options, verbose, args).perform
|
224
|
+
end
|
225
|
+
|
226
|
+
##
|
227
|
+
# Make a `/work_types` route request
|
228
|
+
#
|
229
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
230
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
231
|
+
# @!macro lagotto_options
|
232
|
+
# @return [Hash] A hash
|
233
|
+
#
|
234
|
+
# @example
|
235
|
+
# Lagotto.work_types()
|
236
|
+
# Lagotto.work_types(instance: 'crossref')
|
237
|
+
def self.work_types(instance: 'plos', options: nil, verbose: false)
|
238
|
+
url = pick_url(instance)
|
239
|
+
BasicRequest.new(url, 'work_types', nil, options, verbose, {}).perform
|
240
|
+
end
|
241
|
+
|
242
|
+
##
|
243
|
+
# Make a `/docs` route request
|
244
|
+
#
|
245
|
+
# @param id [Fixnum] Document id
|
246
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
247
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
248
|
+
# @!macro lagotto_options
|
249
|
+
# @return [Hash] A hash
|
250
|
+
#
|
251
|
+
# @example
|
252
|
+
# Lagotto.docs()
|
253
|
+
# Lagotto.docs(instance: 'crossref')
|
254
|
+
# Lagotto.docs(id: 'counter', instance: 'crossref')
|
255
|
+
def self.docs(id: nil, instance: 'plos', options: nil, verbose: false)
|
256
|
+
url = pick_url(instance) + '/docs'
|
257
|
+
if !id.nil?
|
258
|
+
url = url + '/' + id.to_s
|
259
|
+
end
|
260
|
+
BasicRequest.new(url, '', nil, options, verbose, {}).perform
|
261
|
+
end
|
262
|
+
|
263
|
+
##
|
264
|
+
# Make a `/relation_types` route request
|
265
|
+
#
|
266
|
+
# @param id [Fixnum] Relation type id
|
267
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
268
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
269
|
+
# @!macro lagotto_options
|
270
|
+
# @return [Hash] A hash
|
271
|
+
#
|
272
|
+
# @example
|
273
|
+
# Lagotto.relation_types()
|
274
|
+
# Lagotto.relation_types(instance: 'crossref')
|
275
|
+
# Lagotto.relation_types(id: 'corrects', instance: 'crossref')
|
276
|
+
def self.relation_types(id: nil, instance: 'plos', options: nil, verbose: false)
|
277
|
+
url = pick_url(instance) + '/relation_types'
|
278
|
+
if !id.nil?
|
279
|
+
url = url + '/' + id.to_s
|
280
|
+
end
|
281
|
+
BasicRequest.new(url, '', nil, options, verbose, {}).perform
|
282
|
+
end
|
283
|
+
|
284
|
+
##
|
285
|
+
# Make a `/sources` route request
|
286
|
+
#
|
287
|
+
# @param id [Fixnum] Source id
|
288
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
289
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
290
|
+
# @!macro lagotto_options
|
291
|
+
# @return [Hash] A hash
|
292
|
+
#
|
293
|
+
# @example
|
294
|
+
# Lagotto.sources(instance: 'datacite')
|
295
|
+
# Lagotto.sources(instance: 'crossref')
|
296
|
+
# Lagotto.sources(id: 'reddit', instance: 'crossref')
|
297
|
+
def self.sources(id: nil, instance: 'plos', options: nil, verbose: false)
|
298
|
+
url = pick_url(instance) + '/sources'
|
299
|
+
if !id.nil?
|
300
|
+
url = url + '/' + id.to_s
|
301
|
+
end
|
302
|
+
BasicRequest.new(url, '', nil, options, verbose, {}).perform
|
303
|
+
end
|
304
|
+
|
305
|
+
##
|
306
|
+
# Make a `/recommendations` route request
|
307
|
+
#
|
308
|
+
# @param id [Fixnum] A work id
|
309
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
310
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
311
|
+
# @!macro lagotto_options
|
312
|
+
# @return [Hash] A hash
|
313
|
+
#
|
314
|
+
# @example
|
315
|
+
# Lagotto.recommendations(id: '10.1371/journal.ppat.1005123')
|
316
|
+
# Lagotto.recommendations(id: '10.1371/journal.pgen.1005625')
|
317
|
+
def self.recommendations(id:, instance: 'plos', options: nil, verbose: false)
|
318
|
+
url = pick_url(instance) + '/works/' + id.to_s + '/recommendations'
|
319
|
+
BasicRequest.new(url, '', nil, options, verbose, {}).perform
|
320
|
+
end
|
321
|
+
|
322
|
+
##
|
323
|
+
# Make a `/status` route request
|
324
|
+
#
|
325
|
+
# @param key [String] API key
|
326
|
+
# @param instance [String] One of plos, crossref, pkp, elife, copernicus, pensoft
|
327
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
328
|
+
# @!macro lagotto_options
|
329
|
+
# @return [Hash] A hash
|
330
|
+
#
|
331
|
+
# @example
|
332
|
+
# require 'lagotto-rb'
|
333
|
+
# Lagotto.status(key: ENV['PLOS_API_KEY'])
|
334
|
+
# Lagotto.status(key: ENV['PLOS_API_KEY'])
|
335
|
+
def self.status(key: nil, instance: 'plos', options: nil, verbose: false)
|
336
|
+
url = pick_url(instance)
|
337
|
+
BasicRequest.new(url, 'status', key, options, verbose, {}).perform
|
338
|
+
end
|
339
|
+
|
340
|
+
end
|