R/ss_add_tag.R

Defines functions ss_add_tag

Documented in ss_add_tag

#' Add tag to an order in ShipStation
#' @param order_number order number (character/scalar)
#' @param tag_id tag id (numeric/scalar)
#' @export
ss_add_tag <- function(order_number = NULL, tag_id = NULL) {

  if (is.null(tag_id))
    stop("You must specify the tag to use!")
  if (is.null(order_number))
    stop("You must specify the `order_number` to tag!")

  # get orderId for the specified order
  order <- shipstationr::ss_get_orders(order_number = order_number)

  if (!is.null(order) && nrow(order) == 1) {
    out <-
      shipstationr::ss_api(
        path = "orders/addtag",
        fun = httr::POST,
        orderId = order$orderId,
        tagId = 95540
      )
  } else {
    out <- NULL
  }

  return(invisible(out))
}
anthonypileggi/shipstationr documentation built on Aug. 8, 2020, 10:27 a.m.