Skip to content

Commit

Permalink
feat(invites): resource (#792)
Browse files Browse the repository at this point in the history
* feat(invites): resource

* feat(invites): +JsDoc on invites

---------

Co-authored-by: Danny Gauthier <[email protected]>
Co-authored-by: Felix <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2024
1 parent 5899382 commit 478d2d7
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/resources/Invites/Invites.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export interface AuthInviteModel {
/**
* Invite ID.
*/
id: string;
/**
* Invite group name.
*/
displayName: string;
/**
* Organizations array will always have only one item.
*/
organizations: Array<{
/**
* Org ID where the user is invited in a group.
*/
id: string;
/**
* Org ID where the user is invited in a group.
*/
displayName: string;
}>;
}
12 changes: 12 additions & 0 deletions src/resources/Invites/Invites.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Resource from '../Resource.js';
import {AuthInviteModel} from './Invites.model.js';

export default class Invites extends Resource {
static baseUrl = '/rest/invites';
/**
* Lists groups current user is invited too.
*/
list() {
return this.api.get<AuthInviteModel[]>(Invites.baseUrl);
}
}
2 changes: 2 additions & 0 deletions src/resources/Invites/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './Invites.model.js';
export * from './Invites.js';
26 changes: 26 additions & 0 deletions src/resources/Invites/tests/Invites.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import API from '../../../APICore.js';
import Invites from '../Invites.js';
jest.mock('../../../APICore.js');

const APIMock: jest.Mock<API> = API as any;

describe('Invites', () => {
let invites: Invites;

const api = new APIMock() as jest.Mocked<API>;
const serverlessApi = new APIMock() as jest.Mocked<API>;

beforeEach(() => {
jest.clearAllMocks();
invites = new Invites(api, serverlessApi);
});

describe('list', () => {
it('should make a GET call with all parameters', () => {
invites.list();

expect(api.get).toHaveBeenCalledTimes(1);
expect(api.get).toHaveBeenCalledWith(Invites.baseUrl);
});
});
});
3 changes: 3 additions & 0 deletions src/resources/PlatformResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Index from './Indexes/Indexes.js';
import InProductExperiences from './InProductExperiences/InProductExperiences.js';
import InsightPanelConfig from './InsightPanelConfigs/InsightPanelConfig.js';
import InsightPanelInterface from './InsightPanelInterfaces/InsightPanelInterface.js';
import Invites from './Invites/Invites.js';
import IPXInterface from './IPXInterfaces/IPXInterface.js';
import License from './License/License.js';
import Limits from './Limits/Limits.js';
Expand Down Expand Up @@ -71,6 +72,7 @@ const resourcesMap: Array<{key: string; resource: typeof Resource}> = [
{key: 'index', resource: Index},
{key: 'insightPanelConfig', resource: InsightPanelConfig},
{key: 'insightPanelInterface', resource: InsightPanelInterface},
{key: 'invites', resource: Invites},
{key: 'ipx', resource: InProductExperiences},
{key: 'ipxInterface', resource: IPXInterface},
{key: 'license', resource: License},
Expand Down Expand Up @@ -130,6 +132,7 @@ class PlatformResources {
index: Index;
insightPanelConfig: InsightPanelConfig;
insightPanelInterface: InsightPanelInterface;
invites: Invites;
ipx: InProductExperiences;
ipxInterface: IPXInterface;
license: License;
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export * from './Indexes/index.js';
export * from './InProductExperiences/index.js';
export * from './InsightPanelConfigs/index.js';
export * from './InsightPanelInterfaces/index.js';
export * from './Invites/index.js';
export * from './IPXInterfaces/index.js';
export * from './License/index.js';
export * from './Limits/index.js';
Expand Down

0 comments on commit 478d2d7

Please sign in to comment.