figshare_api_v2 0.9.2 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +50 -0
- data/lib/authors.rb +16 -13
- data/lib/base.rb +65 -65
- data/lib/figshare_api_v2.rb +19 -18
- data/lib/institutions.rb +82 -82
- data/lib/oai_pmh.rb +4 -2
- data/lib/other.rb +13 -13
- data/lib/private_articles.rb +159 -91
- data/lib/private_collections.rb +87 -84
- data/lib/private_projects.rb +79 -78
- data/lib/public_articles.rb +60 -51
- data/lib/public_collections.rb +50 -42
- data/lib/public_projects.rb +24 -23
- data/lib/upload.rb +53 -48
- metadata +8 -8
data/lib/private_collections.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module Figshare
|
2
|
-
|
3
2
|
# Figshare Private Collections API
|
4
3
|
#
|
5
4
|
class PrivateCollections < Base
|
6
|
-
|
7
5
|
# Requests a list of own (or institute's) collections
|
8
6
|
#
|
9
7
|
# @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
|
@@ -12,9 +10,9 @@ module Figshare
|
|
12
10
|
# @yield [Hash] {id, title, doi, handle, url, published_date}
|
13
11
|
def list(order: 'published_date', order_direction: 'desc', impersonate: nil, &block)
|
14
12
|
args = {}
|
15
|
-
args[
|
16
|
-
args['order'] = order
|
17
|
-
args['order_direction'] = order_direction
|
13
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
14
|
+
args['order'] = order unless order.nil?
|
15
|
+
args['order_direction'] = order_direction unless order_direction.nil?
|
18
16
|
get_paginate(api_query: 'account/collections', args: args, &block)
|
19
17
|
end
|
20
18
|
|
@@ -31,35 +29,41 @@ module Figshare
|
|
31
29
|
# @param order_direction [String] "desc" Default, "asc"
|
32
30
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
33
31
|
# @yield [Hash] {id, title, doi, handle, url, published_date}
|
34
|
-
def search(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
def search( search_for:,
|
33
|
+
institute: false,
|
34
|
+
group_id: nil,
|
35
|
+
impersonate: nil,
|
36
|
+
published_since: nil,
|
37
|
+
modified_since: nil,
|
38
|
+
resource_doi: nil,
|
39
|
+
doi: nil,
|
40
|
+
handle: nil,
|
41
|
+
order: 'published_date',
|
42
|
+
order_direction: 'desc',
|
43
|
+
&block
|
44
|
+
)
|
41
45
|
args = { 'search_for' => search_for }
|
42
|
-
args[
|
43
|
-
args['institution'] = @institute_id
|
44
|
-
args['group_id'] = group_id
|
45
|
-
args['resource_doi'] = resource_doi
|
46
|
-
args['doi'] = doi
|
47
|
-
args['handle'] = handle
|
48
|
-
args['published_since'] = published_since
|
49
|
-
args['modified_since'] = modified_since
|
50
|
-
args['order'] = order
|
51
|
-
args['order_direction'] = order_direction
|
46
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
47
|
+
args['institution'] = @institute_id unless institute.nil?
|
48
|
+
args['group_id'] = group_id unless group_id.nil?
|
49
|
+
args['resource_doi'] = resource_doi unless resource_doi.nil?
|
50
|
+
args['doi'] = doi unless doi.nil?
|
51
|
+
args['handle'] = handle unless handle.nil?
|
52
|
+
args['published_since'] = published_since unless published_since.nil?
|
53
|
+
args['modified_since'] = modified_since unless modified_since.nil?
|
54
|
+
args['order'] = order unless order.nil?
|
55
|
+
args['order_direction'] = order_direction unless order_direction.nil?
|
52
56
|
post(api_query: 'account/collections/search', args: args, &block)
|
53
57
|
end
|
54
|
-
|
58
|
+
|
55
59
|
# Create a new private Collection by sending collection information
|
56
60
|
#
|
57
61
|
# @param body [Hash] See Figshare API docs
|
58
62
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
59
63
|
def create(body:, impersonate: nil, &block)
|
60
64
|
args = {}
|
61
|
-
args[
|
62
|
-
post(api_query:
|
65
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
66
|
+
post(api_query: 'account/collections', args: args, data: body, &block)
|
63
67
|
end
|
64
68
|
|
65
69
|
# Delete a private collection
|
@@ -68,7 +72,7 @@ module Figshare
|
|
68
72
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
69
73
|
def collection_delete(collection_id:, impersonate: nil, &block)
|
70
74
|
args = {}
|
71
|
-
args[
|
75
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
72
76
|
delete( api_query: "account/collections/#{collection_id}/files/#{file_id}", args: args, &block )
|
73
77
|
end
|
74
78
|
|
@@ -79,10 +83,10 @@ module Figshare
|
|
79
83
|
# @yield [Hash] See figshare api docs
|
80
84
|
def detail(collection_id:, impersonate: nil, &block)
|
81
85
|
args = {}
|
82
|
-
args[
|
86
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
83
87
|
get(api_query: "account/collections/#{collection_id}", args: args, &block)
|
84
88
|
end
|
85
|
-
|
89
|
+
|
86
90
|
# Create a new private Collection by sending collection information
|
87
91
|
#
|
88
92
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -90,10 +94,10 @@ module Figshare
|
|
90
94
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
91
95
|
def update(collection_id:, body:, impersonate: nil, &block)
|
92
96
|
args = {}
|
93
|
-
args[
|
94
|
-
put(api_query: "account/collections", args: args, data: body, &block)
|
95
|
-
end
|
96
|
-
|
97
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
98
|
+
put(api_query: "account/collections/#{collection_id}", args: args, data: body, &block)
|
99
|
+
end
|
100
|
+
|
97
101
|
# Reserve DOI for collection
|
98
102
|
#
|
99
103
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -101,8 +105,8 @@ module Figshare
|
|
101
105
|
# @yield [Hash] { doi }
|
102
106
|
def reserve_doi(collection_id:, impersonate: nil, &block)
|
103
107
|
args = {}
|
104
|
-
args[
|
105
|
-
post(api_query:
|
108
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
109
|
+
post(api_query: "account/collections/#{collection_id}/reserve_doi", args: args, &block)
|
106
110
|
end
|
107
111
|
|
108
112
|
# Reserve Handle for collection
|
@@ -112,12 +116,12 @@ module Figshare
|
|
112
116
|
# @yield [Hash] { handle }
|
113
117
|
def reserve_handle(collection_id:, impersonate: nil, &block)
|
114
118
|
args = {}
|
115
|
-
args[
|
116
|
-
post(api_query:
|
119
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
120
|
+
post(api_query: "account/collections/#{collection_id}/reserve_handle", args: args, &block)
|
117
121
|
end
|
118
122
|
|
119
|
-
# When a collection is published, a new public version will be generated.
|
120
|
-
# Any further updates to the collection will affect the private collection data.
|
123
|
+
# When a collection is published, a new public version will be generated.
|
124
|
+
# Any further updates to the collection will affect the private collection data.
|
121
125
|
# In order to make these changes publicly visible, an explicit publish operation is needed.
|
122
126
|
#
|
123
127
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -125,8 +129,8 @@ module Figshare
|
|
125
129
|
# @yield [Hash] { location }
|
126
130
|
def publish(collection_id:, impersonate: nil, &block)
|
127
131
|
args = {}
|
128
|
-
args[
|
129
|
-
post(api_query:
|
132
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
133
|
+
post(api_query: "account/collections/#{collection_id}/publish", args: args, &block)
|
130
134
|
end
|
131
135
|
|
132
136
|
# Yield collections authors
|
@@ -134,9 +138,9 @@ module Figshare
|
|
134
138
|
# @param collection_id [Integer] Figshare id of the collection
|
135
139
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
136
140
|
# @yield [Hash] {id, full_name, is_active, url_name, orcid_id}
|
137
|
-
def authors(
|
141
|
+
def authors(_article_id, impersonate: nil, &block)
|
138
142
|
args = {}
|
139
|
-
args[
|
143
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
140
144
|
get(api_query: "account/collections/#{collection_id}/authors", args: args, &block)
|
141
145
|
end
|
142
146
|
|
@@ -146,34 +150,34 @@ module Figshare
|
|
146
150
|
# @param authors [Array] Can be a mix of { id } and/or { name }
|
147
151
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
148
152
|
# @yield [Hash] { location }
|
149
|
-
def authors_add(
|
153
|
+
def authors_add(_article_id, authors:, impersonate: nil)
|
150
154
|
args = {}
|
151
|
-
args[
|
152
|
-
post(api_query: "account/collections/#{collection_id}/authors", args: args, data: {
|
155
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
156
|
+
post(api_query: "account/collections/#{collection_id}/authors", args: args, data: { 'authors' => authors }, &block)
|
153
157
|
end
|
154
|
-
|
158
|
+
|
155
159
|
# Replace existing authors list with a new list
|
156
160
|
#
|
157
161
|
# @param collection_id [Integer] Figshare id of the collection
|
158
162
|
# @param authors [Array] Can be a mix of { id } and/or { name }
|
159
163
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
160
|
-
def authors_replace(
|
164
|
+
def authors_replace(_article_id, authors:, impersonate: nil)
|
161
165
|
args = {}
|
162
|
-
args[
|
163
|
-
put(api_query: "account/collections/#{collection_id}/authors", args: args, data: {
|
166
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
167
|
+
put(api_query: "account/collections/#{collection_id}/authors", args: args, data: { 'authors' => authors }, &block)
|
164
168
|
end
|
165
|
-
|
169
|
+
|
166
170
|
# Remove author from the collection
|
167
171
|
#
|
168
172
|
# @param collection_id [Integer] Figshare id of the collection
|
169
173
|
# @param author_id [Integer] Figshare id for the author
|
170
174
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
171
|
-
def author_delete(collection_id:, impersonate: nil
|
175
|
+
def author_delete(collection_id:, author_id:, impersonate: nil)
|
172
176
|
args = {}
|
173
|
-
args[
|
177
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
174
178
|
delete(api_query: "account/collections/#{collection_id}/authors/#{author_id}", args: args, &block)
|
175
179
|
end
|
176
|
-
|
180
|
+
|
177
181
|
# Yield collection categories
|
178
182
|
#
|
179
183
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -181,11 +185,11 @@ module Figshare
|
|
181
185
|
# @yield [Hash] {parent_id, id, title}
|
182
186
|
def categories(collection_id:, impersonate: nil, &block)
|
183
187
|
args = {}
|
184
|
-
args[
|
185
|
-
get(api_query:
|
188
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
189
|
+
get(api_query: "account/collections/#{collection_id}/categories", args: args, &block)
|
186
190
|
end
|
187
|
-
|
188
|
-
# Associate new categories with the collection.
|
191
|
+
|
192
|
+
# Associate new categories with the collection.
|
189
193
|
# This will add new categories to the list of already associated categories
|
190
194
|
#
|
191
195
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -194,7 +198,7 @@ module Figshare
|
|
194
198
|
# @yield [Hash] { location }
|
195
199
|
def categories_add(collection_id:, categories:, impersonate: nil, &block)
|
196
200
|
args = {}
|
197
|
-
args[
|
201
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
198
202
|
post(api_query: "account/collections/#{collection_id}/categories", args: args, data: { 'categories' => categories }, &block)
|
199
203
|
end
|
200
204
|
|
@@ -205,7 +209,7 @@ module Figshare
|
|
205
209
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
206
210
|
def categories_replace(collection_id:, categories:, impersonate: nil, &block)
|
207
211
|
args = {}
|
208
|
-
args[
|
212
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
209
213
|
put(api_query: "account/collections/#{collection_id}/categories", args: args, data: { 'categories' => categories }, &block)
|
210
214
|
end
|
211
215
|
|
@@ -216,7 +220,7 @@ module Figshare
|
|
216
220
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
217
221
|
def categories_delete(collection_id:, category_id:, impersonate: nil, &block)
|
218
222
|
args = {}
|
219
|
-
args[
|
223
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
220
224
|
delete(api_query: "account/collections/#{collection_id}/categories/#{category_id}", args: args, &block)
|
221
225
|
end
|
222
226
|
|
@@ -227,17 +231,17 @@ module Figshare
|
|
227
231
|
# @yield [Hash] See Figshare API docs
|
228
232
|
def articles(collection_id:, impersonate: nil, &block)
|
229
233
|
args = {}
|
230
|
-
args[
|
234
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
231
235
|
get(api_query: "account/collections/#{collection_id}/articles", args: args, &block)
|
232
236
|
end
|
233
|
-
|
237
|
+
|
234
238
|
# Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
|
235
239
|
#
|
236
240
|
# @param article_id [Integer] Figshare id of the article
|
237
241
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
238
242
|
def article_detail(article_id:, impersonate: nil, &block)
|
239
243
|
args = {}
|
240
|
-
args[
|
244
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
241
245
|
get(api_query: "account/articles/#{article_id}", args: args, &block)
|
242
246
|
end
|
243
247
|
|
@@ -245,14 +249,14 @@ module Figshare
|
|
245
249
|
#
|
246
250
|
# @param collection_id [Integer] Figshare id of the collection
|
247
251
|
# @param articles [Array] array of Figshare article ids
|
248
|
-
|
252
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
249
253
|
# @yield [Hash] { location }
|
250
|
-
def articles_add(collection_id:, articles
|
254
|
+
def articles_add(collection_id:, articles:, impersonate: nil, &block)
|
251
255
|
args = {}
|
252
|
-
args[
|
253
|
-
post( api_query: "account/collections/#{collection_id}/articles
|
256
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
257
|
+
post( api_query: "account/collections/#{collection_id}/articles", args: args, data: { articles: articles }, &block)
|
254
258
|
end
|
255
|
-
|
259
|
+
|
256
260
|
# Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
|
257
261
|
#
|
258
262
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -260,21 +264,21 @@ module Figshare
|
|
260
264
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
261
265
|
def articles_replace(collection_id:, articles:, impersonate: nil, &block)
|
262
266
|
args = {}
|
263
|
-
args[
|
264
|
-
put( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, data: {
|
267
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
268
|
+
put( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, data: { articles: articles }, &block)
|
265
269
|
end
|
266
|
-
|
270
|
+
|
267
271
|
# Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
|
268
272
|
#
|
269
273
|
# @param collection_id [Integer] Figshare id of the collection
|
270
274
|
# @param article_id [Integer] Figshare id of the article
|
271
275
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
272
|
-
def article_delete(collection_id:, article_id
|
276
|
+
def article_delete(collection_id:, article_id:, impersonate: nil, &block)
|
273
277
|
args = {}
|
274
|
-
args[
|
278
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
275
279
|
delete( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, &block)
|
276
280
|
end
|
277
|
-
|
281
|
+
|
278
282
|
# List private links
|
279
283
|
#
|
280
284
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -282,10 +286,10 @@ module Figshare
|
|
282
286
|
# @yield [Hash] {id, is_active, expires_date}
|
283
287
|
def links(collection_id:, impersonate: nil, &block)
|
284
288
|
args = {}
|
285
|
-
args[
|
289
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
286
290
|
get(api_query: "account/collections/#{collection_id}/private_links", args: args, &block)
|
287
291
|
end
|
288
|
-
|
292
|
+
|
289
293
|
# Create new private link for this collection
|
290
294
|
#
|
291
295
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -294,21 +298,21 @@ module Figshare
|
|
294
298
|
# @yield [Hash] { location }
|
295
299
|
def link_create(collection_id:, private_link:, impersonate: nil, &block)
|
296
300
|
args = {}
|
297
|
-
args[
|
301
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
298
302
|
post(api_query: "account/collections/#{collection_id}/private_links", args: args, data: private_link, &block)
|
299
303
|
end
|
300
304
|
|
301
305
|
# Disable/delete private link for this collection
|
302
306
|
#
|
303
307
|
# @param collection_id [Integer] Figshare id of the collection
|
304
|
-
# @param link_id [Integer]
|
308
|
+
# @param link_id [Integer]
|
305
309
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
306
|
-
def link_delete(collection_id:,
|
310
|
+
def link_delete(collection_id:, link_id:, impersonate: nil, &block)
|
307
311
|
args = {}
|
308
|
-
args[
|
312
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
309
313
|
delete(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, &block)
|
310
314
|
end
|
311
|
-
|
315
|
+
|
312
316
|
# Update private link for this collection
|
313
317
|
#
|
314
318
|
# @param collection_id [Integer] Figshare id of the collection
|
@@ -316,9 +320,8 @@ module Figshare
|
|
316
320
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
317
321
|
def link_update(collection_id:, link_id:, private_link:, impersonate: nil, &block)
|
318
322
|
args = {}
|
319
|
-
args[
|
323
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
320
324
|
put(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, data: private_link, &block)
|
321
325
|
end
|
322
|
-
|
323
326
|
end
|
324
|
-
end
|
327
|
+
end
|