figshare_api_v2 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +36 -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 +80 -80
- data/lib/oai_pmh.rb +4 -2
- data/lib/other.rb +13 -13
- data/lib/private_articles.rb +135 -112
- 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 +4 -4
data/lib/private_articles.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
module Figshare
|
2
|
-
|
3
2
|
# Figshare private articles API
|
4
3
|
#
|
5
4
|
class PrivateArticles < Base
|
6
|
-
|
7
5
|
# Get Own Articles (or private articles of others if institute is true)
|
8
6
|
#
|
9
7
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
10
8
|
# @yield [Hash] {id, title, doi, handle, url, published_date}
|
11
9
|
def list(impersonate: nil, &block)
|
12
10
|
args = {}
|
13
|
-
args[
|
11
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
14
12
|
get_paginate(api_query: 'account/articles', args: args, &block)
|
15
13
|
end
|
16
14
|
|
@@ -29,28 +27,35 @@ module Figshare
|
|
29
27
|
# @param order_direction [String] "desc" Default, "asc"
|
30
28
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
31
29
|
# @yield [Hash] {id, title, doi, handle, url, published_date}
|
32
|
-
def search(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
def search( search_for:,
|
31
|
+
institute: false,
|
32
|
+
group_id: nil,
|
33
|
+
impersonate: nil,
|
34
|
+
published_since: nil,
|
35
|
+
modified_since: nil,
|
36
|
+
item_type: nil,
|
37
|
+
resource_doi: nil,
|
38
|
+
doi: nil,
|
39
|
+
handle: nil,
|
40
|
+
order: 'published_date',
|
41
|
+
order_direction: 'desc',
|
42
|
+
&block
|
43
|
+
)
|
39
44
|
args = { 'search_for' => search_for }
|
40
|
-
args[
|
41
|
-
args['institution'] = @institute_id
|
42
|
-
args['group_id'] = group_id
|
43
|
-
args['item_type'] = item_type
|
44
|
-
args['resource_doi'] = resource_doi
|
45
|
-
args['doi'] = doi
|
46
|
-
args['handle'] = handle
|
47
|
-
args['published_since'] = published_since
|
48
|
-
args['modified_since'] = modified_since
|
49
|
-
args['order'] = order
|
50
|
-
args['order_direction'] = order_direction
|
45
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
46
|
+
args['institution'] = @institute_id unless institute.nil?
|
47
|
+
args['group_id'] = group_id unless group_id.nil?
|
48
|
+
args['item_type'] = item_type unless item_type.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?
|
51
56
|
post(api_query: 'account/articles/search', args: args, &block)
|
52
57
|
end
|
53
|
-
|
58
|
+
|
54
59
|
# Create a body for use with create and update methods
|
55
60
|
#
|
56
61
|
# @param title [String] Required
|
@@ -70,40 +75,59 @@ module Figshare
|
|
70
75
|
# @param resource_title [String] Not applicable to regular users. In a publisher case, this is the publisher article title.
|
71
76
|
# @param timeline [Hash] Various timeline dates ie. { "firstOnline" => "date_string", "publisherPublication" => "date_string", "publisherAcceptance" => "date_string"},
|
72
77
|
# @param group_id [Integer] Not applicable to regular users. This field is reserved to institutions/publishers with access to assign to specific groups
|
73
|
-
def body(title:,
|
74
|
-
|
78
|
+
def body( title:,
|
79
|
+
description: nil,
|
80
|
+
keywords: nil,
|
81
|
+
references: nil,
|
82
|
+
categories: nil,
|
83
|
+
authors: nil,
|
84
|
+
custom_fields: nil,
|
85
|
+
defined_type: nil,
|
86
|
+
funding: nil,
|
87
|
+
funding_list: nil,
|
88
|
+
license: nil,
|
89
|
+
doi: nil,
|
90
|
+
handle: nil,
|
91
|
+
resource_doi: nil,
|
92
|
+
resource_title: nil,
|
93
|
+
timeline: nil,
|
94
|
+
group_id: nil,
|
95
|
+
contact: nil
|
96
|
+
)
|
97
|
+
body_ = {
|
75
98
|
'title' => title
|
76
99
|
}
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
100
|
+
body_['description'] = description unless description.nil?
|
101
|
+
body_['keywords'] = keywords unless keywords.nil?
|
102
|
+
body_['references'] = references unless references.nil?
|
103
|
+
body_['categories'] = categories unless categories.nil?
|
104
|
+
body_['authors'] = authors unless authors.nil?
|
105
|
+
body_['custom_fields'] = custom_fields unless custom_fields.nil?
|
106
|
+
body_['defined_type'] = defined_type unless defined_type.nil?
|
107
|
+
body_['funding'] = funding unless funding.nil?
|
108
|
+
body_['funding_list'] = funding_list unless funding_list.nil?
|
109
|
+
body_['license'] = license unless license.nil?
|
110
|
+
body_['doi'] = doi unless doi.nil?
|
111
|
+
body_['handle'] = handle unless handle.nil?
|
112
|
+
body_['resource_doi'] = resource_doi unless resource_doi.nil?
|
113
|
+
body_['resource_title'] = resource_title unless resource_title.nil?
|
114
|
+
body_['timeline'] = timeline unless timeline.nil?
|
115
|
+
body_['group_id'] = group_id unless group_id.nil?
|
116
|
+
body_['contact'] = contact unless contact.nil?
|
117
|
+
|
118
|
+
return body_
|
95
119
|
end
|
96
|
-
|
120
|
+
|
97
121
|
# Create a new Article by sending article information
|
98
|
-
# The user calling the API (or impersonated user) looks to be added as an author, even if they aren't.
|
122
|
+
# The user calling the API (or impersonated user) looks to be added as an author, even if they aren't.
|
99
123
|
# A duplicate "Author" entry occurs when adding them explicitly
|
100
124
|
#
|
101
125
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
102
126
|
# @yield [Hash] { location }
|
103
127
|
def create(body:, impersonate: nil, &block)
|
104
128
|
args = {}
|
105
|
-
args[
|
106
|
-
post(api_query:
|
129
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
130
|
+
post(api_query: 'account/articles', args: args, data: body, &block)
|
107
131
|
end
|
108
132
|
|
109
133
|
# Delete an article (WARNING!!!!!)
|
@@ -112,8 +136,8 @@ module Figshare
|
|
112
136
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
113
137
|
def article_delete(article_id:, impersonate: nil, &block)
|
114
138
|
args = {}
|
115
|
-
args[
|
116
|
-
delete(api_query: "account/articles/#{article_id}",
|
139
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
140
|
+
delete(api_query: "account/articles/#{article_id}", args: args, &block)
|
117
141
|
end
|
118
142
|
|
119
143
|
# Get a private article's details
|
@@ -122,10 +146,10 @@ module Figshare
|
|
122
146
|
# @param article_id [Integer] Figshare id of the article
|
123
147
|
def detail(article_id:, impersonate: nil, &block)
|
124
148
|
args = {}
|
125
|
-
args[
|
126
|
-
get(api_query: "account/articles/#{article_id}",
|
149
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
150
|
+
get(api_query: "account/articles/#{article_id}", args: args, &block)
|
127
151
|
end
|
128
|
-
|
152
|
+
|
129
153
|
# Updating an article by passing body parameters
|
130
154
|
#
|
131
155
|
# @param article_id [Integer] Figshare id of the article
|
@@ -133,20 +157,20 @@ module Figshare
|
|
133
157
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
134
158
|
def update(article_id:, body:, impersonate: nil, &block)
|
135
159
|
args = {}
|
136
|
-
args[
|
160
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
137
161
|
put(api_query: "account/articles/#{article_id}", args: args, data: body, &block)
|
138
162
|
end
|
139
|
-
|
163
|
+
|
140
164
|
# Will lift the embargo for the specified article
|
141
165
|
#
|
142
166
|
# @param article_id [Integer] Figshare id of the article
|
143
167
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
144
168
|
def embargo_delete(article_id:, impersonate: nil, &block)
|
145
169
|
args = {}
|
146
|
-
args[
|
170
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
147
171
|
delete(api_query: "account/articles/#{article_id}/embargo", args: args, &block)
|
148
172
|
end
|
149
|
-
|
173
|
+
|
150
174
|
# Get a private article embargo details
|
151
175
|
#
|
152
176
|
# @param article_id [Integer] Figshare id of the article
|
@@ -154,12 +178,12 @@ module Figshare
|
|
154
178
|
# @yield [Hash] {is_embargoed, embargo_date, embargo_reason}
|
155
179
|
def embargo_detail(article_id:, impersonate: nil, &block)
|
156
180
|
args = {}
|
157
|
-
args[
|
181
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
158
182
|
get(api_query: "account/articles/#{article_id}/embargo", args: args, &block)
|
159
183
|
end
|
160
|
-
|
184
|
+
|
161
185
|
# Updates an article embargo status.
|
162
|
-
# Does not imply that the article will be published when the embargo will expire.
|
186
|
+
# Does not imply that the article will be published when the embargo will expire.
|
163
187
|
# You must explicitly call the publish endpoint to enable this functionality.
|
164
188
|
#
|
165
189
|
# @param article_id [Integer] Figshare id of the article
|
@@ -168,51 +192,51 @@ module Figshare
|
|
168
192
|
# @param embargo_type [Integer]
|
169
193
|
# @param embargo_reason [String]
|
170
194
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
171
|
-
def embargo_update(article_id:, is_embargoed: true,
|
195
|
+
def embargo_update(article_id:, embargo_date:, embargo_reason:, is_embargoed: true, embargo_type: 'file', impersonate: nil, &block)
|
172
196
|
args = {}
|
173
|
-
args[
|
174
|
-
embargo_record = {
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
197
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
198
|
+
embargo_record = { 'is_embargoed' => is_embargoed,
|
199
|
+
'embargo_date' => embargo_date.strftime('%Y-%m-%dT%H:%M:%S'),
|
200
|
+
'embargo_type' => embargo_type,
|
201
|
+
'embargo_reason' => embargo_reason
|
202
|
+
}
|
179
203
|
put(api_query: "account/articles/#{article_id}/embargo", args: args, data: embargo_record, &block)
|
180
204
|
end
|
181
205
|
|
182
206
|
# Publish an article
|
183
207
|
# If the whole article is under embargo, it will not be published immediately, but when the embargo expires or is lifted.
|
184
|
-
# When an article is published, a new public version will be generated.
|
185
|
-
# Any further updates to the article will affect the private article data.
|
208
|
+
# When an article is published, a new public version will be generated.
|
209
|
+
# Any further updates to the article will affect the private article data.
|
186
210
|
# In order to make these changes publicly visible, an explicit publish operation is needed.
|
187
211
|
#
|
188
212
|
# @param article_id [Integer] Figshare id of the article
|
189
213
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
190
214
|
def publish(article_id:, impersonate: nil, &block)
|
191
215
|
args = {}
|
192
|
-
args[
|
216
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
193
217
|
post(api_query: "account/articles/#{article_id}/publish", args: args, &block)
|
194
218
|
end
|
195
|
-
|
219
|
+
|
196
220
|
# Reserve DOI for article
|
197
221
|
#
|
198
222
|
# @param article_id [Integer] Figshare id of the article
|
199
223
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
200
224
|
def reserve_doi(article_id:, impersonate: nil, &block)
|
201
225
|
args = {}
|
202
|
-
args[
|
226
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
203
227
|
post(api_query: "account/articles/#{article_id}/reserve_doi", args: args, &block)
|
204
228
|
end
|
205
|
-
|
229
|
+
|
206
230
|
# Reserve Handle for article
|
207
231
|
#
|
208
232
|
# @param article_id [Integer] Figshare id of the article
|
209
233
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
210
234
|
def reserve_handle(article_id:, impersonate: nil, &block)
|
211
235
|
args = {}
|
212
|
-
args[
|
236
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
213
237
|
post(api_query: "account/articles/#{article_id}/reserve_handle", args: args, &block)
|
214
238
|
end
|
215
|
-
|
239
|
+
|
216
240
|
# Yield articles authors
|
217
241
|
#
|
218
242
|
# @param article_id [Integer] Figshare id of the article
|
@@ -220,7 +244,7 @@ module Figshare
|
|
220
244
|
# @yield [Hash] {id, full_name, is_active, url_name, orcid_id}
|
221
245
|
def authors(article_id, impersonate: nil, &block)
|
222
246
|
args = {}
|
223
|
-
args[
|
247
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
224
248
|
get(api_query: "account/articles/#{article_id}/authors", args: args, &block)
|
225
249
|
end
|
226
250
|
|
@@ -231,10 +255,10 @@ module Figshare
|
|
231
255
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
232
256
|
def authors_add(article_id:, authors:, impersonate: nil, &block)
|
233
257
|
args = {}
|
234
|
-
args[
|
235
|
-
post(api_query: "account/articles/#{article_id}/authors", args: args, data: {
|
258
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
259
|
+
post(api_query: "account/articles/#{article_id}/authors", args: args, data: { 'authors' => authors }, &block)
|
236
260
|
end
|
237
|
-
|
261
|
+
|
238
262
|
# Replace existing authors list with a new list
|
239
263
|
#
|
240
264
|
# @param article_id [Integer] Figshare id of the article
|
@@ -242,10 +266,10 @@ module Figshare
|
|
242
266
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
243
267
|
def authors_replace(article_id:, authors:, impersonate: nil, &block)
|
244
268
|
args = {}
|
245
|
-
args[
|
246
|
-
put(api_query: "account/articles/#{article_id}/authors", args: args, data: {
|
269
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
270
|
+
put(api_query: "account/articles/#{article_id}/authors", args: args, data: { 'authors' => authors }, &block)
|
247
271
|
end
|
248
|
-
|
272
|
+
|
249
273
|
# Remove author from the article
|
250
274
|
#
|
251
275
|
# @param article_id [Integer] Figshare id of the article
|
@@ -253,10 +277,10 @@ module Figshare
|
|
253
277
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
254
278
|
def author_delete(article_id:, author_id:, impersonate: nil, &block)
|
255
279
|
args = {}
|
256
|
-
args[
|
280
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
257
281
|
delete(api_query: "account/articles/#{article_id}/authors/#{author_id}", args: args, &block)
|
258
282
|
end
|
259
|
-
|
283
|
+
|
260
284
|
# List categories for a specific article
|
261
285
|
#
|
262
286
|
# @param article_id [Integer] Figshare id of the article
|
@@ -264,11 +288,11 @@ module Figshare
|
|
264
288
|
# yield [Hash] { parent_id, id, title }
|
265
289
|
def categories(article_id:, impersonate: nil, &block)
|
266
290
|
args = {}
|
267
|
-
args[
|
268
|
-
get(api_query: "account/articles/#{article_id}/categories",
|
291
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
292
|
+
get(api_query: "account/articles/#{article_id}/categories", args: args, &block)
|
269
293
|
end
|
270
|
-
|
271
|
-
# Associate new categories with the article.
|
294
|
+
|
295
|
+
# Associate new categories with the article.
|
272
296
|
# This will add new categories to the list of already associated categories
|
273
297
|
#
|
274
298
|
# @param article_id [Integer] Figshare id of the article
|
@@ -276,10 +300,10 @@ module Figshare
|
|
276
300
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
277
301
|
def categories_add(article_id:, categories:, impersonate: nil, &block)
|
278
302
|
args = {}
|
279
|
-
args[
|
303
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
280
304
|
post(api_query: "account/articles/#{article_id}/categories", args: args, data: { 'categories' => categories }, &block)
|
281
305
|
end
|
282
|
-
|
306
|
+
|
283
307
|
# Associate new categories with the article. This will remove all already associated categories and add these new ones
|
284
308
|
#
|
285
309
|
# @param article_id [Integer] Figshare id of the article
|
@@ -287,10 +311,10 @@ module Figshare
|
|
287
311
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
288
312
|
def categories_replace(article_id:, categories:, impersonate: nil, &block)
|
289
313
|
args = {}
|
290
|
-
args[
|
314
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
291
315
|
put(api_query: "account/articles/#{article_id}/categories", args: args, data: { 'categories' => categories }, &block)
|
292
316
|
end
|
293
|
-
|
317
|
+
|
294
318
|
# Delete category from article's categories
|
295
319
|
#
|
296
320
|
# @param article_id [Integer] Figshare id of the article
|
@@ -298,10 +322,10 @@ module Figshare
|
|
298
322
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
299
323
|
def categories_delete(article_id:, category_id:, impersonate: nil, &block)
|
300
324
|
args = {}
|
301
|
-
args[
|
325
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
302
326
|
delete(api_query: "account/articles/#{article_id}/categories/#{category_id}", args: args, &block)
|
303
327
|
end
|
304
|
-
|
328
|
+
|
305
329
|
# List private links
|
306
330
|
#
|
307
331
|
# @param article_id [Integer] Figshare id of the article
|
@@ -309,10 +333,10 @@ module Figshare
|
|
309
333
|
# @yield [Hash] {id, is_active, expires_date}
|
310
334
|
def links(article_id:, impersonate: nil, &block)
|
311
335
|
args = {}
|
312
|
-
args[
|
336
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
313
337
|
get(api_query: "account/articles/#{article_id}/private_links", args: args, &block)
|
314
338
|
end
|
315
|
-
|
339
|
+
|
316
340
|
# Create new private link for this article
|
317
341
|
#
|
318
342
|
# @param article_id [Integer] Figshare id of the article
|
@@ -321,54 +345,54 @@ module Figshare
|
|
321
345
|
# @yield [Hash] { location }
|
322
346
|
def link_create(article_id:, private_link:, impersonate: nil, &block)
|
323
347
|
args = {}
|
324
|
-
args[
|
348
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
325
349
|
post(api_query: "account/articles/#{article_id}/private_links", data: private_link, args: args, &block)
|
326
350
|
end
|
327
351
|
|
328
352
|
# Disable/delete private link for this article
|
329
353
|
#
|
330
354
|
# @param article_id [Integer] Figshare id of the article
|
331
|
-
# @param link_id [Integer]
|
355
|
+
# @param link_id [Integer]
|
332
356
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
333
|
-
def link_delete(article_id:,
|
357
|
+
def link_delete(article_id:, link_id:, impersonate: nil, &block)
|
334
358
|
args = {}
|
335
|
-
args[
|
359
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
336
360
|
delete(api_query: "account/articles/#{article_id}/private_links/#{link_id}", args: args, &block)
|
337
361
|
end
|
338
|
-
|
362
|
+
|
339
363
|
# Update private link for this article
|
340
364
|
#
|
341
365
|
# @param article_id [Integer] Figshare id of the article
|
342
|
-
# @param expires_date [Time]
|
366
|
+
# @param expires_date [Time]
|
343
367
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
344
368
|
def link_update(article_id:, link_id:, expires_date:, impersonate: nil, &block)
|
345
369
|
args = {}
|
346
|
-
args[
|
347
|
-
put(api_query: "account/articles/#{article_id}/private_links/#{link_id}", args: args, data: {
|
370
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
371
|
+
put(api_query: "account/articles/#{article_id}/private_links/#{link_id}", args: args, data: { 'expires_date' => expires_date.iso8601 }, &block)
|
348
372
|
end
|
349
373
|
|
350
374
|
# List private files in an article
|
351
375
|
#
|
352
376
|
# @param article_id [Integer] Figshare id of the article
|
353
377
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
354
|
-
# @yield [Hash] {status, viewer_type, preview_state, upload_url, upload_token, id, name, size, is_link_only,
|
378
|
+
# @yield [Hash] {status, viewer_type, preview_state, upload_url, upload_token, id, name, size, is_link_only,
|
355
379
|
# download_url, supplied_md5, computed_md5}
|
356
380
|
def files(article_id:, impersonate: nil, &block)
|
357
381
|
args = {}
|
358
|
-
args[
|
382
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
359
383
|
get(api_query: "account/articles/#{article_id}/files", args: args, &block)
|
360
384
|
end
|
361
|
-
|
385
|
+
|
362
386
|
# Single file detail
|
363
387
|
#
|
364
388
|
# @param article_id [Integer] Figshare id of the article
|
365
389
|
# @param file_id [Integer] Figshare id of the file
|
366
390
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
367
|
-
# @yield [Hash] {status, viewer_type, preview_state, upload_url, upload_token, id, name, size, is_link_only,
|
391
|
+
# @yield [Hash] {status, viewer_type, preview_state, upload_url, upload_token, id, name, size, is_link_only,
|
368
392
|
# download_url, supplied_md5, computed_md5}
|
369
393
|
def file_detail(article_id:, file_id:, impersonate: nil, &block)
|
370
394
|
args = {}
|
371
|
-
args[
|
395
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
372
396
|
get(api_query: "account/articles/#{article_id}/files/#{file_id}", args: args, &block)
|
373
397
|
end
|
374
398
|
|
@@ -377,9 +401,9 @@ module Figshare
|
|
377
401
|
# @param article_id [Integer] Figshare id of the article
|
378
402
|
# @param file_id [Integer] Figshare id of the file
|
379
403
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
380
|
-
def file_delete(article_id:, file_id
|
404
|
+
def file_delete(article_id:, file_id:, impersonate: nil, &block)
|
381
405
|
args = {}
|
382
|
-
args[
|
406
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
383
407
|
delete( api_query: "account/articles/#{article_id}/files/#{file_id}", args: args, &block )
|
384
408
|
end
|
385
409
|
|
@@ -389,11 +413,10 @@ module Figshare
|
|
389
413
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
390
414
|
# @yield [Hash] Figshare file record of each file being deleted (if block_given?)
|
391
415
|
def delete_all_files(article_id:, impersonate: nil)
|
392
|
-
article_files(article_id: article_id, impersonate: impersonate) do |f|
|
416
|
+
article_files(article_id: article_id, impersonate: impersonate) do |f|
|
393
417
|
yield f if block_given?
|
394
418
|
article_file_delete(article_id: article_id, file_id: f['id'], impersonate: impersonate)
|
395
419
|
end
|
396
420
|
end
|
397
|
-
|
398
421
|
end
|
399
|
-
end
|
422
|
+
end
|