Exemplo n.º 1
0
        public async Task <APIRegisterClient> RegisterNewClient(SRClient clientDevice)
        {
            // var data = null;
            var registerClient = new APIRegisterClient();

            registerClient.deviceId = clientDevice.DeviceID;
            var js = JsonConvert.SerializeObject(clientDevice);

            byte[] gb = Encoding.UTF8.GetBytes(js);
            // registerClient.data = Convert.ToBase64String(gb);
            registerClient.data = SrEncryptor(gb, "MuhammadSurgaSavero", "SRFramework");
            // Debug.WriteLine(registerClient);
            try
            {
                HttpResponseMessage response = await PostAsJson(
                    ApiPath.ApiRegister, UriPath(ApiEnumPath.Register, true), registerClient);

                if (!response.IsSuccessStatusCode)
                {
                    return(registerClient);
                }
                var res = await response.Content.ReadAsAsync <APIRegisterClient>();

                return(res);
                // var deserialize = JsonConvert.DeserializeObject(response);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            // return URI of the created resource.
        }
Exemplo n.º 2
0
        public async Task <APIRegisterClient> DeviceRegister()
        {
            SRClient          clientDevice = SRUtils.Instance.GetClientDevice();
            APIRegisterClient test         = await apis.RegisterNewClient(clientDevice);

            // Debug.WriteLine(test.refId);
            return(test);
        }