-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added billing profile controller for api
- Loading branch information
Oleg Hasjanov
authored and
Oleg Hasjanov
committed
Feb 8, 2024
1 parent
2b4179a
commit fe6e8b8
Showing
2 changed files
with
34 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Api | ||
module V1 | ||
class BillingProfilesController < ApplicationController | ||
before_action :authenticate_user! | ||
respond_to :json | ||
|
||
skip_before_action :verify_authenticity_token | ||
|
||
def index | ||
@billing_profiles = current_user.billing_profiles | ||
|
||
render json: { billing_profiles: @billing_profiles } | ||
end | ||
|
||
def update | ||
@billing_profile = current_user.billing_profiles.find(params[:id]) | ||
|
||
if @billing_profile.update(billing_profile_params) | ||
render json: { billing_profile: @billing_profile } | ||
else | ||
render json: { errors: @billing_profile.errors }, status: 422 | ||
end | ||
end | ||
|
||
private | ||
|
||
def billing_profile_params | ||
params.require(:billing_profile).permit(:name, :vat_code, :street, :city, :state, :postal_code, | ||
:alpha_two_country_code, :uuid) | ||
end | ||
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