Sha256: 0964647e1b5a3f94ceb121a71e234dba7249501f5db296ba63cad12004b1572a

Contents?: true

Size: 1.81 KB

Versions: 51

Compression:

Stored size: 1.81 KB

Contents

module ZuoraConnect
  class StaticController < ApplicationController
    before_action :authenticate_connect_app_request, :except => [:metrics, :health, :initialize_app]
    before_action :clear_connect_app_session,        :only =>   [:metrics, :health, :initialize_app]
    after_action :persist_connect_app_session,       :except => [:metrics, :health, :initialize_app]
    
    skip_before_action :verify_authenticity_token, :only => [:initialize_app]

    def metrics
      type = params[:type].present? ? params[:type] : "versions"
      render json: ZuoraConnect::AppInstance.get_metrics(type).to_json, status: 200
    end

    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

    def initialize_app
      begin
        authenticate_connect_app_request
        @appinstance.new_session(:session => @appinstance.data_lookup(:session => session))
        render json: {
          message: "Success",
          status: 200
        }, status: 200
      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

    private

    def clear_connect_app_session
      Thread.current[:appinstance] = nil
      request.session_options[:skip] = true
    end

  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
zuora_connect-2.1.1 app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.60 app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.59 app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.58 app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57zb app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57za app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57z app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57y app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57x app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57w app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57v app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57u app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57t app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57s app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57r app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57q app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57p app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57o app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57n app/controllers/zuora_connect/static_controller.rb
zuora_connect-2.0.57m app/controllers/zuora_connect/static_controller.rb