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_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,36 +27,107 @@ 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
|
+
|
59
|
+
# Create a body for use with create and update methods
|
60
|
+
#
|
61
|
+
# @param title [String] Required
|
62
|
+
# @param description [String] The article description. In a publisher case, usually this is the remote article description
|
63
|
+
# @param keywords [Array] List of tags (strings) to be associated with the article. Tags can be used instead
|
64
|
+
# @param references [Array] List of links to be associated with the article (e.g ["http://link1", "http://link2", "http://link3"])
|
65
|
+
# @param categories [Array] List of category ids to be associated with the article(e.g [1, 23, 33, 66])
|
66
|
+
# @param authors [Array] List of authors to be associated with the article. The list can contain the following fields: id, name, first_name, last_name, email, orcid_id. If an id is supplied, it will take priority and everything else will be ignored. No more than 10 authors. For adding more authors use the specific authors endpoint. e.g. { "name" => "Joe X"} and or { "id" => 123 }
|
67
|
+
# @param custom_fields [Hash] List of key, values pairs to be associated with the article. eg. { "key" => "value"}
|
68
|
+
# @param defined_type [String] one of "figshare","media","dataset","poster","journal contribution", "presentation", "thesis", "software", "online resource", "preprint", "book", "conference contribution", "chapter", "peer review", "educational resource", "report", "standard", "composition", "funding", "physical object", "data management plan", "workflow", "monograph", "performance", "event", "service", "model", "registration"
|
69
|
+
# @param funding [String] Grant number or funding authority
|
70
|
+
# @param funding_list [Array] Funding creation / update items. eg {"id" => 0, "title" => "string"}
|
71
|
+
# @param license [Integer] License id for this article.
|
72
|
+
# @param doi [String] Not applicable for regular users. In an institutional case, make sure your group supports setting DOIs. This setting is applied by figshare via opening a ticket through our support/helpdesk system.
|
73
|
+
# @param handle [String] Not applicable for regular users. In an institutional case, make sure your group supports setting Handles. This setting is applied by figshare via opening a ticket through our support/helpdesk system.
|
74
|
+
# @param resource_doi [String] Not applicable to regular users. In a publisher case, this is the publisher article DOI.
|
75
|
+
# @param resource_title [String] Not applicable to regular users. In a publisher case, this is the publisher article title.
|
76
|
+
# @param timeline [Hash] Various timeline dates ie. { "firstOnline" => "date_string", "publisherPublication" => "date_string", "publisherAcceptance" => "date_string"},
|
77
|
+
# @param group_id [Integer] Not applicable to regular users. This field is reserved to institutions/publishers with access to assign to specific groups
|
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_ = {
|
98
|
+
'title' => title
|
99
|
+
}
|
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_
|
119
|
+
end
|
120
|
+
|
54
121
|
# Create a new Article by sending article information
|
122
|
+
# The user calling the API (or impersonated user) looks to be added as an author, even if they aren't.
|
123
|
+
# A duplicate "Author" entry occurs when adding them explicitly
|
55
124
|
#
|
56
125
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
57
126
|
# @yield [Hash] { location }
|
58
|
-
def create(impersonate: nil, &block)
|
127
|
+
def create(body:, impersonate: nil, &block)
|
59
128
|
args = {}
|
60
|
-
args[
|
61
|
-
post(api_query:
|
129
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
130
|
+
post(api_query: 'account/articles', args: args, data: body, &block)
|
62
131
|
end
|
63
132
|
|
64
133
|
# Delete an article (WARNING!!!!!)
|
@@ -67,8 +136,8 @@ module Figshare
|
|
67
136
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
68
137
|
def article_delete(article_id:, impersonate: nil, &block)
|
69
138
|
args = {}
|
70
|
-
args[
|
71
|
-
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)
|
72
141
|
end
|
73
142
|
|
74
143
|
# Get a private article's details
|
@@ -77,10 +146,10 @@ module Figshare
|
|
77
146
|
# @param article_id [Integer] Figshare id of the article
|
78
147
|
def detail(article_id:, impersonate: nil, &block)
|
79
148
|
args = {}
|
80
|
-
args[
|
81
|
-
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)
|
82
151
|
end
|
83
|
-
|
152
|
+
|
84
153
|
# Updating an article by passing body parameters
|
85
154
|
#
|
86
155
|
# @param article_id [Integer] Figshare id of the article
|
@@ -88,20 +157,20 @@ module Figshare
|
|
88
157
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
89
158
|
def update(article_id:, body:, impersonate: nil, &block)
|
90
159
|
args = {}
|
91
|
-
args[
|
160
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
92
161
|
put(api_query: "account/articles/#{article_id}", args: args, data: body, &block)
|
93
162
|
end
|
94
|
-
|
163
|
+
|
95
164
|
# Will lift the embargo for the specified article
|
96
165
|
#
|
97
166
|
# @param article_id [Integer] Figshare id of the article
|
98
167
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
99
168
|
def embargo_delete(article_id:, impersonate: nil, &block)
|
100
169
|
args = {}
|
101
|
-
args[
|
170
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
102
171
|
delete(api_query: "account/articles/#{article_id}/embargo", args: args, &block)
|
103
172
|
end
|
104
|
-
|
173
|
+
|
105
174
|
# Get a private article embargo details
|
106
175
|
#
|
107
176
|
# @param article_id [Integer] Figshare id of the article
|
@@ -109,12 +178,12 @@ module Figshare
|
|
109
178
|
# @yield [Hash] {is_embargoed, embargo_date, embargo_reason}
|
110
179
|
def embargo_detail(article_id:, impersonate: nil, &block)
|
111
180
|
args = {}
|
112
|
-
args[
|
181
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
113
182
|
get(api_query: "account/articles/#{article_id}/embargo", args: args, &block)
|
114
183
|
end
|
115
|
-
|
184
|
+
|
116
185
|
# Updates an article embargo status.
|
117
|
-
# 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.
|
118
187
|
# You must explicitly call the publish endpoint to enable this functionality.
|
119
188
|
#
|
120
189
|
# @param article_id [Integer] Figshare id of the article
|
@@ -123,51 +192,51 @@ module Figshare
|
|
123
192
|
# @param embargo_type [Integer]
|
124
193
|
# @param embargo_reason [String]
|
125
194
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
126
|
-
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)
|
127
196
|
args = {}
|
128
|
-
args[
|
129
|
-
embargo_record = {
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|
+
}
|
134
203
|
put(api_query: "account/articles/#{article_id}/embargo", args: args, data: embargo_record, &block)
|
135
204
|
end
|
136
205
|
|
137
206
|
# Publish an article
|
138
207
|
# If the whole article is under embargo, it will not be published immediately, but when the embargo expires or is lifted.
|
139
|
-
# When an article is published, a new public version will be generated.
|
140
|
-
# 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.
|
141
210
|
# In order to make these changes publicly visible, an explicit publish operation is needed.
|
142
211
|
#
|
143
212
|
# @param article_id [Integer] Figshare id of the article
|
144
213
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
145
214
|
def publish(article_id:, impersonate: nil, &block)
|
146
215
|
args = {}
|
147
|
-
args[
|
216
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
148
217
|
post(api_query: "account/articles/#{article_id}/publish", args: args, &block)
|
149
218
|
end
|
150
|
-
|
219
|
+
|
151
220
|
# Reserve DOI for article
|
152
221
|
#
|
153
222
|
# @param article_id [Integer] Figshare id of the article
|
154
223
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
155
224
|
def reserve_doi(article_id:, impersonate: nil, &block)
|
156
225
|
args = {}
|
157
|
-
args[
|
226
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
158
227
|
post(api_query: "account/articles/#{article_id}/reserve_doi", args: args, &block)
|
159
228
|
end
|
160
|
-
|
229
|
+
|
161
230
|
# Reserve Handle for article
|
162
231
|
#
|
163
232
|
# @param article_id [Integer] Figshare id of the article
|
164
233
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
165
234
|
def reserve_handle(article_id:, impersonate: nil, &block)
|
166
235
|
args = {}
|
167
|
-
args[
|
236
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
168
237
|
post(api_query: "account/articles/#{article_id}/reserve_handle", args: args, &block)
|
169
238
|
end
|
170
|
-
|
239
|
+
|
171
240
|
# Yield articles authors
|
172
241
|
#
|
173
242
|
# @param article_id [Integer] Figshare id of the article
|
@@ -175,7 +244,7 @@ module Figshare
|
|
175
244
|
# @yield [Hash] {id, full_name, is_active, url_name, orcid_id}
|
176
245
|
def authors(article_id, impersonate: nil, &block)
|
177
246
|
args = {}
|
178
|
-
args[
|
247
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
179
248
|
get(api_query: "account/articles/#{article_id}/authors", args: args, &block)
|
180
249
|
end
|
181
250
|
|
@@ -186,10 +255,10 @@ module Figshare
|
|
186
255
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
187
256
|
def authors_add(article_id:, authors:, impersonate: nil, &block)
|
188
257
|
args = {}
|
189
|
-
args[
|
190
|
-
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)
|
191
260
|
end
|
192
|
-
|
261
|
+
|
193
262
|
# Replace existing authors list with a new list
|
194
263
|
#
|
195
264
|
# @param article_id [Integer] Figshare id of the article
|
@@ -197,10 +266,10 @@ module Figshare
|
|
197
266
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
198
267
|
def authors_replace(article_id:, authors:, impersonate: nil, &block)
|
199
268
|
args = {}
|
200
|
-
args[
|
201
|
-
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)
|
202
271
|
end
|
203
|
-
|
272
|
+
|
204
273
|
# Remove author from the article
|
205
274
|
#
|
206
275
|
# @param article_id [Integer] Figshare id of the article
|
@@ -208,10 +277,10 @@ module Figshare
|
|
208
277
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
209
278
|
def author_delete(article_id:, author_id:, impersonate: nil, &block)
|
210
279
|
args = {}
|
211
|
-
args[
|
280
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
212
281
|
delete(api_query: "account/articles/#{article_id}/authors/#{author_id}", args: args, &block)
|
213
282
|
end
|
214
|
-
|
283
|
+
|
215
284
|
# List categories for a specific article
|
216
285
|
#
|
217
286
|
# @param article_id [Integer] Figshare id of the article
|
@@ -219,11 +288,11 @@ module Figshare
|
|
219
288
|
# yield [Hash] { parent_id, id, title }
|
220
289
|
def categories(article_id:, impersonate: nil, &block)
|
221
290
|
args = {}
|
222
|
-
args[
|
223
|
-
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)
|
224
293
|
end
|
225
|
-
|
226
|
-
# Associate new categories with the article.
|
294
|
+
|
295
|
+
# Associate new categories with the article.
|
227
296
|
# This will add new categories to the list of already associated categories
|
228
297
|
#
|
229
298
|
# @param article_id [Integer] Figshare id of the article
|
@@ -231,10 +300,10 @@ module Figshare
|
|
231
300
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
232
301
|
def categories_add(article_id:, categories:, impersonate: nil, &block)
|
233
302
|
args = {}
|
234
|
-
args[
|
303
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
235
304
|
post(api_query: "account/articles/#{article_id}/categories", args: args, data: { 'categories' => categories }, &block)
|
236
305
|
end
|
237
|
-
|
306
|
+
|
238
307
|
# Associate new categories with the article. This will remove all already associated categories and add these new ones
|
239
308
|
#
|
240
309
|
# @param article_id [Integer] Figshare id of the article
|
@@ -242,10 +311,10 @@ module Figshare
|
|
242
311
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
243
312
|
def categories_replace(article_id:, categories:, impersonate: nil, &block)
|
244
313
|
args = {}
|
245
|
-
args[
|
314
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
246
315
|
put(api_query: "account/articles/#{article_id}/categories", args: args, data: { 'categories' => categories }, &block)
|
247
316
|
end
|
248
|
-
|
317
|
+
|
249
318
|
# Delete category from article's categories
|
250
319
|
#
|
251
320
|
# @param article_id [Integer] Figshare id of the article
|
@@ -253,10 +322,10 @@ module Figshare
|
|
253
322
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
254
323
|
def categories_delete(article_id:, category_id:, impersonate: nil, &block)
|
255
324
|
args = {}
|
256
|
-
args[
|
325
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
257
326
|
delete(api_query: "account/articles/#{article_id}/categories/#{category_id}", args: args, &block)
|
258
327
|
end
|
259
|
-
|
328
|
+
|
260
329
|
# List private links
|
261
330
|
#
|
262
331
|
# @param article_id [Integer] Figshare id of the article
|
@@ -264,10 +333,10 @@ module Figshare
|
|
264
333
|
# @yield [Hash] {id, is_active, expires_date}
|
265
334
|
def links(article_id:, impersonate: nil, &block)
|
266
335
|
args = {}
|
267
|
-
args[
|
336
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
268
337
|
get(api_query: "account/articles/#{article_id}/private_links", args: args, &block)
|
269
338
|
end
|
270
|
-
|
339
|
+
|
271
340
|
# Create new private link for this article
|
272
341
|
#
|
273
342
|
# @param article_id [Integer] Figshare id of the article
|
@@ -276,54 +345,54 @@ module Figshare
|
|
276
345
|
# @yield [Hash] { location }
|
277
346
|
def link_create(article_id:, private_link:, impersonate: nil, &block)
|
278
347
|
args = {}
|
279
|
-
args[
|
348
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
280
349
|
post(api_query: "account/articles/#{article_id}/private_links", data: private_link, args: args, &block)
|
281
350
|
end
|
282
351
|
|
283
352
|
# Disable/delete private link for this article
|
284
353
|
#
|
285
354
|
# @param article_id [Integer] Figshare id of the article
|
286
|
-
# @param link_id [Integer]
|
355
|
+
# @param link_id [Integer]
|
287
356
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
288
|
-
def link_delete(article_id:,
|
357
|
+
def link_delete(article_id:, link_id:, impersonate: nil, &block)
|
289
358
|
args = {}
|
290
|
-
args[
|
359
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
291
360
|
delete(api_query: "account/articles/#{article_id}/private_links/#{link_id}", args: args, &block)
|
292
361
|
end
|
293
|
-
|
362
|
+
|
294
363
|
# Update private link for this article
|
295
364
|
#
|
296
365
|
# @param article_id [Integer] Figshare id of the article
|
297
|
-
# @param expires_date [Time]
|
366
|
+
# @param expires_date [Time]
|
298
367
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
299
368
|
def link_update(article_id:, link_id:, expires_date:, impersonate: nil, &block)
|
300
369
|
args = {}
|
301
|
-
args[
|
302
|
-
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)
|
303
372
|
end
|
304
373
|
|
305
374
|
# List private files in an article
|
306
375
|
#
|
307
376
|
# @param article_id [Integer] Figshare id of the article
|
308
377
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
309
|
-
# @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,
|
310
379
|
# download_url, supplied_md5, computed_md5}
|
311
380
|
def files(article_id:, impersonate: nil, &block)
|
312
381
|
args = {}
|
313
|
-
args[
|
382
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
314
383
|
get(api_query: "account/articles/#{article_id}/files", args: args, &block)
|
315
384
|
end
|
316
|
-
|
385
|
+
|
317
386
|
# Single file detail
|
318
387
|
#
|
319
388
|
# @param article_id [Integer] Figshare id of the article
|
320
389
|
# @param file_id [Integer] Figshare id of the file
|
321
390
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
322
|
-
# @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,
|
323
392
|
# download_url, supplied_md5, computed_md5}
|
324
393
|
def file_detail(article_id:, file_id:, impersonate: nil, &block)
|
325
394
|
args = {}
|
326
|
-
args[
|
395
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
327
396
|
get(api_query: "account/articles/#{article_id}/files/#{file_id}", args: args, &block)
|
328
397
|
end
|
329
398
|
|
@@ -332,9 +401,9 @@ module Figshare
|
|
332
401
|
# @param article_id [Integer] Figshare id of the article
|
333
402
|
# @param file_id [Integer] Figshare id of the file
|
334
403
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
335
|
-
def file_delete(article_id:, file_id
|
404
|
+
def file_delete(article_id:, file_id:, impersonate: nil, &block)
|
336
405
|
args = {}
|
337
|
-
args[
|
406
|
+
args['impersonate'] = impersonate unless impersonate.nil?
|
338
407
|
delete( api_query: "account/articles/#{article_id}/files/#{file_id}", args: args, &block )
|
339
408
|
end
|
340
409
|
|
@@ -344,11 +413,10 @@ module Figshare
|
|
344
413
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
345
414
|
# @yield [Hash] Figshare file record of each file being deleted (if block_given?)
|
346
415
|
def delete_all_files(article_id:, impersonate: nil)
|
347
|
-
article_files(article_id: article_id, impersonate: impersonate) do |f|
|
416
|
+
article_files(article_id: article_id, impersonate: impersonate) do |f|
|
348
417
|
yield f if block_given?
|
349
418
|
article_file_delete(article_id: article_id, file_id: f['id'], impersonate: impersonate)
|
350
419
|
end
|
351
420
|
end
|
352
|
-
|
353
421
|
end
|
354
|
-
end
|
422
|
+
end
|