naver-searchad-api 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/LICENSE +1 -1
- data/examples/stat.rb +62 -0
- data/lib/naver/searchad/api/auth.rb +3 -0
- data/lib/naver/searchad/api/core/base_service.rb +1 -0
- data/lib/naver/searchad/api/core/http_command.rb +1 -0
- data/lib/naver/searchad/api/stat/service.rb +21 -8
- data/lib/naver/searchad/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4594bb9d684d661862b599e22df40fd15b653f32
|
|
4
|
+
data.tar.gz: 2e0da89546ed9c99f51f90ae66e731dd8dc71df3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6620f0f0d2d6dce05b4abdeffc0d7f8b54774967eb7b4b504786bd3f5e3fedc83963c520b0af3a7459b77bf89a4b7ddf0757989e13de11fc34cef9987133d0e2
|
|
7
|
+
data.tar.gz: 46674a97d00aa7bae3ccc8ca368d8ae9e6f159dc83dd3c5ca06e8c43c8117cf234d0029b9885ffc0ff9fcbd0f709534b18326d2dcda0bb5034ce6e8279bdb603
|
data/.gitignore
CHANGED
data/LICENSE
CHANGED
data/examples/stat.rb
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'naver/searchad/api/stat/service'
|
|
2
|
+
require 'naver/searchad/api/auth'
|
|
3
|
+
|
|
4
|
+
ENV['NAVER_API_KEY'] = 'Access license'
|
|
5
|
+
ENV['NAVER_API_SECRET'] = 'Private key'
|
|
6
|
+
ENV['NAVER_API_CLIENT_ID'] = 'CUSTOMER_ID'
|
|
7
|
+
|
|
8
|
+
# If you want to see debug level logs
|
|
9
|
+
# Naver::Searchad::Api.logger.level = Logger::DEBUG
|
|
10
|
+
|
|
11
|
+
stat = Naver::Searchad::Api::Stat::Service.new
|
|
12
|
+
stat.authorization = Naver::Searchad::Api::Auth.get_application_default
|
|
13
|
+
|
|
14
|
+
ad_id = 'ad id'
|
|
15
|
+
fields = %w[impCnt clkCnt ctr cpc avgRnk ccnt]
|
|
16
|
+
time_range = { since: '2017-11-21', until: '2017-11-21' }
|
|
17
|
+
|
|
18
|
+
puts 'Stat'
|
|
19
|
+
p stat.get_stat_by_id(ad_id, fields, time_range)
|
|
20
|
+
|
|
21
|
+
# breakdown option should be used with `allDays` time_increment
|
|
22
|
+
puts 'Stat with placement level breakdown'
|
|
23
|
+
|
|
24
|
+
result = stat.get_stat_by_id(ad_id, fields, time_range, time_increment: 'allDays', breakdown: 'eventCode')
|
|
25
|
+
result.data.each do |row|
|
|
26
|
+
row['breakdowns'].each do |b|
|
|
27
|
+
p b
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
puts 'Stat with platform breakdown'
|
|
32
|
+
|
|
33
|
+
result = stat.get_stat_by_id(ad_id, fields, time_range, time_increment: 'allDays', breakdown: 'pcMblTp')
|
|
34
|
+
result.data.each do |row|
|
|
35
|
+
row['breakdowns'].each do |b|
|
|
36
|
+
p b
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
puts 'Stat with day in week breakdown'
|
|
41
|
+
result = stat.get_stat_by_id(ad_id, fields, time_range, time_increment: 'allDays', breakdown: 'dayw')
|
|
42
|
+
result.data.each do |row|
|
|
43
|
+
row['breakdowns'].each do |b|
|
|
44
|
+
p b
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
puts 'Stat with 24 hours breakdown'
|
|
49
|
+
result = stat.get_stat_by_id(ad_id, fields, time_range, time_increment: 'allDays', breakdown: 'hh24')
|
|
50
|
+
result.data.each do |row|
|
|
51
|
+
row['breakdowns'].each do |b|
|
|
52
|
+
p b
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
puts 'Stat with region breakdown'
|
|
57
|
+
result = stat.get_stat_by_id(ad_id, fields, time_range, time_increment: 'allDays', breakdown: 'regnNo')
|
|
58
|
+
result.data.each do |row|
|
|
59
|
+
row['breakdowns'].each do |b|
|
|
60
|
+
p b
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -10,26 +10,39 @@ module Naver
|
|
|
10
10
|
super('https://api.naver.com/', '')
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def get_stat_by_id(id,
|
|
13
|
+
def get_stat_by_id(id,
|
|
14
|
+
fields,
|
|
15
|
+
time_range,
|
|
16
|
+
options: {},
|
|
17
|
+
date_preset: nil,
|
|
18
|
+
time_increment: nil,
|
|
19
|
+
breakdown: nil,
|
|
20
|
+
&block)
|
|
14
21
|
command = make_command(:get, 'stats', options)
|
|
15
22
|
command.query['id'] = id
|
|
16
23
|
command.query['fields'] = fields.to_json
|
|
17
24
|
command.query['timeRange'] = time_range.to_json
|
|
18
|
-
command.query['datePreset'] =
|
|
19
|
-
command.query['timeIncrement'] =
|
|
20
|
-
command.query['breakdown'] =
|
|
25
|
+
command.query['datePreset'] = date_preset if date_preset
|
|
26
|
+
command.query['timeIncrement'] = time_increment if time_increment
|
|
27
|
+
command.query['breakdown'] = breakdown if breakdown
|
|
21
28
|
|
|
22
29
|
execute_command(command, &block)
|
|
23
30
|
end
|
|
24
31
|
|
|
25
|
-
def get_stat_by_ids(ids,
|
|
32
|
+
def get_stat_by_ids(ids,
|
|
33
|
+
fields,
|
|
34
|
+
time_range,
|
|
35
|
+
options: {},
|
|
36
|
+
date_preset: nil,
|
|
37
|
+
time_increment: nil,
|
|
38
|
+
breakdown: nil,&block)
|
|
26
39
|
command = make_command(:get, 'stats', options)
|
|
27
40
|
command.query['ids'] = ids
|
|
28
41
|
command.query['fields'] = fields.to_json
|
|
29
42
|
command.query['timeRange'] = time_range.to_json
|
|
30
|
-
command.query['datePreset'] =
|
|
31
|
-
command.query['timeIncrement'] =
|
|
32
|
-
command.query['breakdown'] =
|
|
43
|
+
command.query['datePreset'] = date_preset if date_preset
|
|
44
|
+
command.query['timeIncrement'] = time_increment if time_increment
|
|
45
|
+
command.query['breakdown'] = breakdown if breakdown
|
|
33
46
|
|
|
34
47
|
execute_command(command, &block)
|
|
35
48
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: naver-searchad-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Min Kim
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-11-
|
|
11
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httpclient
|
|
@@ -131,6 +131,7 @@ files:
|
|
|
131
131
|
- Rakefile
|
|
132
132
|
- bin/console
|
|
133
133
|
- bin/setup
|
|
134
|
+
- examples/stat.rb
|
|
134
135
|
- lib/naver/searchad/api.rb
|
|
135
136
|
- lib/naver/searchad/api/ad-keyword/service.rb
|
|
136
137
|
- lib/naver/searchad/api/ad/service.rb
|