Module: CopyAi::Webhook
Constant Summary collapse
- EVENT_TYPES =
[ "workflowRun.started", "workflowRun.completed", "workflowRun.failed", "workflowCreditLimit.reached" ].freeze
- WEBHOOK_URL =
"https://api.copy.ai/api/webhook".freeze
Instance Method Summary collapse
-
#register(client, url:, event_type:, workflow_id: nil) ⇒ Object
If a workflow ID is not included, events for all workflows in your workspace will be received.
Instance Method Details
permalink #register(client, url:, event_type:, workflow_id: nil) ⇒ Object
If a workflow ID is not included, events for all workflows in your workspace will be received
13 14 15 16 17 18 19 20 |
# File 'lib/copy_ai/webhook.rb', line 13 def register(client, url:, event_type:, workflow_id: nil) raise ArgumentError, "Missing Arguments" if client.nil? || url.nil? || event_type.nil? validate!(event_type:) webhook_client = client.dup.tap { |c| c.api_endpoint = WEBHOOK_URL } body = {url:, eventType: event_type, workflowId: workflow_id} webhook_client.post(body:) end |