Class: Hookd::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/hookd/hook.rb

Overview

Represents a registered hook with DNS and HTTP endpoints

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, dns:, http:, https:, created_at:) ⇒ Hook

Returns a new instance of Hook.



8
9
10
11
12
13
14
# File 'lib/hookd/hook.rb', line 8

def initialize(id:, dns:, http:, https:, created_at:)
  @id = id
  @dns = dns
  @http = http
  @https = https
  @created_at = created_at
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



6
7
8
# File 'lib/hookd/hook.rb', line 6

def created_at
  @created_at
end

#dnsObject (readonly)

Returns the value of attribute dns.



6
7
8
# File 'lib/hookd/hook.rb', line 6

def dns
  @dns
end

#httpObject (readonly)

Returns the value of attribute http.



6
7
8
# File 'lib/hookd/hook.rb', line 6

def http
  @http
end

#httpsObject (readonly)

Returns the value of attribute https.



6
7
8
# File 'lib/hookd/hook.rb', line 6

def https
  @https
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/hookd/hook.rb', line 6

def id
  @id
end

Class Method Details

.from_hash(hash) ⇒ Object

Create a Hook from API response hash

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hookd/hook.rb', line 17

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']
  )
end

Instance Method Details

#to_sObject



29
30
31
# File 'lib/hookd/hook.rb', line 29

def to_s
  "#<Hookd::Hook id=#{id} dns=#{dns}>"
end