-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from poojakarma/notification_integration_onAf…
…terCohortMemberAdd Notification integration on after cohort member added and learner added
- Loading branch information
Showing
6 changed files
with
101 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { HttpService } from "@nestjs/axios"; | ||
import { Injectable } from "@nestjs/common"; | ||
import { ConfigService } from "@nestjs/config"; | ||
|
||
import axios, { AxiosRequestConfig } from "axios"; | ||
|
||
@Injectable() | ||
export class NotificationRequest { | ||
private readonly url: string; | ||
constructor(private readonly configService: ConfigService, | ||
private readonly httpService: HttpService) { | ||
this.url = this.configService.get('NOTIFICATION_URL'); | ||
} | ||
|
||
async sendNotification(body) { | ||
const data = JSON.stringify(body); | ||
const config: AxiosRequestConfig<any> = { | ||
method: 'POST', | ||
maxBodyLength: Infinity, | ||
url: this.url, | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
data: data, | ||
}; | ||
try { | ||
const response = await axios.request(config) | ||
console.log(response.data); | ||
return response.data; | ||
} catch (error) { | ||
// throw error; | ||
return null | ||
} | ||
} | ||
} |