Class: Naver::Searchad::Api::Adgroup::Service
Instance Attribute Summary
#base_path, #client_options, #request_options, #url
Instance Method Summary
collapse
-
#create_adgroup(adgroup, options: nil, &block) ⇒ Object
-
#delete_adgroup(adgroup_id, options: nil, &block) ⇒ Object
-
#get_adgroup(adgroup_id, options: nil, &block) ⇒ Object
-
#initialize ⇒ Service
constructor
A new instance of Service.
-
#list_adgroups(options: nil, &block) ⇒ Object
-
#list_adgroups_by_campaign_id(campaign_id, options: nil, &block) ⇒ Object
-
#list_adgroups_by_ids(adgroup_ids, options: nil, &block) ⇒ Object
-
#list_adgroups_by_label_id(label_id, options: nil, &block) ⇒ Object
-
#update_adgroup(adgroup, field: nil, options: nil, &block) ⇒ Object
#authorization, #authorization=, #client
#logger
Constructor Details
Returns a new instance of Service.
9
10
11
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 9
def initialize
super('https://api.naver.com/', 'ncc/')
end
|
Instance Method Details
#create_adgroup(adgroup, options: nil, &block) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 42
def create_adgroup(adgroup, options: nil, &block)
validates_presence_of(%w[nccCampaignId pcChannelId mobileChannelId name], adgroup)
command = make_command(:post, 'adgroups', options)
command.request_object = adgroup
execute_command(command, &block)
end
|
#delete_adgroup(adgroup_id, options: nil, &block) ⇒ Object
60
61
62
63
64
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 60
def delete_adgroup(adgroup_id, options: nil, &block)
command = make_command(:delete, 'adgroups/{adgroup_id}', options)
command.params['adgroup_id'] = adgroup_id
execute_command(command, &block)
end
|
#get_adgroup(adgroup_id, options: nil, &block) ⇒ Object
36
37
38
39
40
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 36
def get_adgroup(adgroup_id, options: nil, &block)
command = make_command(:get, 'adgroups/{adgroup_id}', options)
command.params['adgroup_id'] = adgroup_id
execute_command(command, &block)
end
|
#list_adgroups(options: nil, &block) ⇒ Object
13
14
15
16
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 13
def list_adgroups(options: nil, &block)
command = make_command(:get, 'adgroups', options)
execute_command(command, &block)
end
|
#list_adgroups_by_campaign_id(campaign_id, options: nil, &block) ⇒ Object
24
25
26
27
28
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 24
def list_adgroups_by_campaign_id(campaign_id, options: nil, &block)
command = make_command(:get, 'adgroups', options)
command.query['nccCampaignId'] = campaign_id
execute_command(command, &block)
end
|
#list_adgroups_by_ids(adgroup_ids, options: nil, &block) ⇒ Object
18
19
20
21
22
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 18
def list_adgroups_by_ids(adgroup_ids, options: nil, &block)
command = make_command(:get, 'adgroups', options)
command.query['ids'] = adgroup_ids.join(',')
execute_command(command, &block)
end
|
#list_adgroups_by_label_id(label_id, options: nil, &block) ⇒ Object
30
31
32
33
34
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 30
def list_adgroups_by_label_id(label_id, options: nil, &block)
command = make_command(:get, 'adgroups', options)
command.query['nccLabelId'] = label_id
execute_command(command, &block)
end
|
#update_adgroup(adgroup, field: nil, options: nil, &block) ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/naver/searchad/api/adgroup/service.rb', line 50
def update_adgroup(adgroup, field: nil, options: nil, &block)
validates_presence_of(%w[nccAdgroupId], adgroup)
command = make_command(:put, 'adgroups/{adgroup_id}', options)
command.params['adgroup_id'] = adgroup['nccAdgroupId']
command.query['fields'] = field if field
command.request_object = adgroup
execute_command(command, &block)
end
|