Class: Figshare::PrivateCollections

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

Overview

Figshare Private Collections API

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(collection_id:, article_id:, impersonate: nil, &block) ⇒ Object

Get a private article’s details (Not a figshare API call. Duplicates PrivateArticles:article_detail)

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • 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



426
427
428
429
430
# File 'lib/private_collections.rb', line 426

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

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

Get a private article’s details (Not a figshare API call. Duplicates PrivateArticles:article_detail)

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



381
382
383
384
385
# File 'lib/private_collections.rb', line 381

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

#articles(collection_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Yield collection articles

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    See Figshare API docs



369
370
371
372
373
374
375
# File 'lib/private_collections.rb', line 369

def articles(collection_id:, impersonate: nil, &block)
  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  args['offset'] = 0
  args['limit'] = 100 # Looks to respect this. The default is 10!
  get_paginate(api_query: "account/collections/#{collection_id}/articles", args: args, &block)
end

#articles_add(collection_id:, articles:, impersonate: nil) {|Hash| ... } ⇒ Object

Associate new articles with the collection. This will add new articles to the list of already associated articles

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • articles (Array)

    array of Figshare article ids

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    { location }



393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/private_collections.rb', line 393

def articles_add(collection_id:, articles:, impersonate: nil, &block)
  # Adding articles that are already in the collection causes an error, so we remove the duplicates
  existing_articles = []
  self.articles(collection_id: collection_id, impersonate: impersonate) { |a| existing_articles << a['id'] }
  insert_list = []
  articles.each { |article| insert_list << article unless existing_articles.include?(article) }

  args = {}
  args['impersonate'] = impersonate unless impersonate.nil?
  # There is a 10 article limit, for one add. No idea why
  (0...insert_list.length).step(10) do |offset|
    eor = offset + 10  # end of range
    eor = articles.length if eor > articles.length # Truncate range, if beyond end of the array
    post( api_query: "account/collections/#{collection_id}/articles", args: args, data: { articles: insert_list[offset...eor] }, &block)
  end
end

#articles_replace(collection_id:, articles:, impersonate: nil, &block) ⇒ Object

Get a private article’s details (Not a figshare API call. Duplicates PrivateArticles:article_detail)

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • articles (Array)

    array of Figshare article ids

  • impersonate (Integer) (defaults to: nil)

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



415
416
417
418
419
# File 'lib/private_collections.rb', line 415

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

#author_delete(collection_id:, author_id:, impersonate: nil) ⇒ Object

Remove author from the collection

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • 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



312
313
314
315
316
# File 'lib/private_collections.rb', line 312

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

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

Yield collections authors

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • 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



278
279
280
281
282
# File 'lib/private_collections.rb', line 278

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

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

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

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • authors (Array)

    Can be a mix of { id } and/or { name }

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    { location }



290
291
292
293
294
# File 'lib/private_collections.rb', line 290

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

#authors_replace(collection_id:, authors:, impersonate: nil) ⇒ Object

Replace existing authors list with a new list

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • authors (Array)

    Can be a mix of { id } and/or { name }

  • impersonate (Integer) (defaults to: nil)

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



301
302
303
304
305
# File 'lib/private_collections.rb', line 301

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

#body(title:, description: nil, is_metadata_record: nil, metadata_reason: 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) ⇒ 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



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
168
169
170
171
# File 'lib/private_collections.rb', line 112

def body( title:,
          description: nil,
          is_metadata_record: nil,
          metadata_reason: 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
        )
  body_ = {
    'title' => title
  }
  body_['description'] = description unless description.nil?
  body_['is_metadata_record'] =  unless .nil?
  body_['metadata_reason'] =  unless .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?

  return body_
end

#categories(collection_id:, impersonate: nil) {|Hash| ... } ⇒ Object

Yield collection categories

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    id, title, path, source_id, taxonomy_id



323
324
325
326
327
# File 'lib/private_collections.rb', line 323

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

#categories_add(collection_id:, categories:, impersonate: nil) {|Hash| ... } ⇒ Object

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

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • categories (Array)

    [ categorie_id, … ]

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    { location }



336
337
338
339
340
# File 'lib/private_collections.rb', line 336

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

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

Delete category from collection’s categories

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • 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



358
359
360
361
362
# File 'lib/private_collections.rb', line 358

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

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

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

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • categories (Array)

    [ categorie_id, … ]

  • impersonate (Integer) (defaults to: nil)

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



347
348
349
350
351
# File 'lib/private_collections.rb', line 347

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

#collection_delete(collection_id:, impersonate: nil, &block) ⇒ Object

Delete a private collection

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • impersonate (Integer) (defaults to: nil)

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



187
188
189
190
191
# File 'lib/private_collections.rb', line 187

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

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

Collection Resource

Parameters:

  • collection_id (Integer)
  • id (Integer) (defaults to: nil)
  • title (String)
  • doi (String) (defaults to: nil)
  • link (String) (defaults to: nil)
  • status (String) (defaults to: nil)

    ‘frozen’, …

  • version (Integer) (defaults to: nil)

Yields:

  • (Hash)

    { location: “string” }



247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/private_collections.rb', line 247

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

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

Create a new private Collection by sending collection information

Parameters:

  • body (Hash)

    See Figshare API docs

  • impersonate (Integer) (defaults to: nil)

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



177
178
179
180
181
# File 'lib/private_collections.rb', line 177

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

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

Return details of specific collection (default version)

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    See figshare api docs



198
199
200
201
202
# File 'lib/private_collections.rb', line 198

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

Create new private link for this collection

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • 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: }



450
451
452
453
454
455
456
457
# File 'lib/private_collections.rb', line 450

def link_create(collection_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/collections/#{collection_id}/private_links", args: args, data: link_properties, &block)
end

Disable/delete private link for this collection

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

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

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



464
465
466
467
468
# File 'lib/private_collections.rb', line 464

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

Update private link for this collection

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • 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



476
477
478
479
480
481
482
483
# File 'lib/private_collections.rb', line 476

def link_update(collection_id:, link_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?
  put(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, data: link_properties, &block)
end

List private links

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    {id:, is_active:, expires_date:, html_location: }



437
438
439
440
441
# File 'lib/private_collections.rb', line 437

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

#list(order: 'published_date', order_direction: 'desc', page: nil, page_size: nil, offset: nil, limit: nil, impersonate: nil) {|Hash| ... } ⇒ Object

Requests a list of own (or institute’s) collections

Parameters:

  • 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:

  • (Hash)

    title, doi, handle, url, timeline: {…, published_date} see docs.figshare.com



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/private_collections.rb', line 15

def list( order: 'published_date',
          order_direction: 'desc',
          page: nil,
          page_size: nil,
          offset: nil,
          limit: nil,
          impersonate: nil,
          &block
        )
  args = {}
  args['impersonate'] = impersonate unless impersonate.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?
  get_paginate(api_query: 'account/collections', args: args, &block)
end

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

When a collection is published, a new public version will be generated. Any further updates to the collection will affect the private collection data. In order to make these changes publicly visible, an explicit publish operation is needed.

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    { location }



267
268
269
270
271
# File 'lib/private_collections.rb', line 267

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

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

Reserve DOI for collection

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    { “doi” => “the_doi” }



220
221
222
223
224
# File 'lib/private_collections.rb', line 220

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

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

Reserve Handle for collection

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • impersonate (Integer) (defaults to: nil)

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

Yields:

  • (Hash)

    { handle }



231
232
233
234
235
# File 'lib/private_collections.rb', line 231

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

#search(search_for:, institute: false, group_id: nil, impersonate: nil, published_since: nil, modified_since: 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) {|Hash| ... } ⇒ Object

Search within the own (or institute’s) collections

Parameters:

  • institution (Boolean)

    Just our institution

  • group_id (Integer) (defaults to: nil)

    Only return this group’s collections

  • 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)

    Matches this resource id

  • resource_doi (String) (defaults to: nil)

    Matches this resource doi

  • 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:

  • (Hash)

    title, doi, handle, url, published_date



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
87
88
# File 'lib/private_collections.rb', line 53

def search( search_for:,
            institute: false,
            group_id: nil,
            impersonate: nil,
            published_since: nil,
            modified_since: 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
  args['group'] = group_id unless group_id.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/collections/search', args: args, &block)
end

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

Create a new private Collection by sending collection information

Parameters:

  • collection_id (Integer)

    Figshare id of the collection

  • body (Hash)

    See Figshare API docs

  • impersonate (Integer) (defaults to: nil)

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



209
210
211
212
213
# File 'lib/private_collections.rb', line 209

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