public dynamic Push(string deviceId, PushbulletPushType type, string title, string body)
        {
            var response = type != PushbulletPushType.File
                                        ? SendText(deviceId, type, title, body)
                                        : SendFile(deviceId, body);
            var responseString = HandleResponse(response);

            return(JObject.Parse(responseString));
        }
        private HttpResponseMessage SendText(string deviceId, PushbulletPushType type, string title, string content)
        {
            var postData = new KeyValuePairList <string, string>
            {
                { "device_iden", deviceId },
                { "type", type.ToString().ToLowerInvariant() },
                {
                    type != PushbulletPushType.Address
                                                ? "title"
                                                : "name",
                    title
                }
            };

            switch (type)
            {
            case PushbulletPushType.Note:
                postData.Add("body", content);
                break;

            case PushbulletPushType.Link:
                postData.Add("url", content);
                break;

            case PushbulletPushType.Address:
                postData.Add("address", content);
                break;

            case PushbulletPushType.List:
                foreach (var item in content.Split(';'))
                {
                    postData.Add("items", item);
                }
                break;
            }
            using (var postContent = new FormUrlEncodedContent(postData))
            {
                return(_client.PostAsync(PushbulletApiConstants.PushesUrl, postContent).Result);
            }
        }
 private static string GetIconData(PushbulletPushType type)
 {
     return((string)Application.Current.Resources[type + "IconData"]);
 }
 private static Brush GetIconBackground(PushbulletPushType type)
 {
     return((Brush)Application.Current.Resources[type + "IconBackground"]);
 }
Example #5
0
 public void SendPush(string deviceId, PushbulletPushType type, string title, string body)
 {
     throw new System.NotImplementedException();
 }
Example #6
0
 public async void SendPush(string deviceId, PushbulletPushType type, string title, string body)
 {
     EnsureClient();
     _client.Push(deviceId, type, title, body);
 }