コード例 #1
0
        public static async Task <GetMyInfo> GetMyInfo()
        {
            try
            {
                var request = RequestBuilder("user/GetMyInfo");
                var content = await ClientExecute(request);

                DumpFile.Write("GetMyInfo.json", content);

                if (!isJsonFormat(content))
                {
                    throw new Exception("Response: not json format!");
                }

                return(JsonConvert.DeserializeObject <GetMyInfo>(content));
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR : " + ex.Message);
                return(new GetMyInfo()
                {
                    errno = -100,
                    msg = ex.Message
                });
            }
        }
コード例 #2
0
        public static async Task <GetUserInfo> GetUser(string id)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(id))
                {
                    throw new Exception("ID can't be null");
                }

                var request = RequestBuilder($"user/GetUserInfo?uid={id}");
                var content = await ClientExecute(request);

                DumpFile.Write("GetUserInfo.json", content);

                if (!isJsonFormat(content))
                {
                    throw new Exception("Response: not json format!");
                }

                return(JsonConvert.DeserializeObject <GetUserInfo>(content));
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR : " + ex.Message);
                return(new GetUserInfo()
                {
                    errno = -100,
                    msg = ex.Message
                });
            }
        }
コード例 #3
0
        public static async Task <GetRooms> GetRooms(int page = 0, int status = 1)
        {
            try
            {
                var request = RequestBuilder($"room/GetRooms?page={page}&status={status}");
                var content = await ClientExecute(request);

                DumpFile.Write("GetRooms.json", content);

                if (!isJsonFormat(content))
                {
                    throw new Exception("Response: not json format!");
                }

                return(JsonConvert.DeserializeObject <GetRooms>(content));
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR : " + ex.Message);
                return(new GetRooms()
                {
                    errno = -100,
                    msg = ex.Message
                });
            }
        }
コード例 #4
0
        public static async Task <GetMyInfo> Login()
        {
            try
            {
                var _username = Configs.GetUsername();
                var _password = Configs.GetPassword();

                if (string.IsNullOrWhiteSpace(_username) || string.IsNullOrWhiteSpace(_password))
                {
                    throw new Exception("Please fill the Username & Password!");
                }

                var request = RequestBuilder("user/login", Method.POST);
                request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
                request.AddParameter("application/x-www-form-urlencoded", $"remember=true&username={_username}&password={_password}", ParameterType.RequestBody);
                var content = await ClientExecute(request);

                DumpFile.Write("Login.json", content);

                if (!isJsonFormat(content))
                {
                    throw new Exception("Response: not json format!");
                }

                return(JsonConvert.DeserializeObject <GetMyInfo>(content));
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR : " + ex.Message);
                return(new GetMyInfo()
                {
                    errno = -100,
                    msg = ex.Message
                });
            }
        }