Module: Laposta::Client::Campaigns

Included in:
Laposta::Client
Defined in:
lib/laposta/client/campaigns.rb

Instance Method Summary collapse

Instance Method Details

#campaigns(params = {}) ⇒ Object



4
5
6
# File 'lib/laposta/client/campaigns.rb', line 4

def campaigns(params = {})
  list("campaign", params)
end

#create_campaign!(params = {}) ⇒ Object

Allowed attributes: Name Type Description


type string (mandatory) Type of campaign (must be set to: regular) name string (mandatory) A name for this campaign for internal use subject string (mandatory) Subject line from object (mandatory) from string (mandatory) The name of the sender from string (mandatory) The email address of the sender (must be a sender address approved within the program) reply_to string Email address for receiving replies list_ids array (mandatory) Recipients, array of list_ids and segment_ids if needed stats object stats boolean Link Google Analytics (true or false) stats boolean Link Mtrack (true or false)




32
33
34
35
36
37
38
39
40
41
# File 'lib/laposta/client/campaigns.rb', line 32

def create_campaign!(params = {})
  cleaned = params.permit(:type,
                          :name,
                          :subject,
                          { from: [:name, :email] },
                          :reply_to,
                          :list_ids,
                          { stats: [:ga, :mtrack] })
  create("campaign", cleaned)
end

#delete_campaign!(campaign_id, params = {}) ⇒ Object

Parameters Name Type Description


campaign_id string (mandatory) The ID of the campaign to be deleted




78
79
80
# File 'lib/laposta/client/campaigns.rb', line 78

def delete_campaign!(campaign_id, params = {})
  delete("campaign/#{campaign_id}")
end

#fill_campaign_content!(campaign_id, params = {}) ⇒ Object

Parameters Name Type Description


campaign_id string (mandatory) The ID of the campaign


Allowed attributes: Name Type Description


html string The html for the campaign import_url string The URL from which the html must be imported inline_css boolean Potential inlining of css (true or false)




104
105
106
107
108
109
# File 'lib/laposta/client/campaigns.rb', line 104

def fill_campaign_content!(campaign_id, params = {})
  cleaned = params.permit(:html,
                          :import_url,
                          :inline_css)
  update("campaign/#{campaign_id}/content", cleaned)
end

#get_campaign(campaign_id) ⇒ Object

Parameters Name Type Description


campaign_id string (mandatory) The ID of the campaign




13
14
15
# File 'lib/laposta/client/campaigns.rb', line 13

def get_campaign(campaign_id)
  get("campaign/#{campaign_id}")
end

#get_campaign_content(campaign_id) ⇒ Object

Parameters Name Type Description


campaign_id string (mandatory) The ID of the campaign




87
88
89
# File 'lib/laposta/client/campaigns.rb', line 87

def get_campaign_content(campaign_id)
  get("campaign/#{campaign_id}/content")
end

#schedule_campaign!(campaign_id, params = {}) ⇒ Object

Parameters Name Type Description


campaign_id string (mandatory) The ID of the campaign


Allowed attributes: Name Type Description


delivery_requested string(mandatory) The time and date of sending (format YYYY-MM-DD HH:MM:SS)




131
132
133
134
# File 'lib/laposta/client/campaigns.rb', line 131

def schedule_campaign!(campaign_id, params = {})
  cleaned = params.permit(:delivery_requested)
  update("campaign/#{campaign_id}/action/schedule", cleaned)
end

#send_campaign!(campaign_id) ⇒ Object

Parameters Name Type Description


campaign_id string (mandatory) The ID of the campaign




116
117
118
# File 'lib/laposta/client/campaigns.rb', line 116

def send_campaign!(campaign_id)
  update("campaign/#{campaign_id}/action/send", {})
end

#test_campaign!(campaign_id, params = {}) ⇒ Object

Parameters Name Type Description


campaign_id string (mandatory) The ID of the campaign


Allowed attributes: Name Type Description


email string(mandatory) The email address to which the test should be sent.




147
148
149
150
# File 'lib/laposta/client/campaigns.rb', line 147

def test_campaign!(campaign_id, params = {})
  cleaned = params.permit(:email)
  update("campaign/#{campaign_id}/action/testmail", cleaned)
end

#update_campaign!(campaign_id, params = {}) ⇒ Object

Parameters Name Type Description


campaign_id string (mandatory) The ID of the campaign that has to be modified


Allowed attributes: Name Type Description


name string (mandatory) A name for this campaign for internal use subject string (mandatory) Subject line from object (mandatory) from string (mandatory) The name of the sender from string (mandatory) The email address of the sender (must be a sender address approved within the program) reply_to string Email address for receiving replies list_ids array (mandatory) Recipients, array of list_ids and segment_ids if needed stats object stats boolean Link Google Analytics (true or false) stats boolean Link Mtrack (true or false)




63
64
65
66
67
68
69
70
71
# File 'lib/laposta/client/campaigns.rb', line 63

def update_campaign!(campaign_id, params = {})
  cleaned = params.permit(:name,
                          :subject,
                          { from: [:name, :email] },
                          :reply_to,
                          :list_ids,
                          { stats: [:ga, :mtrack] })
  update("campaign/#{campaign_id}", cleaned)
end