get_table: Harvest API v2 get request wrapper

Description Usage Arguments Details Value References See Also Examples

View source: R/get_table.R

Description

Submits get requests to the Harvest API v2 with options configured for authentication, parallelism, and logging

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
get_table(
  table = NULL,
  user = harvestR::get_harvest_account(),
  key = harvestR::get_harvest_pat(),
  query = NULL,
  plan_options = NULL,
  quiet = T,
  ...,
  auto_retry = lifecycle::deprecated(),
  email = lifecycle::deprecated(),
  verbose = lifecycle::deprecated(),
  strategy = lifecycle::deprecated()
)

Arguments

table

Character table name to be submitted to the Harvest API v2. Refer to Harvest API v2.

user

Character account number (e.g. user = '12345') for authentication. Register at Harvest Developers. Defaults to 'get_harvest_account()'

key

Character key (e.g. key = 'Bearer <secret key>') for API authentication. Register at Harvest Developers. Defaults to 'get_harvest_pat()'

plan_options

List; list of parameters passed to future::plan. The strategy parameter is required to implement parallel requests, see Future Package Overview for more details.

quiet

Logical; controls harvestR messaging, TRUE returns only errors in the console and FALSE returns messages, warnings, and errors. Does not impact deprecation warnings.

...

Additional arguments forwarded to 'httr::RETRY()' and 'httr::config()'. Refer to details for more information.

Details

\lifecycle

maturing

Description of ... parameters. Additional arguments are forwarded to config.

Value

dataframe with contents of requested Harvest table

References

Harvest API v2 Harvest Developers Page, Future Pacakge Overview, Future Package Output

See Also

'future::plan()' for more detail regarding how to implement parallel api calls

'httr::httr_options()' for more detail regarding httr configurations

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 

# Create a credentials record on the system keyring
create_harvest_creds()

# Set the credentials in the environment for get_table
set_harvest_creds()

# Barebones call to get_table
projects <- get_table(table = 'projects')

# Parallel request with 2 retries and messaging
# Windows users should use multisession, multicore will not work
time_entries <- get_table(table = 'time_entries',
query = list(from = '2018-01-01', to = '2018-12-31'),
plan_options = list(strategy = "multicore"),
times = 2,
quiet = F)

# Request using an httr option (see `httr::httr_options()`) and an oauth token
projects <- get_table(table = 'projects',
http_version = 2,
token = my_token)


## End(Not run)

propellerpdx/harvestR documentation built on Jan. 5, 2021, 2:33 p.m.