-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathopportunities_controller.rb
More file actions
49 lines (43 loc) · 1.14 KB
/
opportunities_controller.rb
File metadata and controls
49 lines (43 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module MarketingRedesign
class OpportunitiesController < BaseController
HUB_CONVERSION_POINT = "Upcase: Contact Us".freeze
HUB_PROJECT_TYPE = "Team Training / Mentoring".freeze
def new
end
def create
Hub::Opportunities.create({
**opportunity_params,
conversion_point: HUB_CONVERSION_POINT,
project_type: HUB_PROJECT_TYPE,
inbound: true
})
redirect_to(
{action: :show}
)
end
def show
end
private
def opportunity_params
params.require(:opportunity).permit(
:contact_first_name,
:contact_last_name,
:email,
:company_name,
:contact_job_title
)
.then { combine_contact_name_params(_1) }
end
# @param params [ActionController::Parameters]
# @return [ActionController::Parameters]
def combine_contact_name_params(params)
params = params.dup
contact_name = [
params.delete(:contact_first_name),
params.delete(:contact_last_name)
].compact_blank.join(" ")
params[:contact_name] = contact_name if contact_name.present?
params
end
end
end