Module: RailsAgents::OpenWireAdapter

Defined in:
lib/rails_agents/open_wire_adapter.rb

Overview

Open-Wire channel adapter — thin wrapper so agents don't talk HTTP directly.

Class Method Summary collapse

Class Method Details

.client(base_url: nil, api_key: nil) ⇒ Object



10
11
12
# File 'lib/rails_agents/open_wire_adapter.rb', line 10

def client(base_url: nil, api_key: nil)
  ::OpenWire::Client.new(base_url: base_url, api_key: api_key)
end

.reply!(installation_id:, to:, text:, thread_id: nil, client: nil) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/rails_agents/open_wire_adapter.rb', line 22

def reply!(installation_id:, to:, text:, thread_id: nil, client: nil)
  (client || self.client).send_message(
    installation_id: installation_id,
    to: to,
    text: text,
    thread_id: thread_id
  )
end

.verify_inbound!(secret:, body:, headers:) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/rails_agents/open_wire_adapter.rb', line 14

def verify_inbound!(secret:, body:, headers:)
  ::OpenWire::Webhook.verify_and_parse!(
    secret: secret,
    body: body,
    headers: headers
  )
end