Class: Naver::Searchad::Api::AdKeyword::Service

Inherits:
Core::BaseService show all
Defined in:
lib/naver/searchad/api/ad-keyword/service.rb

Instance Attribute Summary

Attributes inherited from Core::BaseService

#base_path, #client_options, #request_options, #url

Instance Method Summary collapse

Methods inherited from Core::BaseService

#authorization, #authorization=, #client

Methods included from Core::Logging

#logger

Constructor Details

#initializeService

Returns a new instance of Service.



9
10
11
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 9

def initialize
  super('https://api.naver.com/', 'ncc/')
end

Instance Method Details

#create_ad_keywords(ad_keywords, adgroup_id, options: nil, &block) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 37

def create_ad_keywords(ad_keywords, adgroup_id, options: nil, &block)
  ad_keywords.each { |kw| validates_presence_of(%w[keyword], kw) }

  command = make_command(:post, 'keywords', options)
  command.query['nccAdgroupId'] = adgroup_id
  command.request_object = ad_keywords
  execute_command(command, &block)
end

#delete_ad_keyword(ad_keyword_id, options: nil, &block) ⇒ Object



65
66
67
68
69
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 65

def delete_ad_keyword(ad_keyword_id, options: nil, &block)
  command = make_command(:delete, 'keywords/{ad_keyword_id}', options)
  command.params['ad_keyword_id'] = ad_keyword_id
  execute_command(command, &block)
end

#delete_ad_keywords(ad_keyword_ids, options: nil, &block) ⇒ Object



71
72
73
74
75
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 71

def delete_ad_keywords(ad_keyword_ids, options: nil, &block)
  command = make_command(:delete, 'keywords', options)
  command.query['ids'] = ad_keyword_ids.join(',')
  execute_command(command, &block)
end

#get_ad_keyword(ad_keyword_id, options: nil, &block) ⇒ Object



31
32
33
34
35
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 31

def get_ad_keyword(ad_keyword_id, options: nil, &block)
  command = make_command(:get, 'keywords/{ad_keyword_id}', options)
  command.params['ad_keyword_id'] = ad_keyword_id
  execute_command(command, &block)
end

#list_ad_keywords_by_adgroup_id(adgroup_id, options: nil, &block) ⇒ Object



19
20
21
22
23
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 19

def list_ad_keywords_by_adgroup_id(adgroup_id, options: nil, &block)
  command = make_command(:get, 'keywords', options)
  command.query['nccAdgroupId'] = adgroup_id
  execute_command(command, &block)
end

#list_ad_keywords_by_ids(ad_keyword_ids, options: nil, &block) ⇒ Object



13
14
15
16
17
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 13

def list_ad_keywords_by_ids(ad_keyword_ids, options: nil, &block)
  command = make_command(:get, 'keywords', options)
  command.query['ids'] = ad_keyword_ids.join(',')
  execute_command(command, &block)
end

#list_ad_keywords_by_label_id(label_id, options: nil, &block) ⇒ Object



25
26
27
28
29
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 25

def list_ad_keywords_by_label_id(label_id, options: nil, &block)
  command = make_command(:get, 'keywords', options)
  command.query['nccLabelId'] = label_id
  execute_command(command, &block)
end

#update_ad_keyword(ad_keyword, field: '', options: nil, &block) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 46

def update_ad_keyword(ad_keyword, field: '', options: nil, &block)
  validates_presence_of(%w[nccKeywordId nccAdgroupId], ad_keyword)

  command = make_command(:put, 'keywords/{ad_keyword_id}', options)
  command.params['ad_keyword_id'] = ad_keyword['nccKeywordId']
  command.query['fields'] = field
  command.request_object = ad_keyword
  execute_command(command, &block)
end

#update_ad_keywords(ad_keywords, field: '', options: nil, &block) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/naver/searchad/api/ad-keyword/service.rb', line 56

def update_ad_keywords(ad_keywords, field: '', options: nil, &block)
  ad_keywords.each { |kw| validates_presence_of(%w[nccKeywordId nccAdgroupId], kw) }

  command = make_command(:put, 'keywords', options)
  command.query['fields'] = field
  command.request_object = ad_keywords
  execute_command(command, &block)
end