Beispiel #1
0
        /// <summary>
        /// Updates the budget amount for the budget of the adgroup specified by the accountId and billingId, with the budget amount in the request. This method supports patch semantics.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/budget/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 AdExchangeBuyer service.</param>
        /// <param name="accountId">The account id associated with the budget being updated.</param>
        /// <param name="billingId">The billing id associated with the budget being updated.</param>
        /// <param name="body">A valid AdExchangeBuyer v1.4 body.</param>
        /// <returns>BudgetResponse</returns>
        public static Budget Patch(AdExchangeBuyerService service, string accountId, string billingId, Budget body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (accountId == null)
                {
                    throw new ArgumentNullException(accountId);
                }
                if (billingId == null)
                {
                    throw new ArgumentNullException(billingId);
                }

                // Make the request.
                return(service.Budget.Patch(body, accountId, billingId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Budget.Patch failed.", ex);
            }
        }
        /// <summary>
        /// Update a given private auction proposal
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/marketplaceprivateauction/updateproposal
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="privateAuctionId">The private auction id to be updated.</param>
        /// <param name="body">A valid AdExchangeBuyer v1.4 body.</param>
        public static void Updateproposal(AdExchangeBuyerService service, string privateAuctionId, UpdatePrivateAuctionProposalRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (privateAuctionId == null)
                {
                    throw new ArgumentNullException(privateAuctionId);
                }

                // Make the request.
                return(service.Marketplaceprivateauction.Updateproposal(body, privateAuctionId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Marketplaceprivateauction.Updateproposal failed.", ex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Get all the notes associated with a proposal
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/marketplacenotes/list
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="proposalId">The proposalId to get notes for. To search across all proposals specify order_id = '-' as part of the URL.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>GetOrderNotesResponseResponse</returns>
        public static GetOrderNotesResponse List(AdExchangeBuyerService service, string proposalId, MarketplacenotesListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (proposalId == null)
                {
                    throw new ArgumentNullException(proposalId);
                }

                // Building the initial request.
                var request = service.Marketplacenotes.List(proposalId);

                // Applying optional parameters to the request.
                request = (MarketplacenotesResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Marketplacenotes.List failed.", ex);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Add notes to the proposal
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/marketplacenotes/insert
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="proposalId">The proposalId to add notes for.</param>
        /// <param name="body">A valid AdExchangeBuyer v1.4 body.</param>
        /// <returns>AddOrderNotesResponseResponse</returns>
        public static AddOrderNotesResponse Insert(AdExchangeBuyerService service, string proposalId, AddOrderNotesRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (proposalId == null)
                {
                    throw new ArgumentNullException(proposalId);
                }

                // Make the request.
                return(service.Marketplacenotes.Insert(body, proposalId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Marketplacenotes.Insert failed.", ex);
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            long accountId = long.Parse("INSERT ACCOUNT ID HERE");
            string configName = "INSERT CONFIG NAME HERE";
            PretargetingConfig.DimensionsData dimensions = new PretargetingConfig.DimensionsData
            {
                Width = int.Parse("INSERT WIDTH HERE"),
                Height = int.Parse("INSERT HEIGHT HERE")
            };
            bool active = bool.Parse("INSERT TRUE OR FALSE HERE");

            PretargetingConfig config = new PretargetingConfig
            {
                ConfigName = configName,
                CreativeType = new[] { "PRETARGETING_CREATIVE_TYPE_HTML" },
                Dimensions = new[] { dimensions },
                IsActive = active
            };

            PretargetingConfig responseConfig = service.PretargetingConfig.
                Insert(config, accountId).Execute();

            Console.WriteLine("Inserted new pretargeting config:");
            Console.WriteLine("Config Name: {0}", responseConfig.ConfigName);
            Console.WriteLine("Config Id: {0}", responseConfig.ConfigId);
            Console.WriteLine("Is active: {0}", responseConfig.IsActive);
            Console.WriteLine("Creative Type: {0}", responseConfig.CreativeType);
        }
Beispiel #6
0
        /// <summary>
        /// Gets a specific pretargeting configuration
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/pretargetingConfig/get
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="accountId">The account id to get the pretargeting config for.</param>
        /// <param name="configId">The specific id of the configuration to retrieve.</param>
        /// <returns>PretargetingConfigResponse</returns>
        public static PretargetingConfig Get(AdExchangeBuyerService service, string accountId, string configId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (accountId == null)
                {
                    throw new ArgumentNullException(accountId);
                }
                if (configId == null)
                {
                    throw new ArgumentNullException(configId);
                }

                // Make the request.
                return(service.PretargetingConfig.Get(accountId, configId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request PretargetingConfig.Get failed.", ex);
            }
        }
        /// <summary>
        /// Updates an existing account.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/accounts/update
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="id">The account id</param>
        /// <param name="body">A valid AdExchangeBuyer v1.4 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>AccountResponse</returns>
        public static Account Update(AdExchangeBuyerService service, int id, Account body, AccountsUpdateOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Building the initial request.
                var request = service.Accounts.Update(body, id);

                // Applying optional parameters to the request.
                request = (AccountsResource.UpdateRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Accounts.Update failed.", ex);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Update the given proposal
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/proposals/update
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="proposalId">The proposal id to update.</param>
        /// <param name="revisionNumber">The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision.</param>
        /// <param name="updateAction">The proposed action to take on the proposal. This field is required and it must be set when updating a proposal.</param>
        /// <param name="body">A valid AdExchangeBuyer v1.4 body.</param>
        /// <returns>ProposalResponse</returns>
        public static Proposal Update(AdExchangeBuyerService service, string proposalId, string revisionNumber, string updateAction, Proposal body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (proposalId == null)
                {
                    throw new ArgumentNullException(proposalId);
                }
                if (revisionNumber == null)
                {
                    throw new ArgumentNullException(revisionNumber);
                }
                if (updateAction == null)
                {
                    throw new ArgumentNullException(updateAction);
                }

                // Make the request.
                return(service.Proposals.Update(body, proposalId, revisionNumber, updateAction).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Proposals.Update failed.", ex);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Replaces all the deals in the proposal with the passed in deals
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/marketplacedeals/update
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="proposalId">The proposalId to edit deals on.</param>
        /// <param name="body">A valid AdExchangeBuyer v1.4 body.</param>
        /// <returns>EditAllOrderDealsResponseResponse</returns>
        public static EditAllOrderDealsResponse Update(AdExchangeBuyerService service, string proposalId, EditAllOrderDealsRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (proposalId == null)
                {
                    throw new ArgumentNullException(proposalId);
                }

                // Make the request.
                return(service.Marketplacedeals.Update(body, proposalId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Marketplacedeals.Update failed.", ex);
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerService adXService = (AdExchangeBuyerService)service;

            CreativesResource.ListRequest request = adXService.Creatives.List();

            // Maximum number of entries returned on one request to the API
            request.MaxResults = 100;
            CreativesList page = null;

            while (page == null || page.Items.Count == request.MaxResults)
            {
                if (page != null)
                {
                    request.PageToken = page.NextPageToken;
                }

                page = request.Execute();

                foreach (Creative creative in page.Items)
                {
                    Console.WriteLine("Account id: {0}", creative.AccountId);
                    Console.WriteLine("Buyer Creative id: {0}", creative.BuyerCreativeId);
                    Console.WriteLine("Deals Status: {0}", creative.DealsStatus);
                    Console.WriteLine("Open Auction Status: {0}", creative.OpenAuctionStatus);
                    Console.WriteLine();
                }
            }
        }
 /// <summary>
 /// Main method, to run this code example as a standalone application.
 /// </summary>
 /// <param name="args">The command line arguments</param>
 public static void Main(string[] args)
 {
     AdExchangeBuyerService service = Utilities.GetService();
     ExampleBase example = new GetCreative();
     Console.WriteLine(example.Description);
     example.Run(service);
 }
Beispiel #12
0
        /// <summary>
        /// Add a deal id association for the creative.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/creatives/addDeal
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="accountId">The id for the account that will serve this creative.</param>
        /// <param name="buyerCreativeId">The buyer-specific id for this creative.</param>
        /// <param name="dealId">The id of the deal id to associate with this creative.</param>
        public static void AddDeal(AdExchangeBuyerService service, int accountId, string buyerCreativeId, string dealId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (buyerCreativeId == null)
                {
                    throw new ArgumentNullException(buyerCreativeId);
                }
                if (dealId == null)
                {
                    throw new ArgumentNullException(dealId);
                }

                // Make the request.
                return(service.Creatives.AddDeal(accountId, buyerCreativeId, dealId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Creatives.AddDeal failed.", ex);
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            long   accountId  = long.Parse("INSERT ACCOUNT ID HERE");
            string configName = "INSERT CONFIG NAME HERE";

            PretargetingConfig.DimensionsData dimensions = new PretargetingConfig.DimensionsData
            {
                Width  = int.Parse("INSERT WIDTH HERE"),
                Height = int.Parse("INSERT HEIGHT HERE")
            };
            bool active = bool.Parse("INSERT TRUE OR FALSE HERE");

            PretargetingConfig config = new PretargetingConfig
            {
                ConfigName   = configName,
                CreativeType = new[] { "PRETARGETING_CREATIVE_TYPE_HTML" },
                Dimensions   = new[] { dimensions },
                IsActive     = active
            };

            PretargetingConfig responseConfig = service.PretargetingConfig.
                                                Insert(config, accountId).Execute();

            Console.WriteLine("Inserted new pretargeting config:");
            Console.WriteLine("Config Name: {0}", responseConfig.ConfigName);
            Console.WriteLine("Config Id: {0}", responseConfig.ConfigId);
            Console.WriteLine("Is active: {0}", responseConfig.IsActive);
            Console.WriteLine("Creative Type: {0}", responseConfig.CreativeType);
        }
Beispiel #14
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            int accountId = int.Parse("INSERT ACCOUNT ID HERE");
            // Date report should start - mm/dd/yyyy format - oldest date
            string reportStartDate = "1/1/2014";
            // Date report should end - mm/dd/yyyy format - most recent date
            string reportEndDate             = "4/1/2014";
            PerformanceReportList allReports = service.PerformanceReport.List(accountId,
                                                                              reportEndDate, reportStartDate).Execute();

            if (allReports.PerformanceReport == null)
            {
                Console.WriteLine("No performance reports associated with this user");
            }
            else
            {
                foreach (PerformanceReport report in allReports.PerformanceReport)
                {
                    Console.WriteLine("Region:", report.Region);
                    Console.WriteLine("\tTime Stamp:", report.Timestamp);
                    Console.WriteLine("\tPixel Match Requests:", report.PixelMatchRequests);
                    Console.WriteLine("\tPixel Match Responses:", report.PixelMatchResponses);
                }
            }
        }
        /// <summary>
        /// Main method, to run this code example as a standalone application.
        /// </summary>
        /// <param name="args">The command line arguments</param>
        public static void Main(string[] args)
        {
            AdExchangeBuyerService service = Utilities.GetV1Service();
            ExampleBase            example = new ListPerformanceReports();

            Console.WriteLine(example.Description);
            example.Run(service);
        }
        /// <summary>
        /// Main method, to run this code example as a standalone application.
        /// </summary>
        /// <param name="args">The command line arguments</param>
        public static void Main(string[] args)
        {
            AdExchangeBuyerService service = Utilities.GetV1Service();
            ExampleBase            example = new InsertPretargetingConfig();

            Console.WriteLine(example.Description);
            example.Run(service);
        }
 /// <summary>
 /// Runs the code example.
 /// </summary>
 /// <param name="service">An authenticated AdExchangeBuyerService</param>
 public override void Run(AdExchangeBuyerService service)
 {
     AccountsList allAccounts = service.Accounts.List().Execute();
     foreach (Account account in allAccounts.Items)
     {
         Console.WriteLine("Account id: {0}", account.Id);
         Console.WriteLine("\tMax. total Qps: {0}", account.MaximumTotalQps);
         Console.WriteLine("\tCookie matching Nid: {0}", account.CookieMatchingNid);
         Console.WriteLine("\tCookie Matching Url: {0}", account.CookieMatchingUrl);
     }
 }
 /// <summary>
 /// Runs the code example.
 /// </summary>
 /// <param name="service">An authenticated AdExchangeBuyerService</param>
 public override void Run(AdExchangeBuyerService service)
 {
     DirectDealsList allDirectDeals = service.DirectDeals.List().Execute();
     foreach (DirectDeal directDeal in allDirectDeals.DirectDeals)
     {
         Console.WriteLine("Deal id: {0}", directDeal.Id);
         Console.WriteLine("\tAdvertiser: {0}", directDeal.Advertiser);
         Console.WriteLine("\tAccount id: {0}", directDeal.AccountId);
         Console.WriteLine("\tFixed Cpm: {0}", directDeal.FixedCpm);
         Console.WriteLine("\tSeller Network: {0}", directDeal.SellerNetwork);
     }
 }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            AccountsList allAccounts = service.Accounts.List().Execute();

            foreach (Account account in allAccounts.Items)
            {
                Console.WriteLine("Account id: {0}", account.Id);
                Console.WriteLine("\tMax. total Qps: {0}", account.MaximumTotalQps);
                Console.WriteLine("\tCookie matching Nid: {0}", account.CookieMatchingNid);
                Console.WriteLine("\tCookie Matching Url: {0}", account.CookieMatchingUrl);
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            DirectDealsList allDirectDeals = service.DirectDeals.List().Execute();

            foreach (DirectDeal directDeal in allDirectDeals.DirectDeals)
            {
                Console.WriteLine("Deal id: {0}", directDeal.Id);
                Console.WriteLine("\tAdvertiser: {0}", directDeal.Advertiser);
                Console.WriteLine("\tAccount id: {0}", directDeal.AccountId);
                Console.WriteLine("\tFixed Cpm: {0}", directDeal.FixedCpm);
                Console.WriteLine("\tSeller Network: {0}", directDeal.SellerNetwork);
            }
        }
        /// <summary>
        /// The main method.
        /// </summary>
        /// <param name="args">Command line arguments - see ShowUsage for options</param>
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowUsage();
                return;
            }

            Console.WriteLine("Authorized Buyers AdExchange Buyer API DotNet Sample");
            Console.WriteLine("====================");

            // Create a new service instance for v1 and v2 of AdExchangeBuyer.
            // Note: This is where security configuration takes place and will need to be
            // configured before the code will work!
            AdExchangeBuyerService   v1Service = Utilities.GetV1Service();
            AdExchangeBuyerIIService v2Service = Utilities.GetV2Service();

            // If --all is passed run all the examples
            string[] examplesToRun = (args[0].ToLower() == "--all")
                ? examples.Keys.ToArray() : args;

            foreach (string exampleName in examplesToRun)
            {
                if (examples.ContainsKey(exampleName))
                {
                    ExampleBase example = examples[exampleName];
                    Console.WriteLine(example.Description);

                    if (example.getClientType() == ExampleBase.ClientType.ADEXCHANGEBUYER)
                    {
                        example.Run(v1Service);
                    }
                    else if (example.getClientType() == ExampleBase.ClientType.ADEXCHANGEBUYERII)
                    {
                        example.Run(v2Service);
                    }
                }
                else
                {
                    Console.WriteLine("Unrecognised argument " + exampleName);
                    ShowUsage();
                    break;
                }
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            int accountId = int.Parse("INSERT ACCOUNT ID HERE");

            Account account = new Account
            {
                Id = accountId,
                CookieMatchingUrl = "UPDATED COOKIE MATCHING URL HERE",
            };

            Account responseAccount = service.Accounts.Patch(account, accountId).Execute();

            Console.WriteLine("Updated account");
            Console.WriteLine("Account id: {0}", responseAccount.Id);
            Console.WriteLine("Cookie Matching Url: {0}", responseAccount.CookieMatchingUrl);
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            int accountId = int.Parse("INSERT ACCOUNT ID HERE");

            Account account = new Account
            {
                Id = accountId,
                CookieMatchingUrl = "UPDATED COOKIE MATCHING URL HERE",
            };

            Account responseAccount = service.Accounts.Patch(account, accountId).Execute();

            Console.WriteLine("Updated account");
            Console.WriteLine("Account id: {0}", responseAccount.Id);
            Console.WriteLine("Cookie Matching Url: {0}", responseAccount.CookieMatchingUrl);
        }
        /// <summary>
        /// Returns the billing information for one account specified by account ID.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.3/reference/billingInfo/get
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="accountId">The account id.</param>
        /// <returns>BillingInfoResponse</returns>
        public static BillingInfo Get(AdExchangeBuyerService service, int accountId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Make the request.
                return(service.BillingInfo.Get(accountId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request BillingInfo.Get failed.", ex);
            }
        }
        /// <summary>
        /// Gets the requested publisher profile(s) by publisher accountId.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/pubprofiles/list
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="accountId">The accountId of the publisher to get profiles for.</param>
        /// <returns>GetPublisherProfilesByAccountIdResponseResponse</returns>
        public static GetPublisherProfilesByAccountIdResponse List(AdExchangeBuyerService service, int accountId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Make the request.
                return(service.Pubprofiles.List(accountId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Pubprofiles.List failed.", ex);
            }
        }
Beispiel #26
0
        /// <summary>
        /// Retrieves the authenticated user's list of accounts.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.3/reference/accounts/list
        /// 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 AdExchangeBuyer service.</param>
        /// <returns>AccountsListResponse</returns>
        public static AccountsList List(AdExchangeBuyerService service)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Make the request.
                return(service.Accounts.List().Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Accounts.List failed.", ex);
            }
        }
Beispiel #27
0
        /// <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>
        /// 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>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            int accountId = int.Parse("INSERT ACCOUNT ID HERE");
            String buyerCreativeId = "INSERT BUYER CREATIVE ID HERE";

            try
            {
                Creative creative = service.Creatives.Get(accountId, buyerCreativeId).Execute();
                Console.WriteLine("Account id: {0}", creative.AccountId);
                Console.WriteLine("Buyer Creative id: {0}", creative.BuyerCreativeId);
                Console.WriteLine("Status: {0}", creative.Status);
            }
            catch (Google.GoogleApiException)
            {
                Console.WriteLine("Can't find this creative.");
                Console.WriteLine("It can take up to 40 minutes after submitting a new creative"
                    + " for the status to be available.");
                Console.WriteLine("Check your input parameters");
                throw;
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(AdExchangeBuyerService service)
        {
            CreativesResource.ListRequest request = service.Creatives.List();
            // Maximum number of entries returned on one request to the API
            request.MaxResults = 100;
            CreativesList page = null;
            while (page == null || page.Items.Count == request.MaxResults)
            {
                if (page != null) request.PageToken = page.NextPageToken;

                page = request.Execute();

                foreach (Creative creative in page.Items)
                {
                    Console.WriteLine("Account id: {0}", creative.AccountId);
                    Console.WriteLine("Buyer Creative id: {0}", creative.BuyerCreativeId);
                    Console.WriteLine("Status: {0}", creative.Status);
                    Console.WriteLine();
                }
            }
        }
Beispiel #31
0
        /// <summary>
        /// Update the given proposal to indicate that setup has been completed.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/proposals/setupcomplete
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="proposalId">The proposal id for which the setup is complete</param>
        public static void Setupcomplete(AdExchangeBuyerService service, string proposalId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (proposalId == null)
                {
                    throw new ArgumentNullException(proposalId);
                }

                // Make the request.
                return(service.Proposals.Setupcomplete(proposalId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Proposals.Setupcomplete failed.", ex);
            }
        }
        /// <summary>
        /// Submit a new creative.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.3/reference/creatives/insert
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="body">A valid AdExchangeBuyer v1.3 body.</param>
        /// <returns>CreativeResponse</returns>
        public static Creative Insert(AdExchangeBuyerService service, Creative body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Make the request.
                return(service.Creatives.Insert(body).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Creatives.Insert failed.", ex);
            }
        }
        /// <summary>
        /// Gets one direct deal by ID.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.3/reference/directDeals/get
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="id">The direct deal id</param>
        /// <returns>DirectDealResponse</returns>
        public static DirectDeal Get(AdExchangeBuyerService service, string id)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Make the request.
                return(service.DirectDeals.Get(id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request DirectDeals.Get failed.", ex);
            }
        }
Beispiel #34
0
        /// <summary>
        /// The main method.
        /// </summary>
        /// <param name="args">Command line arguments - see ShowUsage for options</param>
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowUsage();
                return;
            }

            Console.WriteLine("AdExchange Buyer DotNet API Sample");
            Console.WriteLine("====================");

            // Create a new AdExchangeBuyerService instance.
            // Note: This is where security configuration takes place and will
            // need to be configured before the code will work!
            AdExchangeBuyerService service = Utilities.GetService();

            // If --all is passed run all the examples
            string[] examplesToRun = (args[0].ToLower() == "--all")
                ? examples.Keys.ToArray() : args;

            foreach (string exampleName in examplesToRun)
            {
                if (examples.ContainsKey(exampleName))
                {
                    ExampleBase example = examples[exampleName];
                    Console.WriteLine(example.Description);
                    example.Run(service);
                }
                else
                {
                    Console.WriteLine("Unrecognised argument " + exampleName);
                    ShowUsage();
                    break;
                }
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Beispiel #35
0
        /// <summary>
        /// Updates an existing account.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.3/reference/accounts/update
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="id">The account id</param>
        /// <param name="body">A valid AdExchangeBuyer v1.3 body.</param>
        /// <returns>AccountResponse</returns>
        public static Account Update(AdExchangeBuyerService service, int id, Account body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Make the request.
                return(service.Accounts.Update(body, id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Accounts.Update failed.", ex);
            }
        }
        /// <summary>
        /// Gets the requested product by id.
        /// Documentation https://developers.google.com/adexchangebuyer/v1.4/reference/products/get
        /// 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 AdExchangeBuyer service.</param>
        /// <param name="productId">The id for the product to get the head revision for.</param>
        /// <returns>ProductResponse</returns>
        public static Product Get(AdExchangeBuyerService service, string productId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (productId == null)
                {
                    throw new ArgumentNullException(productId);
                }

                // Make the request.
                return(service.Products.Get(productId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Products.Get failed.", ex);
            }
        }
 /// <summary>
 /// Runs the code example.
 /// </summary>
 /// <param name="service">An authenticated AdExchangeBuyerService</param>
 public override void Run(AdExchangeBuyerService service)
 {
     int accountId = int.Parse("INSERT ACCOUNT ID HERE");
     // Date report should start - mm/dd/yyyy format - oldest date
     string reportStartDate = "1/1/2014";
     // Date report should end - mm/dd/yyyy format - most recent date
     string reportEndDate = "4/1/2014";
     PerformanceReportList allReports = service.PerformanceReport.List(accountId,
         reportEndDate, reportStartDate).Execute();
     if (allReports.PerformanceReport == null)
     {
         Console.WriteLine("No performance reports associated with this user");
     }
     else
     {
         foreach (PerformanceReport report in allReports.PerformanceReport)
         {
             Console.WriteLine("Region:", report.Region);
             Console.WriteLine("\tTime Stamp:", report.Timestamp);
             Console.WriteLine("\tPixel Match Requests:", report.PixelMatchRequests);
             Console.WriteLine("\tPixel Match Responses:", report.PixelMatchResponses);
         }
     }
 }
        private static void Main(string[] args)
        {
            // See the README.md for details of these fields. 
            // Retrieved from https://console.developers.google.com
            String ServiceAccountEmail = "SERVICE ACCOUNT EMAIL HERE";
            String ServiceKeyFilePath = "PATH TO P12 KEYFILE HERE-INCLUDE FILENAME";
            String ServiceKeyFilePassword = "******";

            // Create a certificate object using the key file.
            X509Certificate2 certificate = new X509Certificate2(ServiceKeyFilePath,
                ServiceKeyFilePassword, X509KeyStorageFlags.Exportable);

            // Use the certificate to create credentials.
            ServiceAccountCredential oAuth2Credentials = new ServiceAccountCredential(
                new ServiceAccountCredential.Initializer(ServiceAccountEmail)
                {
                    Scopes = new[] { AdExchangeBuyerService.Scope.AdexchangeBuyer }
                }.FromCertificate(certificate));

            // Use the credentials to create a client for the API service.
            AdExchangeBuyerService buyerService = new AdExchangeBuyerService(
                new BaseClientService.Initializer
                {
                    HttpClientInitializer = oAuth2Credentials,
                    ApplicationName = "FirstAPICall"
                });

            // Call the Accounts resource on the service to retrieve a list of
            // Accounts for the service account
            AccountsList allAccounts = buyerService.Accounts.List().Execute();
            foreach (Account account in allAccounts.Items)
            {
                Console.WriteLine("Account id: {0}", account.Id);
            }
            Console.ReadLine();
        }
 public abstract void Run(AdExchangeBuyerService service);