class Figshare::PrivateProjects

Figshare private project api

Public Instance Methods

article_create(project_id:, article:, impersonate: nil, &block) click to toggle source

Create a new Article and associate it with this project

@param project_id [Integer] Figshare id of the project @param article [Hash] See figshare API docs @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] { location }

# File lib/private_projects.rb, line 253
def article_create(project_id:, article:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  # Figshare Docs say this should be post_paginate, but that makes no sense. Will have to test
  post_paginate(api_query: "account/projects/#{project_id}/articles", args: args, &block)
end
article_delete(project_id:, article_id:, impersonate: nil, &block) click to toggle source

delete an article from a project

@param project_id [Integer] Figshare id of the project @param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_projects.rb, line 265
def article_delete(project_id:, article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: "account/projects/#{project_id}/articles/#{article_id}", args: args, &block)
end
article_detail(project_id:, article_id:, impersonate: nil, &block) click to toggle source

Get the details of an artilcle in a project

@param project_id [Integer] Figshare id of the project @param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] See Fishare API docs for article hash

# File lib/private_projects.rb, line 277
def article_detail(project_id:, article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/projects/#{project_id}/articles/#{article_id}", args: args, &block)
end
articles(project_id:, impersonate: nil, &block) click to toggle source

Return details of list of articles for a specific project

@param project_id [Integer] Figshare id of the project @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] See Figshare API Doc

# File lib/private_projects.rb, line 241
def articles(project_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get_paginate(api_query: "account/projects/#{project_id}/articles", args: args, &block)
end
artilce_file_detail(project_id:, article_id:, file_id:, impersonate: nil, &block) click to toggle source

Get the files associated with an artilcle in a project

@param project_id [Integer] Figshare id of the project @param article_id [Integer] Figshare id of the article @param file_id [Integer] Figshare id of the file @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_projects.rb, line 301
def artilce_file_detail(project_id:, article_id:, file_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: "account/projects/#{project_id}/articles/#{article_id}/files/#{file_id}", args: args, &block)
end
artilce_files(project_id:, article_id:, impersonate: nil, &block) click to toggle source

Get the files associated with an artilcle in a project

@param project_id [Integer] Figshare id of the project @param article_id [Integer] Figshare id of the article @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] See Fishare API docs for article hash

# File lib/private_projects.rb, line 289
def artilce_files(project_id:, article_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/projects/#{project_id}/articles/#{article_id}/files", args: args, &block)
end
collaborator_invite(project_id:, role_name:, user_id: nil, email: nil, comment:, impersonate: nil, &block) click to toggle source

Invite a new collaborators to the project

@param project_id [Integer] Figshare id of the project_id @param role_name [String] @param user_id [Integer] Need user_id or email @param email [String] Used, if user_id is nil @param comment [String] @yield [String] { message }

# File lib/private_projects.rb, line 208
def collaborator_invite(project_id:, role_name:, user_id: nil, email: nil, comment:, impersonate: nil, &block)
  args = {
    'role_name' => role_name,
    'comment' => comment
  }
  if ! user_id.nil?
    args['user_id'] = user_id
  elsif ! email.nil?
    args['email'] = email
  else
    raise "collaborator_invite(): Need a user_id or an email address" 
  end
  args["impersonate"] = impersonate  if ! impersonate.nil?
  collaborator = { "role_name" => role_name, "user_id" => user_id, "email" => email, "comment" => comment }
  post(api_query: "account/project/#{project_id}/collaborators", args: args, data: collaborator, &block)
end
collaborator_remove(project_id:, user_id:, impersonate: nil, &block) click to toggle source

Leave a project (Please note: project's owner cannot leave the project.)

@param project_id [Integer] Figshare id of the project_id @param user_id [Integer] Figshare id of a user in the project @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_projects.rb, line 230
def collaborator_remove(project_id:, user_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: "account/project/#{project_id}/collaborators/#{user_id}", args: args, &block)
end
collaborators(project_id:, impersonate: nil, &block) click to toggle source

Get the project collaborators

@param project_id [Integer] Figshare id of the project_id @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] { status, role_name, user_id, name }

# File lib/private_projects.rb, line 194
def collaborators(project_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/projects/#{project_id}/collaborators", args: args, &block)
end
create(title:, description:, funding: '', funding_list: [], group_id:, impersonate: nil, &block) click to toggle source

Create a new project

@param title [String] @param description [String] @param funding [String] @param funding_list [Array] [{id, title}, … ]

param group_id [Integer] Figshare group the project falls under.

@param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] { location }

# File lib/private_projects.rb, line 60
def create(title:, description:, funding: '', funding_list: [], group_id:, impersonate: nil, &block)
  args = { "title" => title, 
           "description" => description, 
           "group_id" => group_id,
           "funding" => funding,
           "funding_list" => funding_list
         }
  args["impersonate"] = impersonate  if ! impersonate.nil?
  post(api_query: 'account/projects', args: args, &block)
end
detail(project_id:, impersonate: nil, &block) click to toggle source

Return details of specific private project

@param project_id [Integer] Figshare id of the project_id @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] See figshare api docs

# File lib/private_projects.rb, line 86
def detail(project_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/projects/#{project_id}",  args: args, &block)
end
list(storage: nil, roles: nil, order: 'published_date', order_direction: 'desc', impersonate: nil, &block) click to toggle source

Requests a list private projects

@param storage [String] group, individual (only return collections from this institution) @param roles [String] Any combination of owner, collaborator, viewer separated by comma. Examples: “owner” or “owner,collaborator”. @param order [String] “published_date” Default, “modified_date”, “views”, “cites”, “shares” @param order_direction [String] “desc” Default, “asc” @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] {role, storage, url, published_date, id, title}

# File lib/private_projects.rb, line 14
def list(storage: nil, roles: nil, order: 'published_date', order_direction: 'desc', impersonate: nil, &block)
  args = {}
  args['storage'] = storage if ! storage.nil?
  args['roles'] = roles if ! roles.nil?
  args['order'] = order if ! order.nil?
  args['order_direction'] = order_direction if ! order_direction.nil?
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get_paginate(api_query: 'account/projects', args: args, &block)
end
note_create(project_id:, text:, impersonate: nil, &block) click to toggle source

Create a project note

@param project_id [Integer] Figshare id of the project @param text [String] The note @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] { location }

# File lib/private_projects.rb, line 139
def note_create(project_id:, text:, impersonate: nil, &block)
  args = { 'text' => text }
  args["impersonate"] = impersonate  if ! impersonate.nil?
  post(api_query: "account/projects/#{project_id}/notes", args: args, &block)
end
note_delete(project_id:, note_id:, impersonate: nil, &block) click to toggle source

Delete a project note

@param project_id [Integer] Figshare id of the project @param note_id [Integer] Figshare id of the note @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_projects.rb, line 150
def note_delete(project_id:, note_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: "account/projects/#{project_id}/notes/#{note_id}", args: args, &block)
end
note_detail(impersonate: nil, &block) click to toggle source

Get a note's text

@param project_id [Integer] Figshare id of the project @param note_id [Integer] Figshare id of the note @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] { text }

# File lib/private_projects.rb, line 162
def note_detail(impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get(api_query: "account/projects/#{project_id}/notes/#{note_id}", args: args, &block)
end
notes(project_id:, impersonate: nil, &block) click to toggle source

List projects notes

@param project_id [Integer] Figshare id of the project @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] {id, user_id, abstract, user_name, created_date, modified_date}

# File lib/private_projects.rb, line 127
def notes(project_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  get_paginate(api_query: "account/projects/#{project_id}/notes", args: args, &block)
end
private_project_collaborators_leave(project_id:, impersonate: nil, &block) click to toggle source

Leave a project (Please note: project's owner cannot leave the project.)

@param project_id [Integer] Figshare id of the project_id

# File lib/private_projects.rb, line 183
def private_project_collaborators_leave(project_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  post(api_query: "account/projects/#{project_id}/leave", args: args, &block)
end
project_delete(project_id:, impersonate: nil, &block) click to toggle source

Delete an existing project

@param project_id [Integer] Figshare project ID @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of

# File lib/private_projects.rb, line 75
def project_delete(project_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  delete(api_query: 'account/projects/#{project_id}', args: args, &block)
end
publish(project_id:, impersonate: nil, &block) click to toggle source

Publish a project

@param project_id [Integer] Figshare id of the project @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] Message

# File lib/private_projects.rb, line 116
def publish(project_id:, impersonate: nil, &block)
  args = {}
  args["impersonate"] = impersonate  if ! impersonate.nil?
  post(api_query: "account/projects/#{project_id}/publish", args: args, &block)
end
update(project_id:, title: nil, description: nil, funding: nil, funding_list: nil, impersonate: nil, &block) click to toggle source

Update an existing project

@param project_id [Integer] Figshare id of the project_id @param title [String] @param description [String] @param funding [String] @param funding_list [Array] [{id, title}, … ] @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of @yield [Hash] { location }

# File lib/private_projects.rb, line 101
def update(project_id:, title: nil, description: nil, funding: nil, funding_list: nil, impersonate: nil, &block)
  args = {}
  args["title"] = title if ! title.nil? 
  args["description"] = description if ! description.nil? 
  args["funding"] = funding if ! funding.nil? 
  args["funding_list"] = funding_list if ! funding_list.nil? 
  args["impersonate"] = impersonate  if ! impersonate.nil?
  put(api_query: "account/projects/#{project_id}", args: args, &block)
end