Class: Figshare::PublicProjects

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

Overview

Figshare public projects 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

#articles(project_id:) {|Hash| ... } ⇒ Object

Get list of articles for a specific project

Parameters:

  • project_id (Integer)

    Figshare id of the project

Yields:

  • (Hash)

    See Figshare API Doc



61
62
63
# File 'lib/public_projects.rb', line 61

def articles(project_id:, &block)
  get_paginate(api_query: "projects/#{project_id}/articles", &block)
end

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

Return details of specific project_id

Parameters:

  • project_id (Integer)

    Figshare id of the project_id

Yields:

  • (Hash)

    See figshare api docs



53
54
55
# File 'lib/public_projects.rb', line 53

def detail(project_id:, &block)
  get(api_query: "projects/#{project_id}",  &block)
end

#list(institute: false, group_id: nil, published_since: nil, order: 'published_date', order_direction: 'desc') {|Hash| ... } ⇒ Object

Requests a list projects

Parameters:

  • institution (Boolean)

    Just our institution

  • group_id (Integer) (defaults to: nil)

    Only return this group’s project

  • published_since (Time) (defaults to: nil)

    Return results if published after this time

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

    published_date, id, title



14
15
16
17
18
19
20
21
22
# File 'lib/public_projects.rb', line 14

def list(institute: false,group_id: nil, published_since: nil, order: 'published_date', order_direction: 'desc', &block)
  args = {}
  args['institution'] = @institute_id if ! institute.nil?
  args['group'] = group_id if ! group_id.nil?
  args['published_since'] = published_since if ! published_since.nil?
  args['order'] = order if ! order.nil?
  args['order_direction'] = order_direction if ! order_direction.nil?
  get_paginate(api_query: 'projects', args: args, &block)
end

#search(institute: false, group_id: nil, published_since: nil, modified_since: nil, order: 'published_date', order_direction: 'desc', search_for:) {|Hash| ... } ⇒ Object

Search within all projects

Parameters:

  • institution (Boolean)

    Just our institution

  • group_id (Integer) (defaults to: nil)

    Only return this group’s project

  • 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

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

    title, doi, handle, url, published_date



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/public_projects.rb', line 33

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