trabajo-afectivo/app/controllers/integration/idoit_controller.rb

52 lines
1.1 KiB
Ruby
Raw Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
2017-09-06 06:39:02 +00:00
class Integration::IdoitController < ApplicationController
prepend_before_action { authentication_check && authorize! }
2017-09-06 06:39:02 +00:00
def verify
response = ::Idoit.verify(params[:api_token], params[:endpoint], params[:client_id])
render json: {
result: 'ok',
2017-09-06 06:39:02 +00:00
response: response,
}
rescue => e
logger.error e
render json: {
result: 'failed',
message: e.message,
}
end
def query
response = ::Idoit.query(params[:method], params[:filter])
render json: {
result: 'ok',
2017-09-06 06:39:02 +00:00
response: response,
}
rescue => e
logger.error e
render json: {
result: 'failed',
message: e.message,
}
end
def update
params[:object_ids] ||= []
ticket = Ticket.find(params[:ticket_id])
ticket.with_lock do
authorize!(ticket, :show?)
ticket.preferences[:idoit] ||= {}
ticket.preferences[:idoit][:object_ids] = Array(params[:object_ids]).uniq
ticket.save!
end
2017-09-06 06:39:02 +00:00
render json: {
result: 'ok',
}
end
end