Пример #1
0
        /// <param name="optional">Optional paramaters.</param>        /// <returns>ListClientUsersResponseResponse</returns>
        public static ListClientUsersResponse List(AdExchangeBuyerIIService service, string accountId, string clientAccountId, UsersListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (accountId == null)
                {
                    throw new ArgumentNullException(accountId);
                }
                if (clientAccountId == null)
                {
                    throw new ArgumentNullException(clientAccountId);
                }

                // Building the initial request.
                var request = service.Users.List(accountId, clientAccountId);

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

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Users.List failed.", ex);
            }
        }
Пример #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;
            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 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);
        }
Пример #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;
            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);
            }
        }
Пример #5
0
        /// <param name="userId">Numerical identifier of the user to retrieve. (required)</param>
        /// <param name="body">A valid AdExchangeBuyerII v2beta1 body.</param>
        /// <returns>ClientUserResponse</returns>
        public static ClientUser Update(AdExchangeBuyerIIService service, string accountId, string clientAccountId, string userId, ClientUser 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 (clientAccountId == null)
                {
                    throw new ArgumentNullException(clientAccountId);
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Make the request.
                return(service.Users.Update(body, accountId, clientAccountId, userId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Users.Update failed.", ex);
            }
        }
Пример #6
0
        /// <param name="invitationId">Numerical identifier of the user invitation to retrieve. (required)</param>
        /// <returns>ClientUserInvitationResponse</returns>
        public static ClientUserInvitation Get(AdExchangeBuyerIIService service, string accountId, string clientAccountId, string invitationId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (accountId == null)
                {
                    throw new ArgumentNullException(accountId);
                }
                if (clientAccountId == null)
                {
                    throw new ArgumentNullException(clientAccountId);
                }
                if (invitationId == null)
                {
                    throw new ArgumentNullException(invitationId);
                }

                // Make the request.
                return(service.Invitations.Get(accountId, clientAccountId, invitationId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Invitations.Get failed.", ex);
            }
        }
        /// <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);
                }
            }
        }
Пример #9
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);
                }
            }
        }
Пример #10
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);
                }
            }
        }
        /// <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.");
                    }
                }
            }
        }
Пример #12
0
        /// <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)
        {
            AdExchangeBuyerIIService service = Utilities.GetV2Service();
            ExampleBase example = new AcceptProposal();

            Console.WriteLine(example.Description);

            example.Run(service);
        }
Пример #13
0
        /// <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)
        {
            AdExchangeBuyerIIService service = Utilities.GetV2Service();
            ExampleBase example = new ListBidderLevelFilterSets();

            Console.WriteLine(example.Description);

            example.Run(service);
        }
        /// <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();
        }
Пример #15
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 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);
        }
Пример #17
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);
                }
            }
        }
Пример #19
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);
            }
        }