Module: Mailblastr::Automations

Defined in:
lib/mailblastr/automations.rb

Overview

Automations are DOMAIN-FIRST: domain is required on create, and only Events.send calls naming the same domain trigger them.

Class Method Summary collapse

Class Method Details

.add_step(automation_id, params) ⇒ Object

Append a step. POST /automations/:id/steps — params: { type:, config:, key: }



38
39
40
# File 'lib/mailblastr/automations.rb', line 38

def add_step(automation_id, params)
  Client.request(:post, "/automations/#{Client.path_escape(automation_id)}/steps", body: params)
end

.create(params) ⇒ Object

POST /automations Mailblastr::Automations.create({ name: "Welcome series", domain: "yourdomain.com", trigger: "contact.created" }) The built-in "mailblastr:schedule" trigger fires once at trigger_config ({ at: ISO 8601 instant, timezone: IANA name }), enrolling every contact of the domain's pool — trigger_config is required with that trigger and not accepted on any other.



15
16
17
18
# File 'lib/mailblastr/automations.rb', line 15

def create(params)
  Client.require_domain!(params, "Automations.create")
  Client.request(:post, "/automations", body: params)
end

.delete(automation_id) ⇒ Object

DELETE /automations/:id



63
64
65
# File 'lib/mailblastr/automations.rb', line 63

def delete(automation_id)
  Client.request(:delete, "/automations/#{Client.path_escape(automation_id)}")
end

.delete_step(automation_id, step_id) ⇒ Object

Delete a step. DELETE /automations/:id/steps/:step_id



43
44
45
# File 'lib/mailblastr/automations.rb', line 43

def delete_step(automation_id, step_id)
  Client.request(:delete, "/automations/#{Client.path_escape(automation_id)}/steps/#{Client.path_escape(step_id)}")
end

.get(automation_id) ⇒ Object

GET /automations/:id



21
22
23
# File 'lib/mailblastr/automations.rb', line 21

def get(automation_id)
  Client.request(:get, "/automations/#{Client.path_escape(automation_id)}")
end

.get_run(automation_id, run_id) ⇒ Object

Retrieve a single run with its step trace. GET /automations/:id/runs/:run_id



53
54
55
# File 'lib/mailblastr/automations.rb', line 53

def get_run(automation_id, run_id)
  Client.request(:get, "/automations/#{Client.path_escape(automation_id)}/runs/#{Client.path_escape(run_id)}")
end

.list(params = {}) ⇒ Object

GET /automations



26
27
28
# File 'lib/mailblastr/automations.rb', line 26

def list(params = {})
  Client.request(:get, "/automations", query: Client.pagination(params))
end

.runs(automation_id, params = {}) ⇒ Object

List an automation's runs. GET /automations/:id/runs



48
49
50
# File 'lib/mailblastr/automations.rb', line 48

def runs(automation_id, params = {})
  Client.request(:get, "/automations/#{Client.path_escape(automation_id)}/runs", query: Client.pagination(params))
end

.stop(automation_id) ⇒ Object

Stop an automation — no new runs; in-progress runs finish. POST /automations/:id/stop



58
59
60
# File 'lib/mailblastr/automations.rb', line 58

def stop(automation_id)
  Client.request(:post, "/automations/#{Client.path_escape(automation_id)}/stop")
end

.update(automation_id, params) ⇒ Object

PATCH /automations/:id — params: { name:, status: "enabled"|"disabled", ... } trigger_config ({ at:, timezone: }) updates the "mailblastr:schedule" trigger's schedule (only valid on automations with that trigger).



33
34
35
# File 'lib/mailblastr/automations.rb', line 33

def update(automation_id, params)
  Client.request(:patch, "/automations/#{Client.path_escape(automation_id)}", body: params)
end