Skip to content

Commit 43b8e59

Browse files
jjoshi-cbbernardthered
authored andcommitted
[CMP-150] Added: 1. CUIPortals API (list, get)
1 parent d6793aa commit 43b8e59

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed
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 CUIPortalsService from './CUIPortalsService'
3+
4+
test('list calls the correct endpoint', async () => {
5+
const mockFn = jest.spyOn(baseApi, 'get').mockResolvedValue({
6+
data: { hello: 'world' }
7+
})
8+
await CUIPortalsService.list()
9+
expect(mockFn).toHaveBeenCalledWith('/api/v3/cmp/cuiPortals/')
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 CUIPortalsService.get('cuiPortal-id')
17+
expect(mockFn).toHaveBeenCalledWith('/api/v3/cmp/cuiPortals/cuiPortal-id/')
18+
})
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 = 'api/v3/cmp/cuiPortals'
4+
5+
export default {
6+
/**
7+
* Retrieve a list of existing CUI Portals
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 CUI Portal by id
15+
* @param {string} id or global_id
16+
* @returns {Promise} resolves with a cloudbolt API Response object of the CUI Portal object
17+
*/
18+
get: (id) => crud.getItemById(URL, id)
19+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import BlueprintCategoriesService from './BlueprintCategoriesService'
55
import BlueprintFiltersService from './BlueprintFiltersService'
66
import BlueprintsService from './BlueprintsService'
77
import BrandedPortalsService from './BrandedPortalsService'
8+
import CUIPortalsService from './CUIPortalsService'
89
import CatalogBlueprintsService from './CatalogBlueprintsService'
910
import CitService from './CitService'
1011
import CustomFormsService from './CustomFormsService'
@@ -52,6 +53,7 @@ export default {
5253
blueprintFilters: BlueprintFiltersService,
5354
blueprints: BlueprintsService,
5455
brandedPortals: BrandedPortalsService,
56+
cuiPortals: CUIPortalsService,
5557
catalogBlueprints: CatalogBlueprintsService,
5658
citService: CitService,
5759
customForms: CustomFormsService,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const services = [
1414
'blueprintFilters',
1515
'blueprints',
1616
'brandedPortals',
17+
'cuiPortals',
1718
'catalogBlueprints',
1819
'citService',
1920
'customForms',

0 commit comments

Comments
 (0)