Esempio n. 1
0
        /// <summary>
        /// Retrieves a list of keywords satisfying optional criteria.
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public List <KeywordInfo> ListBiddableKeywords(ListBiddableKeywordsParameter parameter = null)
        {
            var queryData = string.Empty;

            if (parameter != null)
            {
                queryData = GenQueryData(parameter);
            }

            var url = $"{APIEndpoint.GetUrl(this.Marketplace)}/{this.ApiVersion}/keywords?{queryData}";

            return(this.HttpRequest <List <KeywordInfo> >(url));
        }
Esempio n. 2
0
        private static string GenQueryData(ListBiddableKeywordsParameter parameter)
        {
            var queryData = new List <string>();

            if (parameter.StartIndex.HasValue)
            {
                queryData.Add($"startIndex={parameter.StartIndex}");
            }
            if (parameter.Count.HasValue)
            {
                queryData.Add($"count={parameter.Count}");
            }
            if (!string.IsNullOrWhiteSpace(parameter.CampaignType))
            {
                queryData.Add($"campaignType={parameter.CampaignType}");
            }
            if (!string.IsNullOrWhiteSpace(parameter.MatchTypeFilter))
            {
                queryData.Add($"matchTypeFilter={parameter.MatchTypeFilter}");
            }
            if (!string.IsNullOrWhiteSpace(parameter.KeywordText))
            {
                queryData.Add($"keywordText={parameter.KeywordText}");
            }
            if (!string.IsNullOrWhiteSpace(parameter.StateFilter))
            {
                queryData.Add($"stateFilter={parameter.StateFilter}");
            }
            if (!string.IsNullOrWhiteSpace(parameter.CampaignIdFilter))
            {
                queryData.Add($"campaignIdFilter={parameter.CampaignIdFilter}");
            }
            if (!string.IsNullOrWhiteSpace(parameter.AdGroupIdFilter))
            {
                queryData.Add($"adGroupIdFilter={parameter.AdGroupIdFilter}");
            }
            if (!string.IsNullOrWhiteSpace(parameter.KeywordIdFilter))
            {
                queryData.Add($"keywordIdFilter={parameter.KeywordIdFilter}");
            }

            return(string.Join("&", queryData));
        }