figshare_api_v2 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,10 +5,24 @@ module Figshare
5
5
  # Get Own Articles (or private articles of others if institute is true)
6
6
  #
7
7
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
8
- # @yield [Hash] {id, title, doi, handle, url, published_date}
9
- def list(impersonate: nil, &block)
8
+ # @param page [Numeric] Pages start at 1. Page and Page size go together
9
+ # @param page_size [Numeric]
10
+ # @param offset [Numeric] offset is 0 based. Offset and Limit go together
11
+ # @param limit [Numeric]
12
+ # @yield [Array] [{id, title, doi, handle, url, published_date, ...}] See docs.figshare.com
13
+ def list( impersonate: nil,
14
+ page: nil,
15
+ page_size: nil,
16
+ offset: nil,
17
+ limit: nil,
18
+ &block
19
+ )
10
20
  args = {}
11
21
  args['impersonate'] = impersonate unless impersonate.nil?
22
+ args['page'] = page unless page.nil?
23
+ args['page_size'] = page_size unless page_size.nil?
24
+ args['offset'] = offset unless offset.nil?
25
+ args['limit'] = limit unless limit.nil?
12
26
  get_paginate(api_query: 'account/articles', args: args, &block)
13
27
  end
14
28
 
@@ -19,14 +33,19 @@ module Figshare
19
33
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
20
34
  # @param published_since [Time] Return results if published after this time
21
35
  # @param modified_since [Time] Return results if modified after this time
36
+ # @param resource_id [String] Looks like a quoted Integer
22
37
  # @param resource_doi [String] Matches this resource doi
23
38
  # @param item_type [String] Matches this item_type. See Figshare API docs for list (https://docs.figshare.com/#articles_list)
24
39
  # @param doi [String] Matches this doi
25
40
  # @param handle [String] Matches this handle
26
41
  # @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
27
42
  # @param order_direction [String] "desc" Default, "asc"
43
+ # @param page [Numeric] Pages start at 1. Page and Page size go together
44
+ # @param page_size [Numeric]
45
+ # @param offset [Numeric] offset is 0 based. Offset and Limit go together
46
+ # @param limit [Numeric]
28
47
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
29
- # @yield [Hash] {id, title, doi, handle, url, published_date}
48
+ # @yield [Array] [{id, title, doi, handle, url, published_date, ...}] See docs.figshare.com
30
49
  def search( search_for:,
31
50
  institute: false,
32
51
  group_id: nil,
@@ -34,18 +53,24 @@ module Figshare
34
53
  published_since: nil,
35
54
  modified_since: nil,
36
55
  item_type: nil,
56
+ resource_id: nil,
37
57
  resource_doi: nil,
38
58
  doi: nil,
39
59
  handle: nil,
40
60
  order: 'published_date',
41
61
  order_direction: 'desc',
62
+ page: nil,
63
+ page_size: nil,
64
+ offset: nil,
65
+ limit: nil,
42
66
  &block
43
67
  )
44
68
  args = { 'search_for' => search_for }
45
69
  args['impersonate'] = impersonate unless impersonate.nil?
46
- args['institution'] = @institute_id unless institute.nil?
47
- args['group_id'] = group_id unless group_id.nil?
70
+ args['institution'] = @institute_id unless institute.nil? # Inconsistent use. Other calls use institute_id
71
+ args['group'] = group_id unless group_id.nil? # Not sure if this changed from group_id to group
48
72
  args['item_type'] = item_type unless item_type.nil?
73
+ args['resource_id'] = resource_id unless resource_id.nil?
49
74
  args['resource_doi'] = resource_doi unless resource_doi.nil?
50
75
  args['doi'] = doi unless doi.nil?
51
76
  args['handle'] = handle unless handle.nil?
@@ -53,18 +78,25 @@ module Figshare
53
78
  args['modified_since'] = modified_since unless modified_since.nil?
54
79
  args['order'] = order unless order.nil?
55
80
  args['order_direction'] = order_direction unless order_direction.nil?
56
- post(api_query: 'account/articles/search', args: args, &block)
81
+ args['page'] = page unless page.nil?
82
+ args['page_size'] = page_size unless page_size.nil?
83
+ args['offset'] = offset unless offset.nil?
84
+ args['limit'] = limit unless limit.nil?
85
+ post_paginate(api_query: 'account/articles/search', args: args, &block)
57
86
  end
58
87
 
59
88
  # Create a body for use with create and update methods
60
89
  #
61
90
  # @param title [String] Required
62
91
  # @param description [String] The article description. In a publisher case, usually this is the remote article description
92
+ # @param tags [Array] List of tags (strings) to be associated with the article. Tags can be used instead
63
93
  # @param keywords [Array] List of tags (strings) to be associated with the article. Tags can be used instead
64
94
  # @param references [Array] List of links to be associated with the article (e.g ["http://link1", "http://link2", "http://link3"])
65
95
  # @param categories [Array] List of category ids to be associated with the article(e.g [1, 23, 33, 66])
96
+ # @param categories_by_source_id [Array] List of category ids to be associated with the article(e.g ["300204", "400207"])
66
97
  # @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
98
  # @param custom_fields [Hash] List of key, values pairs to be associated with the article. eg. { "key" => "value"}
99
+ # @param custom_fields_list [Array] List of key, values pairs to be associated with the article. eg. [{ "key" => "value"}]
68
100
  # @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
101
  # @param funding [String] Grant number or funding authority
70
102
  # @param funding_list [Array] Funding creation / update items. eg {"id" => 0, "title" => "string"}
@@ -77,11 +109,14 @@ module Figshare
77
109
  # @param group_id [Integer] Not applicable to regular users. This field is reserved to institutions/publishers with access to assign to specific groups
78
110
  def body( title:,
79
111
  description: nil,
112
+ tags: nil,
80
113
  keywords: nil,
81
114
  references: nil,
82
115
  categories: nil,
116
+ categories_by_source_id: nil,
83
117
  authors: nil,
84
118
  custom_fields: nil,
119
+ custom_fields_list: nil,
85
120
  defined_type: nil,
86
121
  funding: nil,
87
122
  funding_list: nil,
@@ -98,11 +133,14 @@ module Figshare
98
133
  'title' => title
99
134
  }
100
135
  body_['description'] = description unless description.nil?
136
+ body_['tags'] = tags unless tags.nil?
101
137
  body_['keywords'] = keywords unless keywords.nil?
102
138
  body_['references'] = references unless references.nil?
103
139
  body_['categories'] = categories unless categories.nil?
140
+ body_['categories_by_source_id'] = categories_by_source_id unless categories_by_source_id.nil?
104
141
  body_['authors'] = authors unless authors.nil?
105
142
  body_['custom_fields'] = custom_fields unless custom_fields.nil?
143
+ body_['custom_fields_list'] = custom_fields_list unless custom_fields_list.nil?
106
144
  body_['defined_type'] = defined_type unless defined_type.nil?
107
145
  body_['funding'] = funding unless funding.nil?
108
146
  body_['funding_list'] = funding_list unless funding_list.nil?
@@ -123,7 +161,7 @@ module Figshare
123
161
  # A duplicate "Author" entry occurs when adding them explicitly
124
162
  #
125
163
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
126
- # @yield [Hash] { location }
164
+ # @yield [Hash] { entity_id:, location:, warnings: [ "string"] }
127
165
  def create(body:, impersonate: nil, &block)
128
166
  args = {}
129
167
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -144,6 +182,7 @@ module Figshare
144
182
  #
145
183
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
146
184
  # @param article_id [Integer] Figshare id of the article
185
+ # @yield [Hash] See docs.figshare.com
147
186
  def detail(article_id:, impersonate: nil, &block)
148
187
  args = {}
149
188
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -175,7 +214,7 @@ module Figshare
175
214
  #
176
215
  # @param article_id [Integer] Figshare id of the article
177
216
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
178
- # @yield [Hash] {is_embargoed, embargo_date, embargo_reason}
217
+ # @yield [Hash] {is_embargoed, embargo_date, embargo_title, embargo_reason, embargo_options [{...}] }
179
218
  def embargo_detail(article_id:, impersonate: nil, &block)
180
219
  args = {}
181
220
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -188,21 +227,61 @@ module Figshare
188
227
  #
189
228
  # @param article_id [Integer] Figshare id of the article
190
229
  # @param is_embargoed [Boolean]
191
- # @param embargo_data [Time] Still needs to be published, after this date
230
+ # @param embargo_date [Time] Still needs to be published, after this date
192
231
  # @param embargo_type [Integer]
232
+ # @param embargo_title [String]
193
233
  # @param embargo_reason [String]
234
+ # @param embargo_options [Array]
194
235
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
195
- def embargo_update(article_id:, embargo_date:, embargo_reason:, is_embargoed: true, embargo_type: 'file', impersonate: nil, &block)
236
+ def embargo_update( article_id:,
237
+ embargo_date:, embargo_title:, embargo_reason:,
238
+ is_embargoed: true,
239
+ embargo_type: 'file',
240
+ embargo_options: [],
241
+ impersonate: nil,
242
+ &block
243
+ )
196
244
  args = {}
197
245
  args['impersonate'] = impersonate unless impersonate.nil?
198
246
  embargo_record = { 'is_embargoed' => is_embargoed,
199
247
  'embargo_date' => embargo_date.strftime('%Y-%m-%dT%H:%M:%S'),
200
248
  'embargo_type' => embargo_type,
201
- 'embargo_reason' => embargo_reason
249
+ 'embargo_title' => embargo_title,
250
+ 'embargo_reason' => embargo_reason,
251
+ 'embargo_options' => embargo_options
202
252
  }
203
253
  put(api_query: "account/articles/#{article_id}/embargo", args: args, data: embargo_record, &block)
204
254
  end
205
255
 
256
+ # Article Resource
257
+ #
258
+ # @param article_id [Integer] Figshare id of the article
259
+ # @param resource [Hash]
260
+ # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
261
+ # @yield [Hash] {location:, "string"}
262
+ def article_resource( article_id:,
263
+ id:,
264
+ title:,
265
+ doi:,
266
+ link:,
267
+ status:,
268
+ version:,
269
+ impersonate: nil,
270
+ &block
271
+ )
272
+ args = {}
273
+ args['impersonate'] = impersonate unless impersonate.nil?
274
+ resource_record = {
275
+ 'id' => id,
276
+ 'title' => title,
277
+ 'doi' => doi,
278
+ 'link' => link,
279
+ 'status' => status,
280
+ 'version' => version
281
+ }
282
+ post(api_query: "account/articles/#{article_id}/resource", args: args, data: resource_record, &block)
283
+ end
284
+
206
285
  # Publish an article
207
286
  # If the whole article is under embargo, it will not be published immediately, but when the embargo expires or is lifted.
208
287
  # When an article is published, a new public version will be generated.
@@ -211,6 +290,7 @@ module Figshare
211
290
  #
212
291
  # @param article_id [Integer] Figshare id of the article
213
292
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
293
+ # @yield [Hash] {location:, "string"}
214
294
  def publish(article_id:, impersonate: nil, &block)
215
295
  args = {}
216
296
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -221,6 +301,7 @@ module Figshare
221
301
  #
222
302
  # @param article_id [Integer] Figshare id of the article
223
303
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
304
+ # @yield [Hash] {doi:, "string"}
224
305
  def reserve_doi(article_id:, impersonate: nil, &block)
225
306
  args = {}
226
307
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -231,18 +312,46 @@ module Figshare
231
312
  #
232
313
  # @param article_id [Integer] Figshare id of the article
233
314
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
315
+ # @yield [Hash] {handle:, "string"}
234
316
  def reserve_handle(article_id:, impersonate: nil, &block)
235
317
  args = {}
236
318
  args['impersonate'] = impersonate unless impersonate.nil?
237
319
  post(api_query: "account/articles/#{article_id}/reserve_handle", args: args, &block)
238
320
  end
239
321
 
322
+ # Update Article Version
323
+ #
324
+ # @param article_id [Integer]
325
+ # @param version_id [Interger]
326
+ # @param body [Hash] Update fields, rather than overwrite article metadata. see docs.figshare.com
327
+ def article_version(article_id:, version_id:, body: nil, impersonate: nil, &block)
328
+ args = {}
329
+ args['impersonate'] = impersonate unless impersonate.nil?
330
+ if body.nil?
331
+ put(api_query: "account/articles/#{article_id}/versions/#{version_id}/", args: args, &block)
332
+ else
333
+ patch(api_query: "account/articles/#{article_id}/versions/#{version_id}/", args: args, data: body, &block)
334
+ end
335
+ end
336
+
337
+ # Update Article Thumbnail of a specific version of the article
338
+ #
339
+ # @param article_id [Integer]
340
+ # @param version_id [Interger]
341
+ # @param file_id [integer] File id of one of the articles files, to use as a thumbnail. see docs.figshare.com
342
+ def article_version_update_thumbnail(article_id:, version_id:, file_id:, impersonate: nil, &block)
343
+ args = {}
344
+ args['impersonate'] = impersonate unless impersonate.nil?
345
+ args['file_id'] = file_id
346
+ put(api_query: "account/articles/#{article_id}/versions/#{version_id}/update_thumb", args: args, &block)
347
+ end
348
+
240
349
  # Yield articles authors
241
350
  #
242
351
  # @param article_id [Integer] Figshare id of the article
243
352
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
244
- # @yield [Hash] {id, full_name, is_active, url_name, orcid_id}
245
- def authors(article_id, impersonate: nil, &block)
353
+ # @yield [Hash] [{id, full_name, is_active, url_name, orcid_id}]
354
+ def authors(article_id:, impersonate: nil, &block)
246
355
  args = {}
247
356
  args['impersonate'] = impersonate unless impersonate.nil?
248
357
  get(api_query: "account/articles/#{article_id}/authors", args: args, &block)
@@ -251,7 +360,7 @@ module Figshare
251
360
  # Associate new authors with the article. This will add new authors to the list of already associated authors
252
361
  #
253
362
  # @param article_id [Integer] Figshare id of the article
254
- # @param authors [Array] Can be a mix of { id } and/or { name }
363
+ # @param authors [Array] Can be a mix of [{ id: 1234 } and/or { name: "x y" }]
255
364
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
256
365
  def authors_add(article_id:, authors:, impersonate: nil, &block)
257
366
  args = {}
@@ -262,7 +371,7 @@ module Figshare
262
371
  # Replace existing authors list with a new list
263
372
  #
264
373
  # @param article_id [Integer] Figshare id of the article
265
- # @param authors [Array] Can be a mix of { id } and/or { name }
374
+ # @param authors [Array] Can be a mix of [{ id: 1234 } and/or { name: "x y" }]
266
375
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
267
376
  def authors_replace(article_id:, authors:, impersonate: nil, &block)
268
377
  args = {}
@@ -285,7 +394,7 @@ module Figshare
285
394
  #
286
395
  # @param article_id [Integer] Figshare id of the article
287
396
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
288
- # yield [Hash] { parent_id, id, title }
397
+ # yield [Hash] { parent_id, id, title, path, source_id, taxonomy_id }
289
398
  def categories(article_id:, impersonate: nil, &block)
290
399
  args = {}
291
400
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -330,7 +439,7 @@ module Figshare
330
439
  #
331
440
  # @param article_id [Integer] Figshare id of the article
332
441
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
333
- # @yield [Hash] {id, is_active, expires_date}
442
+ # @yield [Hash] {id, is_active, expires_date, html_location}
334
443
  def links(article_id:, impersonate: nil, &block)
335
444
  args = {}
336
445
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -340,13 +449,17 @@ module Figshare
340
449
  # Create new private link for this article
341
450
  #
342
451
  # @param article_id [Integer] Figshare id of the article
343
- # @param private_link [Hash] { expires_date }
452
+ # @param expires_date [Time]
453
+ # @param read_only [Boolean]
344
454
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
345
- # @yield [Hash] { location }
346
- def link_create(article_id:, private_link:, impersonate: nil, &block)
455
+ # @yield [Hash] { location:, html_location:, token: }
456
+ def link_create(article_id:, expires_date: nil, read_only: true, impersonate: nil, &block)
347
457
  args = {}
348
458
  args['impersonate'] = impersonate unless impersonate.nil?
349
- post(api_query: "account/articles/#{article_id}/private_links", data: private_link, args: args, &block)
459
+ link_properties = {}
460
+ link_properties['expires_date'] = expires_date.iso8601 unless expires_date.nil?
461
+ link_properties['read_only'] = read_only unless read_only.nil?
462
+ post(api_query: "account/articles/#{article_id}/private_links", data: link_properties, args: args, &block)
350
463
  end
351
464
 
352
465
  # Disable/delete private link for this article
@@ -364,11 +477,15 @@ module Figshare
364
477
  #
365
478
  # @param article_id [Integer] Figshare id of the article
366
479
  # @param expires_date [Time]
480
+ # @param read_only [Boolean]
367
481
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
368
- def link_update(article_id:, link_id:, expires_date:, impersonate: nil, &block)
482
+ def link_update(article_id:, link_id:, expires_date: nil, read_only: nil, impersonate: nil, &block)
369
483
  args = {}
370
484
  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)
485
+ link_properties = {}
486
+ link_properties['expires_date'] = expires_date.iso8601 unless expires_date.nil?
487
+ link_properties['read_only'] = read_only unless read_only.nil?
488
+ put(api_query: "account/articles/#{article_id}/private_links/#{link_id}", args: args, data: link_properties, &block)
372
489
  end
373
490
 
374
491
  # List private files in an article
@@ -6,13 +6,29 @@ module Figshare
6
6
  #
7
7
  # @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
8
8
  # @param order_direction [String] "desc" Default, "asc"
9
+ # @param page [Numeric] Pages start at 1. Page and Page size go together
10
+ # @param page_size [Numeric]
11
+ # @param offset [Numeric] offset is 0 based. Offset and Limit go together
12
+ # @param limit [Numeric]
9
13
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
10
- # @yield [Hash] {id, title, doi, handle, url, published_date}
11
- def list(order: 'published_date', order_direction: 'desc', impersonate: nil, &block)
14
+ # @yield [Hash] {id, title, doi, handle, url, timeline: {...}, published_date} see docs.figshare.com
15
+ def list( order: 'published_date',
16
+ order_direction: 'desc',
17
+ page: nil,
18
+ page_size: nil,
19
+ offset: nil,
20
+ limit: nil,
21
+ impersonate: nil,
22
+ &block
23
+ )
12
24
  args = {}
13
25
  args['impersonate'] = impersonate unless impersonate.nil?
14
26
  args['order'] = order unless order.nil?
15
27
  args['order_direction'] = order_direction unless order_direction.nil?
28
+ args['page'] = page unless page.nil?
29
+ args['page_size'] = page_size unless page_size.nil?
30
+ args['offset'] = offset unless offset.nil?
31
+ args['limit'] = limit unless limit.nil?
16
32
  get_paginate(api_query: 'account/collections', args: args, &block)
17
33
  end
18
34
 
@@ -22,11 +38,16 @@ module Figshare
22
38
  # @param group_id [Integer] Only return this group's collections
23
39
  # @param published_since [Time] Return results if published after this time
24
40
  # @param modified_since [Time] Return results if modified after this time
41
+ # @param resource_id [String] Matches this resource id
25
42
  # @param resource_doi [String] Matches this resource doi
26
43
  # @param doi [String] Matches this doi
27
44
  # @param handle [String] Matches this handle
28
45
  # @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
29
46
  # @param order_direction [String] "desc" Default, "asc"
47
+ # @param page [Numeric] Pages start at 1. Page and Page size go together
48
+ # @param page_size [Numeric]
49
+ # @param offset [Numeric] offset is 0 based. Offset and Limit go together
50
+ # @param limit [Numeric]
30
51
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
31
52
  # @yield [Hash] {id, title, doi, handle, url, published_date}
32
53
  def search( search_for:,
@@ -35,17 +56,23 @@ module Figshare
35
56
  impersonate: nil,
36
57
  published_since: nil,
37
58
  modified_since: nil,
59
+ resource_id: nil,
38
60
  resource_doi: nil,
39
61
  doi: nil,
40
62
  handle: nil,
41
63
  order: 'published_date',
42
64
  order_direction: 'desc',
65
+ page: nil,
66
+ page_size: nil,
67
+ offset: nil,
68
+ limit: nil,
43
69
  &block
44
70
  )
45
71
  args = { 'search_for' => search_for }
46
72
  args['impersonate'] = impersonate unless impersonate.nil?
47
73
  args['institution'] = @institute_id unless institute.nil?
48
- args['group_id'] = group_id unless group_id.nil?
74
+ args['group'] = group_id unless group_id.nil?
75
+ args['resource_id'] = resource_id unless resource_id.nil?
49
76
  args['resource_doi'] = resource_doi unless resource_doi.nil?
50
77
  args['doi'] = doi unless doi.nil?
51
78
  args['handle'] = handle unless handle.nil?
@@ -53,7 +80,11 @@ module Figshare
53
80
  args['modified_since'] = modified_since unless modified_since.nil?
54
81
  args['order'] = order unless order.nil?
55
82
  args['order_direction'] = order_direction unless order_direction.nil?
56
- post(api_query: 'account/collections/search', args: args, &block)
83
+ args['page'] = page unless page.nil?
84
+ args['page_size'] = page_size unless page_size.nil?
85
+ args['offset'] = offset unless offset.nil?
86
+ args['limit'] = limit unless limit.nil?
87
+ post_paginate(api_query: 'account/collections/search', args: args, &block)
57
88
  end
58
89
 
59
90
  # Create a new private Collection by sending collection information
@@ -73,7 +104,7 @@ module Figshare
73
104
  def collection_delete(collection_id:, impersonate: nil, &block)
74
105
  args = {}
75
106
  args['impersonate'] = impersonate unless impersonate.nil?
76
- delete( api_query: "account/collections/#{collection_id}/files/#{file_id}", args: args, &block )
107
+ delete( api_query: "account/collections/#{collection_id}", args: args, &block )
77
108
  end
78
109
 
79
110
  # Return details of specific collection (default version)
@@ -120,6 +151,29 @@ module Figshare
120
151
  post(api_query: "account/collections/#{collection_id}/reserve_handle", args: args, &block)
121
152
  end
122
153
 
154
+ # Collection Resource
155
+ #
156
+ # @param collection_id [Integer]
157
+ # @param id [Integer]
158
+ # @param title [String]
159
+ # @param doi [String]
160
+ # @param link [String]
161
+ # @param status [String] 'frozen', ...
162
+ # @param version [Integer]
163
+ # @yield [Hash] { location: "string" }
164
+ def collection_resource(collection_id:, title:, id: nil, doi: nil, link: nil, status: nil, version: nil, impersonate: nil, &block)
165
+ args = {}
166
+ args['impersonate'] = impersonate unless impersonate.nil?
167
+ resource = {}
168
+ resource['title'] = title
169
+ resource['id'] = id unless id.nil?
170
+ resource['doi'] = doi unless doi.nil?
171
+ resource['link'] = link unless link.nil?
172
+ resource['status'] = status unless status.nil?
173
+ resource['version'] = version unless version.nil?
174
+ post(api_query: "account/collections/#{collection_id}/resource", args: args, data: resource, &block)
175
+ end
176
+
123
177
  # When a collection is published, a new public version will be generated.
124
178
  # Any further updates to the collection will affect the private collection data.
125
179
  # In order to make these changes publicly visible, an explicit publish operation is needed.
@@ -138,7 +192,7 @@ module Figshare
138
192
  # @param collection_id [Integer] Figshare id of the collection
139
193
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
140
194
  # @yield [Hash] {id, full_name, is_active, url_name, orcid_id}
141
- def authors(_article_id, impersonate: nil, &block)
195
+ def authors(collection_id:, impersonate: nil, &block)
142
196
  args = {}
143
197
  args['impersonate'] = impersonate unless impersonate.nil?
144
198
  get(api_query: "account/collections/#{collection_id}/authors", args: args, &block)
@@ -150,7 +204,7 @@ module Figshare
150
204
  # @param authors [Array] Can be a mix of { id } and/or { name }
151
205
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
152
206
  # @yield [Hash] { location }
153
- def authors_add(_article_id, authors:, impersonate: nil)
207
+ def authors_add(collection_id:, authors:, impersonate: nil)
154
208
  args = {}
155
209
  args['impersonate'] = impersonate unless impersonate.nil?
156
210
  post(api_query: "account/collections/#{collection_id}/authors", args: args, data: { 'authors' => authors }, &block)
@@ -161,7 +215,7 @@ module Figshare
161
215
  # @param collection_id [Integer] Figshare id of the collection
162
216
  # @param authors [Array] Can be a mix of { id } and/or { name }
163
217
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
164
- def authors_replace(_article_id, authors:, impersonate: nil)
218
+ def authors_replace(collection_id:, authors:, impersonate: nil)
165
219
  args = {}
166
220
  args['impersonate'] = impersonate unless impersonate.nil?
167
221
  put(api_query: "account/collections/#{collection_id}/authors", args: args, data: { 'authors' => authors }, &block)
@@ -182,7 +236,7 @@ module Figshare
182
236
  #
183
237
  # @param collection_id [Integer] Figshare id of the collection
184
238
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
185
- # @yield [Hash] {parent_id, id, title}
239
+ # @yield [Hash] {parent_id, id, title, path, source_id, taxonomy_id}
186
240
  def categories(collection_id:, impersonate: nil, &block)
187
241
  args = {}
188
242
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -265,7 +319,7 @@ module Figshare
265
319
  def articles_replace(collection_id:, articles:, impersonate: nil, &block)
266
320
  args = {}
267
321
  args['impersonate'] = impersonate unless impersonate.nil?
268
- put( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, data: { articles: articles }, &block)
322
+ put( api_query: "account/collections/#{collection_id}/articles", args: args, data: { articles: articles }, &block)
269
323
  end
270
324
 
271
325
  # Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
@@ -283,7 +337,7 @@ module Figshare
283
337
  #
284
338
  # @param collection_id [Integer] Figshare id of the collection
285
339
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
286
- # @yield [Hash] {id, is_active, expires_date}
340
+ # @yield [Hash] {id:, is_active:, expires_date:, html_location: }
287
341
  def links(collection_id:, impersonate: nil, &block)
288
342
  args = {}
289
343
  args['impersonate'] = impersonate unless impersonate.nil?
@@ -293,13 +347,17 @@ module Figshare
293
347
  # Create new private link for this collection
294
348
  #
295
349
  # @param collection_id [Integer] Figshare id of the collection
296
- # @param private_link [Hash] { expires_date, read_only }
350
+ # @param expires_date [Time]
351
+ # @param read_only [Boolean]
297
352
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
298
- # @yield [Hash] { location }
299
- def link_create(collection_id:, private_link:, impersonate: nil, &block)
353
+ # @yield [Hash] { location:, html_location:, token: }
354
+ def link_create(collection_id:, expires_date: nil, read_only: true, impersonate: nil, &block)
300
355
  args = {}
301
356
  args['impersonate'] = impersonate unless impersonate.nil?
302
- post(api_query: "account/collections/#{collection_id}/private_links", args: args, data: private_link, &block)
357
+ link_properties = {}
358
+ link_properties['expires_date'] = expires_date.iso8601 unless expires_date.nil?
359
+ link_properties['read_only'] = read_only unless read_only.nil?
360
+ post(api_query: "account/collections/#{collection_id}/private_links", args: args, data: link_properties, &block)
303
361
  end
304
362
 
305
363
  # Disable/delete private link for this collection
@@ -316,12 +374,16 @@ module Figshare
316
374
  # Update private link for this collection
317
375
  #
318
376
  # @param collection_id [Integer] Figshare id of the collection
319
- # @param private_link [Hash] { expires_date, read_only }
377
+ # @param expires_date [Time]
378
+ # @param read_only [Boolean]
320
379
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
321
- def link_update(collection_id:, link_id:, private_link:, impersonate: nil, &block)
380
+ def link_update(collection_id:, link_id:, expires_date: nil, read_only: true, impersonate: nil, &block)
322
381
  args = {}
323
382
  args['impersonate'] = impersonate unless impersonate.nil?
324
- put(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, data: private_link, &block)
383
+ link_properties = {}
384
+ link_properties['expires_date'] = expires_date.iso8601 unless expires_date.nil?
385
+ link_properties['read_only'] = read_only unless read_only.nil?
386
+ put(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, data: link_properties, &block)
325
387
  end
326
388
  end
327
389
  end