class AdtekioAdnetworks::Revenue::Chartboost

Constants

BASE_URL

Public Instance Methods

query_url(from, to) click to toggle source
# File lib/adtekio_adnetworks/importers/revenue/chartboost.rb, line 29
def query_url(from, to)
  params = {
    :userId        => credentials.user_id,
    :userSignature => credentials.signature,
    :dateMin       => from.strftime("%Y-%m-%d"),
    :dateMax       => to.strftime("%Y-%m-%d"),
    :groupBy       => :app,
    :aggregate     => :daily,
  }

  uri = Addressable::URI.new
  uri.query_values = params
  URI.parse("%s?%s" % [BASE_URL, uri.query])
end
report(from, to) click to toggle source
# File lib/adtekio_adnetworks/importers/revenue/chartboost.rb, line 24
def report(from, to)
  JSON(Net::HTTP::Persistent.new('chartboost').
       request(query_url(from,to)).body)
end
revenues(from, to) click to toggle source
# File lib/adtekio_adnetworks/importers/revenue/chartboost.rb, line 10
def revenues(from, to)
  report(from,to).map do |hsh|
    {
      :impressions => hsh["impressionsDelivered"].to_i,
      :amount      => hsh["moneyEarned"].to_f,
      :date        => Date.strptime(hsh["dt"], "%Y-%m-%d"),
      :appname     => hsh["app"],
      :not_matched => not_matched(:platform    => hsh["platform"],
                                  :appBundleId => hsh["appBundleId"],
                                  :appId       => hsh["appId"])
    }
  end
end