static JsonObject JsonObj(CreateFeedRequest newFeed) { var jsonObj = new JsonObject(); jsonObj["template"] =SerializeTemplate(newFeed.Template); jsonObj["feed_url"] = newFeed.FeedUrl; jsonObj["broadcast"] = newFeed.BroadCast; return jsonObj; }
static JsonObject JsonObj(CreateFeedRequest newFeed) { var jsonObj = new JsonObject(); jsonObj["template"] = SerializeTemplate(newFeed.Template); jsonObj["feed_url"] = newFeed.FeedUrl; jsonObj["broadcast"] = newFeed.BroadCast; return(jsonObj); }
public void Execute(CreateFeedRequest request, Action<CreateFeedResponse> responseCallback, Action<Exception> exceptionCallback) { var webRequest = RequestBuilder.Build("https://go.urbanairship.com/api/feeds/"); webRequest.Method = "POST"; webRequest.ContentType = "application/json"; var asyncRequest = new AsyncRequest { WriteToRequest = stream => stream.WriteToStream(request.Serialize), Request = webRequest, ReadFromResponse = stream => responseCallback(CreateFeedResponseDeSerializer.DeSerialize(stream)), ExceptionCallback = exceptionCallback, }; asyncRequest.Execute(); }
public void Execute(CreateFeedRequest request, Action <CreateFeedResponse> responseCallback, Action <Exception> exceptionCallback) { var webRequest = RequestBuilder.Build("https://go.urbanairship.com/api/feeds/"); webRequest.Method = "POST"; webRequest.ContentType = "application/json"; var asyncRequest = new AsyncRequest { WriteToRequest = stream => stream.WriteToStream(request.Serialize), Request = webRequest, ReadFromResponse = stream => responseCallback(CreateFeedResponseDeSerializer.DeSerialize(stream)), ExceptionCallback = exceptionCallback, }; asyncRequest.Execute(); }
public void Simple() { var service = new CreateFeedService { RequestBuilder = ServerRequestBuilder.Instance }; var notification = new CreateFeedRequest { FeedUrl = "http://example.com/atom.xml", Template = new Template { FeedPayload = new FeedPayload { Badge = 1, Sound = "cat.caf", Alert = "New item from some place! {{ title }}" } }, BroadCast = true }; service.Execute(notification,Callback,ExceptionHandler.Handle); }
public void Simple() { var newFeed = new CreateFeedRequest { FeedUrl = "http://example.com/atom.", BroadCast = true, Template = new Template { FeedPayload = new FeedPayload { Alert = "MyAlert", Badge = 10, Sound = "MySound" }, Tags = new List<string> { "tag1", "tag2" } }, }; var text = newFeed.Serialize().FormatAsJson(); var expected = @" { 'template': { 'aps': { 'alert': 'MyAlert', 'badge': 10, 'sound': 'MySound' }, 'tags': [ 'tag1', 'tag2' ] }, 'feed_url': 'http://example.com/atom.', 'broadcast': true }".Replace("\r\n", "\n"); Assert.AreEqual(expected, text); }
public static string Serialize(this CreateFeedRequest newFeed) { var jsonObj = JsonObj(newFeed); return(jsonObj.ToString()); }