Class: Hookd::HookActivity

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

Overview

Summarises a long-lived hook that currently has pending interactions, returned by Client#activity.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hook:, pending_count:, last_interaction_at:) ⇒ HookActivity

Returns a new instance of HookActivity.



9
10
11
12
13
# File 'lib/hookd/hook_activity.rb', line 9

def initialize(hook:, pending_count:, last_interaction_at:)
  @hook = hook
  @pending_count = pending_count
  @last_interaction_at = last_interaction_at
end

Instance Attribute Details

#hookObject (readonly)

Returns the value of attribute hook.



7
8
9
# File 'lib/hookd/hook_activity.rb', line 7

def hook
  @hook
end

#last_interaction_atObject (readonly)

Returns the value of attribute last_interaction_at.



7
8
9
# File 'lib/hookd/hook_activity.rb', line 7

def last_interaction_at
  @last_interaction_at
end

#pending_countObject (readonly)

Returns the value of attribute pending_count.



7
8
9
# File 'lib/hookd/hook_activity.rb', line 7

def pending_count
  @pending_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Create a HookActivity from an API response hash

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
# File 'lib/hookd/hook_activity.rb', line 16

def self.from_hash(hash)
  raise ArgumentError, "Invalid hash: expected Hash, got #{hash.class}" unless hash.is_a?(Hash)

  new(
    hook: Hook.from_hash(hash['hook']),
    pending_count: hash['pending_count'],
    last_interaction_at: hash['last_interaction_at']
  )
end

Instance Method Details

#to_sObject



26
27
28
# File 'lib/hookd/hook_activity.rb', line 26

def to_s
  "#<Hookd::HookActivity hook=#{hook.id} pending=#{pending_count}>"
end