module BjondApi
Public Class Methods
register_app(integration_app, bjondhost=ENV['BJOND_SERVER'])
click to toggle source
Registers the given integration_app with a bjond-server.
# File lib/bjond-api.rb, line 15 def self.register_app(integration_app, bjondhost=ENV['BJOND_SERVER']) conn = Faraday.new(:url => bjondhost) puts integration_app.to_json return conn.post do |req| req.url '/server-core/services/integrationmanager/register' req.headers['Content-Type'] = 'application/json' req.body = integration_app.to_json end end
Public Instance Methods
fire_event(bjond_registration, payload, event_id)
click to toggle source
Fires events to all bjond_registrations
# File lib/bjond-api.rb, line 27 def fire_event(bjond_registration, payload, event_id) puts "Firing event for registration: " puts bjond_registration.id services = BjondService.where(:bjond_registration_id => bjond_registration.id) connections = [] services.each do |bjond_svc| url = bjond_svc.endpoint + "/#{event_id}" puts "Creating connection to " + url puts BjondJwt::jwt_encode_payload(payload, bjond_registration) conn = Faraday.new(:url => url) conn.post do |req| req.headers['Content-Type'] = 'application/json' req.body = BjondJwt::jwt_encode_payload(payload, bjond_registration) end end return connections end
fire_event_for_group(bjond_registration, payload, event_id, group_id)
click to toggle source
# File lib/bjond-api.rb, line 46 def fire_event_for_group(bjond_registration, payload, event_id, group_id) puts "Fire event for group #{group_id}" bjond_svc = BjondService.find_by_group_id_and_bjond_registration_id(group_id, bjond_registration.id) url = bjond_svc.endpoint + "/#{event_id}" puts "Creating connection to #{url}" conn = Faraday.new(:url => url) conn.post do |req| req.headers['Content-Type'] = 'application/json' req.body = BjondJwt::jwt_encode_payload(payload, bjond_registration) end end