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



52
53
54
# File 'lib/authors.rb', line 52

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

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

Search authors

Parameters:

  • institution (Boolean)

    Just our institution. We have already stored the institute_id.

  • orcid (String) (defaults to: nil)

    Matches this orcid

  • group_id (Integer) (defaults to: nil)

    Only return this group’s collections

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

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

  • (Hash)

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



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/authors.rb', line 19

def search( search_for:,
            institute: false,
            group_id: nil,
            orcid: nil,
            is_active: true,
            is_public: true,
            order: 'published_date',
            order_direction: 'desc',
            page: nil,
            page_size: nil,
            offset: nil,
            limit: nil,
            &block
          )
  args = { 'search_for' => search_for }
  args['institution'] = @institute_id.to_i if institute
  args['group_id'] = group_id unless group_id.nil?
  args['is_active'] = is_active unless is_active.nil?
  args['is_public'] = is_public unless is_public.nil?
  args['orcid'] = orcid unless orcid.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/authors/search', args: args, &block)
end