Skip to content

Commit

Permalink
updated to 201809 and
Browse files Browse the repository at this point in the history
removed extra files
  • Loading branch information
brurucy committed Jan 23, 2019
1 parent 0ff2625 commit 7501120
Show file tree
Hide file tree
Showing 53 changed files with 1,810 additions and 579 deletions.
4 changes: 2 additions & 2 deletions R/getData.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param clientCustomerId Adwords Account Id
#' @param google_auth list of authentication
#' @param statement awql statement generated with \code{\link{statement}}.
#' @param apiVersion supports 201806, 201802, 201710 defaults to 201806.
#' @param apiVersion supports 201809, 201806, 201802 defaults to 201806.
#' @param transformation If TRUE, data will be transformed with \code{\link{transformData}} into suitable R dataframe.
#' Else, the data are returned in raw format.
#' @param includeZeroImpressions If TRUE zero impressions will be included. Defaults to FALSE.
Expand All @@ -19,7 +19,7 @@
getData <- function(clientCustomerId,
google_auth,
statement,
apiVersion = "201806",
apiVersion = "201809",
transformation=TRUE,
changeNames=TRUE,
includeZeroImpressions=FALSE,
Expand Down
8 changes: 4 additions & 4 deletions R/metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#' @description metrics provides an overview of all available metrics/attributes for a specified report type.
#'
#' @param report Report type
#' @param apiVersion Supports 201806, 201802, 201710. Defaults to 201806.
#' @param apiVersion Supports 201809, 201806, 201802. Defaults to 201809.
#'
#' @importFrom utils read.csv
#' @export
#' @return List of available metrics/attributes.
#'
metrics <- function(report="ACCOUNT_PERFORMANCE_REPORT", apiVersion="201806"){
metrics <- function(report="ACCOUNT_PERFORMANCE_REPORT", apiVersion="201809"){
# Function which returns all available metrics for a specific report.
#
# Args:
Expand All @@ -19,9 +19,9 @@ metrics <- function(report="ACCOUNT_PERFORMANCE_REPORT", apiVersion="201806"){
report <- gsub('_','-',report)
report <- tolower(report)
switch(apiVersion,
"201809" = report <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201809/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8"),
"201806" = report <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201806/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8"),
"201802" = report <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201802/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8"),
"201710" = report <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201710/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8")
"201802" = report <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201802/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8")
)
metrics <- report$Name
metrics
Expand Down
9 changes: 5 additions & 4 deletions R/reports.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
#'
#' @description reports provides an overview of all available Adwords report types. The report type is specified in \code{\link{statement}}.
#'
#' @param apiVersion Supports 201806, 201802 and 201710. Defaults to 201806.
#' @param apiVersion Supports 201809, 201806 and 201802. Defaults to 201809.
#'
#' @export
#' @return Available report types.
reports <- function(apiVersion = "201806"){
reports <- function(apiVersion = "201809"){
# Function which returns all available report types
# Args: apiVersion
# Returns: Report types
switch (apiVersion,
"201809" = reportTypes <- list.files(system.file(package="RAdwords",'extdata/api201809/')),
"201806" = reportTypes <- list.files(system.file(package="RAdwords",'extdata/api201806/')),
"201802" = reportTypes <- list.files(system.file(package="RAdwords",'extdata/api201802/')),
"201710" = reportTypes <- list.files(system.file(package="RAdwords",'extdata/api201710/'))
"201802" = reportTypes <- list.files(system.file(package="RAdwords",'extdata/api201802/'))
)

reportTypes <- sub('.csv', '', reportTypes)
reportTypes <- gsub('-', '_', reportTypes)
reportTypes <- toupper(reportTypes)
Expand Down
6 changes: 3 additions & 3 deletions R/statement.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' CONTAINS | CONTAINS_IGNORE_CASE | DOES_NOT_CONTAIN | DOES_NOT_CONTAIN_IGNORE_CASE
#' @param start Beginning of date range. Format: 2018-01-01
#' @param end End of date rage. Format: 2018-01-10
#' @param apiVersion Adwords API Version, supports 201806, 201802, 201710 defaults to 201806.
#' @param apiVersion Adwords API Version, supports 201809, 201806, 201802 defaults to 201809.
#' @param compress TRUE / FALSE, Gzipped data download if TRUE
#'
#' @export
Expand Down Expand Up @@ -40,7 +40,7 @@ statement <- function(select = c("AccountDescriptiveName",
where,
start = "2018-01-01",
end = "2018-01-10",
apiVersion = "201806",
apiVersion = "201809",
compress = TRUE){
# Generates and builds the Adwords Query Language Statement for querying the Adwords API.
#
Expand All @@ -53,7 +53,7 @@ statement <- function(select = c("AccountDescriptiveName",
# CONTAINS | CONTAINS_IGNORE_CASE | DOES_NOT_CONTAIN | DOES_NOT_CONTAIN_IGNORE_CASE
# start: Start date
# end: End date
# apiVersion. Adwords API version 201806
# apiVersion. Adwords API version 201809
# compress: TRUE / FALSE, Gzipped data download if TRUE
#
# Returns:
Expand Down
8 changes: 4 additions & 4 deletions R/transformData.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#'
#' @param data Raw csv data from Adwords API.
#' @param report Report type.
#' @param apiVersion set automatically by \code{\link{getData}}. Supported are 201806, 201802, 201710. Defaults to 201806.
#' @param apiVersion set automatically by \code{\link{getData}}. Supported are 201809, 201806, 201802. Defaults to 201809.
#'
#' @importFrom utils read.csv read.csv2
#' @export
#'
#' @return Dataframe with the Adwords Data.
transformData <- function(data,
report = reportType,
apiVersion = "201806"){
apiVersion = "201809"){
# Transforms the csv into a dataframe. Moreover the variables are converted into suitable formats.
#
# Args:
Expand Down Expand Up @@ -60,9 +60,9 @@ transformData <- function(data,
report <- gsub('_','-',report)
report <- tolower(report)
switch(apiVersion,
"201809" = reportType <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201809/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8"),
"201806" = reportType <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201806/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8"),
"201802" = reportType <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201802/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8"),
"201710" = reportType <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201710/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8")
"201802" = reportType <- read.csv(paste(system.file(package="RAdwords"),'/extdata/api201802/',report,'.csv',sep=''), sep = ',', encoding = "UTF-8")
)
#transform factor into character
i <- sapply(data, is.factor)
Expand Down
Loading

0 comments on commit 7501120

Please sign in to comment.