Skip to content

Instantly share code, notes, and snippets.

@Tetsuya-Minase
Created June 27, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tetsuya-Minase/25bb27de0ed971efd7ab122baa32cbe8 to your computer and use it in GitHub Desktop.
Save Tetsuya-Minase/25bb27de0ed971efd7ab122baa32cbe8 to your computer and use it in GitHub Desktop.
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