Class: HookSniff::EventType

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ EventType

Returns a new instance of EventType.



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

def initialize(client)
  @client = client
end

Instance Method Details

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



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

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

#delete(event_type_name) ⇒ Object



61
62
63
64
# File 'lib/hooksniff/api/event_type.rb', line 61

def delete(event_type_name)
  @client.execute_request("DELETE", "/v1/event-types/#{event_type_name}")
  nil
end

#get(event_type_name) ⇒ Object



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

def get(event_type_name)
  res = @client.execute_request("GET", "/v1/event-types/#{event_type_name}")
  EventTypeOut.deserialize(res)
end

#list(options = {}) ⇒ Object



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

def list(options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "GET",
    "/v1/event-types",
    query_params: {
      "limit" => options["limit"],
      "offset" => options["offset"],
      "include_archived" => options["include_archived"]
    }
  )
  ListResponseEventTypeOut.deserialize(res)
end

#patch(event_type_name, event_type_patch) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/hooksniff/api/event_type.rb', line 52

def patch(event_type_name, event_type_patch)
  res = @client.execute_request(
    "PATCH",
    "/v1/event-types/#{event_type_name}",
    body: event_type_patch
  )
  EventTypeOut.deserialize(res)
end

#update(event_type_name, event_type_update) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/hooksniff/api/event_type.rb', line 43

def update(event_type_name, event_type_update)
  res = @client.execute_request(
    "PUT",
    "/v1/event-types/#{event_type_name}",
    body: event_type_update
  )
  EventTypeOut.deserialize(res)
end