module AdriverApi::ApiMethods

Public Instance Methods

ad(ad_id, raw: false) click to toggle source

Info about ad

# File lib/adriver_api/api_methods.rb, line 21
def ad(ad_id, raw: false)
  response = make_request("ads/#{ad_id}")
  return response if raw
  h = {}
  h[:id] = response.body['entry']['content']['ad']['id']
  h[:name] = response.body['entry']['content']['ad']['name']
  h[:enable] = response.body['entry']['content']['ad']['enable']
  h[:adplacements] = Array.wrap(response.body['entry']['content']['ad']['adPlacements']['href']).map{|x| x.split('/').last}
  h
end
adplacements(ad_id, raw: false) click to toggle source
Сценарии

TODO: возвращать так же сценарий “дефолтовые баннеры”

# File lib/adriver_api/api_methods.rb, line 34
def adplacements(ad_id, raw: false)
  response = make_request('adplacements', ad_id: ad_id)
  return response if raw 
  Array.wrap(response.body['feed']['entry']).map{|x| {id: x['content']['adPlacement']['id'], name: x['content']['adPlacement']['name'], banners: x['content']['adPlacement']['banners'] ? Array.wrap(x['content']['adPlacement']['banners']['href']).map{|x2| x2.split('/').last} : []} }
end
ads(raw: false) click to toggle source

List of all user ad companies Список всех рекламных кампаний данного аккаунта

# File lib/adriver_api/api_methods.rb, line 6
def ads(raw: false)
  response = make_request('ads', user_id: @user_id.to_s)
  return response if raw
end
ads_delegated(raw: false) click to toggle source

List of all delegated to user ad companies Список всех рекламных кампаний делегированных данному аккаунту

# File lib/adriver_api/api_methods.rb, line 14
def ads_delegated(raw: false)
  response = make_request('ads/delegated', user_id: @user_id.to_s)
  return response if raw
  Array.wrap(response.body['feed']['entry']).map{|x| x['id'].split('/').last}
end
banner(ban_id, raw: false) click to toggle source
stat_banner(ban_id, period: :daily, start_date: nil, stop_date: Date.today, raw: false) click to toggle source
# File lib/adriver_api/api_methods.rb, line 48
def stat_banner(ban_id, period: :daily, start_date: nil, stop_date: Date.today, raw: false)
  start_date ||= (Date.today - 365)
  response = make_request("stat/banners/#{ban_id}", start_date: start_date, stop_date: stop_date, granularity: period)
  return response if raw
  h = {}
  Array.wrap(response.body['entry']['content']['statObject']['stat']['item']).each{|x| h[x['date']] = {views: x['exp'], clicks: x['click']} }
  h
end