Sha256: 35616bf15ebf32168798bc6e180da7c6287bc8a9c7d33f07273025dd0d02e564

Contents?: true

Size: 1021 Bytes

Versions: 69

Compression:

Stored size: 1021 Bytes

Contents

require 'date'
require_relative 'base_client'
require 'rest-client'

class AdopsReportScrapper::RubiconClient < AdopsReportScrapper::BaseClient
  def date_supported?(date = nil)
    _date = date || @date
    return true if _date < Date.today
    false
  end

  def init_client
    fail 'please specify rubicon account id' unless @options['account_id']
    @account_id = @options['account_id']
  end

  def before_quit_with_error
  end

  private

  def scrap
    date_str = date.strftime '%F'

    response = RestClient::Request.execute method: :get, url: "https://api.rubiconproject.com/analytics/v1/report/?account=publisher/#{@account_id}&start=#{date_str}T00:00:00-07:00&end=#{date_str}T23:59:59-08:00&dimensions=date,site,country,device_type,ad_format&metrics=bid_requests,paid_impression,revenue", user: @login, password: @secret

    data = JSON.parse response.body
    @data = [data['data']['items'].first.keys]
    @data += data['data']['items'].reject{ |item| item['date'] != date_str }.map(&:values)
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
adops_report_scrapper-0.2.52 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.51 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.50 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.49 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.48 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.46 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.45 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.44 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.43 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.42 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.41 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.40 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.39 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.38 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.37 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.35 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.34 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.33 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.32 lib/adops_report_scrapper/rubicon_client.rb
adops_report_scrapper-0.2.31 lib/adops_report_scrapper/rubicon_client.rb