Title: | 'R' Interface to the 'Diariodeobras' Application |
---|---|
Description: | Provides a set of functions for securely storing 'API' tokens and interacting with the <https://diariodeobras.net> system. Includes convenient wrappers around the 'httr2' package to perform authenticated requests, retrieve project details, tasks, reports, and more. |
Authors: | Andre Leite [aut, cre], Felipe Ferreira [aut], Hugo Vaconcelos [aut], Diogo Bezerra [aut], Roger Azevedo [aut] |
Maintainer: | Andre Leite <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2025-02-15 05:10:20 UTC |
Source: | https://github.com/strategicprojects/diario |
This function retrieves company details from the Diario API.
diario_get_company()
diario_get_company()
A list containing company details.
## Not run: company <- diario_get_company() ## End(Not run)
## Not run: company <- diario_get_company() ## End(Not run)
This function retrieves all registered entities from the Diario API.
diario_get_entities()
diario_get_entities()
A list containing the entities data.
## Not run: entities <- diario_get_entities() ## End(Not run)
## Not run: entities <- diario_get_entities() ## End(Not run)
This function retrieves details of a specific project by its ID from the Diario API.
diario_get_project_details(project_id)
diario_get_project_details(project_id)
project_id |
A valid non-empty string with the project ID. |
A list containing the project details.
## Not run: project <- diario_get_project_details("66face5fe26175e0a904d398") ## End(Not run)
## Not run: project <- diario_get_project_details("66face5fe26175e0a904d398") ## End(Not run)
This function retrieves a list of projects from the Diario API.
diario_get_projects()
diario_get_projects()
A tibble containing the projects data.
## Not run: projects <- diario_get_projects(query = list(status = "active")) ## End(Not run)
## Not run: projects <- diario_get_projects(query = list(status = "active")) ## End(Not run)
This function retrieves details of a specific report by report ID within a project.
diario_get_report_details(project_id, report_id)
diario_get_report_details(project_id, report_id)
project_id |
A valid non-empty string with the project ID. |
report_id |
A valid non-empty string with the report ID. |
A list containing the report details.
## Not run: report <- diario_get_report_details("6717f864d163f517ae06e242", "67648080f0971de9d00324c2") ## End(Not run)
## Not run: report <- diario_get_report_details("6717f864d163f517ae06e242", "67648080f0971de9d00324c2") ## End(Not run)
This function retrieves reports of a specific project with optional parameters for limit and order.
diario_get_reports(project_id, limit = 50, order = "desc")
diario_get_reports(project_id, limit = 50, order = "desc")
project_id |
A valid non-empty string with the project ID. |
limit |
An integer specifying the maximum number of reports to retrieve. Default is 50. |
order |
A character string specifying the order of the reports (e.g., "asc" or "desc"). Default is "desc". |
A tibble containing the reports.
## Not run: reports <- diario_get_reports("6717f864d163f517ae06e242", limit = 10, order = "asc") ## End(Not run)
## Not run: reports <- diario_get_reports("6717f864d163f517ae06e242", limit = 10, order = "asc") ## End(Not run)
This function retrieves details of a specific task by task ID within a project.
diario_get_task_details(project_id, task_id)
diario_get_task_details(project_id, task_id)
project_id |
A valid non-empty string with the project ID. |
task_id |
A valid non-empty string with the task ID. |
A list containing task details.
## Not run: task <- diario_get_task_details("66cf438223aa80386306e647", "66cf44209e4fedefb306bcd3") ## End(Not run)
## Not run: task <- diario_get_task_details("66cf438223aa80386306e647", "66cf44209e4fedefb306bcd3") ## End(Not run)
This function retrieves the task list of a specific project by its ID.
diario_get_task_list(project_id)
diario_get_task_list(project_id)
project_id |
A valid non-empty string with the project ID. |
A tibble containing the task list.
## Not run: tasks <- diario_get_task_list("66cf438223aa80386306e647") ## End(Not run)
## Not run: tasks <- diario_get_task_list("66cf438223aa80386306e647") ## End(Not run)
This function performs an authenticated request to the specified endpoint of the Diario API.
diario_perform_request( endpoint, query = list(), method = "GET", body = NULL, verbosity = 0 )
diario_perform_request( endpoint, query = list(), method = "GET", body = NULL, verbosity = 0 )
endpoint |
A non-empty character string specifying the API endpoint. |
query |
A named list of query parameters (optional). |
method |
The HTTP method to use (e.g., "GET", "POST", "PUT", "DELETE"). Default is "GET". |
body |
A list representing the JSON body for request methods that support a body (e.g., POST). |
verbosity |
Verbosity level for the request (0 = none, 1 = minimal). Default is 0. |
A list (by default) containing the response from the API. If the content is JSON, it will be returned as an R object. If not, an error is raised.
## Not run: diario_perform_request("v1/obras", query = list(status = "active")) ## End(Not run)
## Not run: diario_perform_request("v1/obras", query = list(status = "active")) ## End(Not run)
This function retrieves the stored authentication token using the keyring
package.
If no valid token (or keyring) is found, it will return NULL
and print a message
in English indicating that no valid token was found.
diario_retrieve_token()
diario_retrieve_token()
A character string containing the API token, or NULL
if no valid token is found.
token <- diario_retrieve_token()
token <- diario_retrieve_token()
This function stores the provided authentication token using the keyring
package.
If the token cannot be stored (for example, because the keyring is not accessible),
it prints a message instead of throwing an error, and returns FALSE
.
diario_store_token(token)
diario_store_token(token)
token |
A character string containing the API token to be stored. |
TRUE
(invisibly) if the token was stored successfully;
FALSE
otherwise.
# Attempt to store a token: diario_store_token("your-api-token")
# Attempt to store a token: diario_store_token("your-api-token")