#' Get card eligibility for rewards
#'
#' \code{ct_get_rewards} Check for rewards eligibility
#'
#' Passes the ct_auth2 token, and clientid to test for card eligibility for a specific
#' rewards program with a specific merchant.
#'
#' @param ct_token pass the output from ct_auth
#' @param cc_number numeric credit card number to be encrypted with sha256
#'
#' @return If all inputs are integer and logical, then the output
#' will be an integer. If integer overflow
#' \url{http://en.wikipedia.org/wiki/Integer_overflow} occurs, the output
#' will be NA with a warning. Otherwise it will be a length-one numeric or
#' complex vector.
#'
#' Zero-length vectors have sum 0 by definition. See
#' \url{http://en.wikipedia.org/wiki/Empty_sum} for more details.
#'
#' @examples
#' ct_get_rewards
#'
#' \dontrun{
#' sum("a")
#' }
#' @export
ct_get_rewards <- function(ct_token, client_id, cc_number, reward_program, merchant_code) {
## needs to be the output from ct_auth
token <- ct_token
reward_program <- "THANKU"
merchant_code <- "FLOWR"
# cloked_cc <- openssl::sha512(cc_number)
cloked_cc <- "c88b3dbf7f7546c90523fe046ae5aa8639fb2dab2d8e5f4c3cc9351f99ef963086bf854bcaa6924a524a18a6c90817fc21b192c3694180a0a99ae8c1f5e68da0"
# get request for cc rewards data using 2-legged auth
ct_get_r <- httr::GET(url = paste0("https://sandbox.apihub.citi.com/gcb/api/v1/rewards/",
cloked_cc,
"/eligibility?rewardProgram=",
reward_program,
"&merchantCode=",
merchant_code),
httr::add_headers(
accept="application/json",
"accept-language"="en-us",
authorization=paste("Bearer", token, sep = " "),
businesscode="GCB",
client_id = client_id,
"content-type"="application/json",
countrycode="US",
uuid = uuid::UUIDgenerate()))
httr::stop_for_status(ct_get_r)
httr::content(ct_get_r, as = "parsed")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.