/
ChatworkNotifier.cs
36 lines (29 loc) · 1014 Bytes
/
ChatworkNotifier.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections.Generic;
using UniRx;
using UniRx.WebRequest;
namespace Assets.Notifier
{
public class ChatworkNotifier : NotifierBase
{
public string ApiToken { get; private set; }
public string RoomId { get; private set; }
public ChatworkNotifier(string apiToken, string roomId)
{
ApiToken = apiToken;
RoomId = roomId;
}
protected override IObservable<Unit> CreateNotifyObservable(string message)
{
var header = new Dictionary<string,string>()
{
{ "X-ChatWorkToken",ApiToken}
};
var data = new Dictionary<string, string>()
{
{ "body",message}
};
var request = ObservableWebRequest.Post("https://api.chatwork.com/v1/rooms/" + RoomId + "/messages", data, header);
return request.Do(UnityEngine.Debug.Log).AsUnitObservable();
}
}
}