Class: Hookd::Hook
- Inherits:
-
Object
- Object
- Hookd::Hook
- Defined in:
- lib/hookd/hook.rb
Overview
Represents a registered hook with DNS and HTTP endpoints. expires_at and metadata are populated for long-lived hooks (registered with a ttl) and nil otherwise.
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#dns ⇒ Object
readonly
Returns the value of attribute dns.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#https ⇒ Object
readonly
Returns the value of attribute https.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Create a Hook from API response hash.
Instance Method Summary collapse
-
#initialize(id:, dns:, http:, https:, created_at:, expires_at: nil, metadata: nil) ⇒ Hook
constructor
A new instance of Hook.
- #to_s ⇒ Object
Constructor Details
#initialize(id:, dns:, http:, https:, created_at:, expires_at: nil, metadata: nil) ⇒ Hook
Returns a new instance of Hook.
10 11 12 13 14 15 16 17 18 |
# File 'lib/hookd/hook.rb', line 10 def initialize(id:, dns:, http:, https:, created_at:, expires_at: nil, metadata: nil) @id = id @dns = dns @http = http @https = https @created_at = created_at @expires_at = expires_at @metadata = end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/hookd/hook.rb', line 8 def created_at @created_at end |
#dns ⇒ Object (readonly)
Returns the value of attribute dns.
8 9 10 |
# File 'lib/hookd/hook.rb', line 8 def dns @dns end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
8 9 10 |
# File 'lib/hookd/hook.rb', line 8 def expires_at @expires_at end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
8 9 10 |
# File 'lib/hookd/hook.rb', line 8 def http @http end |
#https ⇒ Object (readonly)
Returns the value of attribute https.
8 9 10 |
# File 'lib/hookd/hook.rb', line 8 def https @https end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/hookd/hook.rb', line 8 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/hookd/hook.rb', line 8 def @metadata end |
Class Method Details
.from_hash(hash) ⇒ Object
Create a Hook from API response hash
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hookd/hook.rb', line 21 def self.from_hash(hash) raise ArgumentError, "Invalid hash: expected Hash, got #{hash.class}" unless hash.is_a?(Hash) new( id: hash['id'], dns: hash['dns'], http: hash['http'], https: hash['https'], created_at: hash['created_at'], expires_at: hash['expires_at'], metadata: hash['metadata'] ) end |
Instance Method Details
#to_s ⇒ Object
35 36 37 |
# File 'lib/hookd/hook.rb', line 35 def to_s "#<Hookd::Hook id=#{id} dns=#{dns}>" end |