adops_report_scrapper 0.2.34 → 0.2.35

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: cf4ac1a315226d668a8af808d33bd889b69ee081
4
- data.tar.gz: 58225251358703f7d69cf821b020c7e918b55fdb
3
+ metadata.gz: d9a80c798f022a79269546a5f1fb2f8e99921b06
4
+ data.tar.gz: 37cf1e17c2ad5e7837ff1e90936015fd5b232aaf
5
5
  SHA512:
6
- metadata.gz: bb157ca70b584aeddc044b1f5523f8f622fd0d8890081cc1244b26217daf8e44289c57e779ae85bea8e52769d76a9aec083ccf55a92393036cc8381234a84d13
7
- data.tar.gz: 271b472d8ffb9ad0a13207ac89cc1d12ee5b92047ebe3f63a18bfe99e205de97b48b73ec3aef539dbde6884cc180f940d0e4f3e36c90a2304c1fcf9b62df1e5b
6
+ metadata.gz: 3adf61abd8e28530eb3d5bcf1ff16d6c799d135c16bf03096a1a978e5e6e2dd2885c27753fdb1e60469d2e988fbb82a5d2c977811a094cc39a74000acde1438e
7
+ data.tar.gz: 3053718c47f72ee09e5f1d0bd5d43145a46cdd398ebe1c71916bff8ebc0157d8eb2d0fbe3fe521c7fc7fff1c9f5a23dd32b38104628dbaaf1f1c1d2d995f57d9
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.35
4
+ implement indexexchange
5
+
3
6
  ## 0.2.34
4
7
  fix sovrn
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 => [:anyclip, :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, :lkqd] do # openx is the most unstable one, run it first
10
+ task :all => [:anyclip, :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, :lkqd, :indexexchange] do # openx is the most unstable one, run it first
11
11
  puts '========== You are all set'
12
12
  end
13
13
 
@@ -226,6 +226,11 @@ task :lkqd do
226
226
  save_as_csv :lkqd, :lkqd
227
227
  end
228
228
 
229
+ desc 'Collect indexexchange data'
230
+ task :indexexchange do
231
+ save_as_csv :indexexchange, :indexexchange
232
+ end
233
+
229
234
  def date
230
235
  @date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
231
236
  end
@@ -56,3 +56,4 @@ require 'adops_report_scrapper/email_client'
56
56
  require 'adops_report_scrapper/anyclip_client'
57
57
  require 'adops_report_scrapper/adsparc_client'
58
58
  require 'adops_report_scrapper/lkqd_client'
59
+ require 'adops_report_scrapper/indexexchange_client'
@@ -0,0 +1,46 @@
1
+ require 'date'
2
+ require_relative 'base_client'
3
+ require 'rest-client'
4
+
5
+ class AdopsReportScrapper::IndexexchangeClient < AdopsReportScrapper::BaseClient
6
+ def date_supported?(date = nil)
7
+ _date = date || @date
8
+ return true if _date < (Date.today + 1)
9
+ false
10
+ end
11
+
12
+ def init_client
13
+ end
14
+
15
+ def before_quit_with_error
16
+ end
17
+
18
+ private
19
+
20
+ def scrap
21
+ date_str = @date.strftime('%Y-%m-%d')
22
+
23
+ response = RestClient.post 'https://auth.indexexchange.com/auth/oauth/token', { 'username' => @login, 'key' => @secret }.to_json, { 'Content-Type' => 'application/json; charset=utf-8' }
24
+ access_token = JSON.parse(response)['data']['accessToken']
25
+
26
+ header = { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json; charset=utf-8' }
27
+
28
+ response = RestClient.post 'https://api01.indexexchange.com/api/publishers/sites', '', header
29
+ site_tag_map = JSON.parse(response)['data'].map { |e| [e['siteID'], e['name']] }.to_h
30
+
31
+ response = RestClient.post 'https://api01.indexexchange.com/api/publishers/stats/earnings/open', { 'filters' => { 'startDate' => date_str, 'endDate' => date_str }, 'aggregation' => 'siteID' }.to_json, header
32
+ data = JSON.parse(response)['data'].each do |datum|
33
+ datum['siteTagName'] = site_tag_map[datum['aggregateID']]
34
+ end
35
+
36
+ unless data[0]
37
+ @data = []
38
+ return
39
+ end
40
+ header = data[0].keys
41
+ @data = [header]
42
+ @data += data.map do |datum|
43
+ header.map { |key| datum[key] }
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module AdopsReportScrapper
2
- VERSION = "0.2.34"
2
+ VERSION = "0.2.35"
3
3
  end
data/secret.sample.yml CHANGED
@@ -151,5 +151,8 @@ anyclip:
151
151
  login: ------
152
152
  secret: ------
153
153
  adsparc:
154
+ login: ------
155
+ secret: ------
156
+ indexexchange:
154
157
  login: ------
155
158
  secret: ------
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.34
4
+ version: 0.2.35
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-08-28 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -269,6 +269,7 @@ files:
269
269
  - lib/adops_report_scrapper/gcs_client.rb
270
270
  - lib/adops_report_scrapper/gumgum_client.rb
271
271
  - lib/adops_report_scrapper/imonomy_client.rb
272
+ - lib/adops_report_scrapper/indexexchange_client.rb
272
273
  - lib/adops_report_scrapper/littlethings_client.rb
273
274
  - lib/adops_report_scrapper/liveintent_client.rb
274
275
  - lib/adops_report_scrapper/lkqd_client.rb