adops_report_scrapper 0.2.6 → 0.2.7

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: f636029cf43a613c9965e05bd0bbdb83ec30cec6
4
- data.tar.gz: 6dfdbfea6f72b1329ee405d8fb68dbf65340a742
3
+ metadata.gz: 233ebd6a08873224c62a4d7aa571637d4df47898
4
+ data.tar.gz: 3955a0a8f90af62e798fb0959624f7b94c752bae
5
5
  SHA512:
6
- metadata.gz: c5b3da35539f0c4d439e105ea14c3a9148664ff1fc1c5f44d9f6244b01aff257e40396ba382c7d9d0f71def15fba7c1e5a18af351fd4913f0db298d027558609
7
- data.tar.gz: 17d92482d740753fa1ba5ef88575aedb4527423c2b5b2f311dcf5d29ee5edf106cf76908794f342fd845ae46080c79b711189aa9de754984cbd31427f6e14ff9
6
+ metadata.gz: 75a70e05d63e34ac991166148d148df63143ff9337dcc9b6919568fbce5894ad9042090ca9f247049ef01bf71569d494c59ba9da89989dea65ca829bc9d7732a
7
+ data.tar.gz: 2814eb614ceba77277a21f71cad0a2844cfc48eca5add03d9a24f420c2d696ebebb6d7974b036fe6bbcf12e566eae586737094f5767f3f32ef4df6b0f32cbc1e
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.7
4
+ implement spotxchange
5
+
3
6
  ## 0.2.6
4
7
  tremor bug fix. tremor sucks!
5
8
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'adops_report_scrapper'
7
7
  require 'byebug'
8
8
 
9
9
  desc 'Collect all data'
10
- task :all => [:openx, :tremor, :brightroll, :yellowhammer, :adaptv, :fourninefive, :adx, :revcontent, :gcs, :browsi, :netseer, :sonobi, :nativo, :adsupply, :marfeel, :adsense, :criteo, :triplelift, :conversant, :liveintent, :adiply, :contentad, :facebookaudience, :adtechus, :adtomation, :rhythmone, :littlethings, :appnexus, :sovrn] do # openx is the most unstable one, run it first
10
+ task :all => [:openx, :tremor, :brightroll, :yellowhammer, :adaptv, :fourninefive, :adx, :revcontent, :gcs, :browsi, :netseer, :sonobi, :nativo, :adsupply, :marfeel, :adsense, :criteo, :triplelift, :conversant, :liveintent, :adiply, :contentad, :facebookaudience, :adtechus, :adtomation, :rhythmone, :littlethings, :appnexus, :sovrn, :spotxchange] do # openx is the most unstable one, run it first
11
11
  puts '========== You are all set'
12
12
  end
13
13
 
@@ -191,6 +191,11 @@ task :gumgum do
191
191
  save_as_csv :gumgum, :gumgum
192
192
  end
193
193
 
194
+ desc 'Collect spotxchange data'
195
+ task :spotxchange do
196
+ save_as_csv :spotxchange, :spotxchange
197
+ end
198
+
194
199
  def date
195
200
  @date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
196
201
  end
@@ -49,3 +49,4 @@ require 'adops_report_scrapper/brightcom_client'
49
49
  require 'adops_report_scrapper/appnexus_client'
50
50
  require 'adops_report_scrapper/sovrn_client'
51
51
  require 'adops_report_scrapper/gumgum_client'
52
+ require 'adops_report_scrapper/spotxchange_client'
@@ -0,0 +1,36 @@
1
+ require 'date'
2
+ require_relative 'base_client'
3
+ require 'httpclient'
4
+
5
+ class AdopsReportScrapper::SpotxchangeClient < AdopsReportScrapper::BaseClient
6
+ private
7
+
8
+ def init_client
9
+ fail 'please specify spotxchange oauth code' unless @options['code']
10
+ @code = @options['code']
11
+ end
12
+
13
+ def before_quit_with_error
14
+ end
15
+
16
+ def scrap
17
+ date_str = @date.strftime('%Y-%m-%d')
18
+
19
+ body = { 'client_id' => @login, 'client_secret' => @secret, 'grant_type' => 'authorization_code', 'code' => @code }
20
+ response = HTTPClient.post 'https://publisher-api.spotxchange.com/1.0/token', body
21
+ token = JSON.parse(response.body)['value']['data']['access_token']
22
+
23
+ header = { 'Authorization' => "Bearer #{token}" }
24
+ response = HTTPClient.get 'https://api.spotxchange.com/1.0/me', nil, header
25
+ publisher_id = JSON.parse(response.body)['value']['affiliate_id']
26
+
27
+ response = HTTPClient.get "https://api.spotxchange.com/1.0/Publisher(#{publisher_id})/Channels/TrafficReport", { date_range: "#{date_str}|#{date_str}" }, header
28
+ data = JSON.parse(response.body)['value']['data']
29
+
30
+ @data = []
31
+
32
+ header = data[0].keys
33
+ @data = [header]
34
+ @data += data.map { |datum| header.map { |key| datum[key].is_a?(Hash) ? datum[key]['value'] : datum[key] } }
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module AdopsReportScrapper
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
data/secret.sample.yml CHANGED
@@ -131,3 +131,8 @@ gumgum:
131
131
  yume:
132
132
  login: ------
133
133
  secret: ------
134
+ spotxchange:
135
+ login: ------
136
+ secret: ------
137
+ options:
138
+ code: ------
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adops_report_scrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stayman Hou
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -263,6 +263,7 @@ files:
263
263
  - lib/adops_report_scrapper/rubicon_client.rb
264
264
  - lib/adops_report_scrapper/sonobi_client.rb
265
265
  - lib/adops_report_scrapper/sovrn_client.rb
266
+ - lib/adops_report_scrapper/spotxchange_client.rb
266
267
  - lib/adops_report_scrapper/springserve_client.rb
267
268
  - lib/adops_report_scrapper/tremor_client.rb
268
269
  - lib/adops_report_scrapper/triplelift_client.rb