/// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public void Run(DfpUser user)
        {
            RateCardService rateCardService =
                (RateCardService)user.GetService(DfpService.v201605.RateCardService);

            // Create a statement to select rate cards.
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .Where("currencyCode = :currencyCode")
                                                .OrderBy("id ASC")
                                                .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
                                                .AddValue("currencyCode", "USD");

            // Retrieve a small amount of rate cards at a time, paging through
            // until all rate cards have been retrieved.
            RateCardPage page = new RateCardPage();

            try {
                do
                {
                    page = rateCardService.getRateCardsByStatement(statementBuilder.ToStatement());

                    if (page.results != null)
                    {
                        // Print out some information for each rate card.
                        int i = page.startIndex;
                        foreach (RateCard rateCard in page.results)
                        {
                            Console.WriteLine("{0}) Rate card with ID \"{1}\", name \"{2}\", "
                                              + "and currency code \"{3}\" was found.",
                                              i++,
                                              rateCard.id,
                                              rateCard.name,
                                              rateCard.currencyCode);
                        }
                    }

                    statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
                } while (statementBuilder.GetOffset() < page.totalResultSetSize);

                Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
            } catch (Exception e) {
                Console.WriteLine("Failed to get rate cards. Exception says \"{0}\"",
                                  e.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public void Run(DfpUser dfpUser)
        {
            RateCardService rateCardService =
                (RateCardService)dfpUser.GetService(DfpService.v201608.RateCardService);

            // Create a statement to select rate cards.
            int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .Where("forMarketplace = :forMarketplace")
                                                .OrderBy("id ASC")
                                                .Limit(pageSize)
                                                .AddValue("forMarketplace", true);

            // Retrieve a small amount of rate cards at a time, paging through until all
            // rate cards have been retrieved.
            int totalResultSetSize = 0;

            do
            {
                RateCardPage page = rateCardService.getRateCardsByStatement(
                    statementBuilder.ToStatement());

                // Print out some information for each rate card.
                if (page.results != null)
                {
                    totalResultSetSize = page.totalResultSetSize;
                    int i = page.startIndex;
                    foreach (RateCard rateCard in page.results)
                    {
                        Console.WriteLine(
                            "{0}) Rate card with ID {1}, name \"{2}\", and currency code \"{3}\" was found.",
                            i++,
                            rateCard.id,
                            rateCard.name,
                            rateCard.currencyCode
                            );
                    }
                }

                statementBuilder.IncreaseOffsetBy(pageSize);
            } while (statementBuilder.GetOffset() < totalResultSetSize);

            Console.WriteLine("Number of results found: {0}", totalResultSetSize);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(DfpUser user)
        {
            // Get the RateCardService.
            RateCardService rateCardService =
                (RateCardService)user.GetService(DfpService.v201602.RateCardService);

            // Create a statement to get all rate cards using USD as currency.
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .Where("currencyCode = :currencyCode")
                                                .OrderBy("id ASC")
                                                .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
                                                .AddValue("currencyCode", "USD");

            // Set default for page.
            RateCardPage page = new RateCardPage();

            try {
                do
                {
                    // Get rate cards by statement.
                    page = rateCardService.getRateCardsByStatement(statementBuilder.ToStatement());

                    if (page.results != null && page.results.Length > 0)
                    {
                        int i = page.startIndex;
                        foreach (RateCard rateCard in page.results)
                        {
                            Console.WriteLine("{0}) Rate card with ID ='{1}', name '{2}', and currency '{3}' " +
                                              "was found.", i++, rateCard.id, rateCard.name, rateCard.currencyCode);
                        }
                    }
                    statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
                } while (statementBuilder.GetOffset() < page.totalResultSetSize);
                Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
            } catch (Exception e) {
                Console.WriteLine("Failed to get rate cards by statement. Exception says \"{0}\"",
                                  e.Message);
            }
        }
Esempio n. 4
0
        /// <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 RateCardService.
            RateCardService rateCardService =
                (RateCardService)user.GetService(DfpService.v201505.RateCardService);

            // Create a statement to get all rate cards.
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .OrderBy("id ASC")
                                                .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

            // Sets default for page.
            RateCardPage page = new RateCardPage();

            try {
                do
                {
                    // Get rate cards by statement.
                    page = rateCardService.getRateCardsByStatement(statementBuilder.ToStatement());

                    if (page.results != null && page.results.Length > 0)
                    {
                        int i = page.startIndex;
                        foreach (RateCard rateCard in page.results)
                        {
                            Console.WriteLine("{0}) Rate card with ID = '{1}' and name '{2}' was" +
                                              " found.", i++, rateCard.id, rateCard.name);
                        }
                    }

                    statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
                } while (statementBuilder.GetOffset() < page.totalResultSetSize);

                Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
            } catch (Exception e) {
                Console.WriteLine("Failed to get rate cards. Exception says \"{0}\"",
                                  e.Message);
            }
        }