Skip to content

Commit a719077

Browse files
Update to v0.1.2
1 parent 5bd8d9f commit a719077

File tree

237 files changed

+3478
-1148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+3478
-1148
lines changed

DESCRIPTION

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
Package: rdfp
2-
Title: DoubleClick for Publishers API from R
3-
Version: 0.1.1.9000
4-
Date: 2018-03-29
5-
Description: An implementation of Google's DoubleClick for Publishers API in R.
2+
Title: An Implementation of the 'DoubleClick for Publishers' API
3+
Version: 0.1.2
4+
Date: 2018-04-07
5+
Description: An implementation of Google's 'DoubleClick for Publishers' (DFP) API
6+
<https://developers.google.com/doubleclick-publishers/docs/start>.
67
This package is automatically compiled from the API WSDLs (Web Service Description
78
Language) files to dictate how the API is structured. Theoretically, all API
89
actions are possible using this package; however, care must be taken to format
9-
the inputs correctly and parse the outputs correctly as well. See Google's DFP
10-
API reference and the rdfp pkgdown website for more information, documentation
11-
and examples.
10+
the inputs correctly and parse the outputs correctly as well. Please see Google's
11+
DFP API reference and this package's website <https://stevenmmortimer.github.io/rdfp/>
12+
for more information, documentation, and examples.
1213
Authors@R: c(
13-
person(c("Steven", "M."), "Mortimer", , "[email protected]", c("aut", "cre"))
14+
person(c("Steven", "M."), "Mortimer", , "[email protected]", c("aut", "cre")),
15+
person("Jennifer", "Bryan", , "[email protected]", c("ctb")),
16+
person("Joanna", "Zhao", , "[email protected]", c("ctb"))
1417
)
1518
URL: https://github.com/StevenMMortimer/rdfp
1619
BugReports: https://github.com/StevenMMortimer/rdfp/issues
@@ -34,7 +37,8 @@ Imports:
3437
Suggests:
3538
knitr,
3639
testthat,
37-
rmarkdown
40+
rmarkdown,
41+
here
3842
RoxygenNote: 6.0.1
3943
Collate:
4044
'ActivityGroupService.R'

LICENSE

+2-52
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,2 @@
1-
MIT License
2-
3-
Copyright (c) 2018 Steven M. Mortimer
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
22-
23-
The rdfp package includes other open source software components. The following
24-
is a list of these components (full copies of the license agreements used by
25-
these components are included below):
26-
27-
- googlesheets, https://github.com/jennybc/googlesheets
28-
29-
30-
googlesheets License
31-
----------------------------------------------------------------------
32-
The MIT License (MIT)
33-
34-
Copyright (c) 2017 Jennifer Bryan, Joanna Zhao
35-
36-
Permission is hereby granted, free of charge, to any person obtaining a copy
37-
of this software and associated documentation files (the "Software"), to deal
38-
in the Software without restriction, including without limitation the rights
39-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40-
copies of the Software, and to permit persons to whom the Software is
41-
furnished to do so, subject to the following conditions:
42-
43-
The above copyright notice and this permission notice shall be included in
44-
all copies or substantial portions of the Software.
45-
46-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
52-
THE SOFTWARE.
1+
YEAR: 2018
2+
COPYRIGHT HOLDER: Steven M. Mortimer

NEWS.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
## rdfp 0.1.1.9000
1+
## rdfp 0.1.2 [release](https://github.com/StevenMMortimer/rdfp/releases/tag/v0.1.2)
22

33
### Features
44

55
* `dfp_report_url_to_dataframe()` now returns a `tbl_df` object for better
66
printing and casted data types
7-
* Simplified `dfp_select()` so that it automatically uses `dfp_select_parse()`
7+
* Simplify `dfp_select()` so that it automatically uses `dfp_select_parse()`
88
to format the result into a `tbl_df`
9-
* Added `dfp_date_as_list()` that will convert a date or datetime representation
10-
in R to the required list format for submission to DFP
11-
* Started to add some examples to functions so that the inline documentation
9+
* Add `dfp_date_as_list()` that will convert a date or datetime representation
10+
in R to the required list format for submission to DFP
11+
* Add examples to functions so that the inline documentation
1212
gives a better idea of how to make it work in R
13-
14-
### Bug Fixes
15-
16-
* Nothing yet!
13+
* Add `addtl_scopes` arugment to `dfp_auth()` so that users can create token that
14+
can be used with other R packages to connect to other Google services
1715

1816
---
1917

R/dfp_auth.R

+22-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# of allowing httr to refresh if 401 error occurs
1010
# - renamed the function gs_auth to dfp_auth to be consistent with package endpoint
1111

12-
# Copyright (c) 2015 Jennifer Bryan, Joanna Zhao
12+
# Copyright (c) 2017 Jennifer Bryan, Joanna Zhao
1313

1414
# Licensed under MIT license.
1515

@@ -55,9 +55,9 @@ is_legit_token <- function(x, verbose = FALSE) {
5555
#' Authorize \code{rdfp} to access your Google user data. You will be
5656
#' directed to a web browser, asked to sign in to your Google account, and to
5757
#' grant \code{rdfp} access to user data for Double Click for Publishers.
58-
#' These user credentials are cached in a file named
59-
#' \code{.httr-oauth} in the current working directory, from where they can be
60-
#' automatically refreshed, as necessary.
58+
#' These user credentials are cached in a file named \code{.httr-oauth} in
59+
#' the current working directory, from where they can be automatically refreshed,
60+
#' as necessary.
6161
#'
6262
#' Most users, most of the time, do not need to call this function
6363
#' explicitly -- it will be triggered by the first action that
@@ -77,7 +77,7 @@ is_legit_token <- function(x, verbose = FALSE) {
7777
#'
7878
#' In a call to \code{dfp_auth}, the user can provide the token, app key and
7979
#' secret explicitly and can dictate whether credentials will be cached in
80-
#' \code{.httr_oauth}. They must be specified.
80+
#' \code{.httr-oauth}. They must be specified.
8181
#'
8282
#' To set options in a more persistent way, predefine one or more of
8383
#' them with lines like this in a \code{.Rprofile} file:
@@ -101,6 +101,10 @@ is_legit_token <- function(x, verbose = FALSE) {
101101
#' want to wipe the slate clean and re-authenticate with the same or different
102102
#' Google account. This deletes the \code{.httr-oauth} file in current working
103103
#' directory.
104+
#' @param addtl_scopes character, strings that indicate additional Google services
105+
#' the client should authorize. Use this when trying to generate a token that will
106+
#' work to authenticate to other packages using Google services, such as the googlesheets
107+
#' package or RGoogleAnalytics package.
104108
#' @param key,secret the "Client ID" and "Client secret" for the application
105109
#' @param cache logical indicating if \code{rdfp} should cache
106110
#' credentials in the default cache file \code{.httr-oauth}
@@ -111,6 +115,15 @@ is_legit_token <- function(x, verbose = FALSE) {
111115
#' @export
112116
dfp_auth <- function(token = NULL,
113117
new_user = FALSE,
118+
addtl_scopes = c("https://spreadsheets.google.com/feeds",
119+
"https://www.googleapis.com/auth/drive",
120+
"https://www.googleapis.com/auth/spreadsheets",
121+
"https://www.googleapis.com/auth/presentations",
122+
"https://www.googleapis.com/auth/analytics",
123+
"https://www.googleapis.com/auth/yt-analytics.readonly",
124+
"https://www.googleapis.com/auth/gmail.readonly",
125+
"https://www.googleapis.com/auth/gmail.compose",
126+
"https://www.googleapis.com/auth/gmail.send"),
114127
key = getOption("rdfp.client_id"),
115128
secret = getOption("rdfp.client_secret"),
116129
cache = getOption("rdfp.httr_oauth_cache"),
@@ -124,6 +137,10 @@ dfp_auth <- function(token = NULL,
124137
if(is.null(token)) {
125138

126139
scope_list <- c("https://www.googleapis.com/auth/dfp")
140+
if(!missing(addtl_scopes)){
141+
addtl_scopes <- match.arg(addtl_scopes, several.ok = TRUE)
142+
scope_list <- c(scope_list, addtl_scopes)
143+
}
127144

128145
rdfp_app <- httr::oauth_app("google", key = key, secret = secret)
129146

R/dfp_utils.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ dfp_date_to_list <- function(this_date,
9595
which_daytime <- match.arg(daytime)
9696

9797
if(ensure_today_works & (difftime(this_date, (Sys.time()+hours(1))) < 0)){
98-
warning("The date provided is not at least 1 hour into the future. Setting to one hour after now.")
98+
message("The date provided is not at least 1 hour into the future. Setting to one hour after now.")
9999
this_date <- Sys.time() + hours(1)
100100
}
101101

@@ -106,7 +106,7 @@ dfp_date_to_list <- function(this_date,
106106
} else {
107107
this_hour <- hour(this_date)
108108
this_minute <- minute(this_date)
109-
this_second <- second(this_date)
109+
this_second <- round(second(this_date), 0)
110110
}
111111

112112
x <- list(date=list(year = year(this_date),

README.Rmd

+10-12
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ inventory, create orders, pull reports, and more!
2828
* [Installation](#installation)
2929
* [Vignettes](#vignettes)
3030
* [Usage](#usage)
31-
* [Functions](#functions)
32-
* [Set API Version](#set-api-version)
31+
* [Set API Version](#load-package-and-set-api-version)
3332
* [Authenticate](#authenticate)
3433
* [Get Current User Info](#get-current-user-info)
3534
* [Pull a LineItem](#pull-a-lineitem)
@@ -40,8 +39,9 @@ inventory, create orders, pull reports, and more!
4039
## Installation
4140

4241
```{r, eval = FALSE}
43-
# this package is currently not on CRAN, so it should be installed from GitHub
44-
# install.packages("devtools")
42+
install.packages("devtools")
43+
44+
# or to get the latest version available on GitHub
4545
devtools::install_github("StevenMMortimer/rdfp")
4646
```
4747

@@ -61,8 +61,6 @@ more detailed examples on usage.
6161

6262
## Usage
6363

64-
### Functions
65-
6664
All functions start with `dfp_` so that you can easily identify DFP-specific
6765
operations and use tab completion in RStudio. Most **rdfp** functions will
6866
return a `data.frame` or `list` parsed from the XML returned in the SOAP response.
@@ -94,25 +92,25 @@ your browswer will pop open and you will interactively authenticate.
9492

9593
The package has other options like a client\_id and client\_secret where you can
9694
connect using your own API client instead of the package default. Using your own
97-
client requires setting one up in the [Google Developers Console]
98-
(https://console.developers.google.com).
95+
client requires setting one up in the
96+
[Google Developers Console](https://console.developers.google.com).
9997

10098
```{r eval = FALSE}
10199
options(rdfp.network_code = "12345678")
102100
options(rdfp.application_name = "MyApp")
103101
options(rdfp.client_id = "012345678901-99thisisatest99.apps.googleusercontent.com")
104102
options(rdfp.client_secret = "Th1s1sMyC1ientS3cr3t")
105103
106-
# this function will use the options set above and
107-
# cache an OAuth token in the working directory
104+
# dfp_auth will use the options above and cache an OAuth token in the working directory
108105
# the token will be refreshed when necessary
109106
dfp_auth()
110107
```
111108

112109
```{r auth, include = FALSE}
113-
token_path <- file.path(".", "tests", "testthat", "rdfp_token.rds")
110+
library(here)
111+
token_path <- here("tests", "testthat", "rdfp_token.rds")
114112
suppressMessages(dfp_auth(token = token_path, verbose = FALSE))
115-
options_path <- file.path(".", "tests", "testthat", "rdfp_options.rds")
113+
options_path <- here("tests", "testthat", "rdfp_options.rds")
116114
rdfp_options <- readRDS(options_path)
117115
options(rdfp.network_code = rdfp_options$network_code)
118116
```

README.md

+18-21
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ Table of Contents
1414
- [Installation](#installation)
1515
- [Vignettes](#vignettes)
1616
- [Usage](#usage)
17-
- [Functions](#functions)
18-
- [Set API Version](#set-api-version)
17+
- [Set API Version](#load-package-and-set-api-version)
1918
- [Authenticate](#authenticate)
2019
- [Get Current User Info](#get-current-user-info)
2120
- [Pull a LineItem](#pull-a-lineitem)
@@ -27,8 +26,9 @@ Installation
2726
------------
2827

2928
``` r
30-
# this package is currently not on CRAN, so it should be installed from GitHub
31-
# install.packages("devtools")
29+
install.packages("devtools")
30+
31+
# or to get the latest version available on GitHub
3232
devtools::install_github("StevenMMortimer/rdfp")
3333
```
3434

@@ -48,8 +48,6 @@ The README below outlines the package functionality, but review the vignettes fo
4848
Usage
4949
-----
5050

51-
### Functions
52-
5351
All functions start with `dfp_` so that you can easily identify DFP-specific operations and use tab completion in RStudio. Most **rdfp** functions will return a `data.frame` or `list` parsed from the XML returned in the SOAP response.
5452

5553
### Load Package and Set API Version
@@ -69,16 +67,15 @@ options(rdfp.version = "v201711")
6967

7068
To authenticate you will first need to specify the `network_code` of the DFP instance you'd like to connect to. This is the only required option that the user must specify when using the **rdfp** package. After setting the `network_code` all you need to do is run `dfp_auth()`. If you already have a cached `.httr-oauth` file in the current working directory, then the token will be loaded and refreshed if necessary. Otherwise, your browswer will pop open and you will interactively authenticate.
7169

72-
The package has other options like a client\_id and client\_secret where you can connect using your own API client instead of the package default. Using your own client requires setting one up in the \[Google Developers Console\] (<https://console.developers.google.com>).
70+
The package has other options like a client\_id and client\_secret where you can connect using your own API client instead of the package default. Using your own client requires setting one up in the [Google Developers Console](https://console.developers.google.com).
7371

7472
``` r
7573
options(rdfp.network_code = "12345678")
7674
options(rdfp.application_name = "MyApp")
7775
options(rdfp.client_id = "012345678901-99thisisatest99.apps.googleusercontent.com")
7876
options(rdfp.client_secret = "Th1s1sMyC1ientS3cr3t")
7977

80-
# this function will use the options set above and
81-
# cache an OAuth token in the working directory
78+
# dfp_auth will use the options above and cache an OAuth token in the working directory
8279
# the token will be refreshed when necessary
8380
dfp_auth()
8481
```
@@ -139,20 +136,20 @@ request_data <- list(reportJob=list(reportQuery=list(dimensions='MONTH_AND_YEAR'
139136
# if you would like more control, see the example below which moves through each step in the process
140137
report_data <- dfp_full_report_wrapper(request_data)
141138
report_data[,c('Dimension.MONTH_AND_YEAR', 'Dimension.AD_UNIT_ID', 'Column.AD_SERVER_CLICKS')]
142-
#> # A tibble: 25 x 3
139+
#> # A tibble: 27 x 3
143140
#> Dimension.MONTH_AND_YEAR Dimension.AD_UNIT_ID Column.AD_SERVER_CLICKS
144141
#> <chr> <dbl> <dbl>
145-
#> 1 2018-03 133765096. 1778.
146-
#> 2 2018-03 133765216. 422.
147-
#> 3 2018-03 133765336. 642.
148-
#> 4 2018-03 133765456. 2176.
149-
#> 5 2018-03 142461136. 91.
150-
#> 6 2018-03 133765576. 17581.
151-
#> 7 2018-03 133765696. 945.
152-
#> 8 2018-03 133765936. 18171.
153-
#> 9 2018-03 142461016. 312.
154-
#> 10 2018-03 143543776. 1496.
155-
#> # ... with 15 more rows
142+
#> 1 2018-04 133765096. 1815.
143+
#> 2 2018-04 133765216. 452.
144+
#> 3 2018-04 133765336. 652.
145+
#> 4 2018-04 133765456. 2247.
146+
#> 5 2018-04 142461136. 88.
147+
#> 6 2018-04 133765576. 17440.
148+
#> 7 2018-04 133765696. 961.
149+
#> 8 2018-04 133765936. 17514.
150+
#> 9 2018-04 142461016. 324.
151+
#> 10 2018-04 143543776. 1348.
152+
#> # ... with 17 more rows
156153
```
157154

158155
Credits

_pkgdown.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ url: https://stevenmmortimer.github.io/rdfp/
33
template:
44
params:
55
bootswatch: spacelab
6-
ganalytics: UA-98603021-1
6+
ganalytics: UA-98603021-2
77

88
home:
99
strip_header: true
@@ -12,6 +12,7 @@ navbar:
1212
type: default
1313
left:
1414
- text: "Articles"
15+
icon: fas fa-book
1516
menu:
1617
- text: Administrative Tasks
1718
href: articles/administrative-tasks.html
@@ -24,11 +25,14 @@ navbar:
2425
- text: Pulling Reports
2526
href: articles/pulling-reports.html
2627
- text: Reference
28+
icon: fa-file-code-o
2729
href: reference/index.html
2830
- text: News
31+
icon: fa-newspaper-o
2932
href: news/index.html
3033
right:
31-
- icon: fa-github fa-lg
34+
- text: GitHub
35+
icon: fa-github fa-lg
3236
href: https://github.com/StevenMMortimer/rdfp
3337

3438
reference:

0 commit comments

Comments
 (0)