Class: ZuoraConnect::StaticController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ZuoraConnect::StaticController
- Defined in:
- app/controllers/zuora_connect/static_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#health ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/zuora_connect/static_controller.rb', line 11 def health if params[:error].present? begin raise ZuoraConnect::Exceptions::Error.new('This is an error') rescue => ex case params[:error] when 'Log' Rails.logger.error("Error in Health", ex) when 'Exception' raise end end end render json: { message: "Alive", status: 200 }, status: 200 end |
#initialize_app ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/zuora_connect/static_controller.rb', line 31 def initialize_app begin authenticate_connect_app_request unless performed? @appinstance.new_session(:session => @appinstance.data_lookup(:session => session)) render json: { message: 'Success', status: 200 }, status: 200 end rescue => ex Rails.logger.error("Failed to Initialize application", ex) if performed? Rails.logger.error("Failed to Initialize application #{performed?}", ex) else render json: { message: "Failure initializing app instance", status: 500 }, status: 500 end end end |
#instance_user ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'app/controllers/zuora_connect/static_controller.rb', line 76 def instance_user ZuoraConnect::AppInstance.read_master_db do ZuoraConnect.logger.with_fields = {} if ZuoraConnect.logger.is_a?(Ougai::Logger) Rails.logger.with_fields = {} if Rails.logger.is_a?(Ougai::Logger) if defined?(ElasticAPM) && ElasticAPM.running? && ElasticAPM.respond_to?(:set_label) ElasticAPM.set_label(:trace_id, request.uuid) end unless params[:id].present? render json: { status: 400, message: 'No app instance id provided' }, status: :bad_request return end @appinstance = ZuoraConnect::AppInstance.find(params[:id]).new_session end zuora_client = @appinstance.send(ZuoraConnect::AppInstance::LOGIN_TENANT_DESTINATION).client client_describe, = zuora_client.rest_call( url: zuora_client.rest_endpoint('genesis/user/info').gsub('v1/', ''), session_type: zuora_client.class == ZuoraAPI::Oauth ? :bearer : :basic ) render json: { status: 200, message: 'Success', user_id: client_describe['coreUserId'], username: client_describe['username'], email: client_describe['workEmail'] }, status: 200 rescue ActiveRecord::RecordNotFound render json: { status: 400, message: 'No app instance found' }, status: :bad_request rescue StandardError => e Rails.logger.error('Error occurred getting user details', e) render json: { status: 500, message: 'Failed to get user details' }, status: 500 end |
#provision ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/zuora_connect/static_controller.rb', line 54 def provision create_new_instance unless performed? render json: { status: 200, message: 'Success', app_instance_id: @appinstance.id }, status: 200 end rescue StandardError => e = 'Failed to provision new instance' if performed? Rails.logger.error("#{}: #{performed?}", e) else Rails.logger.error(, e) render json: { status: 500, message: }, status: 500 end end |