Пример #1
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;
            string accountId = "INSERT ACCOUNT ID HERE";

            ListPublisherProfilesResponse response = adXService.Accounts.PublisherProfiles
                                                     .List(accountId).Execute();

            Console.WriteLine("========================================\n");
            Console.WriteLine("Listing Marketplace publisher profiles");
            Console.WriteLine("========================================\n");

            if (response.PublisherProfiles.Count == 0)
            {
                Console.WriteLine("No publisher profiles found.");
            }
            else
            {
                foreach (PublisherProfile publisherProfile in
                         response.PublisherProfiles)
                {
                    Console.WriteLine("Publisher profile ID: {0}",
                                      publisherProfile.PublisherProfileId);
                    Console.WriteLine("\tSeller account ID: {0}",
                                      publisherProfile.Seller.AccountId);
                    Console.WriteLine("\tSeller sub-account ID: {0}",
                                      publisherProfile.Seller.SubAccountId);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;
            string bidderResourceId             = "INSERT_BIDDER_RESOURCE_ID_HERE";
            string filterSetResourceId          = "INSERT_FILTER_SET_RESOURCE_ID_HERE";
            string filterSetName = String.Format(
                "bidders/{0}/filterSets/{1}", bidderResourceId, filterSetResourceId);

            ListBidMetricsResponse response = adXService.Bidders.FilterSets.BidMetrics
                                              .List(filterSetName).Execute();

            Console.WriteLine("========================================\n");
            Console.WriteLine("Listing bid metrics for filter set \"{0}\"", filterSetName);
            Console.WriteLine("========================================\n");

            foreach (BidMetricsRow bidMetrics in response.BidMetricsRows)
            {
                TimeInterval timeInterval = bidMetrics.RowDimensions
                                            .TimeInterval;
                Console.WriteLine("* Bid Metrics from {0} - {1}:",
                                  timeInterval.StartTime, timeInterval.EndTime);
                PrintMetric("Bids", bidMetrics.Bids);
                PrintMetric("BidsInAuction", bidMetrics.BidsInAuction);
                PrintMetric("BilledImpressions", bidMetrics.BilledImpressions);
                PrintMetric("ImpressionsWon", bidMetrics.ImpressionsWon);
                PrintMetric("MeasurableImpressions", bidMetrics.MeasurableImpressions);
                PrintMetric("ViewableImpressions", bidMetrics.ViewableImpressions);
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerService adXService = (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 = adXService.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);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService =
                (AdExchangeBuyerIIService)service;
            long accountId = long.Parse("INSERT ACCOUNT ID HERE");

            ListClientsResponse response = adXService.Accounts.Clients
                                           .List(accountId).Execute();

            Console.WriteLine("========================================\n");
            Console.WriteLine("Listing of client buyers associated with AdX "
                              + "Account \"{0}\"", accountId);
            Console.WriteLine("========================================\n");

            if (response.Clients.Count == 0)
            {
                Console.WriteLine("No client buyers found.");
            }
            else
            {
                foreach (Client clientBuyer in response.Clients)
                {
                    Console.WriteLine("Client Account ID: {0}", clientBuyer.ClientAccountId);
                    Console.WriteLine("\tClient Name: {0}", clientBuyer.ClientName);
                    Console.WriteLine("\tEntity ID: {0}", clientBuyer.EntityId);
                    Console.WriteLine("\tEntity Name: {0}", clientBuyer.EntityName);
                    Console.WriteLine("\tEntity Type: {0}", clientBuyer.EntityType);
                    Console.WriteLine("\tRole: {0}", clientBuyer.Role);
                    Console.WriteLine("\tStatus: {0}", clientBuyer.Status);
                }
            }
        }
        /// <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>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerService adXService = (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 = adXService.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);
        }
Пример #7
0
 public YouTubeApi(string apiKey)
 {
     _service = new YouTubeService(new BaseClientService.Initializer()
     {
         ApiKey          = apiKey ?? throw new ArgumentException("API key not set."),
         ApplicationName = "coffeetube"
     });
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService =
                (AdExchangeBuyerIIService)service;

            long   accountId       = long.Parse("INSERT ACCOUNT ID HERE");
            long   clientAccountId = long.Parse("INSERT CLIENT ACCOUNT ID HERE");
            Client clientBuyer     = new Client
            {
                ClientName = "INSERT CLIENT NAME HERE",
                EntityId   = long.Parse("INSERT ENTITY ID HERE"),
                EntityName = "INSERT ENTITY NAME HERE",
                // Valid values: "ADVERTISER", "BRAND", or "AGENCY"
                EntityType = "INSERT ENTITY TYPE HERE",
                // Valid values: "CLIENT_DEAL_VIEWER",
                // "CLIENT_DEAL_NEGOTIATOR" or "CLIENT_DEAL_APPROVER"
                Role = "INSERT ROLE HERE",
                // Valid values: "ACTIVE", or "DISABLED"
                Status          = "INSERT STATUS HERE",
                VisibleToSeller = bool.Parse("INSERT VISIBLE_TO_SELLER HERE")
            };

            Client responseClientBuyer = adXService.Accounts.Clients.Update(clientBuyer, accountId, clientAccountId)
                                         .Execute();

            Console.WriteLine("Updated client buyer for account ID \"{0}\":", accountId);
            Console.WriteLine("Client account ID: {0}", responseClientBuyer.ClientAccountId);
            Console.WriteLine("Client name: {0}", responseClientBuyer.ClientName);
            Console.WriteLine("Entity ID: {0}", responseClientBuyer.EntityId);
            Console.WriteLine("Entity name: {0}", responseClientBuyer.EntityName);
            Console.WriteLine("Entity type: {0}", responseClientBuyer.EntityType);
            Console.WriteLine("Role: {0}", responseClientBuyer.Role);
            Console.WriteLine("Status: {0}", responseClientBuyer.Status);
            Console.WriteLine("Visible to seller: {0}", responseClientBuyer.VisibleToSeller);
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;
            long   accountId     = long.Parse("INSERT ACCOUNT ID HERE");
            string clientBuyerId = "INSERT CLIENT BUYER ID HERE";

            ListClientUserInvitationsResponse response = adXService.Accounts
                                                         .Clients.Invitations.List(accountId, clientBuyerId).Execute();

            Console.WriteLine("========================================\n");
            Console.WriteLine("Listing of invitations associated with AdX account \"{0}\" and " +
                              "client buyer ID \"{1}\"", accountId, clientBuyerId);
            Console.WriteLine("========================================\n");

            if (response.Invitations.Count == 0)
            {
                Console.WriteLine("No client users found.");
            }
            else
            {
                foreach (ClientUserInvitation invite in response.Invitations)
                {
                    Console.WriteLine("Invitations ID: {0}", invite.InvitationId);
                    Console.WriteLine("\tEmail: {0}", invite.Email);
                }
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService =
                (AdExchangeBuyerIIService)service;

            long       accountId       = long.Parse("INSERT ACCOUNT ID HERE");
            long       clientAccountId = long.Parse("INSERT CLIENT ACCOUNT ID HERE");
            long       userId          = long.Parse("INSERT CLIENT USER ID HERE");
            ClientUser clientUser      = new ClientUser
            {
                // Valid values: "ACTIVE", or "DISABLED"
                Status = "INSERT STATUS HERE"
            };

            ClientUser responseClientUser = adXService.Accounts.Clients.Users
                                            .Update(clientUser, accountId, clientAccountId, userId).Execute();

            Console.WriteLine("Updated client user for account ID \"{0}\" and "
                              + "client buyer ID \"{1}\":", accountId, clientAccountId);
            Console.WriteLine("User ID: {0}",
                              responseClientUser.UserId);
            Console.WriteLine("Status: {0}",
                              responseClientUser.Status);
            Console.WriteLine("Email: {0}",
                              responseClientUser.Email);
        }
        private void InitalizeNewAndSetAsCurrentBatchRequest(BaseClientService youTubeService)
        {
            var req = new BatchRequest(youTubeService);

            BatchRequests.Add(req);
            SetCurrentRequest(req);
        }
Пример #12
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;
            long   accountId     = long.Parse("INSERT ACCOUNT ID HERE");
            string clientBuyerId = "INSERT CLIENT BUYER ID HERE";

            ListClientUsersResponse response = adXService.Accounts.Clients.Users.List(
                accountId, clientBuyerId).Execute();

            Console.WriteLine("========================================\n");
            Console.WriteLine("Listing of client users associated with Authorized Buyers \"{0}\"" +
                              "and client buyer ID \"{1}\"", accountId, clientBuyerId);
            Console.WriteLine("========================================\n");

            if (response.Users.Count == 0)
            {
                Console.WriteLine("No client users found.");
            }
            else
            {
                foreach (ClientUser clientUser in response.Users)
                {
                    Console.WriteLine("User ID: {0}", clientUser.UserId);
                    Console.WriteLine("\tEmail: {0}", clientUser.Email);
                    Console.WriteLine("\tStatus: {0}", clientUser.Status);
                }
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;
            string accountId = "INSERT ACCOUNT ID HERE";

            // Optional: Specify a filter to target proposals that match certain criteria.
            // string filter = "INSERT_FILTER_HERE";
            // Optional: Specify the filter syntax. The proposals.list method will use PQL by
            // default for legacy support, but it is recommended that new users use LIST_FILTER.
            // AccountsResource.ProposalsResource.ListRequest.FilterSyntaxEnum filterSyntax =
            //     AccountsResource.ProposalsResource.ListRequest.FilterSyntaxEnum.LISTFILTER;

            AccountsResource.ProposalsResource.ListRequest request = adXService.Accounts.Proposals
                                                                     .List(accountId);
            // request.Filter = filter;
            // request.FilterSyntax = filterSyntax;
            ListProposalsResponse response = request.Execute();

            Console.WriteLine("========================================\n");
            Console.WriteLine("Listing Marketplace publisher profiles for buyer account ID " +
                              "\"{0}\"");
            Console.WriteLine("========================================\n");

            if (response.Proposals.Count == 0)
            {
                Console.WriteLine("No publisher profiles found.");
            }
            else
            {
                foreach (Proposal proposal in response.Proposals)
                {
                    Console.WriteLine("\tProposal ID: {0}", proposal.ProposalId);
                    Console.WriteLine("\tBuyer account ID: {0}", proposal.Buyer.AccountId);
                    Console.WriteLine("\tSeller account ID: {0}", proposal.Seller.AccountId);
                    Console.WriteLine("\tSeller sub-account ID: {0}", proposal.Seller.AccountId);
                    Console.WriteLine("\tProposal state: {0}", proposal.ProposalState);
                    Console.WriteLine("\tProposal revision: {0}", proposal.ProposalRevision);

                    IList <Deal> proposalDeals = proposal.Deals;

                    Console.WriteLine("\tDeals:");

                    if (proposalDeals != null && proposalDeals.Count > 0)
                    {
                        foreach (Deal proposalDeal in proposalDeals)
                        {
                            Console.WriteLine("\t\tDeal ID: {0}", proposalDeal.DealId);
                            Console.WriteLine("\t\t\tExternal deal ID: {0}",
                                              proposalDeal.ExternalDealId);
                            Console.WriteLine("\t\t\tDisplay name: {0}", proposalDeal.DisplayName);
                        }
                    }
                    else
                    {
                        Console.WriteLine("\t\tNone.");
                    }
                }
            }
        }
Пример #14
0
        public static BaseClientService AddExecuteInterceptor(
            this BaseClientService service,
            IHttpExecuteInterceptor interceptor)
        {
            service.HttpClient.MessageHandler.AddExecuteInterceptor(interceptor);

            return(service);
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerService adXService  = (AdExchangeBuyerService)service;
            AccountsList           allAccounts = adXService.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);
            }
        }
Пример #16
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;

            string buyerAccountId   = "INSERT_BUYER_ACCOUNT_ID_HERE";
            string proposalId       = "INSERT_PROPOSAL_ID_HERE";
            long   proposalRevision = long.Parse("INSERT_PROPOSAL_REVISION_HERE");

            AcceptProposalRequest acceptProposalBody = new AcceptProposalRequest();

            acceptProposalBody.ProposalRevision = proposalRevision;

            // Accept the Proposal
            Proposal acceptedProposal = adXService.Accounts.Proposals.Accept(
                acceptProposalBody, buyerAccountId, proposalId).Execute();

            Console.WriteLine("========================================");
            Console.WriteLine("Created new proposal for buyer account ID \"{0}\":",
                              buyerAccountId);
            Console.WriteLine("========================================");
            Console.WriteLine("\tProposal ID: {0}", proposalId);
            Console.WriteLine("\tBuyer account ID: {0}", acceptedProposal.Buyer.AccountId);
            Console.WriteLine("\tSeller account ID: {0}", acceptedProposal.Seller.AccountId);
            Console.WriteLine("\tSeller sub-account ID: {0}", acceptedProposal.Seller.AccountId);
            Console.WriteLine("\tProposal state: {0}", acceptedProposal.ProposalState);
            Console.WriteLine("\tProposal revision: {0}", acceptedProposal.ProposalRevision);

            IList <Deal> proposalDeals = acceptedProposal.Deals;

            Console.WriteLine("\tDeals:");

            if (proposalDeals != null && proposalDeals.Count > 0)
            {
                foreach (Deal proposalDeal in proposalDeals)
                {
                    Console.WriteLine("\t\tDeal ID: {0}", proposalDeal.DealId);
                    Console.WriteLine("\t\t\tExternal deal ID: {0}",
                                      proposalDeal.ExternalDealId);
                    Console.WriteLine("\t\t\tDisplay name: {0}", proposalDeal.DisplayName);
                }
            }
            else
            {
                Console.WriteLine("\t\tNone.");
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerService adXService = (AdExchangeBuyerService)service;
            int accountId = int.Parse("INSERT ACCOUNT ID HERE");

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

            Account responseAccount = adXService.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 AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;

            long accountId       = long.Parse("INSERT ACCOUNT ID HERE");
            long clientAccountId = long.Parse("INSERT CLIENT ACCOUNT ID HERE");

            ClientUserInvitation invite = new ClientUserInvitation
            {
                Email = "INSERT EMAIL ADDRESS HERE"
            };

            ClientUserInvitation responseInvite = adXService.Accounts.Clients.Invitations.Create(
                invite, accountId, clientAccountId).Execute();

            Console.WriteLine("Created and sent new invitation for account ID \"{0}\" and client " +
                              "account ID \"{1}\" to \"{2}\".", accountId, responseInvite.ClientAccountId,
                              invite.Email);
        }
Пример #19
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerService adXService = (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 = adXService.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(BaseClientService service)
        {
            AdExchangeBuyerService adXService = (AdExchangeBuyerService)service;
            int    accountId       = int.Parse("INSERT ACCOUNT ID HERE");
            String buyerCreativeId = "INSERT BUYER CREATIVE ID HERE";

            try
            {
                Creative creative = adXService.Creatives.Get(accountId, buyerCreativeId).Execute();
                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);
            }
            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;
            }
        }
 public GcsFileUploader(BaseClientService.Initializer serviceInitializer, string project)
 {
     _bucketService = new StorageService(serviceInitializer);
     _project = project;
 }
Пример #22
0
 public static BaseClientService AddUserAgent(
     this BaseClientService service,
     string userAgent)
 {
     return(service.AddExecuteInterceptor(new UserAgentInterceptor(userAgent)));
 }
Пример #23
0
 public abstract void Run(BaseClientService service);
Пример #24
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;

            string buyerAccountId  = "INSERT_BUYER_ACCOUNT_ID_HERE";
            string sellerAccountId = "INSERT_SELLER_ACCOUNT_ID_HERE";
            // Optionally set seller sub-account ID.
            // string sellerSubAccountId = "INSERT_SELLER_SUB_ACCOUNT_ID_HERE";

            // Build the Proposal for the proposals.create request.
            Buyer buyer = new Buyer();

            buyer.AccountId = buyerAccountId;

            Seller seller = new Seller();

            seller.AccountId = sellerAccountId;
            // Optionally set seller sub-account ID.
            // seller.SubAccountId = sellerSubAccountId;

            Proposal proposal = new Proposal();

            proposal.Buyer       = buyer;
            proposal.Seller      = seller;
            proposal.DisplayName = string.Format("Test Proposal #{0}",
                                                 Guid.NewGuid());

            // Build the Programmatic Guaranteed Deal to be associated with the proposal.
            Money egsAmount = new Money();

            egsAmount.CurrencyCode = "USD";
            egsAmount.Units        = 0L;
            egsAmount.Nanos        = 1;

            Price estimatedGrossSpend = new Price();

            estimatedGrossSpend.PricingType = "COST_PER_MILLE";
            estimatedGrossSpend.Amount      = egsAmount;

            Money fixedPriceAmount = new Money();

            fixedPriceAmount.CurrencyCode = "USD";
            fixedPriceAmount.Units        = 0L;
            fixedPriceAmount.Nanos        = 1;

            Price fixedPrice = new Price();

            fixedPrice.PricingType = "COST_PER_MILLE";
            fixedPrice.Amount      = fixedPriceAmount;

            PricePerBuyer price = new PricePerBuyer();

            price.Price = fixedPrice;
            price.Buyer = buyer;

            List <PricePerBuyer> fixedPrices = new List <PricePerBuyer>();

            fixedPrices.Add(price);

            // The pricing terms used in this example are GuaranteedFixedPriceTerms, make this a
            // programmatic guaranteed deal. Alternatively, you could use
            // NonGuaranteedFixPriceTerms to specify a preferred deal. Private auction deals use
            // NonGuaranteedAuctionTerms; however, only sellers can create this deal type.
            GuaranteedFixedPriceTerms guaranteedFixedPriceTerms = new GuaranteedFixedPriceTerms();

            guaranteedFixedPriceTerms.FixedPrices           = fixedPrices;
            guaranteedFixedPriceTerms.GuaranteedLooks       = 1;
            guaranteedFixedPriceTerms.GuaranteedImpressions = 1;
            guaranteedFixedPriceTerms.MinimumDailyLooks     = 1;

            DealTerms dealTerms = new DealTerms();

            dealTerms.EstimatedGrossSpend       = estimatedGrossSpend;
            dealTerms.GuaranteedFixedPriceTerms = guaranteedFixedPriceTerms;
            dealTerms.Description  = "Test deal.";
            dealTerms.BrandingType = "BRANDED";
            dealTerms.EstimatedImpressionsPerDay = 1;
            dealTerms.SellerTimeZone             = "America/New_York";

            Deal deal = new Deal();

            deal.DealTerms          = dealTerms;
            deal.DisplayName        = string.Format("Test Deal #{0}", Guid.NewGuid());
            deal.SyndicationProduct = "GAMES";

            List <Deal> deals = new List <Deal>();

            deals.Add(deal);

            // Append deals to the proposal.
            proposal.Deals = deals;

            // Create the Proposal
            AccountsResource.ProposalsResource.CreateRequest createRequest =
                adXService.Accounts.Proposals.Create(proposal, buyerAccountId);
            Proposal createdProposal = createRequest.Execute();
            string   proposalId      = createdProposal.ProposalId;

            Console.WriteLine("========================================");
            Console.WriteLine("Created new proposal for buyer account ID \"{0}\":",
                              buyerAccountId);
            Console.WriteLine("========================================");
            Console.WriteLine("\tProposal ID: {0}", proposalId);
            Console.WriteLine("\tBuyer account ID: {0}", createdProposal.Buyer.AccountId);
            Console.WriteLine("\tSeller account ID: {0}", createdProposal.Seller.AccountId);
            Console.WriteLine("\tSeller sub-account ID: {0}", createdProposal.Seller.AccountId);
            Console.WriteLine("\tProposal state: {0}", createdProposal.ProposalState);
            Console.WriteLine("\tProposal revision: {0}", createdProposal.ProposalRevision);
            Console.WriteLine("\tDeals:");
            foreach (Deal proposalDeal in createdProposal.Deals)
            {
                Console.WriteLine("\t\tDeal ID: {0}", proposalDeal.DealId);
                Console.WriteLine("\t\t\tExternal deal ID: {0}", proposalDeal.ExternalDealId);
                Console.WriteLine("\t\t\tDisplay name: {0}", proposalDeal.DisplayName);
            }
        }
 public DataSourceAssert(IDataSourceBase <BaseClientService> dataSource)
 {
     _service = dataSource.Service;
 }
Пример #26
0
 public CustomInitializer(string projectId, BaseClientService.Initializer initializer)
 {
     _initializer = initializer;
     _projectId = projectId;
 }
Пример #27
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;
            string bidderResourceId             = "INSERT_BIDDER_RESOURCE_ID_HERE";
            string ownerName = String.Format("bidders/{0}", bidderResourceId);

            ListFilterSetsResponse response = adXService.Bidders.FilterSets.List(ownerName)
                                              .Execute();

            Console.WriteLine("========================================\n");
            Console.WriteLine("Listing of filter sets associated with owner name \"{0}\"",
                              ownerName);
            Console.WriteLine("========================================\n");

            if (response.FilterSets.Count == 0)
            {
                Console.WriteLine("No filter sets found.");
            }
            else
            {
                foreach (FilterSet filterSet in response.FilterSets)
                {
                    Console.WriteLine("* Name: {0}", filterSet.Name);
                    AbsoluteDateRange absDateRange = filterSet.AbsoluteDateRange;
                    if (absDateRange != null)
                    {
                        Console.WriteLine("\tAbsoluteDateRange:");
                        Date startDate = absDateRange.StartDate;
                        Console.WriteLine("\t\tStartDate:");
                        Console.WriteLine("\t\t\tYear: {0}", startDate.Year);
                        Console.WriteLine("\t\t\tMonth: {0}", startDate.Month);
                        Console.WriteLine("\t\t\tDay: {0}", startDate.Day);
                        Date endDate = absDateRange.EndDate;
                        Console.WriteLine("\t\tEndDate:");
                        Console.WriteLine("\t\t\tYear: {0}", endDate.Year);
                        Console.WriteLine("\t\t\tMonth: {0}", endDate.Month);
                        Console.WriteLine("\t\t\tDay: {0}", endDate.Day);
                    }
                    RelativeDateRange relDateRange = filterSet.RelativeDateRange;
                    if (relDateRange != null)
                    {
                        Console.WriteLine("\tRelativeDateRange:");
                        Console.WriteLine("\t\tOffsetDays: {0}", relDateRange.OffsetDays);
                        Console.WriteLine("\t\tDurationDays: {0}", relDateRange.DurationDays);
                    }
                    RealtimeTimeRange rtTimeRange = filterSet.RealtimeTimeRange;
                    if (rtTimeRange != null)
                    {
                        Console.WriteLine("\tRealtimeTimeRange:");
                        Console.WriteLine("\t\tStartTimestamp: {0}", rtTimeRange.StartTimestamp);
                    }
                    String timeSeriesGranularity = filterSet.TimeSeriesGranularity;
                    if (timeSeriesGranularity != null)
                    {
                        Console.WriteLine("\tTimeSeriesGranularity: {0}", timeSeriesGranularity);
                    }
                    IList <String> formats = filterSet.Formats;
                    if (formats != null)
                    {
                        Console.WriteLine("\tFormats:");
                        foreach (string format in formats)
                        {
                            Console.WriteLine("\t\t{0}", format);
                        }
                    }
                    String environment = filterSet.Environment;
                    if (environment != null)
                    {
                        Console.WriteLine("\tEnvironment: {0}", environment);
                    }
                    IList <string> platforms = filterSet.Platforms;
                    if (platforms != null)
                    {
                        Console.WriteLine("\tPlatforms:");
                        foreach (string platform in platforms)
                        {
                            Console.WriteLine("\t\t{0}", platform);
                        }
                    }
                    IList <int?> sellerNetworkIds = filterSet.SellerNetworkIds;
                    if (sellerNetworkIds != null)
                    {
                        Console.WriteLine("\tSellerNetworkIds:");
                        foreach (int?sellerNetworkId in sellerNetworkIds)
                        {
                            Console.WriteLine("\t\t{0}", sellerNetworkId);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;

            string bidderResourceId  = "INSERT_BIDDER_RESOURCE_ID_HERE";
            string accountResourceId = "INSERT_ACCOUNT_RESOURCE_ID_HERE";
            string resourceId        = "INSERT_DESIRED_FILTER_SET_RESOURCE_ID_HERE";
            // Optional strings representing the start and end date for the AbsoluteDateRange to be
            // used in the new filter set. The date should be specified in the given format--e.g.
            // 20170101. If left unmodified, the dates for the first and last day of the past week
            // will be used.
            string startDateString = "YYYYMMDD";
            string endDateString   = "YYYYMMDD";
            // By default, this example will create transient (temporary) filter sets. To create
            // filter sets that can be used indefinitely, set this to false.
            bool isTransient = true;

            string ownerName = string.Format("bidders/{0}/accounts/{1}", bidderResourceId,
                                             accountResourceId);

            if (startDateString.Equals("YYYYMMDD"))
            {
                if (endDateString.Equals("YYYYMMDD"))
                {
                    DateTime defaultEndDate = DateTime.Now;
                    endDateString = defaultEndDate.ToString(dateFormat);
                    DateTime defaultStartDate = defaultEndDate.AddDays(-7);
                    startDateString = defaultStartDate.ToString(dateFormat);
                }
                else
                {
                    throw new ArgumentException("Both the startDate and endDate must be set.");
                }
            }

            AbsoluteDateRange dateRange = BuildAbsoluteDateRange(startDateString, endDateString);

            FilterSet filterSet = new FilterSet
            {
                Name = string.Format("{0}/filterSets/{1}", ownerName, resourceId),
                AbsoluteDateRange = dateRange,
                CreativeId        = "INSERT_CREATIVE_ID_HERE",
                DealId            = long.Parse("INSERT_DEAL_ID_HERE"),
                // Valid values: DAILY, HOURLY
                TimeSeriesGranularity = "INSERT_TIME_SERIES_GRANULARITY_HERE",
                // Valid values: DISPLAY, VIDEO
                Format = "INSERT_FORMAT_HERE",
                // Valid values: APP, WEB
                Environment = "INSERT_ENVIRONMENT_HERE",
                // Valid values: DESKTOP, MOBILE, TABLET
                Platforms = new List <string>()
                {
                    "INSERT_PLATFORMS_HERE"
                },
                SellerNetworkIds = new List <int?>()
                {
                    int.Parse("INSERT_SELLER_NETWORK_IDS_HERE")
                }
            };

            BiddersResource.AccountsResource.FilterSetsResource.CreateRequest request =
                adXService.Bidders.Accounts.FilterSets.Create(filterSet, ownerName);
            request.IsTransient = isTransient;
            FilterSet response = request.Execute();

            Console.WriteLine("Created new account-level filter set for owner \"{0}\":",
                              ownerName);
            Console.WriteLine("Name: {0}", response.Name);
            Console.WriteLine("\tAbsoluteDateRange:");
            Date startDate = response.AbsoluteDateRange.StartDate;

            Console.WriteLine("\t\tStartDate:");
            Console.WriteLine("\t\t\tYear: {0}", startDate.Year);
            Console.WriteLine("\t\t\tMonth: {0}", startDate.Month);
            Console.WriteLine("\t\t\tDay: {0}", startDate.Day);
            Date endDate = response.AbsoluteDateRange.EndDate;

            Console.WriteLine("\t\tEndDate:");
            Console.WriteLine("\t\t\tYear: {0}", endDate.Year);
            Console.WriteLine("\t\t\tMonth: {0}", endDate.Month);
            Console.WriteLine("\t\t\tDay: {0}", endDate.Day);

            string creativeId = response.CreativeId;

            if (creativeId != null)
            {
                Console.WriteLine("\tCreativeId: {0}", creativeId);
            }
            long?dealId = response.DealId;

            if (dealId != null)
            {
                Console.WriteLine("\tDealId: {0}", dealId);
            }
            String timeSeriesGranularity = response.TimeSeriesGranularity;

            if (timeSeriesGranularity != null)
            {
                Console.WriteLine("\tTimeSeriesGranularity: {0}", timeSeriesGranularity);
            }
            String format = response.Format;

            if (format != null)
            {
                Console.WriteLine("\tFormat: {0}", format);
            }
            String environment = response.Environment;

            if (environment != null)
            {
                Console.WriteLine("\tEnvironment: {0}", environment);
            }
            IList <string> platforms = response.Platforms;

            if (platforms != null)
            {
                Console.WriteLine("\tPlatforms:");
                foreach (string platform in platforms)
                {
                    Console.WriteLine("\t\t{0}", platform);
                }
            }
            IList <int?> sellerNetworkIds = response.SellerNetworkIds;

            if (sellerNetworkIds != null)
            {
                Console.WriteLine("\tSellerNetworkIds:");
                foreach (int?sellerNetworkId in sellerNetworkIds)
                {
                    Console.WriteLine("\t\t{0}", sellerNetworkId);
                }
            }
        }