/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { // Get the LineItemCreativeAssociationService. LineItemCreativeAssociationService licaService = (LineItemCreativeAssociationService) user.GetService( DfpService.v201306.LineItemCreativeAssociationService); // Get the CreativeService. CreativeService creativeService = (CreativeService) user.GetService(DfpService.v201306.CreativeService); // Set the line item ID and creative IDs to associate. long lineItemId = long.Parse(_T("INSERT_LINE_ITEM_ID_HERE")); long[] creativeIds = new long[] {long.Parse(_T("INSERT_CREATIVE_ID_HERE"))}; // Create an array to store local LICA objects. LineItemCreativeAssociation[] licas = new LineItemCreativeAssociation[creativeIds.Length]; // For each line item, associate it with the given creative. int i = 0; foreach (long creativeId in creativeIds) { LineItemCreativeAssociation lica = new LineItemCreativeAssociation(); lica.creativeId = creativeId; lica.lineItemId = lineItemId; licas[i++] = lica; } try { // Create the LICAs on the server. licas = licaService.createLineItemCreativeAssociations(licas); if (licas != null) { foreach (LineItemCreativeAssociation lica in licas) { Console.WriteLine("A LICA with line item ID \"{0}\", creative ID \"{1}\", and status " + "\"{2}\" was created.", lica.lineItemId, lica.creativeId, lica.status); } } else { Console.WriteLine("No LICAs created."); } } catch (Exception ex) { Console.WriteLine("Failed to associate creative with line item. Exception says \"{0}\"", ex.Message); } }
public LineItemCreativeAssociation CreateLica(DfpUser user, long lineItemId, long creativeId) { LineItemCreativeAssociationService licaService = (LineItemCreativeAssociationService)user.GetService( DfpService.v201306.LineItemCreativeAssociationService); LineItemCreativeAssociation lica = new LineItemCreativeAssociation(); lica.creativeId = creativeId; lica.lineItemId = lineItemId; return licaService.createLineItemCreativeAssociation(lica); }
public virtual LineItemCreativeAssociation updateLineItemCreativeAssociation(LineItemCreativeAssociation lineItemCreativeAssociation) { object[] results = this.Invoke("updateLineItemCreativeAssociation", new object[] { lineItemCreativeAssociation }); return ((LineItemCreativeAssociation) (results[0])); }
public void TestCreateLineItemCreativeAssociations() { LineItemCreativeAssociation localLica1 = new LineItemCreativeAssociation(); localLica1.creativeId = creativeId1; localLica1.lineItemId = lineItemId1; LineItemCreativeAssociation localLica2 = new LineItemCreativeAssociation(); localLica2.creativeId = creativeId2; localLica2.lineItemId = lineItemId2; LineItemCreativeAssociation[] newLicas = null; Assert.DoesNotThrow(delegate() { newLicas = licaService.createLineItemCreativeAssociations( new LineItemCreativeAssociation[] {localLica1, localLica2}); }); Assert.NotNull(newLicas); Assert.AreEqual(newLicas.Length, 2); Assert.NotNull(newLicas[0]); Assert.AreEqual(newLicas[0].creativeId, localLica1.creativeId); Assert.AreEqual(newLicas[0].lineItemId, localLica1.lineItemId); Assert.NotNull(newLicas[1]); Assert.AreEqual(newLicas[1].creativeId, localLica2.creativeId); Assert.AreEqual(newLicas[1].lineItemId, localLica2.lineItemId); }
public void TestCreateLineItemCreativeAssociation() { LineItemCreativeAssociation lica = new LineItemCreativeAssociation(); lica.creativeId = creativeId1; lica.lineItemId = lineItemId1; LineItemCreativeAssociation newLica = null; Assert.DoesNotThrow(delegate() { newLica = licaService.createLineItemCreativeAssociation(lica); }); Assert.NotNull(newLica); Assert.AreEqual(newLica.creativeId, lica.creativeId); Assert.AreEqual(newLica.lineItemId, lica.lineItemId); }
public void Init() { TestUtils utils = new TestUtils(); licaService = (LineItemCreativeAssociationService) user.GetService( DfpService.v201306.LineItemCreativeAssociationService); advertiserId = utils.CreateCompany(user, CompanyType.ADVERTISER).id; salespersonId = utils.GetSalesperson(user).id; traffickerId = utils.GetTrafficker(user).id; orderId = utils.CreateOrder(user, advertiserId, salespersonId, traffickerId).id; adUnitId = utils.CreateAdUnit(user).id; lineItemId1 = utils.CreateLineItem(user, orderId, adUnitId).id; lineItemId2 = utils.CreateLineItem(user, orderId, adUnitId).id; lineItemId3 = utils.CreateLineItem(user, orderId, adUnitId).id; lineItemId4 = utils.CreateLineItem(user, orderId, adUnitId).id; creativeId1 = utils.CreateCreative(user, advertiserId).id; creativeId2 = utils.CreateCreative(user, advertiserId).id; creativeId3 = utils.CreateCreative(user, advertiserId).id; creativeId4 = utils.CreateCreative(user, advertiserId).id; lica1 = utils.CreateLica(user, lineItemId3, creativeId3); lica2 = utils.CreateLica(user, lineItemId4, creativeId4); }