2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module RenderServiceResults
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def success_response(result)
|
|
|
|
render({
|
2023-03-04 22:38:38 +05:30
|
|
|
status: result[:http_status],
|
|
|
|
json: result[:body]
|
|
|
|
})
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def continue_polling_response
|
|
|
|
render({
|
2023-03-04 22:38:38 +05:30
|
|
|
status: :no_content,
|
|
|
|
json: {
|
|
|
|
status: _('processing'),
|
|
|
|
message: _('Not ready yet. Try again later.')
|
|
|
|
}
|
|
|
|
})
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def error_response(result)
|
|
|
|
render({
|
2023-03-04 22:38:38 +05:30
|
|
|
status: result[:http_status] || :bad_request,
|
|
|
|
json: { status: result[:status], message: result[:message] }
|
|
|
|
})
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
end
|