Class: GetResponse::CampaignProxy
- Inherits:
-
Object
- Object
- GetResponse::CampaignProxy
- Defined in:
- lib/get_response/campaign_proxy.rb
Overview
Proxy class for campaign operations.
Instance Method Summary collapse
-
#all ⇒ Object
Get all campaigns from account.
-
#create(attrs) ⇒ GetResponse::Campaign
Create new campaign from passed attributes.
-
#initialize(connection) ⇒ CampaignProxy
constructor
A new instance of CampaignProxy.
Constructor Details
#initialize(connection) ⇒ CampaignProxy
Returns a new instance of CampaignProxy.
6 7 8 |
# File 'lib/get_response/campaign_proxy.rb', line 6 def initialize(connection) @connection = connection end |
Instance Method Details
#all ⇒ Object
Get all campaigns from account.
- returns
-
Array of GetResponse::Campaign
14 15 16 17 18 19 |
# File 'lib/get_response/campaign_proxy.rb', line 14 def all response = @connection.send_request("get_campaigns", {})["result"] response.inject([]) do |campaigns, resp| campaigns << Campaign.new(resp[1].merge("id" => resp[0]), @connection) end end |
#create(attrs) ⇒ GetResponse::Campaign
Create new campaign from passed attributes
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/get_response/campaign_proxy.rb', line 26 def create(attrs) new_campaign = Campaign.new(attrs, @connection) new_campaign.description = attrs["description"] new_campaign.language_code = attrs["language_code"] new_campaign.reply_to_field = attrs["reply_to_field"] new_campaign.from_field = attrs["from_field"] new_campaign.confirmation_body = attrs["confirmation_body"] new_campaign.confirmation_subject = attrs["confirmation_subject"] new_campaign.save new_campaign end |