2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2017-09-06 06:39:02 +00:00
|
|
|
|
|
|
|
class Integration::IdoitController < ApplicationController
|
2020-03-19 09:39:51 +00:00
|
|
|
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: {
|
2018-12-19 17:31:51 +00:00
|
|
|
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: {
|
2018-12-19 17:31:51 +00:00
|
|
|
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])
|
2018-07-26 14:24:31 +00:00
|
|
|
ticket.with_lock do
|
2020-03-19 09:39:51 +00:00
|
|
|
authorize!(ticket, :show?)
|
2018-07-26 14:24:31 +00:00
|
|
|
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
|