Class: PartyBus::Events::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/party_bus/events/create.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection_id, payload, topic, timestamp) ⇒ Create

Returns a new instance of Create.



13
14
15
16
17
18
# File 'lib/party_bus/events/create.rb', line 13

def initialize(connection_id, payload, topic, timestamp)
  @connection_id = connection_id
  @topic = topic
  @payload = payload
  @timestamp = timestamp
end

Class Method Details

.perform_using(connection_id:, payload:, timestamp: Time.now, topic:) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/party_bus/events/create.rb', line 4

def self.perform_using(
  connection_id:,
  payload:,
  timestamp: Time.now,
  topic:
)
  new(connection_id, payload, topic, timestamp).perform
end

Instance Method Details

#performObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/party_bus/events/create.rb', line 20

def perform
  @response ||= PartyBus::Client.post(
    body: {
      event: {
        payload: @payload,
        topic: @topic,
      }
    },
    path: "/api/v1/connections/#{@connection_id}/events",
    timestamp: @timestamp
  )
end