Class: Iterable::Campaigns
- Inherits:
-
ApiResource
- Object
- ApiResource
- Iterable::Campaigns
- Defined in:
- lib/iterable/campaigns.rb
Overview
Interact with /campaigns API endpoints
Instance Attribute Summary
Attributes inherited from ApiResource
Instance Method Summary collapse
-
#all ⇒ Iterable::Response
Get all campaigns.
-
#create(name, template_id, list_ids = [], attrs = {}) ⇒ Iterable::Response
Create a new campaign.
-
#metrics(campaign_ids = [], start_time = nil, end_time = nil) ⇒ Iterable::Response
Export metrics in CSV format for one or more campaigns.
-
#recurring(campaign_id) ⇒ Iterable::Response
Get recurring child campaigns for a campaign.
Methods inherited from ApiResource
#default_config, default_config, #initialize
Constructor Details
This class inherits a constructor from Iterable::ApiResource
Instance Method Details
#all ⇒ Iterable::Response
Get all campaigns
20 21 22 |
# File 'lib/iterable/campaigns.rb', line 20 def all Iterable.request(conf, '/campaigns').get end |
#create(name, template_id, list_ids = [], attrs = {}) ⇒ Iterable::Response
Create a new campaign. Requires a name, templateId and at least one listId
34 35 36 37 |
# File 'lib/iterable/campaigns.rb', line 34 def create(name, template_id, list_ids = [], attrs = {}) body = attrs.merge(name: name, templateId: template_id, listIds: list_ids) Iterable.request(conf, '/campaigns/create').post(body) end |
#metrics(campaign_ids = [], start_time = nil, end_time = nil) ⇒ Iterable::Response
Export metrics in CSV format for one or more campaigns
59 60 61 62 63 64 65 66 |
# File 'lib/iterable/campaigns.rb', line 59 def metrics(campaign_ids = [], start_time = nil, end_time = nil) params = { campaignId: campaign_ids } if start_time params[:startTime] = start_time.to_date.strftime(Iterable::DATE_FORMAT) params[:endTime] = end_time.to_date.strftime(Iterable::DATE_FORMAT) end Iterable.request(conf, '/campaigns/metrics', params).get end |
#recurring(campaign_id) ⇒ Iterable::Response
Get recurring child campaigns for a campaign
46 47 48 |
# File 'lib/iterable/campaigns.rb', line 46 def recurring(campaign_id) Iterable.request(conf, "/campaigns/recurring/#{campaign_id}/childCampaigns").get end |