Exemple #1
0
        /// <summary>
        /// Creates a price table row.
        /// </summary>
        /// <param name="header">The row header.</param>
        /// <param name="description">The description text.</param>
        /// <param name="finalUrl">The final URL.</param>
        /// <param name="finalMobileUrl">The mobile final URL, or null if this field
        /// should not be set.</param>
        /// <param name="priceInMicros">The price in micros.</param>
        /// <param name="currencyCode">The currency code.</param>
        /// <param name="priceUnit">The price unit.</param>
        /// <returns>A price table row for creating price extension.</returns>
        private static PriceTableRow CreatePriceTableRow(String header, String description,
                                                         String finalUrl, String finalMobileUrl, long priceInMicros, String currencyCode,
                                                         PriceExtensionPriceUnit priceUnit)
        {
            PriceTableRow retval = new PriceTableRow()
            {
                header      = header,
                description = description,
                finalUrls   = new UrlList()
                {
                    urls = new String[] { finalUrl }
                },
                price = new MoneyWithCurrency()
                {
                    currencyCode = currencyCode,
                    money        = new Money()
                    {
                        microAmount = priceInMicros
                    }
                },
                priceUnit = priceUnit
            };

            // Optional: set the mobile final URLs.
            if (!string.IsNullOrEmpty(finalMobileUrl))
            {
                retval.finalMobileUrls = new UrlList()
                {
                    urls = new String[] { finalMobileUrl }
                };
            }
            return(retval);
        }
Exemple #2
0
 /// <summary>
 /// Creates a price table row.
 /// </summary>
 /// <param name="header">The row header.</param>
 /// <param name="description">The description text.</param>
 /// <param name="finalUrl">The final URL.</param>
 /// <param name="priceInMicros">The price in micros.</param>
 /// <param name="currencyCode">The currency code.</param>
 /// <param name="priceUnit">The price unit.</param>
 /// <returns>A price table row for creating price extension.</returns>
 private static PriceTableRow CreatePriceTableRow(String header, String description,
                                                  String finalUrl, long priceInMicros, String currencyCode,
                                                  PriceExtensionPriceUnit priceUnit)
 {
     return(new PriceTableRow()
     {
         header = header,
         description = description,
         finalUrls = new UrlList()
         {
             urls = new String[] { finalUrl }
         },
         price = new MoneyWithCurrency()
         {
             currencyCode = currencyCode,
             money = new Money()
             {
                 microAmount = priceInMicros
             }
         },
         priceUnit = priceUnit
     });
 }
        /// <summary>
        /// Creates a new price offer with the specified parameters.
        /// </summary>
        /// <param name="header">The headline for the price extension.</param>
        /// <param name="description">The detailed description line that may show on the price
        /// extension.</param>
        /// <param name="priceInMicros">The price to display, measured in micros
        /// (e.g. 1_000_000 micros = 1 USD).</param>
        /// <param name="currencyCode">The currency code representing the unit of currency.</param>
        /// <param name="unit">Optionally set a unit describing the quantity obtained for the
        /// price.</param>
        /// <param name="finalUrl">The final URL to which a click on the price extension drives
        /// traffic.</param>
        /// <param name="finalMobileUrl">The final URL to which mobile clicks on the price
        /// extension drives traffic.</param>
        /// <returns></returns>
        private PriceOffer CreatePriceOffer(string header, string description, int priceInMicros,
                                            string currencyCode, PriceExtensionPriceUnit unit, string finalUrl,
                                            string finalMobileUrl)
        {
            PriceOffer priceOffer = new PriceOffer()
            {
                Header      = header,
                Description = description,
                FinalUrls   = { finalUrl },
                Price       = new Money()
                {
                    AmountMicros = priceInMicros,
                    CurrencyCode = currencyCode
                },
                Unit = unit
            };

            // Optional: Sets the final mobile URLs.
            if (!string.IsNullOrEmpty(finalMobileUrl))
            {
                priceOffer.FinalMobileUrls.Add(finalMobileUrl);
            }
            return(priceOffer);
        }
Exemple #4
0
        /// <summary>
        /// Creates a new price offering with the specified attributes.
        /// </summary>
        /// <param name="header">The header for the price offering.</param>
        /// <param name="description">The description for the price offering.</param>
        /// <param name="finalUrl">The final url for the price offering.</param>
        /// <param name="finalMobileUrl">The final mobile url for the price offering. Can be set to
        /// null.</param>
        /// <param name="priceInMicros">The price in micros.</param>
        /// <param name="currencyCode">The currency code.</param>
        /// <param name="unit">The price unit.</param>
        private PriceOffering CreatePriceOffering(string header, string description,
                                                  string finalUrl, string finalMobileUrl, long priceInMicros,
                                                  string currencyCode, PriceExtensionPriceUnit unit)
        {
            PriceOffering priceOffering = new PriceOffering
            {
                Header      = header,
                Description = description,
                FinalUrl    = finalUrl,
                Price       = new Money
                {
                    AmountMicros = priceInMicros,
                    CurrencyCode = currencyCode,
                },
                Unit = unit,
            };

            if (finalMobileUrl != null)
            {
                priceOffering.FinalMobileUrl = finalMobileUrl;
            }

            return(priceOffering);
        }