Commit e9a70c3a authored by Illya Klymov's avatar Illya Klymov

Merge branch '334211-subscriptions-api' into 'master'

Subscriptions hand raise lead API client

See merge request gitlab-org/gitlab!71723
parents 32c8651d 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);
};
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);
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment