Module: BjondApi
- Defined in:
- lib/bjond-api.rb,
lib/bjond-event.rb,
lib/bjond-field.rb,
lib/bjond-app-config.rb,
lib/bjond-app/engine.rb,
lib/bjond-consequence.rb,
lib/bjond-app-definition.rb
Defined Under Namespace
Classes: BjondAppConfig, BjondAppDefinition, BjondConsequence, BjondEvent, BjondField, Engine
Class Method Summary collapse
-
.register_app(integration_app, bjondhost = ENV['BJOND_SERVER']) ⇒ Object
Registers the given integration_app with a bjond-server.
Instance Method Summary collapse
-
#fire_event(bjond_registration, payload, event_id) ⇒ Object
Fires events to all bjond_registrations.
Class Method Details
.register_app(integration_app, bjondhost = ENV['BJOND_SERVER']) ⇒ Object
Registers the given integration_app with a bjond-server.
15 16 17 18 19 20 21 22 23 |
# 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 |
Instance Method Details
#fire_event(bjond_registration, payload, event_id) ⇒ Object
Fires events to all bjond_registrations
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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 |