Exemple #1
0
        public async Task <GetKeywordsByAdGroupIdResponse> GetKeywordsByAdGroupIdAsync(
            ApiAuthentication auth,
            long?accountId,
            long?customerId,
            long adGroupId)
        {
            var request = new GetKeywordsByAdGroupIdRequest
            {
                CustomerAccountId = string.Format("{0}", accountId),
                CustomerId        = string.Format("{0}", customerId),
                AdGroupId         = adGroupId,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetKeywordsByAdGroupIdAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CampaignManagement, "GetKeywordsByAdGroupIdAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #2
0
        public async Task <DeleteAccountResponse> DeleteAccountAsync(ApiAuthentication auth, long accountId)
        {
            var _request = GetAccount(auth, accountId);

            if (_request == null)
            {
                return(null);
            }

            var request = new DeleteAccountRequest
            {
                AccountId = accountId,
                TimeStamp = _request.Account.TimeStamp,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().DeleteAccountAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "DeleteAccountAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #3
0
        public GetAdGroupsByCampaignIdResponse GetAdGroupsByCampaignId(
            ApiAuthentication auth,
            long?accountId,
            long?customerId,
            long campaignId)
        {
            var request = new GetAdGroupsByCampaignIdRequest
            {
                CustomerAccountId = string.Format("{0}", accountId),
                CustomerId        = string.Format("{0}", customerId),
                CampaignId        = campaignId
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().GetAdGroupsByCampaignId(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CampaignManagement, "GetAdGroupsByCampaignId", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #4
0
        public async Task <AddAdGroupsResponse> AddAdGroupsAsync(
            ApiAuthentication auth,
            long?accountId,
            long?customerId,
            long campaignId,
            AdGroup[] adGroups)
        {
            var request = new AddAdGroupsRequest
            {
                CustomerAccountId = string.Format("{0}", accountId),
                CustomerId        = string.Format("{0}", customerId),
                CampaignId        = campaignId,
                AdGroups          = adGroups,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().AddAdGroupsAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CampaignManagement, "AddAdGroupsAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #5
0
        public async Task <GetCampaignCriterionsByIdsResponse> GetCampaignCriterionsByIdsAsync(
            ApiAuthentication auth,
            long[] campaignCriterionIds,
            long campaignId,
            CampaignCriterionType criterionType,
            long?accountId,
            long?customerId = null)
        {
            var request = new GetCampaignCriterionsByIdsRequest
            {
                CampaignCriterionIds = campaignCriterionIds,
                CampaignId           = campaignId,
                CriterionType        = criterionType,
                CustomerAccountId    = string.Format("{0}", accountId),
                CustomerId           = string.Format("{0}", customerId),
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetCampaignCriterionsByIdsAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CampaignManagement, "GetCampaignCriterionsByIdsAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #6
0
        public AddKeywordsResponse AddKeywords(
            ApiAuthentication auth,
            long?accountId,
            long?customerId,
            long adGroupId,
            Keyword[] keywords)
        {
            var request = new AddKeywordsRequest
            {
                CustomerAccountId = string.Format("{0}", accountId),
                CustomerId        = string.Format("{0}", customerId),
                AdGroupId         = adGroupId,
                Keywords          = keywords,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().AddKeywords(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CampaignManagement, "AddKeywords", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #7
0
        /// <summary>
        /// Gets the keyword categories to which the specified keywords belong.
        /// </summary>
        /// <param name="auth">Do not use ApiAuthentication directly. Use PasswordAuthentication or OAuthAuthentication derives from it instead.</param>
        /// <param name="_keywords">An array of keywords for which you want to determine the possible keyword categories that each keyword belongs to.
        /// The array can contain a maximum of 1,000 keywords, and each keyword can contain a maximum of 100 characters.</param>
        /// <param name="_publisherCoutry">The country code of the country/region to use as the source of the category data.
        /// Note: You must set this element to US.</param>
        /// <param name="_language">The language in which the keywords are written. You must set this element to English.</param>
        /// <param name="_maxCategor">The number of categories to include in the results. The maximum number of categories that you can request is 5.</param>
        /// <param name="_customerId">The identifier of the customer that owns the account.
        /// Note: As a best practice you should always specify this element.</param>
        /// <param name="_customerAccountId">The identifier of the account that owns the entities in the request. This header element must have the same value as the AccountId body element when both are required.
        /// Note: Required for service operations related to bid estimations. As a best practice you should always specify this element for operations limited in scope to a single account per service call.</param>
        /// <returns></returns>
        public GetKeywordCategoriesResponse GetKeywordCategories(ApiAuthentication auth, String[] _keywords,
                                                                 String _publisherCoutry, String _language, int _maxCategor, long?_customerId, long?_customerAccountId)
        {
            var request = new GetKeywordCategoriesRequest
            {
                Keywords          = _keywords,
                PublisherCountry  = _publisherCoutry,
                Language          = _language,
                MaxCategories     = _maxCategor,
                CustomerAccountId = string.Format("{0}", _customerAccountId),
                CustomerId        = string.Format("{0}", _customerId),
            };

            SetAuthHelper.SetAuth(auth, request);

            return(Check().GetKeywordCategories(request));
        }
Exemple #8
0
        /// <summary>
        /// Updates an insertion order within the specified account.
        /// https://msdn.microsoft.com/en-us/library/bing-ads-billing-updateinsertionorder(v=msads.90).aspx
        /// </summary>
        /// <param name="auth">Do not use ApiAuthentication directly. Use PasswordAuthentication or OAuthAuthentication derives from it instead.</param>
        /// <param name="order">InsertionOrder</param>
        /// <returns>UpdateInsertionOrderResponse</returns>
        public UpdateInsertionOrderResponse UpdateInsertionOrder(ApiAuthentication auth, InsertionOrder order)
        {
            var request = new UpdateInsertionOrderRequest
            {
                InsertionOrder = order,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().UpdateInsertionOrder(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "UpdateInsertionOrder", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="auth">Do not use ApiAuthentication directly. Use PasswordAuthentication or OAuthAuthentication derives from it instead.</param>
        /// <param name="customerId"></param>
        /// <returns></returns>
        public GetAccessibleCustomerResponse GetAccessibleCustomer(ApiAuthentication auth, long customerId)
        {
            var request = new GetAccessibleCustomerRequest
            {
                CustomerId = customerId,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().GetAccessibleCustomer(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "GetAccessibleCustomer", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #10
0
        public async Task <GetKOHIOInvoicesResponse> GetKOHIOInvoicesAsync(ApiAuthentication auth, string[] invoiceIds)
        {
            var request = new GetKOHIOInvoicesRequest
            {
                InvoiceIds = invoiceIds,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetKOHIOInvoicesAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "GetKOHIOInvoicesAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #11
0
        public AddPrepayAccountResponse AddPrepayAccount(ApiAuthentication auth, AdvertiserAccount prePayAccount)
        {
            var request = new AddPrepayAccountRequest
            {
                Account = prePayAccount
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().AddPrepayAccount(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "AddPrepayAccount", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #12
0
        public async Task <AddAccountResponse> AddAccountAsync(ApiAuthentication auth, AdvertiserAccount account)
        {
            var request = new AddAccountRequest
            {
                Account = account,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().AddAccountAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "AddAccountAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #13
0
        public async Task <UpdateClientLinksResponse> UpdateClientLinksAsync(ApiAuthentication auth, ClientLink[] clientLinks)
        {
            var request = new UpdateClientLinksRequest
            {
                ClientLinks = clientLinks,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().UpdateClientLinksAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "UpdateClientLinksAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #14
0
        /// <summary>
        /// https://msdn.microsoft.com/en-us/library/bing-ads-customer-management-addclientlinks(v=msads.90).aspx
        /// </summary>
        /// <param name="auth"></param>
        /// <param name="clientLinks"></param>
        /// <returns></returns>
        public AddClientLinksResponse AddClientLinks(ApiAuthentication auth, ClientLink[] clientLinks)
        {
            var request = new AddClientLinksRequest
            {
                ClientLinks = clientLinks,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().AddClientLinks(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "AddClientLinks", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #15
0
        /// <summary>
        /// Updates the details of the specified account.
        /// https://msdn.microsoft.com/en-US/library/dn451286(v=msads.90).aspx
        /// </summary>
        /// <param name="auth">Do not use ApiAuthentication directly. Use PasswordAuthentication or OAuthAuthentication derives from it instead.</param>
        /// <param name="account">
        /// AdvertiserAccount:  An AdvertiserAccount object that contains the updated account information.This operation overwrites the existing account data with the contents of the account object that you pass.
        ///                     This operation performs a full update, and not a partial update. The Account object must contain the time stamp value from the last time that the Account object was written to.
        ///                     To ensure that the time stamp contains the correct value, call the GetAccount operation. You can then update the account data as appropriate, and call UpdateAccount.
        ///                     https://msdn.microsoft.com/en-US/library/bing-ads-customer-management-advertiseraccount(v=msads.90).aspx</param>
        /// <returns>UpdateAccountResponse</returns>
        public UpdateAccountResponse UpdateAccount(ApiAuthentication auth, Account account)
        {
            var request = new UpdateAccountRequest
            {
                Account = account,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().UpdateAccount(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "UpdateAccount", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #16
0
        public async Task <SendUserInvitationResponse> SendUserInvitationAsync(ApiAuthentication auth, UserInvitation userInvitation)
        {
            var request = new SendUserInvitationRequest
            {
                UserInvitation = userInvitation,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().SendUserInvitationAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "SendUserInvitationAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #17
0
        public async Task <GetCustomerPilotFeaturesResponse> GetCustomerPilotFeaturesAsync(ApiAuthentication auth, long customerId)
        {
            var request = new GetCustomerPilotFeaturesRequest
            {
                CustomerId = customerId
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetCustomerPilotFeaturesAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "GetCustomerPilotFeaturesAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #18
0
        public async Task <AddInsertionOrderResponse> AddInsertionOrderAsync(ApiAuthentication auth, InsertionOrder order)
        {
            var request = new AddInsertionOrderRequest
            {
                InsertionOrder = order,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().AddInsertionOrderAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "AddInsertionOrderAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
        public async Task <DownloadCampaignsByCampaignIdsResponse> DownloadCampaignsByCampaignIdsAsync(
            ApiAuthentication auth,
            CampaignScope[] campaigns,
            long accountId,
            long?customerId,
            DataScope dataScope,
            BulkDownloadEntity entities,
            CompressionType compressionType   = CompressionType.Zip,
            DownloadFileType downloadFileType = DownloadFileType.Tsv,
            string formatVersion       = "4.0",
            DateTime?lastSyncTimeInUTC = null,
            DateTime?start             = null,
            DateTime?end = null)
        {
            var request = new DownloadCampaignsByCampaignIdsRequest
            {
                CustomerId                = string.Format("{0}", customerId),
                CustomerAccountId         = string.Format("{0}", accountId),
                Campaigns                 = campaigns,
                CompressionType           = compressionType,
                DataScope                 = dataScope,
                DownloadFileType          = downloadFileType,
                Entities                  = entities,
                FormatVersion             = formatVersion,
                LastSyncTimeInUTC         = lastSyncTimeInUTC,
                PerformanceStatsDateRange = BuildDateRange(start, end)
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().DownloadCampaignsByCampaignIdsAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.Bulk, "DownloadCampaignsByCampaignIdsAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #20
0
        public GetDisplayInvoicesResponse GetDisplayInvoices(ApiAuthentication auth, long[] invoiceIds, DataType dataType)
        {
            var request = new GetDisplayInvoicesRequest
            {
                InvoiceIds = invoiceIds,
                Type       = dataType,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().GetDisplayInvoices(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "GetDisplayInvoices", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #21
0
        public async Task <GetBillingDocumentsResponse> GetBillingDocumentsAsync(ApiAuthentication auth, long[] documentIds, DataType dataType = DataType.Xml)
        {
            var request = new GetBillingDocumentsRequest
            {
                DocumentIds = documentIds,
                Type        = dataType,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetBillingDocumentsAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "GetBillingDocumentsAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #22
0
        public async Task <GetInsertionOrdersByAccountResponse> GetInsertionOrdersByAccountAsync(ApiAuthentication auth, long accountId, long[] insertionOrderIds = null)
        {
            var request = new GetInsertionOrdersByAccountRequest
            {
                AccountId         = accountId,
                InsertionOrderIds = insertionOrderIds,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetInsertionOrdersByAccountAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "GetInsertionOrdersByAccountAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #23
0
        public async Task <GetAccountMonthlySpendResponse> GetAccountMonthlySpendAsync(ApiAuthentication auth, long accountId, DateTime monthYear)
        {
            var request = new GetAccountMonthlySpendRequest
            {
                AccountId = accountId,
                MonthYear = monthYear,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetAccountMonthlySpendAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "GetAccountMonthlySpendAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #24
0
        public async Task <GetAccountsInfoResponse> GetAccountsInfoAsync(ApiAuthentication auth, long?customerId, bool onlyParentAccounts)
        {
            var request = new GetAccountsInfoRequest
            {
                CustomerId         = customerId,
                OnlyParentAccounts = onlyParentAccounts,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetAccountsInfoAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "GetAccountsInfoAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #25
0
        public async Task <GetUsersInfoResponse> GetUsersInfoAsync(ApiAuthentication auth, long customerId, UserLifeCycleStatus?statusFilter)
        {
            var request = new GetUsersInfoRequest
            {
                CustomerId   = customerId,
                StatusFilter = statusFilter
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetUsersInfoAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerManagement, "GetUsersInfoAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
        private SubmitGenerateReportResponse SubmitReport(ApiAuthentication auth, ReportRequest reportRequest, long?customerId, long?accountId)
        {
            var request = new SubmitGenerateReportRequest
            {
                ReportRequest     = reportRequest,
                CustomerId        = customerId.HasValue ? string.Format("{0}", customerId.Value) : "",
                CustomerAccountId = accountId.HasValue ? string.Format("{0}", accountId.Value) : "",
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(Check().SubmitGenerateReport(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.Reporting, "SubmitReport", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
        public async Task <GetBulkDownloadStatusResponse> GetBulkDownloadStatusAsync(ApiAuthentication auth, string requestId, long?accountId, long?customerId)
        {
            var request = new GetBulkDownloadStatusRequest
            {
                CustomerAccountId = string.Format("{0}", accountId),
                CustomerId        = string.Format("{0}", customerId),
                RequestId         = requestId,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetBulkDownloadStatusAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.Bulk, "GetBulkDownloadStatusAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #28
0
        public async Task <GetBillingDocumentsInfoResponse> GetBillingDocumentsInfoAsync(ApiAuthentication auth, long[] accountIds, DateTime start, DateTime end)
        {
            var request = new GetBillingDocumentsInfoRequest
            {
                AccountIds = accountIds,
                StartDate  = start,
                EndDate    = end,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().GetBillingDocumentsInfoAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "GetBillingDocumentsInfoAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
        public async Task <PollGenerateReportResponse> PollGenerateReportAsync(ApiAuthentication auth, string reportRequestId, long?customerId, long?accountId)
        {
            var request = new PollGenerateReportRequest
            {
                ReportRequestId   = reportRequestId,
                CustomerId        = customerId.HasValue ? string.Format("{0}", customerId.Value) : "",
                CustomerAccountId = accountId.HasValue ? string.Format("{0}", accountId.Value) : "",
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().PollGenerateReportAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.Reporting, "PollGenerateReportAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }
Exemple #30
0
        public async Task <SearchInsertionOrdersResponse> SearchInsertionOrdersAsync(ApiAuthentication auth, OrderBy[] ordering, Paging pageing, Predicate[] predicates)
        {
            var request = new SearchInsertionOrdersRequest
            {
                Ordering   = ordering,
                PageInfo   = pageing,
                Predicates = predicates,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

                return(await Check().SearchInsertionOrdersAsync(request));
            }
            catch (Exception ex)
            {
                Log(new LogEventArgs(ServiceType.CustomerBilling, "SearchInsertionOrdersAsync", ex.Message, new { Request = request }, ex));
            }

            return(null);
        }