module MailerLite::Clients::Campaigns

MailerLite Campaigns

Public Instance Methods

campaign_action(id, action) click to toggle source

Send, schedule or cancel campaign

@see developers.mailerlite.com/v2/reference#campaign-actions-and-triggers

@param id [Integer] ID of campaign @param action [String] Action type. Possible values: send, cancel

@return [Hash] Response from API.

# File lib/mailerlite/clients/campaigns.rb, line 51
def campaign_action(id, action)
  connection.post("campaigns/#{id}/actions/#{action}")
end
campaigns_by_status(status, options = {}) click to toggle source

Returns all campaigns you have in your account by :status which is required. Also basic summary for each campaign including the ID.

@see developers.mailerlite.com/v2/reference#campaigns-by-type

@param status [String] possible values: 'sent', 'outbox', 'draft' no value means 'sent' @param options [Hash] Options list. See more in MailerLite docs. @option options [Integer] :offset @option options [Integer] :limit @option options [String] :order asc or desc

@return Response from API.

# File lib/mailerlite/clients/campaigns.rb, line 68
def campaigns_by_status(status, options = {})
  connection.get("campaigns/#{status}", options)
end
create_campaign(options = {}) click to toggle source

Create campaign where you will use your custom HTML template

@see developers.mailerlite.com/v2/reference#campaigns

@param options [Hash] A customizable set of options. @option options [String] :type Type of campaign. Available values:

regular, ab.

@option options [String] :subject Mail subject. Required if campaign

type is regular.

@option options [String] :from Email of sender @option options [String] :from_name Name of sender @option options [String] :language ISO 639-1 @option options [Array] :groups IDs of groups @option options [Hash] :ab_settings Required if campaign type is ab.

@return [Hash] Response from API.

# File lib/mailerlite/clients/campaigns.rb, line 23
def create_campaign(options = {})
  connection.post('campaigns', options)
end
delete_campaign(id) click to toggle source

Remove a campaign.

@see developers.mailerlite.com/v2/reference#delete-campaign

@param id [Integer] id of campaign

@return [Boolean] Response from API.

# File lib/mailerlite/clients/campaigns.rb, line 79
def delete_campaign(id)
  connection.delete("campaigns/#{id}")
end
update_campaign_content(id, options = {}) click to toggle source

Upload your HTML template to created campaign

@see developers.mailerlite.com/v2/reference#put-custom-content-to-campaign

@param id [Integer] ID of campaign @param options [Hash] A customizable set of options. @option options [String] :html HTML template source @option options [String] :plain Plain text of email @option options [Boolean] :auto_inline Defines if it is needed to

convert available CSS to inline CSS (excluding media queries)

@return [Hash] Response from API.

# File lib/mailerlite/clients/campaigns.rb, line 39
def update_campaign_content(id, options = {})
  connection.put("campaigns/#{id}/content", options)
end