public static void UpdateDomainModel(this CreativeDto creativeDto, Creative creative)
        {
            ValidateUpdateOfDomainModel(creativeDto, creative);

            creative.Name = creativeDto.Name;
            creative.AdvertiserId = creativeDto.AdvertiserId;
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string videoAssetName = _T("INSERT_VIDEO_ASSET_NAME_HERE");
              string pathToVideoAssetFile = _T("INSERT_PATH_TO_VIDEO_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test in-stream video creative";
              creative.Type = "INSTREAM_VIDEO";

              // Upload the video asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId videoAssetId = assetUtils.uploadAsset(pathToVideoAssetFile, "VIDEO");

              CreativeAsset videoAsset = new CreativeAsset();
              videoAsset.AssetIdentifier = videoAssetId;
              videoAsset.Role = "PARENT_VIDEO";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { videoAsset };

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("In-stream video creative with ID {0} was created.", result.Id);
        }
 public void Init() {
   TestUtils utils = new TestUtils();
   creativeService = (CreativeService)user.GetService(DfpService.v201508.CreativeService);
   advertiserId = utils.CreateCompany(user, CompanyType.ADVERTISER).id;
   creative1 = utils.CreateCreative(user, advertiserId);
   creative2 = utils.CreateCreative(user, advertiserId);
 }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
      long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

      Creative creative = new Creative();
      creative.AdvertiserId = advertiserId;
      creative.Name = "Test image creative";
      creative.Size = new Size() { Id = sizeId };
      creative.Type = "IMAGE";

      // Upload the image asset.
      CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
      CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "IMAGE");

      CreativeAsset imageAsset = new CreativeAsset();
      imageAsset.AssetIdentifier = imageAssetId;
      imageAsset.Role = "PRIMARY";

      // Add the creative assets.
      creative.CreativeAssets = new List<CreativeAsset>() { imageAsset };

      Creative result = service.Creatives.Insert(creative, profileId).Execute();

      // Display the new creative ID.
      Console.WriteLine("Image creative with ID {0} was created.", result.Id);
    }
        public void Mismatch_Between_CreativeId_And_CreativeDtoId_Will_Cause_A_DomainException()
        {
            Creative creative = new Creative(new PersistCreative { AdvertiserId = 5, CreativeName = "Existing Creative Name", CreativeId = 100 });

            _creativeDto.UpdateDomainModel(creative);

            Assert.AreNotEqual(creative.Name, _creativeDto.Name, "The Creative name should not have updated from CreativeDto name.");
        }
        public void Can_Update_CreativeDomainModel_And_Domain_Creative_Values_Match_CreativeDto_Values()
        {
            Creative creative = new Creative(new PersistCreative { AdvertiserId = 5, CreativeName = "Existing Creative Name", CreativeId = 1, Active = true });

            _creativeDto.UpdateDomainModel(creative);

            Assert.AreEqual(_creativeDto.Id, creative.Id);
            Assert.AreEqual(_creativeDto.Name, creative.Name);
            Assert.AreEqual(_creativeDto.AdvertiserId, creative.AdvertiserId);
        }
            public void Then_A_Null_Initial_State_Will_Cause_A_DomainException()
            {
                // ARRANGE
                PersistCreative persistCreative = null;

                // ACT
                var creative = new Creative(persistCreative);

                // ASSERT
                // Nothing to assert.
            }
        private static void ValidateUpdateOfDomainModel(CreativeDto creativeDto, Creative creative)
        {
            if (creativeDto == null)
                throw new DomainException("Unable to update Creative from null CreativeDto.");

            if (creative == null)
                throw new DomainException("Unable to update null Creative from CreativeDto.");

            if (creative.Id != creativeDto.Id)
                throw new DomainException("Unable to update Creative since Id values do not match.");
        }
        public static Creative ConvertToDomainModel(this CreativeDto creativeDto)
        {
            var creative = new Creative(new PersistCreative()
            {
                Active = true,
                CreativeId = creativeDto.Id,
                CreativeName = creativeDto.Name,
                AdvertiserId = creativeDto.AdvertiserId,
            });

            return creative;
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string pathToHtmlAssetFile = _T("INSERT_PATH_TO_HTML_ASSET_FILE_HERE");
              string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test enhanced banner creative";
              creative.Size = new Size() { Id = sizeId };
              creative.Type = "ENHANCED_BANNER";

              // Upload the HTML asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId htmlAssetId = assetUtils.uploadAsset(pathToHtmlAssetFile, "HTML");

              CreativeAsset htmlAsset = new CreativeAsset();
              htmlAsset.AssetIdentifier = htmlAssetId;
              htmlAsset.Role = "PRIMARY";
              htmlAsset.WindowMode = "TRANSPARENT";

              // Upload the backup image asset.
              CreativeAssetId backupImageAssetId =
              assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

              CreativeAsset backupImageAsset = new CreativeAsset();
              backupImageAsset.AssetIdentifier = backupImageAssetId;
              backupImageAsset.Role = "BACKUP_IMAGE";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { htmlAsset, backupImageAsset };

              // Configure the backup image.
              creative.BackupImageClickThroughUrl = "https://www.google.com";
              creative.BackupImageReportingLabel = "backup";
              creative.BackupImageTargetWindow = new TargetWindow() { TargetWindowOption = "NEW_WINDOW" };

              // Add a click tag.
              ClickTag clickTag = new ClickTag();
              clickTag.Name = "clickTag";
              clickTag.EventName = "exit";
              clickTag.Value = "https://www.google.com";
              creative.ClickTags = new List<ClickTag>() { clickTag };

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("Enhanced banner creative with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");
              string pathToImageAsset2File = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.AutoAdvanceImages = true;
              creative.Name = "Test enhanced image creative";
              creative.Size = new Size() { Id = sizeId };
              creative.Type = "ENHANCED_IMAGE";

              // Upload the first image asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId imageAsset1Id = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

              CreativeAsset imageAsset1 = new CreativeAsset();
              imageAsset1.AssetIdentifier = imageAsset1Id;
              imageAsset1.Role = "PRIMARY";

              // Upload the second image asset.
              CreativeAssetId imageAsset2Id = assetUtils.uploadAsset(pathToImageAsset2File, "HTML_IMAGE");

              CreativeAsset imageAsset2 = new CreativeAsset();
              imageAsset2.AssetIdentifier = imageAsset2Id;
              imageAsset2.Role = "PRIMARY";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { imageAsset1, imageAsset2 };

              // Create a click tag for the first image asset.
              ClickTag clickTag1 = new ClickTag();
              clickTag1.Name = imageAsset1Id.Name;
              clickTag1.EventName = imageAsset1Id.Name;

              // Create a click tag for the second image asset.
              ClickTag clickTag2 = new ClickTag();
              clickTag2.Name = imageAsset2Id.Name;
              clickTag2.EventName = imageAsset2Id.Name;

              // Add the click tags.
              creative.ClickTags = new List<ClickTag>() { clickTag1, clickTag2 };

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("Enhanced image creative with ID {0} was created.", result.Id);
        }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      Creative creative = new Creative();
      creative.AdvertiserId = advertiserId;
      creative.Name = "Test tracking creative";
      creative.Type = "TRACKING_TEXT";

      Creative result = service.Creatives.Insert(creative, profileId).Execute();

      // Display the new creative ID.
      Console.WriteLine("Tracking creative with ID {0} was created.", result.Id);
    }
        public ActionResult AddCreative(CreativeModel post)
        {
            User user = Helpers.AuthentificationHelper.GetUser(HttpContext);
            var creative = new Creative()
            {
                CreationDate = DateTime.Now,
                UserId = user.Id,
                ShortDescription = post.Description,
                Title = post.Title,
            };

            DataBase.AddCreative(creative, post.Tags);
            return RedirectToAction("Main", "Home");
        }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
      long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      string imageUrl = _T("INSERT_IMAGE_URL_HERE");

      Creative creative = new Creative();
      creative.AdvertiserId = advertiserId;
      creative.Name = "Test redirect creative";
      creative.RedirectUrl = imageUrl;
      creative.Size = new Size() { Id = sizeId };
      creative.Type = "REDIRECT";

      Creative result = service.Creatives.Insert(creative, profileId).Execute();

      // Display the new creative ID.
      Console.WriteLine("Redirect creative with ID {0} was created.", result.Id);
    }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            Creative creative = new Creative
            {
                AccountId = int.Parse("INSERT ACCOUNT ID HERE"),
                BuyerCreativeId = "INSERT BUYER CREATIVE ID HERE",
                AdvertiserName = "ADVERTISER NAME HERE",
                ClickThroughUrl = new[] { "CLICK THROUGH URL HERE" },
                HTMLSnippet = "<html><body><a href='URL HERE'>MESSAGE HERE!</a></body></html>",
                Width = 300,    // Width and Height need to change to accomodate the creative
                Height = 250
            };

            Creative responseCreative = service.Creatives.Insert(creative).Execute();

            Console.WriteLine("Inserted new creative:");
            Console.WriteLine("Account id: {0}", responseCreative.AccountId);
            Console.WriteLine("Buyer Creative id: {0}", responseCreative.BuyerCreativeId);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string pathToHtml5AssetFile = _T("INSERT_PATH_TO_HTML5_ASSET_FILE_HERE");
              string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test HTML5 banner creative";
              creative.Size = new Size() { Id = sizeId };
              creative.Type = "HTML5_BANNER";

              // Upload the HTML5 asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId html5AssetId = assetUtils.uploadAsset(pathToHtml5AssetFile, "HTML");

              CreativeAsset html5Asset = new CreativeAsset();
              html5Asset.AssetIdentifier = html5AssetId;
              html5Asset.Role = "PRIMARY";

              // Upload the backup image asset.
              CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

              CreativeAsset imageAsset = new CreativeAsset();
              imageAsset.AssetIdentifier = imageAssetId;
              imageAsset.Role = "BACKUP_IMAGE";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { html5Asset, imageAsset };

              // Add a click tag.
              ClickTag clickTag = new ClickTag() { Name = "clickTag" };
              creative.ClickTags = new List<ClickTag>() { clickTag };

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("HTML5 banner creative with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string pathToFlashAssetFile = _T("INSERT_PATH_TO_FLASH_ASSET_FILE_HERE");
              string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test flash in-page creative";
              creative.Size = new Size() { Id = sizeId };
              creative.Type = "FLASH_INPAGE";

              // Upload the flash asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId flashAssetId = assetUtils.uploadAsset(pathToFlashAssetFile, "FLASH");

              CreativeAsset flashAsset = new CreativeAsset();
              flashAsset.AssetIdentifier = flashAssetId;
              flashAsset.Role = "PRIMARY";
              flashAsset.WindowMode = "TRANSPARENT";

              // Upload the backup image asset.
              CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

              CreativeAsset imageAsset = new CreativeAsset();
              imageAsset.AssetIdentifier = imageAssetId;
              imageAsset.Role = "BACKUP_IMAGE";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { flashAsset, imageAsset };

              // Set the backup image target window option.
              creative.BackupImageTargetWindow = new TargetWindow() { TargetWindowOption = "NEW_WINDOW"};

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("Flash in-page creative with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="businessId">The AdWords Express business id.</param>
        public void Run(AdWordsUser user, long businessId)
        {
            // Get the PromotionService
              PromotionService promotionService = (PromotionService)
              user.GetService(AdWordsService.v201601.PromotionService);

              // Set the business ID to the service.
              promotionService.RequestHeader.expressBusinessId = businessId;

              // First promotion
              Promotion marsTourPromotion = new Promotion();
              Money budget = new Money();
              budget.microAmount = 1000000L;
              marsTourPromotion.name = "Mars Tour Promotion " + ExampleUtilities.GetShortRandomString();
              marsTourPromotion.status = PromotionStatus.PAUSED;
              marsTourPromotion.destinationUrl = "http://www.example.com";
              marsTourPromotion.budget = budget;
              marsTourPromotion.callTrackingEnabled = true;

              // Criteria

              // Criterion - Travel Agency product service
              ProductService productService = new ProductService();
              productService.text = "Travel Agency";

              // Criterion - English language
              // The ID can be found in the documentation:
              // https://developers.google.com/adwords/api/docs/appendix/languagecodes
              Language language = new Language();
              language.id = 1000L;

              // Criterion - State of California
              Location location = new Location();
              location.id = 21137L;

              marsTourPromotion.criteria = new Criterion[] { productService, language, location };

              // Creative
              Creative creative = new Creative();
              creative.headline = "Standard Mars Trip";
              creative.line1 = "Fly coach to Mars";
              creative.line2 = "Free in-flight pretzels";

              marsTourPromotion.creatives = new Creative[] { creative };

              PromotionOperation operation = new PromotionOperation();
              operation.@operator = Operator.ADD;
              operation.operand = marsTourPromotion;

              try {
            Promotion[] addedPromotions = promotionService.mutate(
            new PromotionOperation[] { operation });

            Console.WriteLine("Added promotion ID {0} with name {1} to business ID {2}.",
            addedPromotions[0].id, addedPromotions[0].name, businessId);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to add promotions.", e);
              }
        }
 public static Creative createFlashCreative(string flash_url, string target_url)
 {
     Creative creative = new Creative();
     creative.flash_url = flash_url;
     creative.target_url = target_url;
     return creative;
 }
 public void Initialize()
 {
     _creative = CreativeFactory.CreateCreativeDomainObject();
 }
Beispiel #21
0
        /// <summary>
        /// Updates an existing creative. This method supports patch semantics.
        /// Documentation https://developers.google.com/dfareporting/v2.7/reference/creatives/patch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Dfareporting service.</param>
        /// <param name="profileId">User profile ID associated with this request.</param>
        /// <param name="id">Creative ID.</param>
        /// <param name="body">A valid Dfareporting v2.7 body.</param>
        /// <returns>CreativeResponse</returns>
        public static Creative Patch(DfareportingService service, string profileId, string id, Creative body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (profileId == null)
                {
                    throw new ArgumentNullException(profileId);
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Make the request.
                return(service.Creatives.Patch(body, profileId, id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Creatives.Patch failed.", ex);
            }
        }
Beispiel #22
0
 public void Initialize()
 {
     _creative = CreativeFactory.CreateCreativeDomainObject();
 }
 public void Initialize()
 {
     _creative = CreativeFactory.CreateCreativeDomainObjectWithPanels();
     _creativeDto = CreativeFactory.CreateCreativeDtoObject();
     AutoMapperConfig.MapTypes();
 }
Beispiel #24
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToHtml5AssetFile = _T("INSERT_PATH_TO_HTML5_ASSET_FILE_HERE");
            string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            // Locate an advertiser landing page to use as a default.
            LandingPage defaultLandingPage = getAdvertiserLandingPage(service, profileId, advertiserId);

            // Create the creative structure.
            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test HTML5 display creative";
            creative.Size         = new Size()
            {
                Id = sizeId
            };
            creative.Type = "DISPLAY";

            // Upload the HTML5 asset.
            CreativeAssetUtils assetUtils   = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    html5AssetId =
                assetUtils.uploadAsset(pathToHtml5AssetFile, "HTML").AssetIdentifier;

            CreativeAsset html5Asset = new CreativeAsset();

            html5Asset.AssetIdentifier = html5AssetId;
            html5Asset.Role            = "PRIMARY";

            // Upload the backup image asset.
            CreativeAssetId imageAssetId =
                assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE").AssetIdentifier;

            CreativeAsset imageAsset = new CreativeAsset();

            imageAsset.AssetIdentifier = imageAssetId;
            imageAsset.Role            = "BACKUP_IMAGE";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                html5Asset, imageAsset
            };

            // Configure the bacup image.
            creative.BackupImageClickThroughUrl = new CreativeClickThroughUrl()
            {
                LandingPageId = defaultLandingPage.Id
            };
            creative.BackupImageReportingLabel = "backup";
            creative.BackupImageTargetWindow   = new TargetWindow()
            {
                TargetWindowOption = "NEW_WINDOW"
            };

            // Add a click tag.
            ClickTag clickTag = new ClickTag();

            clickTag.Name            = "clickTag";
            clickTag.EventName       = "exit";
            clickTag.ClickThroughUrl = new CreativeClickThroughUrl()
            {
                LandingPageId = defaultLandingPage.Id
            };
            creative.ClickTags = new List <ClickTag>()
            {
                clickTag
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("HTML5 display creative with ID {0} was created.", result.Id);
        }
    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="businessId">The AdWords Express business id.</param>
    public void Run(AdWordsUser user, long businessId) {
      // Get the ExpressBusinessService.
      ExpressBusinessService businessService = (ExpressBusinessService)
          user.GetService(AdWordsService.v201509.ExpressBusinessService);

      // Get the PromotionService
      PromotionService promotionService = (PromotionService)
          user.GetService(AdWordsService.v201509.PromotionService);

      // Get the business for the businessId. We will need its geo point to
      // create a Proximity criterion for the new Promotion.
      Selector businessSelector = new Selector() {
        fields = new string[] {
          ExpressBusiness.Fields.Id, ExpressBusiness.Fields.GeoPoint
        },
        predicates = new Predicate[] {
          Predicate.Equals(ExpressBusiness.Fields.Id, businessId.ToString())
        }
      };

      ExpressBusinessPage businessPage = businessService.get(businessSelector);

      if (businessPage == null || businessPage.entries == null ||
          businessPage.entries.Length == 0) {
        Console.WriteLine("No business was found.");
        return;
      }

      // Set the business ID to the service.
      promotionService.RequestHeader.expressBusinessId = businessId;

      // First promotion
      Promotion marsTourPromotion = new Promotion();
      Money budget = new Money();
      budget.microAmount = 1000000L;
      marsTourPromotion.name = "Mars Tour Promotion " + ExampleUtilities.GetShortRandomString();
      marsTourPromotion.status = PromotionStatus.PAUSED;
      marsTourPromotion.destinationUrl = "http://www.example.com";
      marsTourPromotion.budget = budget;
      marsTourPromotion.callTrackingEnabled = true;

      // Criteria

      // Criterion - Travel Agency product service
      ProductService productService = new ProductService();
      productService.text = "Travel Agency";

      // Criterion - English language
      // The ID can be found in the documentation:
      // https://developers.google.com/adwords/api/docs/appendix/languagecodes
      Language language = new Language();
      language.id = 1000L;

      // Criterion - Within 15 miles
      Proximity proximity = new Proximity();
      proximity.geoPoint = businessPage.entries[0].geoPoint;
      proximity.radiusDistanceUnits = ProximityDistanceUnits.MILES;
      proximity.radiusInUnits = 15;

      marsTourPromotion.criteria = new Criterion[] { productService, language, proximity };

      // Creative
      Creative creative = new Creative();
      creative.headline = "Standard Mars Trip";
      creative.line1 = "Fly coach to Mars";
      creative.line2 = "Free in-flight pretzels";

      marsTourPromotion.creatives = new Creative[] { creative };

      PromotionOperation operation = new PromotionOperation();
      operation.@operator = Operator.ADD;
      operation.operand = marsTourPromotion;

      try {
        Promotion[] addedPromotions = promotionService.mutate(
            new PromotionOperation[] { operation });

        Console.WriteLine("Added promotion ID {0} with name {1} to business ID {2}.",
        addedPromotions[0].id, addedPromotions[0].name, businessId);
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to add promotions.", e);
      }
    }
 public static Creative createTextCreative(string title, string caption, string anchor, string image_url, string target_url)
 {
     Creative creative = new Creative();
     creative.title = title;
     creative.caption = caption;
     creative.anchor = anchor;
     creative.image_url = image_url;
     creative.target_url = target_url;
     return creative;
 }
Beispiel #27
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long instreamVideoCreativeId = long.Parse(_T("INSERT_INSTREAM_VIDEO_CREATIVE_ID_HERE"));
            long targetingTemplateId     = long.Parse(_T("INSERT_TARGETING_TEMPLATE_ID_HERE"));
            long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string videoAssetName       = _T("INSERT_VIDEO_ASSET_NAME_HERE");
            string pathToVideoAssetFile = _T("INSERT_PATH_TO_VIDEO_ASSET_FILE_HERE");

            // Retrieve the specified creative.
            Creative creative = service.Creatives.Get(profileId, instreamVideoCreativeId).Execute();

            if (creative == null || !"INSTREAM_VIDEO".Equals(creative.Type))
            {
                Console.Error.WriteLine("Invalid creative specified.");
                return;
            }

            CreativeAssetSelection selection = creative.CreativeAssetSelection;

            if (!creative.DynamicAssetSelection.Value)
            {
                // Locate an existing video asset to use as a default.
                // This example uses the first PARENT_VIDEO asset found.
                CreativeAsset defaultAsset =
                    creative.CreativeAssets.First(asset => "PARENT_VIDEO".Equals(asset.Role));
                if (defaultAsset == null)
                {
                    Console.Error.WriteLine("Default video asset could not be found.");
                    return;
                }

                // Create a new selection using the existing asset as a default.
                selection = new CreativeAssetSelection();
                selection.DefaultAssetId = defaultAsset.Id;
                selection.Rules          = new List <Rule>();

                // Enable dynamic asset selection for the creative.
                creative.DynamicAssetSelection  = true;
                creative.CreativeAssetSelection = selection;
            }

            // Upload the new video asset and add it to the creative.
            CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId,
                                                                   creative.AdvertiserId.Value);
            CreativeAssetMetadata videoMetadata = assetUtils.uploadAsset(pathToVideoAssetFile, "VIDEO");

            creative.CreativeAssets.Add(new CreativeAsset()
            {
                AssetIdentifier = videoMetadata.AssetIdentifier,
                Role            = "PARENT_VIDEO"
            });

            // Create a rule targeting the new video asset and add it to the selection.
            Rule rule = new Rule();

            rule.AssetId             = videoMetadata.Id;
            rule.Name                = "Test rule for asset " + videoMetadata.Id;
            rule.TargetingTemplateId = targetingTemplateId;
            selection.Rules.Add(rule);

            // Update the creative.
            Creative result = service.Creatives.Update(creative, profileId).Execute();

            Console.WriteLine("Dynamic asset selection enabled for creative with ID {0}.", result.Id);
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="businessId">The AdWords Express business id.</param>
        public void Run(AdWordsUser user, long businessId)
        {
            // Get the ExpressBusinessService.
            ExpressBusinessService businessService = (ExpressBusinessService)
                                                     user.GetService(AdWordsService.v201506.ExpressBusinessService);

            // Get the PromotionService
            PromotionService promotionService = (PromotionService)
                                                user.GetService(AdWordsService.v201506.PromotionService);

            // Get the business for the businessId. We will need its geo point to
            // create a Proximity criterion for the new Promotion.
            Selector businessSelector = new Selector();

            Predicate predicate = new Predicate();

            predicate.field             = "Id";
            predicate.@operator         = PredicateOperator.EQUALS;
            predicate.values            = new string[] { businessId.ToString() };
            businessSelector.predicates = new Predicate[] { predicate };

            businessSelector.fields = new string[] { "Id", "GeoPoint" };

            ExpressBusinessPage businessPage = businessService.get(businessSelector);

            if (businessPage == null || businessPage.entries == null ||
                businessPage.entries.Length == 0)
            {
                Console.WriteLine("No business was found.");
                return;
            }

            // Set the business ID to the service.
            promotionService.RequestHeader.expressBusinessId = businessId;

            // First promotion
            Promotion marsTourPromotion = new Promotion();
            Money     budget            = new Money();

            budget.microAmount                    = 1000000L;
            marsTourPromotion.name                = "Mars Tour Promotion " + ExampleUtilities.GetShortRandomString();
            marsTourPromotion.status              = PromotionStatus.PAUSED;
            marsTourPromotion.destinationUrl      = "http://www.example.com";
            marsTourPromotion.budget              = budget;
            marsTourPromotion.callTrackingEnabled = true;

            // Criteria

            // Criterion - Travel Agency product service
            ProductService productService = new ProductService();

            productService.text = "Travel Agency";

            // Criterion - English language
            // The ID can be found in the documentation:
            // https://developers.google.com/adwords/api/docs/appendix/languagecodes
            Language language = new Language();

            language.id = 1000L;

            // Criterion - Within 15 miles
            Proximity proximity = new Proximity();

            proximity.geoPoint            = businessPage.entries[0].geoPoint;
            proximity.radiusDistanceUnits = ProximityDistanceUnits.MILES;
            proximity.radiusInUnits       = 15;

            marsTourPromotion.criteria = new Criterion[] { productService, language, proximity };

            // Creative
            Creative creative = new Creative();

            creative.headline = "Standard Mars Trip";
            creative.line1    = "Fly coach to Mars";
            creative.line2    = "Free in-flight pretzels";

            marsTourPromotion.creatives = new Creative[] { creative };

            PromotionOperation operation = new PromotionOperation();

            operation.@operator = Operator.ADD;
            operation.operand   = marsTourPromotion;

            try {
                Promotion[] addedPromotions = promotionService.mutate(
                    new PromotionOperation[] { operation });

                Console.WriteLine("Added promotion ID {0} with name {1} to business ID {2}.",
                                  addedPromotions[0].id, addedPromotions[0].name, businessId);
            } catch (Exception ex) {
                throw new System.ApplicationException("Failed to add promotions.", ex);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToHtmlAssetFile  = _T("INSERT_PATH_TO_HTML_ASSET_FILE_HERE");
            string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId = advertiserId;
            creative.Name         = "Test enhanced banner creative";
            creative.Size         = new Size()
            {
                Id = sizeId
            };
            creative.Type = "ENHANCED_BANNER";

            // Upload the HTML asset.
            CreativeAssetUtils assetUtils  = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    htmlAssetId = assetUtils.uploadAsset(pathToHtmlAssetFile, "HTML");

            CreativeAsset htmlAsset = new CreativeAsset();

            htmlAsset.AssetIdentifier = htmlAssetId;
            htmlAsset.Role            = "PRIMARY";
            htmlAsset.WindowMode      = "TRANSPARENT";

            // Upload the backup image asset.
            CreativeAssetId backupImageAssetId =
                assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

            CreativeAsset backupImageAsset = new CreativeAsset();

            backupImageAsset.AssetIdentifier = backupImageAssetId;
            backupImageAsset.Role            = "BACKUP_IMAGE";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                htmlAsset, backupImageAsset
            };

            // Configure the backup image.
            creative.BackupImageClickThroughUrl = "https://www.google.com";
            creative.BackupImageReportingLabel  = "backup";
            creative.BackupImageTargetWindow    = new TargetWindow()
            {
                TargetWindowOption = "NEW_WINDOW"
            };

            // Add a click tag.
            ClickTag clickTag = new ClickTag();

            clickTag.Name      = "clickTag";
            clickTag.EventName = "exit";
            clickTag.Value     = "https://www.google.com";
            creative.ClickTags = new List <ClickTag>()
            {
                clickTag
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("Enhanced banner creative with ID {0} was created.", result.Id);
        }
 public static Creative createAudioCreative(string audio_url, string target_url)
 {
     Creative creative = new Creative();
     creative.audio_url = audio_url;
     creative.target_url = target_url;
     return creative;
 }
 public static Creative createRawCreative(string raw, string target_url)
 {
     Creative creative = new Creative();
     creative.raw = raw;
     creative.target_url = target_url;
     return creative;
 }
 public static Ad createAd(string name, int width, int height, string format, Creative creative, 
     LinkedResource linked_user, LinkedResource linked_contact, LinkedResource linked_targeting_plan)
 {
     Ad ad = new Ad();
     ad.name = name;
     ad.width = width;
     ad.height = height;
     ad.format = format;
     ad.creative = creative;
     ad.linked_user = linked_user;
     ad.linked_contact = linked_contact;
     ad.linked_targeting_plan = linked_targeting_plan;
     return ad;
 }
 public void Then_An_InActive_State_Will_Cause_A_DomainException()
 {
     var creative = new Creative(new PersistCreative { Active = false });
 }
Beispiel #34
0
        /// <summary>
        /// Print a human-readable representation of a single creative.
        /// </summary>
        public static void PrintCreative(Creative creative)
        {
            Console.WriteLine("* Creative ID: {0}", creative.CreativeId);

            int?version = creative.Version;

            if (version != null)
            {
                Console.WriteLine("\t- Version: {0}", version);
            }

            string advertiserName = creative.AdvertiserName;

            if (advertiserName != null)
            {
                Console.WriteLine("\t- Advertiser name: {0}", advertiserName);
            }

            string creativeFormat = creative.CreativeFormat;

            if (creativeFormat != null)
            {
                Console.WriteLine("\t- Creative format: {0}", creativeFormat);
            }

            CreativeServingDecision servingDecision = creative.CreativeServingDecision;

            if (servingDecision != null)
            {
                Console.WriteLine("\t- Creative serving decision");
                Console.WriteLine("\t\tDeals policy compliance: {0}",
                                  servingDecision.DealsPolicyCompliance.Status);
                Console.WriteLine("\t\tNetwork policy compliance: {0}",
                                  servingDecision.NetworkPolicyCompliance.Status);
                Console.WriteLine("\t\tPlatform policy compliance: {0}",
                                  servingDecision.PlatformPolicyCompliance.Status);
                Console.WriteLine("\t\tChina policy compliance: {0}",
                                  servingDecision.ChinaPolicyCompliance.Status);
                Console.WriteLine("\t\tRussia policy compliance: {0}",
                                  servingDecision.RussiaPolicyCompliance.Status);
            }

            IList <string> declaredClickThroughUrls = creative.DeclaredClickThroughUrls;

            if (declaredClickThroughUrls != null)
            {
                Console.WriteLine("\t- Declared click-through URLs:\n\t\t" +
                                  String.Join("\n\t\t", declaredClickThroughUrls));
            }

            IList <string> declaredAttributes = creative.DeclaredAttributes;

            if (declaredAttributes != null)
            {
                Console.WriteLine("\t- Declared attributes:\n\t\t" +
                                  String.Join("\n\t\t", declaredAttributes));
            }

            IList <int?> declaredVendorIds = creative.DeclaredVendorIds;

            if (declaredVendorIds != null)
            {
                Console.WriteLine("\t- Declared vendor IDs:\n\t\t" +
                                  String.Join("\n\t\t", declaredVendorIds));
            }

            IList <string> declaredRestrictedCategories = creative.DeclaredRestrictedCategories;

            if (declaredRestrictedCategories != null)
            {
                Console.WriteLine("\t- Declared restricted categories:\n\t\t" +
                                  String.Join("\n\t\t", declaredRestrictedCategories));
            }

            HtmlContent html = creative.Html;

            if (html != null)
            {
                Console.WriteLine("\t- HTML creative contents:");
                Console.WriteLine("\t\tSnippet: {0}", html.Snippet);
                Console.WriteLine("\t\tHeight: {0}", html.Height);
                Console.WriteLine("\t\tWidth: {0}", html.Width);
            }

            NativeContent native = creative.Native;

            if (native != null)
            {
                Console.WriteLine("\t- Native creative contents:");
                Console.WriteLine("\t\tHeadline: {0}", native.Headline);
                Console.WriteLine("\t\tBody: {0}", native.Body);
                Console.WriteLine("\t\tCall to action: {0}", native.CallToAction);
                Console.WriteLine("\t\tAdvertiser name: {0}", native.AdvertiserName);
                Console.WriteLine("\t\tStar rating: {0}", native.StarRating);
                Console.WriteLine("\t\tClick link URL: {0}", native.ClickLinkUrl);
                Console.WriteLine("\t\tClick tracking URL: {0}", native.ClickTrackingUrl);
                Console.WriteLine("\t\tPrice display text: {0}", native.PriceDisplayText);

                Image image = native.Image;
                if (image != null)
                {
                    Console.WriteLine("\t\tImage contents:");
                    Console.WriteLine("\t\t\tURL: {0}", image.Url);
                    Console.WriteLine("\t\t\tHeight: {0}", image.Height);
                    Console.WriteLine("\t\t\tWidth: {0}", image.Width);
                }

                Image logo = native.Logo;
                if (logo != null)
                {
                    Console.WriteLine("\t\tLogo contents:");
                    Console.WriteLine("\t\t\tURL: {0}", logo.Url);
                    Console.WriteLine("\t\t\tHeight: {0}", logo.Height);
                    Console.WriteLine("\t\t\tWidth: {0}", logo.Width);
                }

                Image appIcon = native.AppIcon;
                if (appIcon != null)
                {
                    Console.WriteLine("\t\tAppIcon contents:");
                    Console.WriteLine("\t\t\tURL: {0}", appIcon.Url);
                    Console.WriteLine("\t\t\tHeight: {0}", appIcon.Height);
                    Console.WriteLine("\t\t\tWidth: {0}", appIcon.Width);
                }
            }

            VideoContent video = creative.Video;

            if (video != null)
            {
                Console.WriteLine("\tVideo creative contents:");

                string videoUrl = video.VideoUrl;
                if (videoUrl != null)
                {
                    Console.WriteLine("\t\tVideo URL: {0}", videoUrl);
                }

                string videoVastXml = video.VideoVastXml;
                if (videoVastXml != null)
                {
                    Console.WriteLine("\t\tVideo VAST XML:\n{0}", videoVastXml);
                }
            }
        }
 public static Creative createImageCreative(string image_url, string target_url)
 {
     Creative creative = new Creative();
     creative.image_url = image_url;
     creative.target_url = target_url;
     return creative;
 }
Beispiel #36
0
 public static CreativeDto ConvertToDto(this Creative domainModel)
 {
     return(Mapper.Map <CreativeDto>(domainModel));
 }
            public void Then_NonNull_Initial_State_Allows_Successful_Instantiation()
            {
                var creative = new Creative(new PersistCreative { Active = true });

                Assert.IsNotNull(creative, "Failed to create creative.");
            }
Beispiel #38
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long sizeId       = long.Parse(_T("INSERT_SIZE_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string pathToImageAssetFile  = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");
            string pathToImageAsset2File = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

            Creative creative = new Creative();

            creative.AdvertiserId      = advertiserId;
            creative.AutoAdvanceImages = true;
            creative.Name = "Test enhanced image creative";
            creative.Size = new Size()
            {
                Id = sizeId
            };
            creative.Type = "ENHANCED_IMAGE";

            // Upload the first image asset.
            CreativeAssetUtils assetUtils    = new CreativeAssetUtils(service, profileId, advertiserId);
            CreativeAssetId    imageAsset1Id = assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE");

            CreativeAsset imageAsset1 = new CreativeAsset();

            imageAsset1.AssetIdentifier = imageAsset1Id;
            imageAsset1.Role            = "PRIMARY";

            // Upload the second image asset.
            CreativeAssetId imageAsset2Id = assetUtils.uploadAsset(pathToImageAsset2File, "HTML_IMAGE");

            CreativeAsset imageAsset2 = new CreativeAsset();

            imageAsset2.AssetIdentifier = imageAsset2Id;
            imageAsset2.Role            = "PRIMARY";

            // Add the creative assets.
            creative.CreativeAssets = new List <CreativeAsset>()
            {
                imageAsset1, imageAsset2
            };

            // Create a click tag for the first image asset.
            ClickTag clickTag1 = new ClickTag();

            clickTag1.Name      = imageAsset1Id.Name;
            clickTag1.EventName = imageAsset1Id.Name;

            // Create a click tag for the second image asset.
            ClickTag clickTag2 = new ClickTag();

            clickTag2.Name      = imageAsset2Id.Name;
            clickTag2.EventName = imageAsset2Id.Name;

            // Add the click tags.
            creative.ClickTags = new List <ClickTag>()
            {
                clickTag1, clickTag2
            };

            Creative result = service.Creatives.Insert(creative, profileId).Execute();

            // Display the new creative ID.
            Console.WriteLine("Enhanced image creative with ID {0} was created.", result.Id);
        }
 public static Creative createVideoCreative(string video_url, string target_url)
 {
     Creative creative = new Creative();
     creative.video_url = video_url;
     creative.target_url = target_url;
     return creative;
 }