houdini/app/controllers/api/nonprofits_controller.rb

32 lines
1.5 KiB
Ruby
Raw Normal View History

2020-04-21 18:47:49 +00:00
# frozen_string_literal: true
2020-06-12 20:03:43 +00:00
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
2020-04-21 18:47:49 +00:00
class Api::NonprofitsController < Api::ApiController
2020-04-10 19:51:34 +00:00
# requires :nonprofit, type: Hash do
# requires :name, type: String, desc: 'Organization Name', allow_blank: false, documentation: { param_type: 'body' }
# requires :zip_code, type: String, allow_blank: false, desc: 'Organization Address ZIP Code', documentation: { param_type: 'body' }
# requires :state_code, type: String, allow_blank: false, desc: 'Organization Address State Code', documentation: { param_type: 'body' }
# requires :city, type: String, allow_blank: false, desc: 'Organization Address City', documentation: { param_type: 'body' }
# end
# requires :user, type: Hash do
# requires :name, type: String, desc: 'Full name', allow_blank: false, documentation: { param_type: 'body' }
# requires :email, type: String, desc: 'Username', allow_blank: false, documentation: { param_type: 'body' }
# requires :password, type: String, desc: 'Password', allow_blank: false, is_equal_to: :password_confirmation, documentation: { param_type: 'body' }
def create
2020-04-21 18:47:49 +00:00
@nonprofit = Nonprofit.new(clean_params.merge({user_id: current_user_id}))
@nonprofit.save!
render status: :created
2020-04-10 19:51:34 +00:00
end
2020-04-17 20:30:54 +00:00
private
2020-04-21 18:47:49 +00:00
2020-04-10 19:51:34 +00:00
def clean_params
2020-04-21 18:47:49 +00:00
params.permit(:name, :zip_code, :state_code, :city, :phone, :email, :website)
2020-04-10 19:51:34 +00:00
end
end