Skip to content

Commit 21952c7

Browse files
authored
Merge pull request #49 from CloudBoltSoftware/feature/ENG-23580-api-helper-custom-forms-phase1
ENG-23580 initial api helper for custom forms
2 parents a2cd169 + 0fb9dbf commit 21952c7

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudbolt/cb-api-helper",
3-
"version": "0.5.3",
3+
"version": "0.5.4",
44
"scripts": {
55
"co:login": "aws sso login && aws codeartifact login --tool npm --repository cloudbolt-npm --domain cloudbolt --domain-owner 499620025628",
66
"husky:install": "husky install",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import crud from '../../../crudOperations'
2+
3+
const URL = 'v3/cmp/customForms'
4+
5+
export default {
6+
/**
7+
* Retrieve a list of existing Custom Forms
8+
* @param options anything parsable by URLSearchParams. See useful options here https://docs.cloudbolt.io/articles/#!cloudbolt-latest-docs/api-conventions/a/h2__904191799
9+
* @returns {Promise} resolves with a list of existing Branded Portals
10+
*/
11+
list: (options) => crud.getItems(URL, options),
12+
13+
/**
14+
* Retrieve an existing Custom Form by id
15+
* @param {string} id or global_id
16+
* @returns {Promise} resolves with a cloudbolt API Response object of the Custom Form object
17+
*/
18+
get: (id) => crud.getItemById(URL, id)
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { baseApi } from '../../../baseApi'
2+
import CustomFormsService from './CustomFormsService'
3+
4+
test('list calls the correct endpoint', async () => {
5+
const mockFn = jest.spyOn(baseApi, 'get').mockResolvedValue({
6+
data: { hello: 'world' }
7+
})
8+
await CustomFormsService.list()
9+
expect(mockFn).toHaveBeenCalledWith('/v3/cmp/customForms/')
10+
})
11+
12+
test('get calls the correct endpoint', async () => {
13+
const mockFn = jest.spyOn(baseApi, 'get').mockResolvedValue({
14+
data: { hello: 'world' }
15+
})
16+
await CustomFormsService.get('customForm-id')
17+
expect(mockFn).toHaveBeenCalledWith('/v3/cmp/customForms/customForm-id/')
18+
})

src/api/services/v3/cmp/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import BlueprintsService from './BlueprintsService'
66
import BrandedPortalsService from './BrandedPortalsService'
77
import CatalogBlueprintsService from './CatalogBlueprintsService'
88
import CitService from './CitService'
9+
import CustomFormsService from './CustomFormsService'
910
import EnvironmentsService from './EnvironmentsService'
1011
import EulaService from './EulaService'
1112
import GroupsService from './GroupsService'
@@ -47,6 +48,7 @@ export default {
4748
brandedPortals: BrandedPortalsService,
4849
catalogBlueprints: CatalogBlueprintsService,
4950
citService: CitService,
51+
customForms: CustomFormsService,
5052
environments: EnvironmentsService,
5153
eula: EulaService,
5254
groups: GroupsService,

src/api/services/v3/cmp/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const services = [
1515
'brandedPortals',
1616
'catalogBlueprints',
1717
'citService',
18+
'customForms',
1819
'environments',
1920
'eula',
2021
'groups',

0 commit comments

Comments
 (0)