Class: MOCO::WebHook
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- MOCO::WebHook
- Defined in:
- lib/moco/entities/web_hook.rb
Overview
Represents a MOCO webhook for event notifications
Required attributes for create:
target - String, entity type to watch:
"Activity", "Company", "Contact", "Project",
"Invoice", "Offer", "Deal", "Expense"
event - String, event type: "create", "update", "delete"
hook - String, URL to receive webhook payloads (e.g., "https://example.org/callback")
Read-only attributes:
id, disabled, disabled_at, created_at, updated_at
Instance methods:
enable - Enable the webhook
disable - Disable the webhook
Example:
# Create webhook for new activities
moco.web_hooks.create(
target: "Activity",
event: "create",
hook: "https://example.org/moco-activity-webhook"
)
# Disable a webhook
webhook = moco.web_hooks.find(123)
webhook.disable
Note:
Only the `hook` URL can be updated after creation.
To change target/event, delete and recreate the webhook.
Instance Attribute Summary
Attributes inherited from BaseEntity
Class Method Summary collapse
-
.entity_path ⇒ Object
Override entity_path to match API path.
Instance Method Summary collapse
- #disable ⇒ Object
-
#enable ⇒ Object
Instance methods for webhook-specific operations.
- #to_s ⇒ Object
Methods inherited from BaseEntity
#==, #association, #destroy, #eql?, #has_many, #hash, #id, #initialize, #inspect, #reload, #save, #to_h, #to_json, #update
Constructor Details
This class inherits a constructor from MOCO::BaseEntity
Class Method Details
.entity_path ⇒ Object
Override entity_path to match API path
38 39 40 |
# File 'lib/moco/entities/web_hook.rb', line 38 def self.entity_path "account/web_hooks" end |
Instance Method Details
#disable ⇒ Object
48 49 50 51 |
# File 'lib/moco/entities/web_hook.rb', line 48 def disable client.put("account/web_hooks/#{id}/disable") self end |
#enable ⇒ Object
Instance methods for webhook-specific operations
43 44 45 46 |
# File 'lib/moco/entities/web_hook.rb', line 43 def enable client.put("account/web_hooks/#{id}/enable") self end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/moco/entities/web_hook.rb', line 53 def to_s "#{target} - #{url}" end |