This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor ad remove coverage folder, see coverage percentage in GitHub…
… Actions build_and_test or generate it in your environment
- Loading branch information
1 parent
5c1cf94
commit e7286fe
Showing
8 changed files
with
662 additions
and
236 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::V1::ApplicationController < ActionController::API | ||
def unauthorized? | ||
return unauthorized_response unless find_user_by_header | ||
end | ||
|
||
def ticket_founded? | ||
@ticket = Ticket.find_by(user_id: @user.id, status: :active) | ||
return ticket_not_found_response unless @ticket.present? | ||
end | ||
|
||
private | ||
def find_user_by_header | ||
return unless request.headers["X-API-KEY"].present? | ||
api_key = request.headers["X-API-KEY"] | ||
@user = User.find_by(api_key: api_key) | ||
return unless @user.present? | ||
@user.api_secret == request.headers["X-API-SECRET"] | ||
end | ||
|
||
def confirmation_hash_founded? | ||
return confirmation_hash_not_found_response unless confirmation_hash.present? | ||
end | ||
|
||
def confirmation_hash | ||
@confirmation_hash ||= block_confirmation_params[:user_confirmation_hash] | ||
end | ||
|
||
def confirmation_hash_not_found_response | ||
render json: { error: "Confirmation hash not found" }, status: :not_found | ||
end | ||
|
||
def ticket_not_found_response | ||
render json: { error: "Ticket not found" }, status: :not_found | ||
end | ||
|
||
def unauthorized_response | ||
render json: { error: "Unauthorized" }, status: :unauthorized | ||
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
Empty file.
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,5 +1,5 @@ | ||
{ | ||
"result": { | ||
"line": 80.9 | ||
"line": 81.24 | ||
} | ||
} |
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.