Class: Naver::Searchad::Api::Ad::Service

Inherits:
Core::BaseService show all
Defined in:
lib/naver/searchad/api/ad/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/service.rb', line 9

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

Instance Method Details

#copy_ads(ad_ids, target_ad_group_id, user_lock, options: nil, &block) ⇒ Object



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

def copy_ads(ad_ids, target_ad_group_id, user_lock, options: nil, &block)
  command = make_command(:put, 'ads', options)
  command.query['ids'] = ad_ids.join(',')
  command.query['targetAdgroupId'] = target_ad_group_id
  command.query['userLock'] = user_lock
  execute_command(command, &block)
end

#create_ad(ad, options: nil, &block) ⇒ Object



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

def create_ad(ad, options: nil, &block)
  validates_presence_of(%w[ad nccAdgroupId type], ad)

  command = make_command(:post, 'ads', options)
  command.request_object = ad
  execute_command(command, &block)
end

#delete_ad(ad_id, options: nil, &block) ⇒ Object



49
50
51
52
53
# File 'lib/naver/searchad/api/ad/service.rb', line 49

def delete_ad(ad_id, options: nil, &block)
  command = make_command(:delete, 'ads/{ad_id}', options)
  command.params['ad_id'] = ad_id
  execute_command(command, &block)
end

#get_ad(ad_id, options: nil, &block) ⇒ Object



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

def get_ad(ad_id, options: nil, &block)
  command = make_command(:get, 'ads/{ad_id}', options)
  command.params['ad_id'] = ad_id
  execute_command(command, &block)
end

#list_ads(ad_ids, options: nil, &block) ⇒ Object



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

def list_ads(ad_ids, options: nil, &block)
  command = make_command(:get, 'ads', options)
  command.query['ids'] = ad_ids.join(',')
  execute_command(command, &block)
end

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



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

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

#update_ad(ad, field: '', options: nil, &block) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/naver/searchad/api/ad/service.rb', line 39

def update_ad(ad, field: '', options: nil, &block)
  validates_presence_of(%w[nccAdId], ad)

  command = make_command(:put, 'ads/{ad_id}', options)
  command.params['ad_id'] = ad['nccAdId']
  command.query['fields'] = field
  command.request_object = ad
  execute_command(command, &block)
end