class Figshare::PrivateArticles

Figshare private articles API

Public Instance Methods

article_delete(article_id:, impersonate: nil, &block) click to toggle source

Delete an article (WARNING!!!!!)

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 113
def article_delete(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: "account/articles/#{article_id}",  args: args, &block)
end
author_delete(article_id:, author_id:, impersonate: nil, &block) click to toggle source

Remove author from the article

@param article_id [Integer] Figshare id of the article @param author_id [Integer] Figshare id for the author @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 254
def author_delete(article_id:, author_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: "account/articles/#{article_id}/authors/#{author_id}", args: args, &block)
end
authors(article_id, impersonate: nil, &block) click to toggle source

Yield articles authors

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] {id, full_name, is_active, url_name, orcid_id}

# File lib/private_articles.rb, line 221
def authors(article_id, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/articles/#{article_id}/authors", args: args, &block)
end
authors_add(article_id:, authors:, impersonate: nil, &block) click to toggle source

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

@param article_id [Integer] Figshare id of the article @param authors [Array] Can be a mix of { id } and/or { name } @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 232
def authors_add(article_id:, authors:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! 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) click to toggle source

Replace existing authors list with a new list

@param article_id [Integer] Figshare id of the article @param authors [Array] Can be a mix of { id } and/or { name } @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 243
def authors_replace(article_id:, authors:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  put(api_query: "account/articles/#{article_id}/authors", args: args, data: {"authors" => authors}, &block)
end
body(title:, description: nil, keywords: nil, references: nil, categories: nil, authors: nil, custom_fields: 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) click to toggle source

Create a body for use with create and update methods

@param title [String] Required @param description [String] The article description. In a publisher case, usually this is the remote article description @param keywords [Array] List of tags (strings) to be associated with the article. Tags can be used instead @param references [Array] List of links to be associated with the article (e.g [“link1”, “link2”, “link3”]) @param categories [Array] List of category ids to be associated with the article(e.g [1, 23, 33, 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 } @param custom_fields [Hash] List of key, values pairs to be associated with the article. eg. { “key” => “value”} @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” @param funding [String] Grant number or funding authority @param funding_list [Array] Funding creation / update items. eg {“id” => 0, “title” => “string”} @param license [Integer] License id for this article. @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. @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. @param resource_doi [String] Not applicable to regular users. In a publisher case, this is the publisher article DOI. @param resource_title [String] Not applicable to regular users. In a publisher case, this is the publisher article title. @param timeline [Hash] Various timeline dates ie. { “firstOnline” => “date_string”, “publisherPublication” => “date_string”, “publisherAcceptance” => “date_string”}, @param group_id [Integer] Not applicable to regular users. This field is reserved to institutions/publishers with access to assign to specific groups

# File lib/private_articles.rb, line 73
def body(title:, description: nil, keywords: nil, references: nil, categories: nil, authors: nil, custom_fields: 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['keywords'] = keywords unless keywords.nil? 
  _body['references'] = references unless references.nil? 
  _body['categories'] = categories unless categories.nil? 
  _body['authors'] = authors unless authors.nil? 
  _body['custom_fields'] = custom_fields unless custom_fields.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?
  
  return _body
end
categories(article_id:, impersonate: nil, &block) click to toggle source

List categories for a specific article

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of yield [Hash] { parent_id, id, title }

# File lib/private_articles.rb, line 265
def categories(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/articles/#{article_id}/categories",  args: args, &block)
end
categories_add(article_id:, categories:, impersonate: nil, &block) click to toggle source

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

@param article_id [Integer] Figshare id of the article @param categories [Array] [ categorie_id, … ] @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 277
def categories_add(article_id:, categories:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! 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) click to toggle source

Delete category from article's categories

@param article_id [Integer] Figshare id of the article @param category_id [Integer] Figshare id of the category @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 299
def categories_delete(article_id:, category_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: "account/articles/#{article_id}/categories/#{category_id}", args: args, &block)
end
categories_replace(article_id:, categories:, impersonate: nil, &block) click to toggle source

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

@param article_id [Integer] Figshare id of the article @param categories [Array] [ categorie_id, … ] @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 288
def categories_replace(article_id:, categories:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  put(api_query: "account/articles/#{article_id}/categories", args: args, data: { 'categories' => categories }, &block)
end
create(body:, impersonate: nil, &block) click to toggle source

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

@param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] { location }

# File lib/private_articles.rb, line 103
def create(body:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  post(api_query: "account/articles", args: args, data: body, &block)
end
delete_all_files(article_id:, impersonate: nil) { |f| ... } click to toggle source

WARNING!!!! Delete every file in an article

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] Figshare file record of each file being deleted (if block_given?)

# File lib/private_articles.rb, line 391
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, &block) click to toggle source

Get a private article's details

@param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @param article_id [Integer] Figshare id of the article

# File lib/private_articles.rb, line 123
def detail(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/articles/#{article_id}",  args: args, &block)
end
embargo_delete(article_id:, impersonate: nil, &block) click to toggle source

Will lift the embargo for the specified article

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 144
def embargo_delete(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: "account/articles/#{article_id}/embargo", args: args, &block)
end
embargo_detail(article_id:, impersonate: nil, &block) click to toggle source

Get a private article embargo details

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] {is_embargoed, embargo_date, embargo_reason}

# File lib/private_articles.rb, line 155
def embargo_detail(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/articles/#{article_id}/embargo", args: args, &block)
end
embargo_update(article_id:, is_embargoed: true, embargo_date: , embargo_type: 'file', embargo_reason:, impersonate: nil, &block) click to toggle source

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.

@param article_id [Integer] Figshare id of the article @param is_embargoed [Boolean] @param embargo_data [Time] Still needs to be published, after this date @param embargo_type [Integer] @param embargo_reason [String] @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 171
def embargo_update(article_id:, is_embargoed: true, embargo_date: , embargo_type: 'file', embargo_reason:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  embargo_record = {"is_embargoed" => is_embargoed,
                    "embargo_date" => embargo_date.strftime("%Y-%m-%dT%H:%M:%S"),
                    "embargo_type" => embargo_type,
                    "embargo_reason" => embargo_reason
                  }
  put(api_query: "account/articles/#{article_id}/embargo", args: args, data: embargo_record, &block)
end
file_delete(article_id:, file_id: , impersonate: nil, &block) click to toggle source

Delete a file from an article

@param article_id [Integer] Figshare id of the article @param file_id [Integer] Figshare id of the file @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 380
def file_delete(article_id:, file_id: , impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete( api_query: "account/articles/#{article_id}/files/#{file_id}", args: args, &block )
end
file_detail(article_id:, file_id:, impersonate: nil, &block) click to toggle source

Single file detail

@param article_id [Integer] Figshare id of the article @param file_id [Integer] Figshare id of the file @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] {status, viewer_type, preview_state, upload_url, upload_token, id, name, size, is_link_only, download_url, supplied_md5, computed_md5}

# File lib/private_articles.rb, line 369
def file_detail(article_id:, file_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/articles/#{article_id}/files/#{file_id}", args: args, &block)
end
files(article_id:, impersonate: nil, &block) click to toggle source

List private files in an article

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] {status, viewer_type, preview_state, upload_url, upload_token, id, name, size, is_link_only, download_url, supplied_md5, computed_md5}

# File lib/private_articles.rb, line 356
def files(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/articles/#{article_id}/files", args: args, &block)
end
list(impersonate: nil, &block) click to toggle source

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

@param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] {id, title, doi, handle, url, published_date}

# File lib/private_articles.rb, line 11
def list(impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get_paginate(api_query: 'account/articles', args: args, &block)
end
publish(article_id:, impersonate: nil, &block) click to toggle source

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.

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 190
def publish(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  post(api_query: "account/articles/#{article_id}/publish", args: args, &block)
end
reserve_doi(article_id:, impersonate: nil, &block) click to toggle source

Reserve DOI for article

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 200
def reserve_doi(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  post(api_query: "account/articles/#{article_id}/reserve_doi", args: args, &block)
end
reserve_handle(article_id:, impersonate: nil, &block) click to toggle source

Reserve Handle for article

@param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 210
def reserve_handle(article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  post(api_query: "account/articles/#{article_id}/reserve_handle", args: args, &block)
end
update(article_id:, body:, impersonate: nil, &block) click to toggle source

Updating an article by passing body parameters

@param article_id [Integer] Figshare id of the article @param body [Hash] See API docs. @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_articles.rb, line 134
def update(article_id:, body:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  put(api_query: "account/articles/#{article_id}", args: args, data: body, &block)
end