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
cd0ad142
Commit
cd0ad142
authored
Oct 05, 2021
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Subscriptions hand raise lead API client
Changelog: added EE: true
parent
02e1be7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
ee/app/assets/javascripts/api/subscriptions_api.js
ee/app/assets/javascripts/api/subscriptions_api.js
+18
-0
ee/spec/frontend/api/subscriptions_api_spec.js
ee/spec/frontend/api/subscriptions_api_spec.js
+54
-0
No files found.
ee/app/assets/javascripts/api/subscriptions_api.js
View file @
cd0ad142
...
...
@@ -3,6 +3,7 @@ import axios from '~/lib/utils/axios_utils';
const
SUBSCRIPTIONS_PATH
=
'
/api/:version/subscriptions
'
;
const
EXTEND_REACTIVATE_TRIAL_PATH
=
'
/-/trials/extend_reactivate
'
;
const
CREATE_HAND_RAISE_LEAD_PATH
=
'
/-/trials/create_hand_raise_lead
'
;
const
TRIAL_EXTENSION_TYPE
=
Object
.
freeze
({
extended
:
1
,
...
...
@@ -41,3 +42,20 @@ export const extendTrial = async (namespaceId) => {
export
const
reactivateTrial
=
async
(
namespaceId
)
=>
{
return
updateTrial
(
namespaceId
,
TRIAL_EXTENSION_TYPE
.
reactivated
);
};
export
const
sendHandRaiseLead
=
async
(
params
)
=>
{
const
url
=
buildApiUrl
(
CREATE_HAND_RAISE_LEAD_PATH
);
const
formParams
=
{
namespace_id
:
params
.
namespaceId
,
company_name
:
params
.
companyName
,
company_size
:
params
.
companySize
,
first_name
:
params
.
firstName
,
last_name
:
params
.
lastName
,
phone_number
:
params
.
phoneNumber
,
country
:
params
.
country
,
state
:
params
.
state
,
comment
:
params
.
comment
,
};
return
axios
.
post
(
url
,
formParams
);
};
ee/spec/frontend/api/subscriptions_api_spec.js
0 → 100644
View file @
cd0ad142
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
*
as
SubscriptionsApi
from
'
ee/api/subscriptions_api
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
httpStatus
from
'
~/lib/utils/http_status
'
;
describe
(
'
SubscriptionsApi
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
});
afterEach
(()
=>
{
mock
.
restore
();
});
describe
(
'
Hand raise leads
'
,
()
=>
{
describe
(
'
sendHandRaiseLead
'
,
()
=>
{
const
expectedUrl
=
`/-/trials/create_hand_raise_lead`
;
const
params
=
{
namespaceId
:
1000
,
companyName
:
'
ACME
'
,
companySize
:
'
1-99
'
,
firstName
:
'
Joe
'
,
lastName
:
'
Doe
'
,
phoneNumber
:
'
1-234567890
'
,
country
:
'
US
'
,
state
:
'
CA
'
,
comment
:
'
A comment
'
,
};
const
formParams
=
{
namespace_id
:
1000
,
company_name
:
'
ACME
'
,
company_size
:
'
1-99
'
,
first_name
:
'
Joe
'
,
last_name
:
'
Doe
'
,
phone_number
:
'
1-234567890
'
,
country
:
'
US
'
,
state
:
'
CA
'
,
comment
:
'
A comment
'
,
};
it
(
'
sends hand raise lead parameters
'
,
async
()
=>
{
jest
.
spyOn
(
axios
,
'
post
'
);
mock
.
onPost
(
expectedUrl
).
replyOnce
(
httpStatus
.
OK
,
[]);
const
{
data
}
=
await
SubscriptionsApi
.
sendHandRaiseLead
(
params
);
expect
(
data
).
toEqual
([]);
expect
(
axios
.
post
).
toHaveBeenCalledWith
(
expectedUrl
,
formParams
);
});
});
});
});
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