R/oRion.R

#' \pkg{oRion} Integrate R and Orion.
#' 
#' Interact with Cheetah Mobile's Orion Platform from your R console.
#' 
#' @section Functions: 
#' 
#' Families.
#' 
#' OAuth
#' \itemize{
#' \item \code{\link{orionOAuth}}
#' }
#' 
#' Get
#' \itemize{
#' \item \code{\link{getReport}}
#' }
#' 
#' \code{show} family
#' Show items
#' \itemize{
#' \item \code{\link{showAd}}
#' \item \code{\link{showAdset}}
#' \item \code{\link{showAdsetAudience}}
#' \item \code{\link{showCampaign}}
#' \item \code{\link{showObject}}
#' }
#' 
#' \code{create} family
#' Create items
#' \itemize{
#' \item \code{\link{createAd}}
#' \item \code{\link{createAdset}}
#' \item \code{\link{createCampaign}}
#' \item \code{\link{createImage}}
#' \item \code{\link{createObject}}
#' }
#' 
#' \code{delete} family
#' Create items
#' \itemize{
#' \item \code{\link{deleteAd}}
#' \item \code{\link{deleteAdset}}
#' \item \code{\link{deleteCampaign}}
#' \item \code{\link{deleteAudience}}
#' \item \code{\link{deleteObject}}
#' }
#' 
#' \code{dict} family
#' Fetch dictionaries
#' \itemize{
#' \item \code{\link{dictCity}}
#' \item \code{\link{dictCountry}}
#' \item \code{\link{dictDevice}}
#' \item \code{\link{dictInterest}}
#' \item \code{\link{dictLanguage}}
#' \item \code{\link{dictOS}}
#' \item \code{\link{dictState}}
#' }
#' 
#' \code{update} family
#' Update items
#' \itemize{
#' \item \code{\link{updateAd}}
#' \item \code{\link{updateAdset}}
#' \item \code{\link{updateCampaign}}
#' \item \code{\link{updateObject}}
#' }
#' 
#' \code{list} family
#' List items
#' \itemize{
#' \item \code{\link{listAds}}
#' \item \code{\link{listAdsets}}
#' \item \code{\link{listCampaigns}}
#' \item \code{\link{listImages}}
#' \item \code{\link{listObjects}}
#' }
#' 
#' \code{helpers}
#' List items
#' \itemize{
#' \item \code{\link{budgetType}}
#' \item \code{\link{objective}}
#' \item \code{\link{appType}}
#' \item \code{\link{webType}}
#' \item \code{\link{landingPage}}
#' \item \code{\link{bidType}}
#' \item \code{\link{appShowType}}
#' \item \code{\link{deliveryType}}
#' \item \code{\link{gender}}
#' \item \code{\link{age}}
#' \item \code{\link{netType}}
#' \item \code{\link{buttonText}}
#' \item \code{\link{switchIt}}
#' }
#' 
#' @examples 
#' \dontrun{
#' # authenticate
#' orionOAuth(client.id = 0000,
#'            client.secret = "0x00000000x00x0x000xxx0000x0xx0")
#'
#' # set body of campaign
#' camp <- list(name = "test",
#'              budget_type = "daily",
#'              budget_daily = "1000", 
#'              pkg_name = "test",
#'              objective = objective("installs"), 
#'              app_type = "2",
#'              web_type = "1", 
#'              landing_page = landingPage("googlePlay"))
#'              
#' # create campaign
#' createCampaign(camp)
#' 
#' # list campaigns
#' campaigns <- listCampaigns(n = 100)
#' 
#' # pick two random countries                       
#' locations <- paste0(sample(dictCountry()$code, 1), "|", 
#'                     sample(dictCountry()$code, 1))
#'                       
#' # create audience template to use in adset                        
#' createAudience(body = list(
#'    audience_template_name = "test",
#'    audience_template_desc = "test template",
#'    country = locations, 
#'    language = sample(dictLanguage()$code, 1),
#'    net_type = netType("wifi")),
#'    interest = dictInterst()$pid[1])
#' 
#' # list audience template
#' audiences <- listAudiences(n = 50)
#' 
#' # create adset
#' createAdset(body = list(
#'    name = "testAdset",
#'    bid_type = appShowType("CPI"),
#'    unit_price = 1000,
#'    budget_lifetime = 10000,
#'    campaign_id = sample(camps$id, 1),
#'    audience_create_way = 2,
#'    app_show_type = appShowType("newsfeed"),
#'    audience_template_id = sample(audiences$id, 1),
#'    click_url = "http://app.myApp.io"))
#' 
#' # list adsets
#' adsets <- listAdsets()
#' 
#' # upload image to use in ad
#' createImage(file = paste0(.libPaths(), "/png/img/Rlogo.png"))
#' 
#' # list images
#' images <- listImages()
#' 
#' # define ad settings
#' body <- list(
#'    adset_id = adsets$id[1],
#'    name = "testAd",
#'    icon_url = images$thumb[1],
#'    title = "Download oRion",
#'    desc = "Download oRion and interact with Orion from your R console",
#'    button_text = buttonText("install"),
#'    image_url = images$local_url[1])
#'    
#' # post ad
#' createAd(body = body)
#' 
#' # list ads
#' ads <- listAds()
#' 
#' # update ad name
#' update <- updateAd(ad.id = ad$id[1], body = list(name = "New Ad Name"))
#'                
#' # show updated ad
#' showAd(ad.id = ads$id[1])
#' 
#' # map ads
#' map <- map(campaigns, adsets, ads, audiences)
#' g <- igraph::graph.data.frame(network[,3:4], directed = TRUE)
#' plot(g)
#' 
#' # get data
#' # get daily campaign impressions and conversions for the past 7 days
#' dat <- getReport(column = c("impression", "conversion"), 
#'                  group.by = c("datetime", "campaign"), 
#'                  start = Sys.Date() - 7)
#' }
#' 
#' @keywords internal
#' @name oRion
#' @docType package
#' 
#' @author John Coene \email{jcoenep@@gmail.com}
NULL
JohnCoene/oRion documentation built on June 13, 2019, 12:44 p.m.