Skip to content

Commit

Permalink
feat(TSP-414): add listByProject endpoint to platform client (#858)
Browse files Browse the repository at this point in the history
* feat(TSP-414): add listByProject endpoint to platform client

* feat(TSP-414): moved projectIds from resultTemplate

* feat(TSP-414): moved projectIds from ipx resultTemplate

* feat(TSP-414): changed variable name

* feat(TSP-414): added interface

* feat(TSP-414): removed unused models

* feat(TSP-414): added ut

* Update src/resources/InProductExperiences/tests/InProductExperiences.spec.ts

Co-authored-by: Gaël Dostie <35579930+gdostie@users.noreply.github.com>

---------

Co-authored-by: Gaël Dostie <35579930+gdostie@users.noreply.github.com>
  • Loading branch information
mtmustapha-coveo and gdostie authored Sep 26, 2024
1 parent ae11c6e commit fe32d54
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/resources/InProductExperiences/InProductExperiences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
UpdateInProductExperienceModel,
InProductExperienceLoader,
CreateInProductExperienceResponse,
InProductExperienceProjectsModel,
} from './InProductExperiencesInterfaces.js';

/**
Expand Down Expand Up @@ -44,6 +45,12 @@ export default class InProductExperiences extends Resource {
return this.api.get<InProductExperienceModel[]>(this.buildPath(`${InProductExperiences.ipxBaseUrl}s`, {name}));
}

listByProject(projectId?: string) {
return this.api.get<InProductExperienceProjectsModel[]>(
this.buildPath(`${InProductExperiences.ipxBaseUrl}s/projectid`, {projectid: projectId}),
);
}

getLoader(ipxId: string, access_token?: string) {
return this.api.get<InProductExperienceLoader>(
this.buildPath(`${InProductExperiences.baseUrl}/${ipxId}/inappwidget/loader`, {access_token}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {ProjectResourceModel} from '../Projects/ProjectInterfaces.js';
import {RestTokenParams} from '../Search/index.js';
import {CSSResourceModel, JavaScriptResourceModel} from '../SearchPages/index.js';

Expand Down Expand Up @@ -84,6 +85,8 @@ export interface InProductExperienceModel extends SharedInProductExperienceModel
token: RestTokenParams;
}

export interface InProductExperienceProjectsModel extends InProductExperienceModel, ProjectResourceModel {}

export interface CreateUpdateInProductExperienceModel extends SharedInProductExperienceModel {
/**
* The CSS classes of the button.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ describe('InProductExperiences', () => {
});
});

describe('listByProject', () => {
it('should make a GET call to the specific Project In-Product Experiences url', async () => {
await ipxService.listByProject();
expect(api.get).toHaveBeenCalledTimes(1);
expect(api.get).toHaveBeenCalledWith(`${InProductExperiences.ipxBaseUrl}s/projectid`);
});
});

describe('create', () => {
it('should make a POST call to the In-Product Experiences base url', () => {
const ipxModel: CreateInProductExperienceModel = {
Expand Down
14 changes: 14 additions & 0 deletions src/resources/Projects/ProjectInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,17 @@ export interface UpdatedProjectResourceAssociationsModel {
*/
removals: UpdatedProjectAssociationsModel;
}

export interface ListResourceByProjectParams {
/**
* Project identifier for which resources are to be fetched
*/
projectId: string;
}

export interface ProjectResourceModel {
/**
* Ids of projects associated to this resource
*/
projectIds: string[];
}

0 comments on commit fe32d54

Please sign in to comment.