Class: Api::V1::AppInstanceController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Api::V1::AppInstanceController
- Defined in:
- app/controllers/zuora_connect/api/v1/app_instance_controller.rb
Instance Method Summary collapse
Instance Method Details
#cache_bust ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/zuora_connect/api/v1/app_instance_controller.rb', line 44 def cache_bust if defined?(Redis.current) @appinstance.fetch_connect_data #Fetch data and set in database if kms key is used @appinstance.cache_app_instance(force_cache: true) #Update cache in redis Redis.current.del("AppInstance:#{@appinstance.id}") @appinstance.cache_app_instance(force_cache: true) #Update cache in redis #TODO: Could be a chance another thread cache back to old value, but will eventually cache will get consitent, move to nolonger needing redis cache respond_to do |format| format.json {render json: {}, status: :ok} end else respond_to do |format| format.json {render json: {}, status: :bad_request} end end end |
#create ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/zuora_connect/api/v1/app_instance_controller.rb', line 6 def create Apartment::Tenant.create(session['AppInstance']) respond_to do |format| format.json {render :json => "Created"} end end |
#drop ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/zuora_connect/api/v1/app_instance_controller.rb', line 13 def drop instance_id = @appinstance.id if session["#{instance_id}::destroy"] && ZuoraConnect::AppInstance.where(:id => instance_id).size != 0 if @appinstance.drop_instance ZuoraConnect::AppInstance.destroy(instance_id) msg = Apartment::Tenant.drop(instance_id) respond_to do |format| if msg..present? format.json {render json: {"message" => msg.}, status: :bad_request } else format.json {render json: {}, status: :ok} end end else respond_to do |format| format.json {render json: {"message" => @appinstance.}, status: :bad_request} end end else respond_to do |format| format.json { render json: { "message" => "Unauthorized"}, status: :unauthorized } end end end |
#status ⇒ Object
39 40 41 42 |
# File 'app/controllers/zuora_connect/api/v1/app_instance_controller.rb', line 39 def status end |