debian-mirror-gitlab/app/services/concerns/alert_management/responses.rb

27 lines
708 B
Ruby
Raw Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
module AlertManagement
# Module to hold common response logic for AlertManagement services.
module Responses
def success(alerts)
ServiceResponse.success(payload: { alerts: Array(alerts) })
end
def bad_request
ServiceResponse.error(message: 'Bad Request', http_status: :bad_request)
end
def unauthorized
ServiceResponse.error(message: 'Unauthorized', http_status: :unauthorized)
end
def unprocessable_entity
ServiceResponse.error(message: 'Unprocessable Entity', http_status: :unprocessable_entity)
end
def forbidden
ServiceResponse.error(message: 'Forbidden', http_status: :forbidden)
end
end
end