Class: Posthubify::WorkflowsResource

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

Overview

PHASE D5 — graph-based conversation automation (node/edge, versioning, run timeline).

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ WorkflowsResource

Returns a new instance of WorkflowsResource.



261
262
263
# File 'lib/posthubify/resources/messaging.rb', line 261

def initialize(http)
  @http = http
end

Instance Method Details

#activate(id) ⇒ Object



291
292
293
# File 'lib/posthubify/resources/messaging.rb', line 291

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

#create(input) ⇒ Object

Draft workflow from a node/edge graph. input: accountId, nodes?, edges?, triggerConfig?.



274
275
276
# File 'lib/posthubify/resources/messaging.rb', line 274

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

#delete(id) ⇒ Object



287
288
289
# File 'lib/posthubify/resources/messaging.rb', line 287

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

#duplicate(id) ⇒ Object



299
300
301
# File 'lib/posthubify/resources/messaging.rb', line 299

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

#events(id, execution_id) ⇒ Object



312
313
314
# File 'lib/posthubify/resources/messaging.rb', line 312

def events(id, execution_id)
  @http.data('GET', "/workflows/#{id}/executions/#{execution_id}/events")
end

#executions(id, limit: nil, cursor: nil) ⇒ Object



303
304
305
# File 'lib/posthubify/resources/messaging.rb', line 303

def executions(id, limit: nil, cursor: nil)
  @http.req('GET', "/workflows/#{id}/executions", query: { 'limit' => limit, 'cursor' => cursor })
end

#generate(command, account_id, create: false) ⇒ Object

F3 — generate a graph with AI from a natural-language command. create:true → a draft is saved (returns the workflow).



279
280
281
# File 'lib/posthubify/resources/messaging.rb', line 279

def generate(command, , create: false)
  @http.data('POST', '/workflows/generate', body: { 'command' => command, 'accountId' => , 'create' => create })
end

#get(id) ⇒ Object



269
270
271
# File 'lib/posthubify/resources/messaging.rb', line 269

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

#list(account_id: nil, status: nil) ⇒ Object



265
266
267
# File 'lib/posthubify/resources/messaging.rb', line 265

def list(account_id: nil, status: nil)
  @http.data('GET', '/workflows', query: { 'accountId' => , 'status' => status })
end

#pause(id) ⇒ Object



295
296
297
# File 'lib/posthubify/resources/messaging.rb', line 295

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

#restore_version(id, version) ⇒ Object

Restore the live graph to a snapshot (reversible).



325
326
327
# File 'lib/posthubify/resources/messaging.rb', line 325

def restore_version(id, version)
  @http.data('POST', "/workflows/#{id}/versions/#{version}/restore")
end

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

Manual test-run (side-effect-free dry-run). input: variables?. → events.



308
309
310
# File 'lib/posthubify/resources/messaging.rb', line 308

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

#set_secret(id, provider, api_key) ⇒ Object

Store a BYOK provider key for the ai node (write-only, encrypted). provider ∈ anthropic|openai|google|mistral|groq.



331
332
333
# File 'lib/posthubify/resources/messaging.rb', line 331

def set_secret(id, provider, api_key)
  @http.data('PUT', "/workflows/#{id}/secrets/#{provider}", body: { 'apiKey' => api_key })
end

#update(id, input) ⇒ Object



283
284
285
# File 'lib/posthubify/resources/messaging.rb', line 283

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

#version(id, version) ⇒ Object



320
321
322
# File 'lib/posthubify/resources/messaging.rb', line 320

def version(id, version)
  @http.data('GET', "/workflows/#{id}/versions/#{version}")
end

#versions(id) ⇒ Object



316
317
318
# File 'lib/posthubify/resources/messaging.rb', line 316

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