class AdtekioAdnetworks::Postbacks::Chartboost

Public Instance Methods

iap_body() click to toggle source
# File lib/adtekio_adnetworks/postbacks/chartboost.rb, line 99
def iap_body
  JSON.generate({
    :platform       => :ios,
    :sdk_version    => 4.2,
    :token          => netcfg.api_token,
    :identifiers    => {
      :ifa          => event.adid,
    },
    :receipt_valid  => false,
    :timestamp      => event.trigger_stamp,
    :iap            => {
      :currency   => event.currency,
      :price      => params[:price].to_f,
      :product_id => params[:st1] || params[:s1] || 'unknown'
    }
  })
end
install_body() click to toggle source
# File lib/adtekio_adnetworks/postbacks/chartboost.rb, line 84
def install_body
  params = if event.android?
    { :gaid => event.gadid,
      :uuid => event.android_id || event.gadid
    }.select {|_,v| v.present?}
  else
    {:ifa => event.adid}
  end

  JSON.generate(params.merge({
    :app_id => netcfg.app_id,
    :claim  => 1
  }))
end
install_signature() click to toggle source
# File lib/adtekio_adnetworks/postbacks/chartboost.rb, line 78
def install_signature
  hsh_string = ["action:attribution", netcfg.api_secret,
                signature, install_body].join("\n")
  Digest::SHA2.hexdigest hsh_string
end
signature() click to toggle source
# File lib/adtekio_adnetworks/postbacks/chartboost.rb, line 72
def signature
  Digest::SHA2.hexdigest("action:pia;app:#{netcfg.app_id};"+
                         "token:#{netcfg.api_token};"+
                         "timestamp:#{event.trigger_stamp};")
end