Created
June 27, 2019 14:34
-
-
Save Tetsuya-Minase/25bb27de0ed971efd7ab122baa32cbe8 to your computer and use it in GitHub Desktop.
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
import { HttpRequest } from '../../../infrastructure/http-request'; | |
import { InformSlackService } from '../inform-slack-service'; | |
import { inject, injectable } from 'inversify'; | |
import 'reflect-metadata'; | |
import { TYPES } from '../../../inversify.types'; | |
@injectable() | |
export class InformSlackServiceImpl implements InformSlackService { | |
private _httpRequest: HttpRequest; | |
private slackUrl = process.env.WEBHOOK; | |
constructor(@inject(TYPES.HttpRequest) httpRequest: HttpRequest) { | |
this._httpRequest = httpRequest; | |
} | |
public async informMessage(message: string) { | |
const param = { | |
url: this.slackUrl, | |
method: 'POST', | |
headers: { 'Content-Type': 'application/json' }, | |
json: { | |
channel: '#weather', | |
username: 'webhookbot', | |
text: message | |
} | |
}; | |
console.info('request param:', param); | |
await this._httpRequest.post(param); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment