I have been asked to replicate a report that can't be run in GAM due to the number of lines that would be returned.
I am trying to munge the existing API examples but am lost at the moment. :)
I am trying to get all line items that are not archived and are any of multiple statuses.
The following code is throwing an error asking about commas so I am sure it is completely wrong.
def main(client):
# Initialize appropriate service.
line_item_service = client.GetService('LineItemService', version='v202202')
# Create a statement to select line items.
statement = (ad_manager.StatementBuilder(version='v202202')
Where('isArchived = :isArchived')
IN status('delivering', 'inactive', 'paused', 'ready')
WithBindVariable('isArchived', False))
And we would like to return a list with
Order name, line item name, line item Id, start date, end date, and custom targeting
I started with this but it is probably wrong :)
while True:
response = line_item_service.getLineItemsByStatement(statement.ToStatement(
))
if 'results' in response and len(response['results']):
for line_item in response['results']:
# Print out some information for each line item.
print(('Line ID "%d"|name "%s"|startDateTime "%s"|endDateTime "%s"|customTargeting "%s"\n' %
(line_item['id'], line_item['name'],line_item['startDate'], line_item['endDate'],line_item['customTargeting'])))
statement.offset += statement.limit
else:
break
I appreciate the help.