Sha256: 9e31c05570d008ad8495821f9da17004e6827175ceef6aa7e3df6c86bb4020d3
Contents?: true
Size: 835 Bytes
Versions: 7
Compression:
Stored size: 835 Bytes
Contents
# encoding: UTF-8 require 'rest_client' require 'websocket_manager' module Factor # Class Listener for integrating with connector service class Listener def initialize(url) @url = url end def definition get("#{@url}/definition") end def listener(listener_id) listen("#{@url}/listeners/#{listener_id}") end def action(action_id) listen("#{@url}/actions/#{action_id}") end private def post(uri_path, payload) content = { 'payload' => MultiJson.dump(payload) } JSON.parse(RestClient.post(uri_path, content)) end def get(uri_path) JSON.parse(RestClient.get(uri_path)) end def delete(uri_path) JSON.parse(RestClient.delete(uri_path)) end def listen(uri_path) WebSocketManager.new(uri_path) end end end
Version data entries
7 entries across 7 versions & 1 rubygems