static JsonObject JsonObj(AddRegistrationRequest registrationRequest)
        {
            var jsonObj = new JsonObject();

            if (registrationRequest.Alias != null)
            {
                jsonObj["alias"] = registrationRequest.Alias;
            }
            jsonObj["tags"] = registrationRequest.Tags.ToJsonArray();

            return(jsonObj);
        }
        static JsonObject JsonObj(AddRegistrationRequest registrationRequest)
        {
            var jsonObj = new JsonObject();

            if (registrationRequest.Alias != null)
            {
                jsonObj["alias"] = registrationRequest.Alias;
            }
            jsonObj["tags"] = registrationRequest.Tags.ToJsonArray();

            return jsonObj;
        }
 public void Execute(AddRegistrationRequest registrationRequest, Action<AddRegistrationResponse> responseCallback, Action<Exception> exceptionCallback)
 {
     var request = RequestBuilder.Build("https://go.urbanairship.com/api/apids/" + registrationRequest.PushId);
     request.Method = "PUT";
     var asyncRequest = new AsyncRequest
         {
             Request = request,
             ReadFromResponse = o => responseCallback(new AddRegistrationResponse()),
             ExceptionCallback = exceptionCallback,
             WriteToRequest = stream => stream.WriteToStream(registrationRequest.Serialize),
             RequestContentType = "application/json"
         };
     asyncRequest.Execute();
 }
 public void Simple()
 {
     var service = new AddRegistrationService
                       {
                           RequestBuilder = ServerRequestBuilder.Instance
                       };
     var registration = new AddRegistrationRequest
                            {
                                PushId = "AndroidPushId",
                                Tags = new List<string> {"MyTag"},
                                Alias = "MyAlias"
                            };
     service.Execute(registration, response => Debug.WriteLine("Success"), ExceptionHandler.Handle);
 }
        public void Tags()
        {
            var service = new AddRegistrationService
                              {
                                  RequestBuilder = RequestBuilderHelper.Build()
                              };
            var registration = new AddRegistrationRequest
                                   {
                                       PushId = RemoteSettings.AndroidPushId,
                                       Tags = new List<string> {"bangladesh"}
                                   };

            var asyncTestHelper = new AsyncTestHelper();
            service.Execute(registration, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
Esempio n. 6
0
        public void Execute(AddRegistrationRequest registrationRequest, Action <AddRegistrationResponse> responseCallback, Action <Exception> exceptionCallback)
        {
            var request = RequestBuilder.Build("https://go.urbanairship.com/api/apids/" + registrationRequest.PushId);

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

            var asyncRequest = new AsyncRequest
            {
                Request           = request,
                ReadFromResponse  = o => responseCallback(new AddRegistrationResponse()),
                ExceptionCallback = exceptionCallback,
                WriteToRequest    = stream => stream.WriteToStream(registrationRequest.Serialize),
            };

            asyncRequest.Execute();
        }
 public void Single2()
 {
     var registration = new AddRegistrationRequest
     {
         Alias = "alias",
         Tags = new List<string> { "tag1", "tag2" },
     };
     var text = registration.Serialize().FormatAsJson();
     var expected = @"
     {
       'alias': 'alias',
       'tags': [
     'tag1',
     'tag2'
       ]
     }".Replace("\r\n", "\n");
     Assert.AreEqual(expected, text);
 }
        public static string Serialize(this AddRegistrationRequest registrationRequest)
        {
            var jsonObj = JsonObj(registrationRequest);

            return(jsonObj.ToString());
        }