Class: Figshare::PrivateArticles

Inherits:
Base
  • Object
show all
Defined in:
lib/private_articles.rb

Overview

Figshare private articles API

Direct Known Subclasses

Upload

Instance Attribute Summary

Attributes inherited from Base

#api_url, #article_index_file, #auth_token, #base_dir, #hostname, #institute_id

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Figshare::Base

Instance Method Details

#article_delete(article_id:, impersonate: nil, &block) ⇒ Object

Delete an article (WARNING!!!!!)

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



185
186
187
188
189
# File 'lib/private_articles.rb', line 185

def article_delete(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  delete(api_query: "account/articles/#{article_id}", args: args, &block)
end

#article_resource(article_id:, id:, title:, doi:, link:, status:, version:, impersonate: nil) {|Hash| ... } ⇒ Object

Article Resource

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • resource (Hash)
  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    “string”



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/private_articles.rb', line 272

def article_resource( article_id:,
                      id:,
                      title:,
                      doi:,
                      link:,
                      status:,
                      version:,
                      impersonate: nil,
                      &block
                    )
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  resource_record = {
    'id' => id,
    'title' => title,
    'doi' => doi,
    'link' => link,
    'status' => status,
    'version' => version
  }
  post(api_query: "account/articles/#{article_id}/resource", args: args, data: resource_record, &block)
end

#article_version(article_id:, version_id:, body: nil, impersonate: nil, &block) ⇒ Object

Update Article Version

Parameters:

  • article_id (Integer)
  • version_id (Interger)
  • body (Hash) (defaults to: nil)

    Update fields, rather than overwrite article metadata. see docs.figshare.com



337
338
339
340
341
342
343
344
345
# File 'lib/private_articles.rb', line 337

def article_version(article_id:, version_id:, body: nil, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  if body.nil?
    put(api_query: "account/articles/#{article_id}/versions/#{version_id}/", args: args, &block)
  else
    patch(api_query: "account/articles/#{article_id}/versions/#{version_id}/", args: args, data: body, &block)
  end
end

#article_version_update_thumbnail(article_id:, version_id:, file_id:, impersonate: nil, &block) ⇒ Object

Update Article Thumbnail of a specific version of the article

Parameters:

  • article_id (Integer)
  • version_id (Interger)
  • file_id (integer)

    File id of one of the articles files, to use as a thumbnail. see docs.figshare.com



352
353
354
355
356
357
# File 'lib/private_articles.rb', line 352

def article_version_update_thumbnail(article_id:, version_id:, file_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  args['file_id'] = file_id
  put(api_query: "account/articles/#{article_id}/versions/#{version_id}/update_thumb", args: args, &block)
end

#author_delete(article_id:, author_id:, impersonate: nil, &block) ⇒ Object

Remove author from the article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • author_id (Integer)

    Figshare id for the author

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



397
398
399
400
401
# File 'lib/private_articles.rb', line 397

def author_delete(article_id:, author_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  delete(api_query: "account/articles/#{article_id}/authors/#{author_id}", args: args, &block)
end

#authors(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Yield articles authors

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    [full_name, is_active, url_name, orcid_id]



364
365
366
367
368
# File 'lib/private_articles.rb', line 364

def authors(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  get(api_query: "account/articles/#{article_id}/authors", args: args, &block)
end

#authors_add(article_id:, authors:, impersonate: nil, &block) ⇒ Object

Associate new authors with the article. This will add new authors to the list of already associated authors

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • authors (Array)

    Can be a mix of [{ id: 1234 } and/or { name: “x y” }]

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



375
376
377
378
379
# File 'lib/private_articles.rb', line 375

def authors_add(article_id:, authors:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  post(api_query: "account/articles/#{article_id}/authors", args: args, data: { 'authors' => authors }, &block)
end

#authors_replace(article_id:, authors:, impersonate: nil, &block) ⇒ Object

Replace existing authors list with a new list

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • authors (Array)

    Can be a mix of [{ id: 1234 } and/or { name: “x y” }]

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



386
387
388
389
390
# File 'lib/private_articles.rb', line 386

def authors_replace(article_id:, authors:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  put(api_query: "account/articles/#{article_id}/authors", args: args, data: { 'authors' => authors }, &block)
end

#body(title:, description: nil, tags: nil, keywords: nil, references: nil, categories: nil, categories_by_source_id: nil, authors: nil, custom_fields: nil, custom_fields_list: nil, defined_type: nil, funding: nil, funding_list: nil, license: nil, doi: nil, handle: nil, resource_doi: nil, resource_title: nil, timeline: nil, group_id: nil, contact: nil) ⇒ Object

Create a body for use with create and update methods

Parameters:

  • title (String)

    Required

  • description (String) (defaults to: nil)

    The article description. In a publisher case, usually this is the remote article description

  • tags (Array) (defaults to: nil)

    List of tags (strings) to be associated with the article. Tags can be used instead

  • keywords (Array) (defaults to: nil)

    List of tags (strings) to be associated with the article. Tags can be used instead

  • references (Array) (defaults to: nil)

    List of links to be associated with the article (e.g [“http://link1”, “http://link2”, “http://link3”])

  • categories (Array) (defaults to: nil)

    List of category ids to be associated with the article(e.g [1, 23, 33, 66])

  • categories_by_source_id (Array) (defaults to: nil)

    List of category ids to be associated with the article(e.g [“300204”, “400207”])

  • authors (Array) (defaults to: nil)

    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 }

  • custom_fields (Hash) (defaults to: nil)

    List of key, values pairs to be associated with the article. eg. { “key” => “value”}

  • custom_fields_list (Array) (defaults to: nil)

    List of key, values pairs to be associated with the article. eg. [{ “key” => “value”}]

  • defined_type (String) (defaults to: nil)

    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”

  • funding (String) (defaults to: nil)

    Grant number or funding authority

  • funding_list (Array) (defaults to: nil)

    Funding creation / update items. eg => 0, “title” => “string”

  • license (Integer) (defaults to: nil)

    License id for this article.

  • doi (String) (defaults to: nil)

    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.

  • handle (String) (defaults to: nil)

    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.

  • resource_doi (String) (defaults to: nil)

    Not applicable to regular users. In a publisher case, this is the publisher article DOI.

  • resource_title (String) (defaults to: nil)

    Not applicable to regular users. In a publisher case, this is the publisher article title.

  • timeline (Hash) (defaults to: nil)

    Various timeline dates ie. { “firstOnline” => “date_string”, “publisherPublication” => “date_string”, “publisherAcceptance” => “date_string”},

  • group_id (Integer) (defaults to: nil)

    Not applicable to regular users. This field is reserved to institutions/publishers with access to assign to specific groups



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/private_articles.rb', line 110

def body( title:,
          description: nil,
          tags: nil,
          keywords: nil,
          references: nil,
          categories: nil,
          categories_by_source_id: nil,
          authors: nil,
          custom_fields: nil,
          custom_fields_list: nil,
          defined_type: nil,
          funding: nil,
          funding_list: nil,
          license: nil,
          doi: nil,
          handle: nil,
          resource_doi: nil,
          resource_title: nil,
          timeline: nil,
          group_id: nil,
          contact: nil
        )
  body_ = {
    'title' => title
  }
  body_['description'] = description unless description.nil?
  body_['tags'] = tags unless tags.nil?
  body_['keywords'] = keywords unless keywords.nil?
  body_['references'] = references unless references.nil?
  body_['categories'] = categories unless categories.nil?
  body_['categories_by_source_id'] = categories_by_source_id unless categories_by_source_id.nil?
  authors_array = []
  if authors.instance_of?(Array)
    authors.each do |author|
      authors_array << if author.instance_of?(Hash)
                         author
                       else
                         { 'name' => author }
                       end
    end
  end
  body_['authors'] = authors_array
  body_['custom_fields'] = custom_fields unless custom_fields.nil?
  body_['custom_fields_list'] = custom_fields_list unless custom_fields_list.nil?
  body_['defined_type'] = defined_type unless defined_type.nil?
  body_['funding'] = funding unless funding.nil?
  body_['funding_list'] = funding_list unless funding_list.nil?
  body_['license'] = license unless license.nil?
  body_['doi'] = doi unless doi.nil?
  body_['handle'] = handle unless handle.nil?
  body_['resource_doi'] = resource_doi unless resource_doi.nil?
  body_['resource_title'] = resource_title unless resource_title.nil?
  body_['timeline'] = timeline unless timeline.nil?
  body_['group_id'] = group_id unless group_id.nil?
  body_['contact'] = contact unless contact.nil?

  return body_
end

#categories(article_id:, impersonate: nil, &block) ⇒ Object

List categories for a specific article

yield [Hash] { parent_id, id, title, path, source_id, taxonomy_id }

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



408
409
410
411
412
# File 'lib/private_articles.rb', line 408

def categories(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  get(api_query: "account/articles/#{article_id}/categories", args: args, &block)
end

#categories_add(article_id:, categories:, impersonate: nil, &block) ⇒ Object

Associate new categories with the article. This will add new categories to the list of already associated categories

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • categories (Array)

    [ categorie_id, … ]

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



420
421
422
423
424
# File 'lib/private_articles.rb', line 420

def categories_add(article_id:, categories:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  post(api_query: "account/articles/#{article_id}/categories", args: args, data: { 'categories' => categories }, &block)
end

#categories_delete(article_id:, category_id:, impersonate: nil, &block) ⇒ Object

Delete category from article’s categories

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • category_id (Integer)

    Figshare id of the category

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



442
443
444
445
446
# File 'lib/private_articles.rb', line 442

def categories_delete(article_id:, category_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  delete(api_query: "account/articles/#{article_id}/categories/#{category_id}", args: args, &block)
end

#categories_replace(article_id:, categories:, impersonate: nil, &block) ⇒ Object

Associate new categories with the article. This will remove all already associated categories and add these new ones

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • categories (Array)

    [ categorie_id, … ]

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



431
432
433
434
435
# File 'lib/private_articles.rb', line 431

def categories_replace(article_id:, categories:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  put(api_query: "account/articles/#{article_id}/categories", args: args, data: { 'categories' => categories }, &block)
end

#create(body:, impersonate: nil) {|Hash| ... } ⇒ Object

Create a new Article by sending article information The user calling the API (or impersonated user) looks to be added as an author, even if they aren’t. A duplicate “Author” entry occurs when adding them explicitly

Parameters:

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    { entity_id:, location:, warnings: [ “string”] }



175
176
177
178
179
# File 'lib/private_articles.rb', line 175

def create(body:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  post(api_query: 'account/articles', args: args, data: body, &block)
end

#delete_all_files(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object

WARNING!!!! Delete every file in an article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    Figshare file record of each file being deleted (if block_given?)



542
543
544
545
546
547
# File 'lib/private_articles.rb', line 542

def delete_all_files(article_id:, impersonate: nil)
  article_files(article_id: article_id, impersonate: impersonate) do |f|
    yield f if block_given?
    article_file_delete(article_id: article_id, file_id: f['id'], impersonate: impersonate)
  end
end

#detail(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Get a private article’s details

Parameters:

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

  • article_id (Integer)

    Figshare id of the article

Yields:

  • (Hash)

    See docs.figshare.com



196
197
198
199
200
# File 'lib/private_articles.rb', line 196

def detail(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  get(api_query: "account/articles/#{article_id}", args: args, &block)
end

#embargo_delete(article_id:, impersonate: nil, &block) ⇒ Object

Will lift the embargo for the specified article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



217
218
219
220
221
# File 'lib/private_articles.rb', line 217

def embargo_delete(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  delete(api_query: "account/articles/#{article_id}/embargo", args: args, &block)
end

#embargo_detail(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Get a private article embargo details

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    embargo_date, embargo_title, embargo_reason, embargo_options [{…] }



228
229
230
231
232
# File 'lib/private_articles.rb', line 228

def embargo_detail(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  get(api_query: "account/articles/#{article_id}/embargo", args: args, &block)
end

#embargo_update(article_id:, embargo_date:, embargo_title:, embargo_reason:, is_embargoed: true, embargo_type: 'file', embargo_options: [], impersonate: nil, &block) ⇒ Object

Updates an article embargo status. Does not imply that the article will be published when the embargo will expire. You must explicitly call the publish endpoint to enable this functionality.

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • is_embargoed (Boolean) (defaults to: true)
  • embargo_date (Time)

    Still needs to be published, after this date

  • embargo_type (Integer) (defaults to: 'file')
  • embargo_title (String)
  • embargo_reason (String)
  • embargo_options (Array) (defaults to: [])
  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/private_articles.rb', line 246

def embargo_update( article_id:,
                    embargo_date:, embargo_title:, embargo_reason:,
                    is_embargoed: true,
                    embargo_type: 'file',
                    embargo_options: [],
                    impersonate: nil,
                    &block
)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  embargo_record = { 'is_embargoed' => is_embargoed,
                     'embargo_date' => embargo_date.strftime('%Y-%m-%dT%H:%M:%S'),
                     'embargo_type' => embargo_type,
                     'embargo_title' => embargo_title,
                     'embargo_reason' => embargo_reason,
                     'embargo_options' => embargo_options
                   }
  put(api_query: "account/articles/#{article_id}/embargo", args: args, data: embargo_record, &block)
end

#file_delete(article_id:, file_id:, impersonate: nil, &block) ⇒ Object

Delete a file from an article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • file_id (Integer)

    Figshare id of the file

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



531
532
533
534
535
# File 'lib/private_articles.rb', line 531

def file_delete(article_id:, file_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  delete( api_query: "account/articles/#{article_id}/files/#{file_id}", args: args, &block )
end

#file_detail(article_id:, file_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Single file detail

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • file_id (Integer)

    Figshare id of the file

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    viewer_type, preview_state, upload_url, upload_token, id, name, size, is_link_only, download_url, supplied_md5, computed_md5



520
521
522
523
524
# File 'lib/private_articles.rb', line 520

def file_detail(article_id:, file_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  get(api_query: "account/articles/#{article_id}/files/#{file_id}", args: args, &block)
end

#files(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object

List private files in an article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    viewer_type, preview_state, upload_url, upload_token, id, name, size, is_link_only, download_url, supplied_md5, computed_md5



507
508
509
510
511
# File 'lib/private_articles.rb', line 507

def files(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  get(api_query: "account/articles/#{article_id}/files", args: args, &block)
end

Create new private link for this article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • expires_date (Time) (defaults to: nil)
  • read_only (Boolean) (defaults to: true)
  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    { location:, html_location:, token: }



466
467
468
469
470
471
472
473
# File 'lib/private_articles.rb', line 466

def link_create(article_id:, expires_date: nil, read_only: true, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  link_properties = {}
  link_properties['expires_date'] = expires_date.iso8601 unless expires_date.nil?
  link_properties['read_only'] = read_only unless read_only.nil?
  post(api_query: "account/articles/#{article_id}/private_links", data: link_properties, args: args, &block)
end

Disable/delete private link for this article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • link_id (Integer)
  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



480
481
482
483
484
# File 'lib/private_articles.rb', line 480

def link_delete(article_id:, link_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  delete(api_query: "account/articles/#{article_id}/private_links/#{link_id}", args: args, &block)
end

Update private link for this article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • expires_date (Time) (defaults to: nil)
  • read_only (Boolean) (defaults to: nil)
  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



492
493
494
495
496
497
498
499
# File 'lib/private_articles.rb', line 492

def link_update(article_id:, link_id:, expires_date: nil, read_only: nil, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  link_properties = {}
  link_properties['expires_date'] = expires_date.iso8601 unless expires_date.nil?
  link_properties['read_only'] = read_only unless read_only.nil?
  put(api_query: "account/articles/#{article_id}/private_links/#{link_id}", args: args, data: link_properties, &block)
end

List private links

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    is_active, expires_date, html_location



453
454
455
456
457
# File 'lib/private_articles.rb', line 453

def links(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  get(api_query: "account/articles/#{article_id}/private_links", args: args, &block)
end

#list(impersonate: nil, page: nil, page_size: nil, offset: nil, limit: nil) {|Array| ... } ⇒ Object

Get Own Articles (or private articles of others if institute is true)

Parameters:

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

  • page (Numeric) (defaults to: nil)

    Pages start at 1. Page and Page size go together

  • page_size (Numeric) (defaults to: nil)
  • offset (Numeric) (defaults to: nil)

    offset is 0 based. Offset and Limit go together

  • limit (Numeric) (defaults to: nil)

Yields:

  • (Array)

    [title, doi, handle, url, published_date, …] See docs.figshare.com



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/private_articles.rb', line 13

def list( impersonate: nil,
          page: nil,
          page_size: nil,
          offset: nil,
          limit: nil,
          &block
        )
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  args['page'] = page unless page.nil?
  args['page_size'] = page_size unless page_size.nil?
  args['offset'] = offset unless offset.nil?
  args['limit'] = limit unless limit.nil?
  get_paginate(api_query: 'account/articles', args: args, &block)
end

#publish(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Publish an article If the whole article is under embargo, it will not be published immediately, but when the embargo expires or is lifted. When an article is published, a new public version will be generated. Any further updates to the article will affect the private article data. In order to make these changes publicly visible, an explicit publish operation is needed.

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    “string”



304
305
306
307
308
# File 'lib/private_articles.rb', line 304

def publish(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  post(api_query: "account/articles/#{article_id}/publish", args: args, &block)
end

#reserve_doi(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Reserve DOI for article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    “string”



315
316
317
318
319
# File 'lib/private_articles.rb', line 315

def reserve_doi(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  post(api_query: "account/articles/#{article_id}/reserve_doi", args: args, &block)
end

#reserve_handle(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Reserve Handle for article

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Hash)

    “string”



326
327
328
329
330
# File 'lib/private_articles.rb', line 326

def reserve_handle(article_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  post(api_query: "account/articles/#{article_id}/reserve_handle", args: args, &block)
end

#search(search_for:, institute: false, group_id: nil, impersonate: nil, published_since: nil, modified_since: nil, item_type: nil, resource_id: nil, resource_doi: nil, doi: nil, handle: nil, order: 'published_date', order_direction: 'desc', page: nil, page_size: nil, offset: nil, limit: nil) {|Array| ... } ⇒ Object

Search within the private articles (our own, or the institutes)

Parameters:

  • institution (Boolean)

    Just our institution

  • group_id (Integer) (defaults to: nil)

    Only return this group’s collections

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

  • published_since (Time) (defaults to: nil)

    Return results if published after this time

  • modified_since (Time) (defaults to: nil)

    Return results if modified after this time

  • resource_id (String) (defaults to: nil)

    Looks like a quoted Integer

  • resource_doi (String) (defaults to: nil)

    Matches this resource doi

  • item_type (String) (defaults to: nil)

    Matches this item_type. See Figshare API docs for list (https://docs.figshare.com/#articles_list)

  • doi (String) (defaults to: nil)

    Matches this doi

  • handle (String) (defaults to: nil)

    Matches this handle

  • order (String) (defaults to: 'published_date')

    “published_date” Default, “modified_date”, “views”, “cites”, “shares”

  • order_direction (String) (defaults to: 'desc')

    “desc” Default, “asc”

  • page (Numeric) (defaults to: nil)

    Pages start at 1. Page and Page size go together

  • page_size (Numeric) (defaults to: nil)
  • offset (Numeric) (defaults to: nil)

    offset is 0 based. Offset and Limit go together

  • limit (Numeric) (defaults to: nil)
  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of

Yields:

  • (Array)

    [title, doi, handle, url, published_date, …] See docs.figshare.com



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/private_articles.rb', line 49

def search( search_for:,
            institute: false,
            group_id: nil,
            impersonate: nil,
            published_since: nil,
            modified_since: nil,
            item_type: nil,
            resource_id: nil,
            resource_doi: nil,
            doi: nil,
            handle: nil,
            order: 'published_date',
            order_direction: 'desc',
            page: nil,
            page_size: nil,
            offset: nil,
            limit: nil,
            &block
          )
  args = { 'search_for' => search_for }
  args['impersonate'] = impersonate unless impersonate.nil?
  args['institution'] = @institute_id.to_i if institute # Inconsistent use. Other calls use institute_id
  args['group'] = group_id unless group_id.nil? # Not sure if this changed from group_id to group
  args['item_type'] = item_type unless item_type.nil?
  args['resource_id'] = resource_id unless resource_id.nil?
  args['resource_doi'] = resource_doi unless resource_doi.nil?
  args['doi'] = doi unless doi.nil?
  args['handle'] = handle unless handle.nil?
  args['published_since'] = published_since unless published_since.nil?
  args['modified_since'] = modified_since unless modified_since.nil?
  args['order'] = order unless order.nil?
  args['order_direction'] = order_direction unless order_direction.nil?
  args['page'] = page unless page.nil?
  args['page_size'] = page_size unless page_size.nil?
  args['offset'] = offset unless offset.nil?
  args['limit'] = limit unless limit.nil?
  post_paginate(api_query: 'account/articles/search', args: args, &block)
end

#update(article_id:, body:, impersonate: nil, &block) ⇒ Object

Updating an article by passing body parameters

Parameters:

  • article_id (Integer)

    Figshare id of the article

  • body (Hash)

    See API docs.

  • impersonate (Integer) (defaults to: nil)

    Figshare account_id of the user we are making this call on behalf of



207
208
209
210
211
# File 'lib/private_articles.rb', line 207

def update(article_id:, body:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  put(api_query: "account/articles/#{article_id}", args: args, data: body, &block)
end