public DownloadCampaignsByCampaignIdsResponse TryDownloadCampaignsByCampaignIds(
     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)
 {
     return(MethodHelper.TryGet(DownloadCampaignsByCampaignIds, this,
                                auth,
                                campaigns,
                                accountId,
                                customerId,
                                dataScope,
                                entities,
                                compressionType,
                                downloadFileType,
                                formatVersion,
                                lastSyncTimeInUTC,
                                start,
                                end));
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
 public GetAdsByAdGroupIdResponse TryGetAdsByAdGroupId(
     ApiAuthentication auth,
     long?accountId,
     long?customerId,
     long adGroupId)
 {
     return(MethodHelper.TryGet(GetAdsByAdGroupId, this, auth, accountId, customerId, adGroupId));
 }
Ejemplo n.º 9
0
 public GetCampaignsByAccountIdResponse TryGetCampaignsByAccountId(
     ApiAuthentication auth,
     long accountId,
     CampaignType campaignType,
     long?customerId = null)
 {
     return(MethodHelper.TryGet(GetCampaignsByAccountId, this, auth, accountId, campaignType, customerId));
 }
Ejemplo n.º 10
0
 public AddKeywordsResponse TryAddKeywords(
     ApiAuthentication auth,
     long?accountId,
     long?customerId,
     long adGroupId,
     Keyword[] keywords)
 {
     return(MethodHelper.TryGet(AddKeywords, this, auth, accountId, customerId, adGroupId, keywords));
 }
Ejemplo n.º 11
0
 public GetBillingDocumentsInfoResponse TryGetBillingDocumentsInfo(ApiAuthentication auth, long[] accountIds, DateTime start, DateTime end)
 {
     return(MethodHelper.TryGet(GetBillingDocumentsInfo,
                                this,
                                auth,
                                accountIds,
                                start,
                                end));
 }
Ejemplo n.º 12
0
 public AddCampaignsResponse TryAddCampaigns(
     ApiAuthentication auth,
     long accountId,
     long?customerId,
     Campaign[] campaigns)
 {
     return(MethodHelper.TryGet(
                AddCampaigns,
                this,
                auth,
                accountId,
                customerId,
                campaigns));
 }
Ejemplo n.º 13
0
 public AddAdGroupsResponse TryAddAdGroups(
     ApiAuthentication auth,
     long?accountId,
     long?customerId,
     long campaignId,
     AdGroup[] adGroups)
 {
     return(MethodHelper.TryGet(AddAdGroups,
                                this,
                                auth,
                                accountId,
                                customerId,
                                campaignId,
                                adGroups));
 }
        //public static void SetAuth<T>(ApiAuthentication auth, T request)
        //    where T : class
        //{
        //    var fs = request.GetType().GetFields();

        //    if (fs.Length > 0 && fs.Count(p => p.Name == "DeveloperToken") > 0)
        //    {
        //        SetAuthUsingField<T>(auth, request);
        //    }
        //    else
        //    {
        //        var ps = request.GetType().GetProperties();
        //        if (ps.Length > 0 && ps.Count(p => p.Name == "DeveloperToken") > 0)
        //            SetAuthUsingPropertity<T>(auth, request);
        //    }
        //}

        public static void SetAuth(ApiAuthentication auth, dynamic request)
        {
            if (auth.GetType() == typeof(PasswordAuthentication))
            {
                var _auth = auth as PasswordAuthentication;
                request.DeveloperToken = _auth.DeveloperToken;
                request.UserName       = _auth.UserName;
                request.Password       = _auth.Password;
            }
            else
            {
                var _auth = auth as OAuthAuthentication;
                request.DeveloperToken      = _auth.DeveloperToken;
                request.AuthenticationToken = _auth.AuthenticationToken;
            }
        }
Ejemplo n.º 15
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));
        }
Ejemplo n.º 16
0
 public GetCampaignCriterionsByIdsResponse TryGetCampaignCriterionsByIds(
     ApiAuthentication auth,
     long[] campaignCriterionIds,
     long campaignId,
     CampaignCriterionType criterionType,
     long?accountId,
     long?customerId = null)
 {
     return(MethodHelper.TryGet(
                GetCampaignCriterionsByIds,
                this,
                auth,
                campaignCriterionIds,
                campaignId,
                criterionType,
                accountId,
                customerId));
 }
Ejemplo n.º 17
0
        public async Task <GetAccessibleCustomerResponse> GetAccessibleCustomerAsync(ApiAuthentication auth, long customerId)
        {
            var request = new GetAccessibleCustomerRequest
            {
                CustomerId = customerId,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

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

            return(null);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Gets a list of the pilot programs in which the specified customer participates.
        /// </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 GetCustomerPilotFeaturesResponse GetCustomerPilotFeatures(ApiAuthentication auth, long customerId)
        {
            var request = new GetCustomerPilotFeaturesRequest
            {
                CustomerId = customerId
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

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

            return(null);
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
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);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Gets the details of an account.
        /// https://msdn.microsoft.com/en-US/library/dn451273(v=msads.90).aspx
        /// </summary>
        /// <param name="auth">Do not use ApiAuthentication directly. Use PasswordAuthentication or OAuthAuthentication derives from it instead.</param>
        /// <param name="accountId">The identifier of the account to get.</param>
        /// <returns>An account object that contains information about the account, such as payment method, account type, and parent customer.</returns>
        public GetAccountResponse GetAccount(ApiAuthentication auth, long accountId)
        {
            var request = new GetAccountRequest
            {
                AccountId = accountId,
            };

            try
            {
                SetAuthHelper.SetAuth(auth, request);

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

            return(null);
        }
Ejemplo n.º 28
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);
        }
        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);
        }
Ejemplo n.º 30
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);
        }