Title: | Access and Analyse 'VALD' Data via Our External 'APIs' |
Version: | 1.0.0 |
Description: | Provides helper functions and wrappers to simplify authentication, data retrieval, and result processing from the 'VALD' 'APIs'. Designed to streamline integration for analysts and researchers working with 'VALD's external 'APIs'. For further documentation, please see https://support.vald.com/hc/en-au/articles/23415335574553-How-to-integrate-with-VALD-APIs for documentation. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Imports: | httr, base64enc, keyring, jsonlite |
NeedsCompilation: | no |
Packaged: | 2025-07-16 01:29:02 UTC; KieranHarrison |
Author: | Kieran Harrison [aut, cre], VALD Support [ctb], VALD [cph] (Copyright holder) |
Maintainer: | Kieran Harrison <k.harrison@vald.com> |
Repository: | CRAN |
Date/Publication: | 2025-07-19 08:40:02 UTC |
Authenticate and retrieve a valid access token
Description
Ensures a valid access token is available based on stored credentials. Also validates required tenant ID and token presence for subsequent function calls.
Usage
authenticate()
Value
A character vector of length 1 (a single string) representing a valid access token. Returned invisibly and used internally for authentication.
Get or refresh VALD access token
Description
Retrieves a cached access token from disk if valid, otherwise fetches a new one.
Usage
get_access_token(config = NULL, verbose = TRUE)
Arguments
config |
Configuration object. If NULL, uses internal config set by |
verbose |
Whether to print a message when refreshing the token. |
Value
A character vector of length 1 (a single string) representing the bearer token used to authenticate requests. Returned invisibly.
Retrieve stored VALD configuration
Description
Returns the configuration list previously set by set_credentials()
.
If credentials have not been set, this function will raise an error.
Usage
get_config(safe = TRUE, quiet = FALSE)
Arguments
safe |
If TRUE (default), sensitive values are redacted in printed output (only when not quiet). |
quiet |
If TRUE, no printed output is shown (default is FALSE). |
Value
A named list containing the stored VALD configuration values for the current user. Sensitive values are redacted. Returned invisibly.
Run full initial data fetch from the VALD ForceDecks API and External Profiles API
Description
This function is intended for first-time use or a full refresh of all datasets. It retrieves profiles, result definitions, tests (from a specified start date), and trials.
Usage
get_forcedecks_data(start_date = NULL)
Arguments
start_date |
In ISO 8601 UTC format (e.g., "2025-06-25T00:00:00Z") indicating the start of the test retrieval window. |
Value
A named list with data frames: profiles
, result_definitions
, tests
, and trials
.
Each element contains the respective dataset fetched from the ForceDecks API.
Examples
## Not run:
# Fetch all data (profiles, results, tests, trials)
data <- get_forcedecks_data()
View(data$profiles)
## End(Not run)
Get ForceDecks result definitions
Description
Retrieves all available result definitions from the ForceDecks API.
Usage
get_forcedecks_result_definitions()
Value
A data frame where each row corresponds to a ForceDecks result definition retrieved from the API. Returned invisibly.
Get only ForceDecks result definitions
Description
Wrapper around get_forcedecks_result_definitions()
to refresh result definitions.
Typically called infrequently unless definitions are known to have changed.
Usage
get_forcedecks_result_definitions_only()
Value
A data frame where each row corresponds to a ForceDecks result definition retrieved from the API. Returned invisibly.
Examples
## Not run:
# Fetch result definitions
results <- get_forcedecks_result_definitions_only()
View(results)
## End(Not run)
Get ForceDecks tests
Description
Retrieves ForceDecks test data with optional filtering by start date and profile ID.
Usage
get_forcedecks_tests(start_date = NULL, profile_id = NULL)
Arguments
start_date |
Optional ISO 8601 UTC date string (e.g., "2025-06-25T00:00:00Z"). |
profile_id |
Optional Profile ID to filter results. |
Value
A data frame containing ForceDecks test results matching the optional filters. If no tests are found, returns an empty data frame. Returned invisibly.
Get only ForceDecks test data
Description
Wrapper around get_forcedecks_tests()
if the user only wants test-level data without trials.
Usage
get_forcedecks_tests_only(start_date = NULL)
Arguments
start_date |
In ISO 8601 UTC format (e.g., "2025-06-25T00:00:00Z") indicating the start of the test retrieval window. |
Value
A data frame containing ForceDecks test-level data.
Examples
## Not run:
# Fetch only tests
tests <- get_forcedecks_tests_only()
View(tests)
## End(Not run)
Run a standard session to get new ForceDecks tests and trials only
Description
Use this when profiles and result definitions have already been downloaded previously.
Usage
get_forcedecks_tests_trials(start_date = NULL)
Arguments
start_date |
In ISO 8601 UTC format (e.g., "2025-06-25T00:00:00Z") indicating the start of the test retrieval window. |
Value
A named list with two data frames: tests
and trials
.
These contain newly retrieved ForceDecks tests and their associated trial results.
Examples
## Not run:
# Fetch tests and trials only
session <- get_forcedecks_tests_trials()
View(session$tests)
View(session$trials)
## End(Not run)
Get trial results for a set of ForceDecks tests
Description
Retrieves and flattens trial-level result data for each test provided.
Usage
get_forcedecks_trials(tests_df)
Arguments
tests_df |
A data frame of tests (as returned by |
Value
A data frame containing flattened trial-level results for the supplied tests. If no trial results are found, returns an empty data frame.
Get trials for an existing test data frame
Description
Useful for re-running or extending analysis without re-downloading tests.
Usage
get_forcedecks_trials_only(tests_df)
Arguments
tests_df |
A data frame of tests (from |
Value
A data frame containing trial-level results corresponding to the input tests.
Examples
## Not run:
# Fetch trials based on existing tests
tests <- get_forcedecks_tests_only()
trials <- get_forcedecks_trials_only(tests)
View(trials)
## End(Not run)
Get VALD profiles
Description
Queries the External Profiles API and returns a data frame of VALD profiles.
Usage
get_profiles()
Value
A data frame containing VALD profiles information for the stored tenant_id
.
If no profiles are found, the function raises an error.
Get only VALD profiles
Description
Wrapper around get_profiles()
to retrieve VALD profiles.
Useful if profile data needs to be refreshed independently.
Usage
get_profiles_only()
Value
A data frame containing VALD profiles information for the stored tenant_id
.
Examples
## Not run:
# Fetch profiles
profiles <- get_profiles_only()
View(profiles)
## End(Not run)
Retrieve the start date from config
Description
Returns the saved start date string from the config file.
Usage
get_start_date()
Value
A character scalar containing the start date string in ISO 8601 format previously saved to configuration.
Check if JWT access token is expired
Description
Check if JWT access token is expired
Usage
is_token_valid(token)
Arguments
token |
A JWT access token |
Value
A logical scalar (TRUE or FALSE) indicating whether the provided JWT access token is still valid based on its expiry timestamp.
Load Stored VALD API Credentials and Configuration
Description
Loads the saved VALD API configuration from the config file in the user's home directory and retrieves sensitive credentials securely from the system keyring.
Usage
load_credentials()
Details
This function is automatically called on package load if a saved configuration file exists.
Value
A logical scalar (TRUE or FALSE), returned invisibly, indicating whether the saved credentials and configuration were loaded successfully. Called primarily for side effects.
Set and Save VALD API Credentials
Description
Stores VALD API credentials securely using the system keyring and saves non-sensitive configuration to a config file in the user's home directory for reuse across sessions.
Usage
set_credentials(client_id, client_secret, tenant_id, region)
Arguments
client_id |
Your VALD API Client ID (stored securely in keyring) |
client_secret |
Your VALD API Client Secret (stored securely in keyring) |
tenant_id |
Your VALD Tenant ID |
region |
The VALD data region code (e.g., "aue", "use", "euw") |
Details
Sensitive values are never written to disk and are retrieved securely when needed.
Value
A logical scalar (TRUE or FALSE), returned invisibly, indicating whether the credentials and configuration were saved successfully. Called primarily for side effects.
Set and persist the start date
Description
Saves the provided ISO 8601 start date to the config file.
Usage
set_start_date(start_date)
Arguments
start_date |
Date in ISO 8601 UTC format, e.g., "2025-06-25T00:00:00Z" |
Value
A logical scalar (TRUE), returned invisibly, indicating that the start date was saved and persisted successfully.