Class: Yandex::API::Direct::CampaignInfo

Inherits:
Base
  • Object
show all
Defined in:
lib/yandex-api/direct/campaign_info.rb

Overview

CampaignInfo

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

arrays, attributes, direct_arrays, direct_attributes, direct_objects, #initialize, objects, #to_hash

Constructor Details

This class inherits a constructor from Yandex::API::Direct::Base

Class Method Details

.find(id) ⇒ Object

Raises:

  • (Yandex::NotFound)


78
79
80
81
82
# File 'lib/yandex-api/direct/campaign_info.rb', line 78

def self.find id
  result = Direct::request('GetCampaignParams', {:CampaignID => id})
  raise Yandex::NotFound.new("not found campaign where CampaignID = #{id}") if result.empty?
  new(result)
end

.listObject



83
84
85
86
87
88
89
# File 'lib/yandex-api/direct/campaign_info.rb', line 83

def self.list
  campaigs = []
  Direct::request('GetCampaignsList').each do |campaig|
    campaigs << new(campaig)
  end
  campaigs 
end

Instance Method Details

#archiveObject



63
64
65
# File 'lib/yandex-api/direct/campaign_info.rb', line 63

def archive
  Direct::request('ArchiveCampaign', {:CampaignID => self.CampaignID})
end

#bannersObject



53
54
55
56
57
58
59
# File 'lib/yandex-api/direct/campaign_info.rb', line 53

def banners
  banners = []
  Direct::request('GetBanners', {:CampaignIDS => [self.CampaignID]}).each do |banner|
    banners << BannerInfo.new(banner)
  end
  banners
end

#deleteObject



75
76
77
# File 'lib/yandex-api/direct/campaign_info.rb', line 75

def delete
  Direct::request('DeleteCampaign', {:CampaignID => self.CampaignID})
end

#resumeObject



69
70
71
# File 'lib/yandex-api/direct/campaign_info.rb', line 69

def resume
  Direct::request('ResumeCampaign', {:CampaignID => self.CampaignID})
end

#saveObject



60
61
62
# File 'lib/yandex-api/direct/campaign_info.rb', line 60

def save
  Direct::request('CreateOrUpdateCampaign', self.to_hash)
end

#stopObject



72
73
74
# File 'lib/yandex-api/direct/campaign_info.rb', line 72

def stop
  Direct::request('StopCampaign', {:CampaignID => self.CampaignID})
end

#unarchiveObject



66
67
68
# File 'lib/yandex-api/direct/campaign_info.rb', line 66

def unarchive
  Direct::request('UnArchiveCampaign', {:CampaignID => self.CampaignID})
end