Class: SearchKit::Events
- Inherits:
-
Object
- Object
- SearchKit::Events
- Defined in:
- lib/search_kit/events.rb,
lib/search_kit/events/cli.rb,
lib/search_kit/events/publish.rb,
lib/search_kit/events/cli/list.rb,
lib/search_kit/events/cli/status.rb,
lib/search_kit/events/cli/pending.rb,
lib/search_kit/events/cli/publish.rb,
lib/search_kit/events/cli/complete.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #complete(id) ⇒ Object
- #index ⇒ Object
-
#initialize ⇒ Events
constructor
A new instance of Events.
- #pending(channel) ⇒ Object
- #publish(channel, payload) ⇒ Object
- #show(id) ⇒ Object
Constructor Details
#initialize ⇒ Events
Returns a new instance of Events.
12 13 14 |
# File 'lib/search_kit/events.rb', line 12 def initialize @connection = SearchKit::Client.connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
10 11 12 |
# File 'lib/search_kit/events.rb', line 10 def connection @connection end |
Instance Method Details
#complete(id) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/search_kit/events.rb', line 16 def complete(id) response = connection.delete("/api/events/#{id}") body = JSON.parse(response.body, symbolize_names: true) fail Errors::EventNotFound if response.status == 404 body end |
#index ⇒ Object
25 26 27 28 29 |
# File 'lib/search_kit/events.rb', line 25 def index response = connection.get('/api/events') JSON.parse(response.body, symbolize_names: true) end |
#pending(channel) ⇒ Object
40 41 42 43 44 |
# File 'lib/search_kit/events.rb', line 40 def pending(channel) response = connection.get("/api/events?filter[channel]=#{channel}") JSON.parse(response.body, symbolize_names: true) end |
#publish(channel, payload) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/search_kit/events.rb', line 46 def publish(channel, payload) action = Publish.new( channel: channel, connection: connection, payload: payload ) action.perform end |
#show(id) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/search_kit/events.rb', line 31 def show(id) response = connection.get("/api/events/#{id}") body = JSON.parse(response.body, symbolize_names: true) fail Errors::EventNotFound if response.status == 404 body end |