Sha256: c61ef936ee107a4a8c14b1abbd86cccfde2e7079fbb69bc1469639a5da6f2ca3

Contents?: true

Size: 689 Bytes

Versions: 51

Compression:

Stored size: 689 Bytes

Contents

require 'date'
require_relative 'base_client'
require 'httpclient'

class AdopsReportScrapper::CriteoClient < AdopsReportScrapper::BaseClient
  private

  def init_client
  end

  def before_quit_with_error
  end

  def scrap
    @data = []
    date_str = @date.strftime('%Y-%m-%d')

    response = HTTPClient.get "https://publishers.criteo.com/api/2.0/stats.json", apitoken: @secret, begindate: date_str, enddate: date_str

    data = JSON.parse response.body
    header = data[0].keys
    @data = [header]
    @data += data.select { |datum| datum['date'].split('T')[0] == date_str }.map { |datum| header.map { |key| datum[key].is_a?(Hash) ? datum[key]['value'] : datum[key] } }
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

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