Class: Posthubify::AutomationsResource

Inherits:
Object
  • Object
show all
Defined in:
lib/posthubify/resources/messaging.rb

Overview

Automation management — CRUD + activate/pause/duplicate + runs + dry-test (Node sdk .automations).

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ AutomationsResource

Returns a new instance of AutomationsResource.



166
167
168
# File 'lib/posthubify/resources/messaging.rb', line 166

def initialize(http)
  @http = http
end

Instance Method Details

#activate(id) ⇒ Object

Activate an automation.



196
197
198
# File 'lib/posthubify/resources/messaging.rb', line 196

def activate(id)
  @http.data('POST', "/automations/#{id}/activate")
end

#create(input) ⇒ Object

Create an automation (trigger + action).



181
182
183
# File 'lib/posthubify/resources/messaging.rb', line 181

def create(input)
  @http.data('POST', '/automations', body: input)
end

#delete(id) ⇒ Object

Delete an automation.



191
192
193
# File 'lib/posthubify/resources/messaging.rb', line 191

def delete(id)
  @http.data('DELETE', "/automations/#{id}")
end

#duplicate(id) ⇒ Object

The copy starts PAUSED (protection against accidental double-triggering).



206
207
208
# File 'lib/posthubify/resources/messaging.rb', line 206

def duplicate(id)
  @http.data('POST', "/automations/#{id}/duplicate")
end

#get(id) ⇒ Object

A single automation.



176
177
178
# File 'lib/posthubify/resources/messaging.rb', line 176

def get(id)
  @http.data('GET', "/automations/#{id}")
end

#listObject

Automation list.



171
172
173
# File 'lib/posthubify/resources/messaging.rb', line 171

def list
  @http.data('GET', '/automations')
end

#pause(id) ⇒ Object

Pause an automation.



201
202
203
# File 'lib/posthubify/resources/messaging.rb', line 201

def pause(id)
  @http.data('POST', "/automations/#{id}/pause")
end

#runs(id, limit: nil) ⇒ Object

Automation run records.



211
212
213
# File 'lib/posthubify/resources/messaging.rb', line 211

def runs(id, limit: nil)
  @http.data('GET', "/automations/#{id}/runs", query: { 'limit' => limit })
end

#test(id, input = {}) ⇒ Object

Dry-run: does a synthetic event match the trigger (nothing is sent).



216
217
218
# File 'lib/posthubify/resources/messaging.rb', line 216

def test(id, input = {})
  @http.data('POST', "/automations/#{id}/test", body: input)
end

#update(id, input) ⇒ Object

Update an automation (partial).



186
187
188
# File 'lib/posthubify/resources/messaging.rb', line 186

def update(id, input)
  @http.data('PATCH', "/automations/#{id}", body: input)
end