12
12
# '
13
13
# ' Creates a new ActivityGroup objects.
14
14
# '
15
- # ' @importFrom plyr llply ldply
16
- # ' @importFrom utils tail
17
- # ' @seealso \href{https://developers.google.com/doubleclick-publishers/docs/reference/v201711/ActivityGroupService#createActivityGroups}{Google Documentation for createActivityGroups}
15
+ # ' @seealso \href{https://developers.google.com/doubleclick-publishers/docs/reference/v201802/ActivityGroupService#createActivityGroups}{Google Documentation for createActivityGroups}
18
16
# '
19
17
# ' @param request_data a \code{list} or \code{data.frame} of data elements
20
18
# ' to be formatted for a SOAP
25
23
# ' @return a \code{data.frame} or \code{list} containing all the elements of a createActivityGroupsResponse
26
24
# ' @export
27
25
dfp_createActivityGroups <- function (request_data , as_df = TRUE , verbose = FALSE ){
28
- request_body <- make_request_body(service = ' ActivityGroupService' , root_name = ' createActivityGroups' , data = request_data )
29
- request <- build_soap_request(body = request_body , verbose = verbose )
30
-
31
- null_root <- is.null(request )
32
- response <- NULL
33
- response <- try(xmlChildren(xmlChildren(xmlChildren(xmlRoot(request ))$ Body )[[' createActivityGroupsResponse' ]]), silent = T )
34
- result <- if (null_root | is.null(response )){
35
- NULL
36
- } else if (is.null(response $ rval )){
37
- NULL
38
- } else if (as_df ){
39
- if (length(response [grepl(' rval' , names(response ))])== 1 &
40
- names(response [grepl(' rval' , names(response ))][[1 ]])[1 ]== ' totalResultSetSize' &
41
- names(response [grepl(' rval' , names(response ))][[1 ]])[2 ]== ' startIndex' ){
42
- ldply(tail(response [grepl(' rval' , names(response ))]$ rval , - 2 ),
43
- .fun = function (x ){
44
- x <- xmlToList(x )
45
- x [sapply(x , is.null )] <- NA
46
- new_x <- as.data.frame(x , stringsAsFactors = F )
47
- return (new_x )
48
- }, .id = NULL )
49
- } else {
50
- ldply(response [grepl(' rval' , names(response ))],
51
- .fun = function (x ){
52
- x <- xmlToList(x )
53
- x [sapply(x , is.null )] <- NA
54
- new_x <- as.data.frame(x , stringsAsFactors = F )
55
- return (new_x )
56
- }, .id = NULL )
57
- }
58
- } else {
59
- llply(response [grepl(' rval' , names(response ))],
60
- .fun = function (x ){
61
- x <- xmlToList(x )
62
- return (x )
63
- })
64
- }
26
+ request_body <- form_request_body(service = ' ActivityGroupService' , root_name = ' createActivityGroups' , data = request_data )
27
+ response <- execute_soap_request(body = request_body , verbose = verbose )
28
+ result <- parse_soap_response(httr_response = response , resp_element = ' createActivityGroupsResponse' , as_df = as_df )
65
29
return (result )
66
30
}
67
31
# '
@@ -76,9 +40,7 @@ dfp_createActivityGroups <- function(request_data, as_df=TRUE, verbose=FALSE){
76
40
# ' \item{status}
77
41
# ' }
78
42
# '
79
- # ' @importFrom plyr llply ldply
80
- # ' @importFrom utils tail
81
- # ' @seealso \href{https://developers.google.com/doubleclick-publishers/docs/reference/v201711/ActivityGroupService#getActivityGroupsByStatement}{Google Documentation for getActivityGroupsByStatement}
43
+ # ' @seealso \href{https://developers.google.com/doubleclick-publishers/docs/reference/v201802/ActivityGroupService#getActivityGroupsByStatement}{Google Documentation for getActivityGroupsByStatement}
82
44
# '
83
45
# ' @param request_data a \code{list} or \code{data.frame} of data elements
84
46
# ' to be formatted for a SOAP
@@ -89,53 +51,17 @@ dfp_createActivityGroups <- function(request_data, as_df=TRUE, verbose=FALSE){
89
51
# ' @return a \code{data.frame} or \code{list} containing all the elements of a getActivityGroupsByStatementResponse
90
52
# ' @export
91
53
dfp_getActivityGroupsByStatement <- function (request_data , as_df = TRUE , verbose = FALSE ){
92
- request_body <- make_request_body(service = ' ActivityGroupService' , root_name = ' getActivityGroupsByStatement' , data = request_data )
93
- request <- build_soap_request(body = request_body , verbose = verbose )
94
-
95
- null_root <- is.null(request )
96
- response <- NULL
97
- response <- try(xmlChildren(xmlChildren(xmlChildren(xmlRoot(request ))$ Body )[[' getActivityGroupsByStatementResponse' ]]), silent = T )
98
- result <- if (null_root | is.null(response )){
99
- NULL
100
- } else if (is.null(response $ rval )){
101
- NULL
102
- } else if (as_df ){
103
- if (length(response [grepl(' rval' , names(response ))])== 1 &
104
- names(response [grepl(' rval' , names(response ))][[1 ]])[1 ]== ' totalResultSetSize' &
105
- names(response [grepl(' rval' , names(response ))][[1 ]])[2 ]== ' startIndex' ){
106
- ldply(tail(response [grepl(' rval' , names(response ))]$ rval , - 2 ),
107
- .fun = function (x ){
108
- x <- xmlToList(x )
109
- x [sapply(x , is.null )] <- NA
110
- new_x <- as.data.frame(x , stringsAsFactors = F )
111
- return (new_x )
112
- }, .id = NULL )
113
- } else {
114
- ldply(response [grepl(' rval' , names(response ))],
115
- .fun = function (x ){
116
- x <- xmlToList(x )
117
- x [sapply(x , is.null )] <- NA
118
- new_x <- as.data.frame(x , stringsAsFactors = F )
119
- return (new_x )
120
- }, .id = NULL )
121
- }
122
- } else {
123
- llply(response [grepl(' rval' , names(response ))],
124
- .fun = function (x ){
125
- x <- xmlToList(x )
126
- return (x )
127
- })
128
- }
54
+ request_body <- form_request_body(service = ' ActivityGroupService' , root_name = ' getActivityGroupsByStatement' , data = request_data )
55
+ response <- execute_soap_request(body = request_body , verbose = verbose )
56
+ result <- parse_soap_response(httr_response = response , resp_element = ' getActivityGroupsByStatementResponse' , as_df = as_df )
129
57
return (result )
130
58
}
131
59
# '
132
60
# ' updateActivityGroups
133
61
# '
134
62
# ' Updates the specified ActivityGroup objects.
135
63
# '
136
- # ' @importFrom plyr llply ldply
137
- # ' @importFrom utils tail
138
- # ' @seealso \href{https://developers.google.com/doubleclick-publishers/docs/reference/v201711/ActivityGroupService#updateActivityGroups}{Google Documentation for updateActivityGroups}
64
+ # ' @seealso \href{https://developers.google.com/doubleclick-publishers/docs/reference/v201802/ActivityGroupService#updateActivityGroups}{Google Documentation for updateActivityGroups}
139
65
# '
140
66
# ' @param request_data a \code{list} or \code{data.frame} of data elements
141
67
# ' to be formatted for a SOAP
@@ -146,43 +72,9 @@ dfp_getActivityGroupsByStatement <- function(request_data, as_df=TRUE, verbose=F
146
72
# ' @return a \code{data.frame} or \code{list} containing all the elements of a updateActivityGroupsResponse
147
73
# ' @export
148
74
dfp_updateActivityGroups <- function (request_data , as_df = TRUE , verbose = FALSE ){
149
- request_body <- make_request_body(service = ' ActivityGroupService' , root_name = ' updateActivityGroups' , data = request_data )
150
- request <- build_soap_request(body = request_body , verbose = verbose )
151
-
152
- null_root <- is.null(request )
153
- response <- NULL
154
- response <- try(xmlChildren(xmlChildren(xmlChildren(xmlRoot(request ))$ Body )[[' updateActivityGroupsResponse' ]]), silent = T )
155
- result <- if (null_root | is.null(response )){
156
- NULL
157
- } else if (is.null(response $ rval )){
158
- NULL
159
- } else if (as_df ){
160
- if (length(response [grepl(' rval' , names(response ))])== 1 &
161
- names(response [grepl(' rval' , names(response ))][[1 ]])[1 ]== ' totalResultSetSize' &
162
- names(response [grepl(' rval' , names(response ))][[1 ]])[2 ]== ' startIndex' ){
163
- ldply(tail(response [grepl(' rval' , names(response ))]$ rval , - 2 ),
164
- .fun = function (x ){
165
- x <- xmlToList(x )
166
- x [sapply(x , is.null )] <- NA
167
- new_x <- as.data.frame(x , stringsAsFactors = F )
168
- return (new_x )
169
- }, .id = NULL )
170
- } else {
171
- ldply(response [grepl(' rval' , names(response ))],
172
- .fun = function (x ){
173
- x <- xmlToList(x )
174
- x [sapply(x , is.null )] <- NA
175
- new_x <- as.data.frame(x , stringsAsFactors = F )
176
- return (new_x )
177
- }, .id = NULL )
178
- }
179
- } else {
180
- llply(response [grepl(' rval' , names(response ))],
181
- .fun = function (x ){
182
- x <- xmlToList(x )
183
- return (x )
184
- })
185
- }
75
+ request_body <- form_request_body(service = ' ActivityGroupService' , root_name = ' updateActivityGroups' , data = request_data )
76
+ response <- execute_soap_request(body = request_body , verbose = verbose )
77
+ result <- parse_soap_response(httr_response = response , resp_element = ' updateActivityGroupsResponse' , as_df = as_df )
186
78
return (result )
187
79
}
188
- # '
80
+ # '
0 commit comments