#' Subscriber's Activation/Termination
#'
#' Manages the activation status of subscribers.
#'
#' @param token
#' Your API token.
#' @param imsi
#' Subscriber's IMSI.
#'
#' @rdname subscribers_activation
#' @export
activate_subscriber <- function(token, imsi) {
path <- sprintf("/subscribers/%s/activate", get_segment(imsi))
response <- POST(get_endpoint(path), add_headers(.headers = to_headers(token)))
status_code <- status_code(response)
content <- content(response, "text", encoding = "UTF-8")
switch(
as.character(status_code),
"200" = {
from_content(content, "soracom_subscriber")
},
"404" = {
stop("Subscriber ", sQuote(imsi), " was not found.")
},
{
stop(content)
}
)
}
#' @rdname subscribers_activation
#' @export
deactivate_subscriber <- function(token, imsi) {
path <- sprintf("/subscribers/%s/deactivate", get_segment(imsi))
response <- POST(get_endpoint(path), add_headers(.headers = to_headers(token)))
status_code <- status_code(response)
content <- content(response, "text", encoding = "UTF-8")
switch(
as.character(status_code),
"200" = {
invisible(from_content(content, "soracom_subscriber"))
},
"404" = {
stop("Subscriber ", sQuote(imsi), " was not found.")
},
{
stop(content)
}
)
}
#' @rdname subscribers_activation
#' @export
terminate_subscriber <- function(token, imsi) {
path <- sprintf("/subscribers/%s/terminate", get_segment(imsi))
response <- POST(get_endpoint(path), add_headers(.headers = to_headers(token)))
status_code <- status_code(response)
content <- content(response, "text", encoding = "UTF-8")
switch(
as.character(status_code),
"200" = {
invisible(from_content(content, "soracom_subscriber"))
},
"404" = {
stop("Subscriber ", sQuote(imsi), " was not found.")
},
{
stop(content)
}
)
}
#' @rdname subscribers_activation
#' @export
enable_termination_subscriber <- function(token, imsi) {
path <- sprintf("/subscribers/%s/enable_termination", get_segment(imsi))
response <- POST(get_endpoint(path), add_headers(.headers = to_headers(token)))
status_code <- status_code(response)
content <- content(response, "text", encoding = "UTF-8")
switch(
as.character(status_code),
"200" = {
invisible(from_content(content, "soracom_subscriber"))
},
"404" = {
stop("Subscriber ", sQuote(imsi), " was not found.")
},
{
stop(content)
}
)
}
#' @rdname subscribers_activation
#' @export
disable_termination_subscriber <- function(token, imsi) {
path <- sprintf("/subscribers/%s/disable_termination", get_segment(imsi))
response <- POST(get_endpoint(path), add_headers(.headers = to_headers(token)))
status_code <- status_code(response)
content <- content(response, "text", encoding = "UTF-8")
switch(
as.character(status_code),
"200" = {
invisible(from_content(content, "soracom_subscriber"))
},
"404" = {
stop("Subscriber ", sQuote(imsi), " was not found.")
},
{
stop(content)
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.