The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Manipulating Orders and LineItems with rdfp

Steven M. Mortimer

2018-03-29

First, we load rdfp and specify the DFP network we would like to connect to. Then we authenticate by using dfp_auth(). Any existing cached token would be used or we will be prompted to authenticate via the browser.

library(rdfp)
options(rdfp.network_code = 123456789)
dfp_auth()

Create an Order

This example uses a test company as an advertiser and yourself as the trafficker, to create an order.

request_data <- list('filterStatement'=list('query'="WHERE name = 'TestCompany1'"))
dfp_getCompaniesByStatement_result <- dfp_getCompaniesByStatement(request_data) 

request_data <- list(list(name='TestOrder', 
                          startDateTime=list(date=list(year=2018, month=12, day=1), 
                                             hour=0,
                                             minute=0,
                                             second=0,
                                             timeZoneID='America/New_York'),
                          endDateTime=list(date=list(year=2018, month=12, day=31), 
                                           hour=23,
                                           minute=59,
                                           second=59,
                                           timeZoneID='America/New_York'), 
                          notes='API Test Order', 
                          externalOrderId=99999, 
                          advertiserId=dfp_getCompaniesByStatement_result$id, 
                          traffickerId=dfp_getCurrentUser()$id))
dfp_createOrders_result <- dfp_createOrders(request_data)

Get Line Items By A Filter

Below is an example of how to get objects by Publishers Query Language (PQL) statement. The statement is constructed as a list of lists that are nested to emulate the hierarchy of the XML to be created. The example uses the dfp_getLineItemsByStatement function from the [LineItemService] (https://developers.google.com/ad-manager/api/reference/v201905/LineItemService)

# retrieve 3 line items that have a status of "DELIVERING"
request <- list('filterStatement'=list('query'="WHERE status='DELIVERING' LIMIT 3"))
resultset <- dfp_getLineItemsByStatement(request, as_df=TRUE)
resultset[,c('orderId', 'id', 'priority', 'deliveryRateType')]
#> # A tibble: 3 x 4
#>      orderId         id priority deliveryRateType
#>        <dbl>      <dbl>    <dbl> <chr>           
#> 1 2231707164 4557799162       12 EVENLY          
#> 2 2231707164 4557800341       12 EVENLY          
#> 3 2231707164 4557803758       12 EVENLY

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.