/// <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.v201311.CreativeService);

            // Set the ID of the creative to get.
            long creativeId = long.Parse(_T("INSERT_CREATIVE_ID_HERE"));

            try {
                // Get the creative.
                Creative creative = creativeService.getCreative(creativeId);

                if (creative != null)
                {
                    Console.WriteLine("Creative with ID ='{0}', name ='{1}' and type ='{2}' " +
                                      "was found.", creative.id, creative.name, creative.CreativeType);
                }
                else
                {
                    Console.WriteLine("No creative found for this ID.");
                }
            } catch (Exception ex) {
                Console.WriteLine("Failed to get creative. Exception says \"{0}\"", ex.Message);
            }
        }
Beispiel #2
0
        public void TestGetCreative()
        {
            Creative localCreative = null;

            Assert.DoesNotThrow(delegate() {
                localCreative = creativeService.getCreative(creative1.id);
            });
            Assert.NotNull(localCreative);
            Assert.AreEqual(localCreative.id, creative1.id);
            Assert.AreEqual(localCreative.GetType(), creative1.GetType());
            Assert.AreEqual(localCreative.name, creative1.name);
            Assert.AreEqual(localCreative.advertiserId, creative1.advertiserId);
            Assert.AreEqual(localCreative.previewUrl, creative1.previewUrl);
            Assert.AreEqual(localCreative.size.height, creative1.size.height);
            Assert.AreEqual(localCreative.size.width, creative1.size.width);
        }