adops_report_scrapper 0.2.16 → 0.2.17

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: 946d431b163ad6d8cbe97ad6e3ed71dca48343c1
4
- data.tar.gz: 611639ffa42c933a3c4ff9992fcbf47e93d6eff8
3
+ metadata.gz: ddbb4d70bdc6ebb9969428ac5cb5015248d40bb5
4
+ data.tar.gz: c0cff82554671c4e774ead06e001cff5b613d6f1
5
5
  SHA512:
6
- metadata.gz: 47b1224876d51997d76280c77eda361774c16f19d274c49c68a156d7cabc22ba26045c1f8c0b9e3113f87c6433823c46cb599a5e03f1c32ed7f4cb8d2586ff46
7
- data.tar.gz: 0726c276afb3f9dde4ca44028476727c32c9038dce0a2bdcd58c5b6dc4e80468415e31ac4083bbb72cb3b61d23ca7d7f8c16c81156b2774f5babaa574f0f957a
6
+ metadata.gz: 2d834f11a4aae983be268a629b948d013276db75910dea5dbbd0a170187c1ca2840ba0cd7fc8e998283f5263d1efe5ee344cb40593adf6ecea690bda4a0ea9f6
7
+ data.tar.gz: 13ce61a60a88eb1c7ff2fdf4b98a290e8434b712b05583aec9a65de08f5368a22dc2f59f37111a316493f661a77b893ebf283d0731511813c984841a351f66f9
data/CHANGELOG CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.17
4
+ add adsupply buyer
5
+
6
+ ## 0.2.16
7
+ fix tremor
8
+
3
9
  ## 0.2.15
4
10
  add anyclip
5
11
 
data/Rakefile CHANGED
@@ -206,6 +206,11 @@ task :anyclip do
206
206
  save_as_csv :anyclip, :anyclip
207
207
  end
208
208
 
209
+ desc 'Collect adsupplybuyer data'
210
+ task :adsupplybuyer do
211
+ save_as_csv :adsupplybuyer, :adsupplybuyer
212
+ end
213
+
209
214
  def date
210
215
  @date ||= ENV['date'].nil? ? Date.today - 1 : Date.today - ENV['date'].to_i
211
216
  end
@@ -18,6 +18,7 @@ require 'adops_report_scrapper/adaptv_client'
18
18
  require 'adops_report_scrapper/adiply_client'
19
19
  require 'adops_report_scrapper/adsense_client'
20
20
  require 'adops_report_scrapper/adsupply_client'
21
+ require 'adops_report_scrapper/adsupplybuyer_client'
21
22
  require 'adops_report_scrapper/adx_client'
22
23
  require 'adops_report_scrapper/brightroll_client'
23
24
  require 'adops_report_scrapper/browsi_client'
@@ -0,0 +1,55 @@
1
+ require 'date'
2
+ require_relative 'base_client'
3
+ require 'rest-client'
4
+
5
+ class AdopsReportScrapper::AdsupplybuyerClient < AdopsReportScrapper::BaseClient
6
+ def date_supported?(date = nil)
7
+ _date = date || @date
8
+ return true if _date < Date.today
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
+ if @options[:hourly]
22
+ scrap_hourly
23
+ else
24
+ scrap_daily
25
+ end
26
+ end
27
+
28
+ def scrap_daily
29
+ date_str = @date.strftime('%-m/%-d/%Y')
30
+ time_zone_id = 'Eastern Standard Time'
31
+
32
+ response = RestClient.post "https://ui.adsupply.com/PublicPortal/Advertiser/#{@login}/Report/Export", SqlCommandId: '', ExportToExcel: 'False', IsOLAP: 'False', DateFilter: date_str, TimeZoneId: time_zone_id, Grouping: '1', 'DimAdvertiser.Value': "#{@login}~", 'DimAdvertiser.IsActive': 'True', 'DimCampaign.Value': '', 'DimCampaign.IsActive': 'True', ApiKey: @secret
33
+
34
+ data = JSON.parse response
35
+ header = data[0].keys
36
+ @data = [header]
37
+ @data += data.map do |datum|
38
+ header.map { |key| datum[key] }
39
+ end
40
+ end
41
+
42
+ def scrap_hourly
43
+ date_str = @date.strftime('%-m/%-d/%Y')
44
+ time_zone_id = 'Eastern Standard Time'
45
+
46
+ response = RestClient.post "https://ui.adsupply.com/PublicPortal/Advertiser/#{@login}/Report/Export", SqlCommandId: '', ExportToExcel: 'False', IsOLAP: 'False', DateFilter: date_str, TimeZoneId: time_zone_id, Grouping: '0', ApiKey: @secret
47
+
48
+ data = JSON.parse response
49
+ header = data[0].keys
50
+ @data = [header]
51
+ @data += data.map do |datum|
52
+ header.map { |key| datum[key] }
53
+ end
54
+ end
55
+ end
@@ -18,8 +18,9 @@ class AdopsReportScrapper::BaseClient
18
18
 
19
19
  # date: (optional)
20
20
  # return data in array of array, first array is the headers, no total included
21
- def get_data(date = nil)
21
+ def get_data(date = nil, options = nil)
22
22
  @date = date if date
23
+ @options = options || {}
23
24
  fail "specified date is not supported by this scrapper #{self.class.name}" unless date_supported?
24
25
  init_client
25
26
  login
@@ -1,3 +1,3 @@
1
1
  module AdopsReportScrapper
2
- VERSION = "0.2.16"
2
+ VERSION = "0.2.17"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adops_report_scrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stayman Hou
@@ -250,6 +250,7 @@ files:
250
250
  - lib/adops_report_scrapper/adiply_client.rb
251
251
  - lib/adops_report_scrapper/adsense_client.rb
252
252
  - lib/adops_report_scrapper/adsupply_client.rb
253
+ - lib/adops_report_scrapper/adsupplybuyer_client.rb
253
254
  - lib/adops_report_scrapper/adtechus_client.rb
254
255
  - lib/adops_report_scrapper/adtomation_client.rb
255
256
  - lib/adops_report_scrapper/adx_client.rb