naver-searchad-api 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea97d969258799c55d9130e6fb313bf806f5d001
4
- data.tar.gz: 947c869a2aa736d4fab7ce2e532d701cdd3f06ba
3
+ metadata.gz: 4594bb9d684d661862b599e22df40fd15b653f32
4
+ data.tar.gz: 2e0da89546ed9c99f51f90ae66e731dd8dc71df3
5
5
  SHA512:
6
- metadata.gz: bf5877376767f873eea86bc5d0d33523a0aee54bd3989bcba1815a52c2c3b4263d14dac36d7c52bccbe1beb9d78060ca523e97a2d091651a13ae1530c1e09fba
7
- data.tar.gz: c7de110c58382c54844e165ad2b8e4db98c9777ec47ddf8c36545c996a60e780be1fd79fdf847619a715089ab1144723ef188695a5a7b206e55dd001b6f395b7
6
+ metadata.gz: 6620f0f0d2d6dce05b4abdeffc0d7f8b54774967eb7b4b504786bd3f5e3fedc83963c520b0af3a7459b77bf89a4b7ddf0757989e13de11fc34cef9987133d0e2
7
+ data.tar.gz: 46674a97d00aa7bae3ccc8ca368d8ae9e6f159dc83dd3c5ca06e8c43c8117cf234d0029b9885ffc0ff9fcbd0f709534b18326d2dcda0bb5034ce6e8279bdb603
data/.gitignore CHANGED
@@ -11,4 +11,5 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
  .DS_Store
14
- .gem
14
+
15
+ *.gem
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Forward3D
3
+ Copyright (c) 2017-present Forward3D
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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
@@ -1,3 +1,6 @@
1
+ require 'base64'
2
+ require 'openssl'
3
+
1
4
  module Naver
2
5
  module Searchad
3
6
  module Api
@@ -1,6 +1,7 @@
1
1
  require 'addressable/uri'
2
2
  require 'addressable/template'
3
3
  require 'httpclient'
4
+ require 'json'
4
5
  require_relative '../options'
5
6
  require_relative '../version'
6
7
  require_relative 'api_command'
@@ -1,5 +1,6 @@
1
1
  require 'addressable/uri'
2
2
  require 'addressable/template'
3
+ require 'json'
3
4
  require_relative '../errors'
4
5
  require_relative '../options'
5
6
  require_relative 'logging'
@@ -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, fields, time_range, options: {}, &block)
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'] = options[:date_preset] if options[:date_preset]
19
- command.query['timeIncrement'] = options[:time_increment] if options[:time_increment]
20
- command.query['breakdown'] = options[:breakdown] if options[: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, fields, time_range, options: {}, &block)
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'] = options[:date_preset] if options[:date_preset]
31
- command.query['timeIncrement'] = options[:time_increment] if options[:time_increment]
32
- command.query['breakdown'] = options[:breakdown] if options[: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
@@ -1,7 +1,7 @@
1
1
  module Naver
2
2
  module Searchad
3
3
  module Api
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.8'
5
5
 
6
6
  OS_VERSION = begin
7
7
  if RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/
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.7
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-20 00:00:00.000000000 Z
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