-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: apply a wide variety of manual fixes for rubocop rules
- Loading branch information
tamsin johnson
committed
Jun 10, 2020
1 parent
07e4727
commit 94556b3
Showing
20 changed files
with
167 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,68 @@ | ||
module Hyrax | ||
module API | ||
# Generate appropriate json response for +response_type+ | ||
|
||
def self.generate_response_body(response_type: :success, message: nil, options: {}) | ||
json_body = default_responses[response_type].merge(options) | ||
json_body[:description] = message if message | ||
json_body | ||
end | ||
|
||
# Default (json) responses for various response types | ||
def self.default_responses | ||
DEFAULT_RESPONSES = | ||
{ | ||
success: { | ||
code: 200, | ||
message: "Request Succeeded", | ||
description: I18n.t('hyrax.api.success.default') | ||
}, | ||
}.freeze, | ||
deleted: { | ||
code: 200, | ||
message: I18n.t('hyrax.api.deleted.default') | ||
}, | ||
}.freeze, | ||
created: { | ||
code: 201, | ||
message: "Created the Resource" | ||
}, | ||
}.freeze, | ||
accepted: { | ||
code: 202, | ||
message: "Accepted", | ||
description: I18n.t('hyrax.api.accepted.default') | ||
}, | ||
}.freeze, | ||
bad_request: { | ||
code: 400, | ||
message: "Bad Request", | ||
description: I18n.t('hyrax.api.bad_request.default') | ||
}, | ||
}.freeze, | ||
unauthorized: { | ||
code: 401, | ||
message: "Authentication Required", | ||
description: I18n.t('hyrax.api.unauthorized.default') | ||
}, | ||
}.freeze, | ||
forbidden: { | ||
code: 403, | ||
message: "Not Authorized", | ||
description: I18n.t('hyrax.api.forbidden.default') | ||
}, | ||
}.freeze, | ||
not_found: { | ||
code: 404, | ||
message: "Resource not found", | ||
description: I18n.t('hyrax.api.not_found.default') | ||
}, | ||
}.freeze, | ||
unprocessable_entity: { | ||
code: 422, | ||
message: "Unprocessable Entity", | ||
description: I18n.t('hyrax.api.unprocessable_entity.default'), | ||
errors: {} | ||
}, | ||
}.freeze, | ||
internal_error: { | ||
code: 500, | ||
message: "Internal Server Error", | ||
description: I18n.t('hyrax.api.internal_error.default') | ||
} | ||
} | ||
}.freeze | ||
}.freeze | ||
|
||
def self.generate_response_body(response_type: :success, message: nil, options: {}) | ||
json_body = default_responses[response_type].merge(options) | ||
json_body[:description] = message if message | ||
json_body | ||
end | ||
|
||
# Default (json) responses for various response types | ||
def self.default_responses | ||
DEFAULT_RESPONSES | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.