Skip to content

Commit

Permalink
Merge branch 'next' into nv-2795-allow-to-create-integration-for-novu…
Browse files Browse the repository at this point in the history
…-sms-and-email-providers
  • Loading branch information
BiswaViraj authored Sep 11, 2023
2 parents 3136baf + ca8db4c commit a7f7f70
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,9 @@ await novu.integrations.delete("integrationId")

// get novu in-app status
await novu.integrations.getInAppStatus()

// set an integration as primary
await novu.integrations.setIntegrationAsPrimary("integrationId")
```

### Feeds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface IIntegrations {
update(integrationId: string, data: IIntegrationsUpdatePayload);
delete(integrationId: string);
getInAppStatus();
setIntegrationAsPrimary(integrationId: string);
}

export interface IIntegrationsPayload extends IIntegrationsUpdatePayload {
Expand Down
21 changes: 21 additions & 0 deletions packages/node/src/lib/integrations/integrations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,25 @@ describe('test use of novus node package - Integrations class', () => {
'/integrations/INTEGRATION_ID'
);
});

test('should set the integration as primary', async () => {
mockedAxios.post.mockResolvedValue({});

await novu.integrations.setIntegrationAsPrimary('INTEGRATION_ID');

expect(mockedAxios.post).toHaveBeenCalled();
expect(mockedAxios.post).toHaveBeenCalledWith(
'/integrations/INTEGRATION_ID/set-primary',
{}
);
});

test('should get the in-app status of the integration', async () => {
mockedAxios.post.mockResolvedValue({});

await novu.integrations.getInAppStatus();

expect(mockedAxios.get).toHaveBeenCalled();
expect(mockedAxios.get).toHaveBeenCalledWith('/integrations/in-app/status');
});
});
21 changes: 16 additions & 5 deletions packages/node/src/lib/integrations/integrations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ChannelTypeEnum } from '@novu/shared';
import { WithHttp } from '../novu.interface';
import {
IIntegrations,
IIntegrationsPayload,
IIntegrationsUpdatePayload,
} from './integrations.interface';
import { WithHttp } from '../novu.interface';

export class Integrations extends WithHttp implements IIntegrations {
async getAll() {
Expand All @@ -14,6 +15,10 @@ export class Integrations extends WithHttp implements IIntegrations {
return await this.http.get('/integrations/active');
}

async getInAppStatus() {
return await this.http.get('/integrations/in-app/status');
}

/**
* @param {string} providerId - Id of the provider to get status
*/
Expand Down Expand Up @@ -44,14 +49,20 @@ export class Integrations extends WithHttp implements IIntegrations {
});
}

/**
* @param {string} integrationId - integrationId of the integration to set it as primary
*/
async setIntegrationAsPrimary(integrationId: string) {
return await this.http.post(
`/integrations/${integrationId}/set-primary`,
{}
);
}

/**
* @param {string} integrationId - integrationId of the integration to delete
*/
async delete(integrationId: string) {
return await this.http.delete(`/integrations/${integrationId}`);
}

async getInAppStatus() {
return await this.http.get('/integrations/in-app/status');
}
}

0 comments on commit a7f7f70

Please sign in to comment.