static JsonObject JsonObj(ModifyFeedRequest newFeed)
 {
     var jsonObj = new JsonObject();
     jsonObj["template"] = CreateFeedRequestSerializer.SerializeTemplate(newFeed.Template);
     jsonObj["feed_url"] = newFeed.FeedUrl;
     jsonObj["url"] = newFeed.Url;
     jsonObj["broadcast"] = newFeed.BroadCast;
     return jsonObj;
 }
示例#2
0
        static JsonObject JsonObj(ModifyFeedRequest newFeed)
        {
            var jsonObj = new JsonObject();

            jsonObj["template"]  = CreateFeedRequestSerializer.SerializeTemplate(newFeed.Template);
            jsonObj["feed_url"]  = newFeed.FeedUrl;
            jsonObj["url"]       = newFeed.Url;
            jsonObj["broadcast"] = newFeed.BroadCast;
            return(jsonObj);
        }
        public void Execute(ModifyFeedRequest newFeed, Action<ModifyFeedResponse> responseCallback, Action<Exception> exceptionCallback)
        {
            var webRequest = RequestBuilder.Build("https://go.urbanairship.com/api/feeds/" + newFeed.FeedId);
            webRequest.Method = "PUT";

            var asyncRequest = new AsyncRequest
                                   {
                                       WriteToRequest = stream => stream.WriteToStream(newFeed.Serialize),
                                       Request = webRequest,
                                       ReadFromResponse = o => responseCallback(new ModifyFeedResponse()),
                                       ExceptionCallback = exceptionCallback,
                                       RequestContentType = "application/json"
                                   };
            asyncRequest.Execute();
        }
        public void Execute(ModifyFeedRequest newFeed, Action <ModifyFeedResponse> responseCallback, Action <Exception> exceptionCallback)
        {
            var webRequest = RequestBuilder.Build("https://go.urbanairship.com/api/feeds/" + newFeed.FeedId);

            webRequest.Method      = "PUT";
            webRequest.ContentType = "application/json";

            var asyncRequest = new AsyncRequest
            {
                WriteToRequest    = stream => stream.WriteToStream(newFeed.Serialize),
                Request           = webRequest,
                ReadFromResponse  = o => responseCallback(new ModifyFeedResponse()),
                ExceptionCallback = exceptionCallback,
            };

            asyncRequest.Execute();
        }
 public void Simple()
 {
     var newFeed = new ModifyFeedRequest
     {
         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" }
                        },
         Url = "myUrl"
     };
     var text = newFeed.Serialize().FormatAsJson();
     var expected = @"
     {
       'template': {
     'aps': {
       'alert': 'MyAlert',
       'badge': 10,
       'sound': 'MySound'
     },
     'tags': [
       'tag1',
       'tag2'
     ]
       },
       'feed_url': 'http://example.com/atom.',
       'url': 'myUrl',
       'broadcast': true
     }".Replace("\r\n", "\n");
     Assert.AreEqual(expected, text);
 }
 public void Simple()
 {
     var service = new ModifyFeedService
                       {
                           RequestBuilder = ServerRequestBuilder.Instance
                       };
     var request = new ModifyFeedRequest
                       {
                           FeedId = "feedId",
                           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(request, response => Debug.WriteLine("Success"), ExceptionHandler.Handle);
 }
示例#7
0
        public static string Serialize(this ModifyFeedRequest newFeed)
        {
            var jsonObj = JsonObj(newFeed);

            return(jsonObj.ToString());
        }