Class: BjondservicesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- BjondservicesController
- Defined in:
- app/controllers/bjondservices_controller.rb
Instance Method Summary collapse
-
#configure_group_endpoint ⇒ Object
Encrypted Communication w Bjond servers ################.
- #get_group_configuration ⇒ Object
- #get_schema ⇒ Object
- #index ⇒ Object
- #register ⇒ Object
- #register_group_endpoint ⇒ Object
Instance Method Details
#configure_group_endpoint ⇒ Object
Encrypted Communication w Bjond servers ################
43 44 45 46 47 48 49 50 |
# File 'app/controllers/bjondservices_controller.rb', line 43 def configure_group_endpoint bjond_registration = BjondRegistration.find_registration_by_remote_ip(request.remote_ip) result = jwt_decode_payload_and_return_json(request.raw_post, bjond_registration) BjondApi::BjondAppConfig.instance.configure_group(result, bjond_registration) render :json => { :status => 'OK' }.to_json end |
#get_group_configuration ⇒ Object
57 58 59 60 61 |
# File 'app/controllers/bjondservices_controller.rb', line 57 def get_group_configuration bjond_registration = BjondRegistration.find_registration_by_remote_ip(request.remote_ip) payload = BjondApi::BjondAppConfig.instance.get_group_configuration(bjond_registration) render :json => jwt_encode_payload(payload.to_json, bjond_registration) end |
#get_schema ⇒ Object
52 53 54 55 |
# File 'app/controllers/bjondservices_controller.rb', line 52 def get_schema render :json => jwt_encode_payload(BjondApi::BjondAppConfig.instance.group_configuration_schema, BjondRegistration.find_registration_by_remote_ip(request.remote_ip)) end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/bjondservices_controller.rb', line 8 def index @app_info = BjondApi::BjondAppConfig.instance.active_definition end |
#register ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/bjondservices_controller.rb', line 12 def register registration = BjondRegistration.find_by_id(params[:id]) if (!registration.nil?) response = BjondApi.register_app(BjondApi::BjondAppConfig.instance.active_definition, registration.server) if (response.status === 200 ) render :json => { :status => 'Updated' } else raise "Failed to update.\n" + response.body end else render :json => { :status => 'Registration not found' } end end |
#register_group_endpoint ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/bjondservices_controller.rb', line 32 def register_group_endpoint registration = BjondRegistration.find_registration_by_remote_ip(request.remote_ip) service = BjondService.find_or_initialize_by(:group_id => params[:groupid], :registration_id => registration.id) if (service.endpoint != params[:endpoint]) service.endpoint = params[:endpoint] service.save end render :json => service end |