Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
473bf37c
Commit
473bf37c
authored
Sep 05, 2019
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API client to talk with subscription portal
parent
67e35588
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletion
+56
-1
ee/app/services/gitlab_subscriptions/create_lead_service.rb
ee/app/services/gitlab_subscriptions/create_lead_service.rb
+13
-1
ee/lib/gitlab/subscription_portal/client.rb
ee/lib/gitlab/subscription_portal/client.rb
+43
-0
No files found.
ee/app/services/gitlab_subscriptions/create_lead_service.rb
View file @
473bf37c
...
...
@@ -3,7 +3,19 @@
module
GitlabSubscriptions
class
CreateLeadService
def
execute
(
company_params
)
{
success:
true
}
response
=
subscription_app_client
.
create_trial_account
(
company_params
)
if
response
.
success
{
success:
true
}
else
{
success:
false
,
errors:
response
.
data
&
.
errors
}
end
end
private
def
subscription_app_client
Gitlab
::
SubscriptionPortal
::
Client
.
new
end
end
end
ee/lib/gitlab/subscription_portal/client.rb
0 → 100644
View file @
473bf37c
# frozen_string_literal: true
module
Gitlab
module
SubscriptionPortal
class
Client
def
create_trial_account
(
params
)
parse_response
(
Gitlab
::
HTTP
.
post
(
"
#{
base_url
}
/trials"
,
body:
params
.
to_json
,
headers:
headers
))
end
private
def
base_url
EE
::
SUBSCRIPTIONS_URL
end
def
headers
{
"Accept"
=>
'application/json'
,
"X-Admin-Email"
=>
ENV
[
'SUBSCRIPTION_PORTAL_ADMIN_EMAIL'
],
"X-Admin-Token"
=>
ENV
[
'SUBSCRIPTION_PORTAL_ADMIN_TOKEN'
]
}
end
def
parse_response
(
http_response
)
response
=
Hashie
::
Mash
.
new
(
success:
false
)
case
http_response
.
response
when
Net
::
HTTPSuccess
response
.
success
=
true
response
.
data
=
JSON
.
parse
(
response
.
body
)
when
Net
::
HTTPUnprocessableEntity
response
.
data
=
JSON
.
parse
(
response
.
body
)
rescue
nil
else
response
.
data
=
{
errors:
"HTTP status code:
#{
http_response
.
code
}
"
}
end
response
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment