/// <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 CreativeService.
              CreativeService creativeService =
              (CreativeService) user.GetService(DfpService.v201211.CreativeService);

              // Set the ID of the advertiser (company) that all creatives will be
              // assigned to.
              long advertiserId = long.Parse(_T("INSERT_ADVERTISER_COMPANY_ID_HERE"));

              // Create an array to store local image creative objects.
              Creative[] imageCreatives = new ImageCreative[5];

              for (int i = 0; i < 5; i++) {
            ImageCreative imageCreative = new ImageCreative();
            imageCreative.name = string.Format("Image creative #{0}", i);
            imageCreative.advertiserId = advertiserId;
            imageCreative.destinationUrl = "http://www.google.com";
            imageCreative.imageName = "image.jpg";
            imageCreative.imageByteArray = MediaUtilities.GetAssetDataFromUrl(
            "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg");

            Size imageSize = new Size();
            imageSize.width = 300;
            imageSize.height = 250;

            imageCreative.size = imageSize;
            imageCreatives[i] = imageCreative;
              }

              try {
            // Create the image creatives on the server.
            imageCreatives = creativeService.createCreatives(imageCreatives);

            if (imageCreatives != null) {
              foreach (Creative creative in imageCreatives) {
            // Use "is" operator to determine what type of creative was
            // returned.
            if (creative is ImageCreative) {
              ImageCreative imageCreative = (ImageCreative) creative;
              Console.WriteLine("An image creative with ID ='{0}', name ='{1}' and size = " +
                  "({2},{3}) was created and can be previewed at: {4}", imageCreative.id,
                  imageCreative.name, imageCreative.size.width, imageCreative.size.height,
                  imageCreative.previewUrl);
            } else {
              Console.WriteLine("A creative with ID ='{0}', name='{1}' and type='{2}' was created.",
                  creative.id, creative.name, creative.CreativeType);
            }
              }
            } else {
              Console.WriteLine("No creatives created.");
            }
              } catch (Exception ex) {
            Console.WriteLine("Failed to create creatives. Exception says \"{0}\"", ex.Message);
              }
        }
    public void TestCreateCreatives() {
      // Create an array to store local image creative objects.
      Creative[] imageCreatives = new ImageCreative[2];

      for (int i = 0; i < 2; i++) {
        // Create creative size.
        Size size = new Size();
        size.width = 300;
        size.height = 250;

        // Create an image creative.
        ImageCreative imageCreative = new ImageCreative();
        imageCreative.name = string.Format("Image creative #{0}", i);
        imageCreative.advertiserId = advertiserId;
        imageCreative.destinationUrl = "http://www.google.com";
        imageCreative.size = size;

        // Create image asset.
        CreativeAsset creativeAsset = new CreativeAsset();
        creativeAsset.fileName = "image.jpg";
        creativeAsset.assetByteArray = MediaUtilities.GetAssetDataFromUrl(
            "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg");
        creativeAsset.size = size;
        imageCreative.primaryImageAsset = creativeAsset;

        imageCreatives[i] = imageCreative;
      }

      Creative[] newCreatives = null;

      Assert.DoesNotThrow(delegate() {
        newCreatives = creativeService.createCreatives(imageCreatives);
      });

      Assert.NotNull(newCreatives);
      Assert.AreEqual(newCreatives.Length, 2);
      Assert.NotNull(newCreatives[0]);
      Assert.That(newCreatives[0] is ImageCreative);
      Assert.AreEqual(newCreatives[0].advertiserId, advertiserId);
      Assert.AreEqual(newCreatives[0].name, "Image creative #0");
      Assert.NotNull(newCreatives[1]);
      Assert.That(newCreatives[1] is ImageCreative);
      Assert.AreEqual(newCreatives[1].advertiserId, advertiserId);
      Assert.AreEqual(newCreatives[1].name, "Image creative #1");
    }
        public void TestCreateCreative()
        {
            ImageCreative imageCreative = new ImageCreative();
              imageCreative.name = string.Format("Image creative #{0}", new TestUtils().GetTimeStamp());
              imageCreative.advertiserId = advertiserId;
              imageCreative.destinationUrl = "http://www.google.com";
              imageCreative.imageName = "image.jpg";
              imageCreative.imageByteArray = MediaUtilities.GetAssetDataFromUrl(
              "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg");

              Size imageSize = new Size();
              imageSize.width = 300;
              imageSize.height = 250;

              imageCreative.size = imageSize;

              Creative newCreative = null;

              Assert.DoesNotThrow(delegate() {
            newCreative = creativeService.createCreative(imageCreative);
              });

              Assert.NotNull(newCreative);
              Assert.That(newCreative is ImageCreative);
              Assert.AreEqual(newCreative.advertiserId, imageCreative.advertiserId);
              Assert.AreEqual(newCreative.name, imageCreative.name);
        }
        public void TestCreateCreatives()
        {
            ImageCreative imageCreative1 = new ImageCreative();
              imageCreative1.name = string.Format("Image creative #{0}", new TestUtils().GetTimeStamp());
              imageCreative1.advertiserId = advertiserId;
              imageCreative1.destinationUrl = "http://www.google.com";
              imageCreative1.imageName = "image.jpg";
              imageCreative1.imageByteArray = MediaUtilities.GetAssetDataFromUrl(
              "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg");

              Size imageSize1 = new Size();
              imageSize1.width = 300;
              imageSize1.height = 250;

              imageCreative1.size = imageSize1;

              ImageCreative imageCreative2 = new ImageCreative();
              imageCreative2.name = string.Format("Image creative #{0}", new TestUtils().GetTimeStamp());
              imageCreative2.advertiserId = advertiserId;
              imageCreative2.destinationUrl = "http://www.google.com";
              imageCreative2.imageName = "image.jpg";
              imageCreative2.imageByteArray = MediaUtilities.GetAssetDataFromUrl(
              "http://www.google.com/intl/en/adwords/select/images/samples/skyscraper.jpg");

              Size imageSize2 = new Size();
              imageSize2.width = 120;
              imageSize2.height = 600;

              imageCreative2.size = imageSize2;

              Creative[] newCreatives = null;

              Assert.DoesNotThrow(delegate() {
            newCreatives = creativeService.createCreatives(new Creative[] {imageCreative1,
            imageCreative2});
              });

              Assert.NotNull(newCreatives);
              Assert.AreEqual(newCreatives.Length, 2);
              Assert.NotNull(newCreatives[0]);
              Assert.That(newCreatives[0] is ImageCreative);
              Assert.AreEqual(newCreatives[0].advertiserId, imageCreative1.advertiserId);
              Assert.AreEqual(newCreatives[0].name, imageCreative1.name);
              Assert.NotNull(newCreatives[1]);
              Assert.That(newCreatives[1] is ImageCreative);
              Assert.AreEqual(newCreatives[1].advertiserId, imageCreative2.advertiserId);
              Assert.AreEqual(newCreatives[1].name, imageCreative2.name);
        }
        /// <summary>
        /// Create a test company for running further tests.
        /// </summary>
        /// <returns>A creative for running further tests.</returns>
        public Creative CreateCreative(DfpUser user, long advertiserId)
        {
            CreativeService creativeService = (CreativeService)user.GetService(
              DfpService.v201511.CreativeService);

              // Create creative size.
              Size size = new Size();
              size.width = 300;
              size.height = 250;

              // Create an image creative.
              ImageCreative imageCreative = new ImageCreative();
              imageCreative.name = string.Format("Image creative #{0}", GetTimeStamp());
              imageCreative.advertiserId = advertiserId;
              imageCreative.destinationUrl = "http://www.google.com";
              imageCreative.size = size;

              // Create image asset.
              CreativeAsset creativeAsset = new CreativeAsset();
              creativeAsset.fileName = "image.jpg";
              creativeAsset.assetByteArray = MediaUtilities.GetAssetDataFromUrl(
              "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg");
              creativeAsset.size = size;
              imageCreative.primaryImageAsset = creativeAsset;

              return creativeService.createCreatives(new Creative[] {imageCreative})[0];
        }
        /// <summary>
        /// Create a test company for running further tests.
        /// </summary>
        /// <returns>A creative for running further tests.</returns>
        public Creative CreateCreative(DfpUser user, long advertiserId)
        {
            CreativeService creativeService = (CreativeService)user.GetService(
              DfpService.v201208.CreativeService);
              ImageCreative imageCreative = new ImageCreative();
              imageCreative.name = string.Format("Image creative #{0}", GetTimeStamp());
              imageCreative.advertiserId = advertiserId;
              imageCreative.destinationUrl = "http://www.google.com";
              imageCreative.imageName = "image.jpg";
              imageCreative.imageByteArray = MediaUtilities.GetAssetDataFromUrl(
              "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg");

              Size imageSize = new Size();
              imageSize.width = 300;
              imageSize.height = 250;

              imageCreative.size = imageSize;

              return creativeService.createCreative(imageCreative);
        }