Skip to contents

R6 class for constructing deposits queries

Value

a depositsClient class (R6 class)

Note

Client should already contain metadata updated with the 'deposit_fill_metadata()' function.

Public fields

service

(character) of deposits host service.

sandbox

(logical) Connect client with sandbox if TRUE (zenodo only)

deposits

(data.frame) Current deposits hosted on service, one row per deposit.

url_base

(character) Base URL of host service API

url_service

(character) URL of deposit service

id

(integer) Deposit identifier from host service.

headers

(list) list of named headers

hostdata

(list) Data as stored by host platform

metadata

(atom4R::DCEntry) holds metadata

term_map

(data.frame) Map between DCMI and deposit terms for specified host service.

Methods


Method new()

Create a new depositsClient object

Usage

depositsClient$new(service, metadata = NULL, sandbox = FALSE, headers = NULL)

Arguments

service

(character) of a deposits service (see deposits_services).

metadata

Either of one three possible ways of defining metadata:

  • The name (or full path) or a local file containing metadata constructed with deposits_metadata_template;

  • A names list of metadata with names matching values given by dcmi_terms, and values specified as individual character strings or lists for multiple entries.

  • An atom4R DCEntry object containing metadata, either constructed directly via atom4R routines, or via deposits_meta_to_dcmi.

sandbox

If TRUE, connect client to sandbox, rather than actual API endpoint (for "zenodo" only).

headers

Any acceptable headers. See examples in httr2 package.

Returns

A new depositsClient object


Method print()

print method for the depositsClient class

Usage

depositsClient$print(x, ...)

Arguments

x

self

...

ignored


Method deposits_list()

Update 'deposits' item of current deposits for given service

Usage

depositsClient$deposits_list()

Returns

Updated 'deposits' client


Method deposits_search()

Search all public deposits

Usage

depositsClient$deposits_search(
  search_string = NULL,
  page_size = 10L,
  page_number = 1L,
  ...
)

Arguments

search_string

Single string to search for

page_size

Number of records to return in one page

page_number

Starting page for return results; used in combination with 'page_size' for pagination.

...

Named pairs of query parameters. Zenodo parameters are described at https://developers.zenodo.org/#list36, and currently include:

  • status: either "draft" or "published"

  • sort: either "bestmatch" (the default) or "mostrecent"

  • all_versions: Either "true" or "false"

  • communities: Search for deposits only within specified communities

  • type: Return deposits only of specified type

  • subtype: Return deposits only of specified subtype

  • bound: A geolocation bounding box

  • custom: Custom keywords

Figshare parameters are described at https://docs.figshare.com/#articles_search, and currently include:

  • resource_doi: Only return deposits matching this 'resource_doi'

  • item_type: Return deopsits of specified type (as integer).

  • doi: Only return deposits matching this DOI

  • handle: Only return deposits matching this handle

  • project_id: Only return deposits from within specified project

  • order: Order for sorting results; one of "published_date", "modified_date", "views", "shares", "downloads", or "cites"

  • search_for: Search term.

  • order_direction: "asc" or "desc"

  • institution: Only return deposits from specified institution (as integer)

  • group: Only return deposits from specified group (as integer)

  • published_since: Only return deposits published since specified date (as YYYY-MM-DD)

  • modified_since: Only return deposits modified since specified date (as YYYY-MM-DD)

Returns

A data.frame of data on deposits matching search parameters (with format depending on the deposits service.)

Examples

\dontrun{
cli <- depositsClient$new (service = "figshare")
search_results <- cli$deposits_search (search_string = "Text string query", page_size = 5L)
}


Method deposit_delete()

Deleted a nominated deposit

Usage

depositsClient$deposit_delete(deposit_id = NULL)

Arguments

deposit_id

Integer identifier of deposit (generally obtained from list_deposits method).

Returns

Updated 'deposits' client


Method deposit_fill_metadata()

Fill deposits client with metadata, and upload to deposits service if connected.

Usage

depositsClient$deposit_fill_metadata(metadata = NULL)

Arguments

metadata

Either of one three possible ways of defining metadata:

  • The name (or full path) or a local file containing metadata constructed with deposits_metadata_template;

  • A names list of metadata with names matching values given by dcmi_terms, and values specified as individual character strings or lists for multiple entries.

  • An atom4R DCEntry object containing metadata, either constructed directly via atom4R routines, or via deposits_meta_to_dcmi.

Returns

Updated deposits client with metadata inserted.


Method deposit_new()

Create a new deposit

Usage

depositsClient$deposit_new()

Returns

Updated deposits client which includes data on new deposit


Method deposit_service()

Create a new depositsClient object

Usage

depositsClient$deposit_service(service = NULL, sandbox = FALSE, headers = NULL)

Arguments

service

(character) of a deposits service (see deposits_services).

sandbox

If TRUE, connect client to sandbox, rather than actual API endpoint (for "zenodo" only).

headers

Any acceptable headers. See examples in httr2 package.


Method deposit_update()

Update metadata for specified deposit

Usage

depositsClient$deposit_update(deposit_id = NULL)

Arguments

deposit_id

The 'id' number of deposit to update. If not specified, the 'id' value of current deposits client is used.


Method deposit_upload_file()

Upload file to an existing deposit

Usage

depositsClient$deposit_upload_file(deposit_id = NULL, path = NULL)

Arguments

deposit_id

The 'id' number of deposit which file is to be uploaded to. If not specified, the 'id' value of current deposits client is used.

path

Path to local file.

Returns

Updated 'deposits' client


Method deposit_retrieve()

Retrieve information on specified deposit

Usage

depositsClient$deposit_retrieve(deposit_id)

Arguments

deposit_id

The 'id' number of deposit for which information is to be retrieved.

Returns

Updated 'deposits' client


Method deposit_download_file()

Download a specified 'filename' from a deposit

Usage

depositsClient$deposit_download_file(
  deposit_id = NULL,
  filename,
  path = NULL,
  overwrite = FALSE,
  quiet = FALSE
)

Arguments

deposit_id

The 'id' number of deposit which file is to be downloaded from. If not specified, the 'id' value of current deposits client is used.

filename

The name of the file to be download as specified in the deposit.

path

The local directory where file is to be downloaded.

overwrite

Do not overwrite existing files unless set to TRUE.

quiet

If FALSE, display download progress.

Returns

The full path of the downloaded file.

Examples

if (FALSE) {
# make a client
cli <- depositsClient$new ("zenodo") # or:
cli <- depositsClient$new ("figshare")
print (cli)

# methods
cli$deposits_list ()

# Fill depositsClient metadata
metadata <- list (
    title = "New Title",
    abstract = "This is the abstract",
    creator = list ("A. Person", "B. Person")
)
cli$deposit_fill_metadata (metadata)
print (cli)

# or pass metadata directly at construction of new client
cli <- depositsClient$new ("figshare", metadata = metadata)
}

## ------------------------------------------------
## Method `depositsClient$deposits_search`
## ------------------------------------------------

if (FALSE) {
cli <- depositsClient$new (service = "figshare")
search_results <- cli$deposits_search (search_string = "Text string query", page_size = 5L)
}