-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
168 changed files
with
3,704 additions
and
2,705 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ APP_BASE_URL="localhost:3000" | |
# Mailer Configuration | ||
EMAIL_DELIVERY_METHOD='letter_opener' | ||
MAILER_SENDER="[email protected]" | ||
REPLY_TO_EMAIL="[email protected]" | ||
|
||
# SendGrid Email Configuration | ||
SENDGRID_USERNAME='apikey' | ||
|
@@ -36,6 +37,7 @@ SIDEKIQ_PASSWORD: <some_password> | |
# Stripe | ||
STRIPE_PUBLISHABLE_KEY="stripe_publishable_key" | ||
STRIPE_SECRET_KEY="stripe_secret_key" | ||
STRIPE_WEBHOOK_ENDPOINT_SECRET="stripe_webhook_endpoint_secret" | ||
|
||
#Wise | ||
WISE_API_URL="https://api.sandbox.transferwise.tech" | ||
|
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
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,6 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::V1::BaseController < ActionController::API | ||
include Authenticable | ||
include CurrentCompanyConcern | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::V1::TimesheetEntryController < Api::V1::BaseController | ||
include Timesheet | ||
|
||
before_action :ensure_project_member | ||
|
||
def create | ||
timesheet_entry = project.timesheet_entries.new(timesheet_entry_params) | ||
timesheet_entry.user = current_user | ||
timesheet_entry.save! | ||
render json: { | ||
notice: I18n.t("timesheet_entry.create.message"), | ||
entry: timesheet_entry.formatted_entry | ||
} | ||
end | ||
|
||
private | ||
|
||
def project_member | ||
ProjectMember.find_by(user_id: current_user.id, project_id: project.id) | ||
end | ||
|
||
def project | ||
@_project ||= current_company.projects.kept.find(params[:timesheet_entry][:project_id]) | ||
end | ||
|
||
def timesheet_entry_params | ||
params.require(:timesheet_entry).permit( | ||
:project_id, :duration, :work_date, :note, :bill_status) | ||
end | ||
|
||
def ensure_project_member | ||
return render json: { notice: "User is not a project member." }, status: :forbidden if project_member.blank? | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module Authenticable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :authenticate_token | ||
end | ||
|
||
def authenticate_token | ||
return render json: { status: 401, notice: "Invalid Token." }, status: 401 if current_user.blank? | ||
end | ||
|
||
private | ||
|
||
def current_user | ||
@current_user ||= User.find_by(token:) | ||
end | ||
|
||
def bearer_token | ||
pattern = /^Bearer / | ||
header = request.headers["Authorization"] | ||
header.gsub(pattern, "") if header && header.match(pattern) | ||
end | ||
|
||
def token | ||
if bearer_token.present? | ||
@_token = bearer_token | ||
elsif params[:auth_token].present? | ||
@_token = params[:auth_token] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module SetCurrentDetails | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action do | ||
Current.user = current_user | ||
Current.company = current_company | ||
end | ||
end | ||
end |
Oops, something went wrong.