Class: Figshare::Authors

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

Overview

Figshare Author APIs

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

#detail(author_id:) {|Hash| ... } ⇒ Object

Get an authors details

Parameters:

  • author_id (Integer)

    Figshare Author ID

Yields:

  • (Hash)

    first_name, last_name, full_name, url_name, is_active, is_public, orcid_id, institution_id, group_id, job_title



36
37
38
# File 'lib/authors.rb', line 36

def detail(author_id:, &block)
  get(api_query: "account/authors/#{author_id}",  &block)
end

#search(institute: false, group_id: nil, orcid: nil, is_active: true, is_public: true, order: 'published_date', order_direction: 'desc', search_for:) {|Hash| ... } ⇒ Object

Search authors

Parameters:

  • institution (Boolean)

    Just our institution

  • group_id (Integer) (defaults to: nil)

    Only return this group’s collections

  • orcid (String) (defaults to: nil)

    Matches this orcid

  • is_active (Boolean) (defaults to: true)
  • is_public (Boolean) (defaults to: true)
  • order (String) (defaults to: 'published_date')

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

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

    “desc” Default, “asc”

Yields:

  • (Hash)

    first_name, last_name, full_name, url_name, is_active, is_public, orcid_id, institution_id, group_id, job_title



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

def search(institute: false, group_id: nil, orcid: nil,
            is_active: true, is_public: true,  
            order: 'published_date', order_direction: 'desc',
            search_for:,
            &block
          )
  args = { 'search_for' => search_for }
  args['institution'] = @institute_id if ! institute.nil?
  args['group_id'] = group_id if ! group_id.nil?
  args['is_active'] = is_active if ! is_active.nil?
  args['is_public'] = is_public if ! is_public.nil?
  args['orcid'] = orcid if ! orcid.nil?
  args['order'] = order if ! order.nil?
  args['order_direction'] = order_direction if ! order_direction.nil?
  post(api_query: 'account/authors/search', args: args, &block)
end