Class: YandexDirect::Keyword
- Inherits:
-
Object
- Object
- YandexDirect::Keyword
- Defined in:
- lib/services/keyword.rb
Constant Summary collapse
- SERVICE =
'keywords'
Class Method Summary collapse
Class Method Details
.add(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/services/keyword.rb', line 4 def self.add(params) words = params[:words] ad_group_id = params[:ad_group_id] keywords = words.map do |word| { "Keyword": word[:word], "AdGroupId": ad_group_id, "Bid": word[:bid], "ContextBid": word[:context_bid], "StrategyPriority": word[:strategy_priority] || "NORMAL" } end YandexDirect.request(SERVICE, 'add', {"Keywords": keywords})["AddResults"] end |
.list(params) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/services/keyword.rb', line 18 def self.list(params) selection_criteria = {"States": ["ON"], "Statuses": ["ACCEPTED", "DRAFT"]} selection_criteria["CampaignIds"] = params[:campaign_ids] if params[:campaign_ids].present? selection_criteria["Ids"] = params[:ids] if params[:ids].present? selection_criteria["AdGroupIds"] = params[:ad_group_ids] if params[:ad_group_ids].present? YandexDirect.request(SERVICE, 'get', { "SelectionCriteria": selection_criteria, "FieldNames": ["Id", "Keyword", "State", "Status", "AdGroupId", "CampaignId", "Bid", "ContextBid"] })["Keywords"] || [] end |
.update(keywords) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/services/keyword.rb', line 29 def self.update(keywords) keywords.map! do |word| { "Id": word[:id], "Keyword": word[:word] } end YandexDirect.request(SERVICE, 'update', {"Keywords": keywords})["AddResults"] end |