adops_report_scrapper 0.2.16 → 0.2.17
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/CHANGELOG +6 -0
- data/Rakefile +5 -0
- data/lib/adops_report_scrapper.rb +1 -0
- data/lib/adops_report_scrapper/adsupplybuyer_client.rb +55 -0
- data/lib/adops_report_scrapper/base_client.rb +2 -1
- data/lib/adops_report_scrapper/version.rb +1 -1
- metadata +2 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ddbb4d70bdc6ebb9969428ac5cb5015248d40bb5
         | 
| 4 | 
            +
              data.tar.gz: c0cff82554671c4e774ead06e001cff5b613d6f1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2d834f11a4aae983be268a629b948d013276db75910dea5dbbd0a170187c1ca2840ba0cd7fc8e998283f5263d1efe5ee344cb40593adf6ecea690bda4a0ea9f6
         | 
| 7 | 
            +
              data.tar.gz: 13ce61a60a88eb1c7ff2fdf4b98a290e8434b712b05583aec9a65de08f5368a22dc2f59f37111a316493f661a77b893ebf283d0731511813c984841a351f66f9
         | 
    
        data/CHANGELOG
    CHANGED
    
    
    
        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
         | 
    
        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. | 
| 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
         |