trem_delete {tremendousr} | R Documentation |
Perform a DELETE request to Tremendous API
Description
Tremendous only supports DELETE requests for one endpoint – deleting an invoice. Per their documentation, this request "removes an invoice. This has no further consequences but is a rather cosmetic operation." See the examples for a walk-through.
Usage
trem_delete(
client,
path,
query = list(),
body = NULL,
disk = NULL,
stream = NULL,
encode = "json",
parse = TRUE
)
Arguments
client |
A Tremendous API Client object, created with
|
path |
The URL path, appended to the base URL, for GET requests such as listing available payment types, funding sources, account members, and more. See the Tremendous API Documentation for examples. |
query |
Query terms as a named list. See crul::HttpClient for more details. |
body |
Request body for Tremendous API, as an R List. |
disk |
A path to write to. |
stream |
An R function to determine how to stream data. |
encode |
"json" by default based on Tremendous API Request format. See crul::HttpClient for more options. |
parse |
Logical: Should the API Response results be parsed into a data frame? |
Value
If parse = TRUE
(default), a list containing the response from the
API request. Otherwise, the R6 HttpResponse object containing API request
data.
Examples
## Not run:
# Create a new Tremendous API Client
test_client <- trem_client_new(api_key = "TEST_YOUR-API-KEY-HERE",
sandbox = TRUE)
# Perform a POST request for an invoice.
# `po_number` is Reference to the purchase order number within your organization
# `amount` is in USD
trem_post(test_client,
path = "invoices",
body = list(po_number = "unique-invoice-id",
amount = 50)
)
# Perform a GET request for listing all current (non-deleted) invoices.
current_invoices <- trem_get(test_client, "invoices")
# Get index for the correct ID
unique_id_index <- which(current_invoices$invoices$po_number == "unique-invoice-id")
# Get the invoice ID for 'unique-invoice-id' to delete
my_invoice_id <- current_invoices$invoices[unique_id_index, "id"]
# Perform a DELETE request for the specific invoice.
trem_delete(test_client, paste0("invoices/", my_invoice_id))
# Perform a GET request for listing all current (non-deleted) invoices.
# The one with id po_number 'unique-invoice-id' should no longer be here.
trem_get(test_client, "invoices")
## End(Not run)