Class: Figshare::PrivateArticles
Overview
Figshare private articles API
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
#api_url, #article_index_file, #auth_token, #base_dir, #hostname, #institute_id
Instance Method Summary collapse
-
#article_delete(article_id:, impersonate: nil, &block) ⇒ Object
Delete an article (WARNING!!!!!).
-
#article_resource(article_id:, id:, title:, doi:, link:, status:, version:, impersonate: nil) {|Hash| ... } ⇒ Object
Article Resource.
-
#article_version(article_id:, version_id:, body: nil, impersonate: nil, &block) ⇒ Object
Update Article Version.
-
#article_version_update_thumbnail(article_id:, version_id:, file_id:, impersonate: nil, &block) ⇒ Object
Update Article Thumbnail of a specific version of the article.
-
#author_delete(article_id:, author_id:, impersonate: nil, &block) ⇒ Object
Remove author from the article.
-
#authors(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
Yield articles authors.
-
#authors_add(article_id:, authors:, impersonate: nil, &block) ⇒ Object
Associate new authors with the article.
-
#authors_replace(article_id:, authors:, impersonate: nil, &block) ⇒ Object
Replace existing authors list with a new list.
-
#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.
-
#categories(article_id:, impersonate: nil, &block) ⇒ Object
List categories for a specific article.
-
#categories_add(article_id:, categories:, impersonate: nil, &block) ⇒ Object
Associate new categories with the article.
-
#categories_delete(article_id:, category_id:, impersonate: nil, &block) ⇒ Object
Delete category from article’s categories.
-
#categories_replace(article_id:, categories:, impersonate: nil, &block) ⇒ Object
Associate new categories with the article.
-
#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.
-
#delete_all_files(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
WARNING!!!! Delete every file in an article.
-
#detail(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
Get a private article’s details.
-
#embargo_delete(article_id:, impersonate: nil, &block) ⇒ Object
Will lift the embargo for the specified article.
-
#embargo_detail(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
Get a private article embargo details.
-
#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.
-
#file_delete(article_id:, file_id:, impersonate: nil, &block) ⇒ Object
Delete a file from an article.
-
#file_detail(article_id:, file_id:, impersonate: nil) {|Hash| ... } ⇒ Object
Single file detail.
-
#files(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
List private files in an article.
-
#link_create(article_id:, expires_date: nil, read_only: true, impersonate: nil) {|Hash| ... } ⇒ Object
Create new private link for this article.
-
#link_delete(article_id:, link_id:, impersonate: nil, &block) ⇒ Object
Disable/delete private link for this article.
-
#link_update(article_id:, link_id:, expires_date: nil, read_only: nil, impersonate: nil, &block) ⇒ Object
Update private link for this article.
-
#links(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
List private links.
-
#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).
-
#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.
-
#reserve_doi(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
Reserve DOI for article.
-
#reserve_handle(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
Reserve Handle for article.
-
#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).
-
#update(article_id:, body:, impersonate: nil, &block) ⇒ Object
Updating an article by passing body parameters.
Methods inherited from Base
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!!!!!)
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
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
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
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
397 398 399 400 401 |
# File 'lib/private_articles.rb', line 397 def (article_id:, author_id:, impersonate: nil, &block) args = {} args['impersonate'] = impersonate unless impersonate.nil? delete(api_query: "account/articles/#{article_id}/authors/#{}", args: args, &block) end |
#authors(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
Yield articles authors
364 365 366 367 368 |
# File 'lib/private_articles.rb', line 364 def (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
375 376 377 378 379 |
# File 'lib/private_articles.rb', line 375 def (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' => }, &block) end |
#authors_replace(article_id:, authors:, impersonate: nil, &block) ⇒ Object
Replace existing authors list with a new list
386 387 388 389 390 |
# File 'lib/private_articles.rb', line 386 def (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' => }, &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
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'] = unless .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? = [] if .instance_of?(Array) .each do || << if .instance_of?(Hash) else { 'name' => } end end end body_['authors'] = 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 }
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
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
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
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
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
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
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
217 218 219 220 221 |
# File 'lib/private_articles.rb', line 217 def (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
228 229 230 231 232 |
# File 'lib/private_articles.rb', line 228 def (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.
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 ( 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? = { 'is_embargoed' => , 'embargo_date' => .strftime('%Y-%m-%dT%H:%M:%S'), 'embargo_type' => , 'embargo_title' => , 'embargo_reason' => , 'embargo_options' => } put(api_query: "account/articles/#{article_id}/embargo", args: args, data: , &block) end |
#file_delete(article_id:, file_id:, impersonate: nil, &block) ⇒ Object
Delete a file from an article
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
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
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 |
#link_create(article_id:, expires_date: nil, read_only: true, impersonate: nil) {|Hash| ... } ⇒ Object
Create new private link for this article
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 |
#link_delete(article_id:, link_id:, impersonate: nil, &block) ⇒ Object
Disable/delete private link for this article
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 |
#link_update(article_id:, link_id:, expires_date: nil, read_only: nil, impersonate: nil, &block) ⇒ Object
Update private link for this article
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 |
#links(article_id:, impersonate: nil) {|Hash| ... } ⇒ Object
List private links
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)
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.
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
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
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)
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
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 |