Class: Svix::StreamingEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/svix/api/streaming_events.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ StreamingEvents

Returns a new instance of StreamingEvents.



8
9
10
# File 'lib/svix/api/streaming_events.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#create(stream_id, create_stream_events_in, options = {}) ⇒ Object



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

def create(stream_id, create_stream_events_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/stream/#{stream_id}/events",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: create_stream_events_in
  )
  CreateStreamEventsOut.deserialize(res)
end

#get(stream_id, sink_id, options = {}) ⇒ Object



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

def get(stream_id, sink_id, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "GET",
    "/api/v1/stream/#{stream_id}/sink/#{sink_id}/events",
    query_params: {
      "limit" => options["limit"],
      "iterator" => options["iterator"],
      "after" => options["after"]
    }
  )
  EventStreamOut.deserialize(res)
end