# NOT RUN {
# }
# 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")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab