Class: HookSniff::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/hooksniff/api/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Message

Returns a new instance of Message.



7
8
9
# File 'lib/hooksniff/api/message.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#create(message_in, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hooksniff/api/message.rb', line 11

def create(message_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/v1/webhooks",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: message_in
  )
  MessageOut.deserialize(res)
end

#get(message_id) ⇒ Object



38
39
40
41
# File 'lib/hooksniff/api/message.rb', line 38

def get(message_id)
  res = @client.execute_request("GET", "/v1/webhooks/#{message_id}")
  MessageOut.deserialize(res)
end

#list(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/hooksniff/api/message.rb', line 24

def list(options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "GET",
    "/v1/webhooks",
    query_params: {
      "limit" => options["limit"],
      "offset" => options["offset"],
      "status" => options["status"]
    }
  )
  ListResponseMessageOut.deserialize(res)
end

#replay(message_id) ⇒ Object



43
44
45
46
# File 'lib/hooksniff/api/message.rb', line 43

def replay(message_id)
  res = @client.execute_request("POST", "/v1/webhooks/#{message_id}/replay")
  ReplayOut.deserialize(res)
end