예제 #1
0
        public async System.Threading.Tasks.Task <BalanceResponse> GetBalanceAsync()
        {
            String url      = $"{Host}/getBalance";
            String postData = $"{{\"clientKey\":\"{ClientKey}\"}}";

            Http.Request request = new Http.Request()
            {
                Url         = url,
                Method      = "POST",
                PostData    = postData,
                ContentType = "application/json"
            };

            Http.Response response = await Client.ExecuteAsync(request);

            if (response.StatusCode == 200)
            {
                BalanceResponse balanceResponse = BalanceResponse.ParseFromJson(response.Body);
                return(balanceResponse);
            }
            else
            {
                throw new Exception(response.ToString());
            }
        }
예제 #2
0
        public async System.Threading.Tasks.Task <TaskResult <SolutionType> > GetTaskResultAsync <SolutionType>(int taskId)
        {
            String url      = $"{Host}/getTaskResult";
            String postData = $"{{\"clientKey\":\"{ClientKey}\", \"taskId\": {taskId}}}";

            Http.Request request = new Http.Request()
            {
                Url         = url,
                Method      = "POST",
                PostData    = postData,
                ContentType = "application/json"
            };

            Http.Response response = await Client.ExecuteAsync(request);

            if (response.StatusCode == 200)
            {
                TaskResult <SolutionType> taskResult = TaskResult <SolutionType> .ParseFromJson(response.Body);

                return(taskResult);
            }
            else
            {
                throw new Exception(response.ToString());
            }
        }
예제 #3
0
        public async System.Threading.Tasks.Task <ReportIncorrectImageCaptchaResponse> ReportIncorrectImageCaptcha(int taskId)
        {
            String url      = $"{Host}/reportIncorrectImageCaptcha ";
            String postData = $"{{\"clientKey\":\"{ClientKey}\", \"taskId\": {taskId}}}";

            Http.Request request = new Http.Request()
            {
                Url         = url,
                Method      = "POST",
                PostData    = postData,
                ContentType = "application/json"
            };

            Http.Response response = await Client.ExecuteAsync(request);

            if (response.StatusCode == 200)
            {
                ReportIncorrectImageCaptchaResponse reportResponse = ReportIncorrectImageCaptchaResponse.ParseFromJson(response.Body);
                return(reportResponse);
            }
            else
            {
                throw new Exception(response.ToString());
            }
        }
예제 #4
0
        public async System.Threading.Tasks.Task <TaskResponse> CreateTaskAsync <TTaskType>(TTaskType taskType)
        {
            String url = $"{Host}/createTask";
            AntiCaptchaTask <TTaskType> task = new AntiCaptchaTask <TTaskType>()
            {
                ClientKey    = this.ClientKey,
                TaskType     = taskType,
                LanguagePool = "en"
            };

            String postData = task.ToJson();

            Http.Request request = new Http.Request()
            {
                Url         = url,
                Method      = "POST",
                PostData    = postData,
                ContentType = "application/json"
            };

            Http.Response response = await Client.ExecuteAsync(request);

            if (response.StatusCode == 200)
            {
                TaskResponse taskResponse = TaskResponse.ParseFromJson(response.Body);
                return(taskResponse);
            }
            else
            {
                throw new Exception(response.ToString());
            }
        }
예제 #5
0
        public async System.Threading.Tasks.Task <QueueStat> GetQueueStats(Queue queueId)
        {
            String url      = $"{Host}/getQueueStats ";
            String postData = $"{{\"queueId\":\"{(int)queueId}\"}}";

            Http.Request request = new Http.Request()
            {
                Url         = url,
                Method      = "POST",
                PostData    = postData,
                ContentType = "application/json"
            };

            Http.Response response = await Client.ExecuteAsync(request);

            if (response.StatusCode == 200)
            {
                QueueStat queueStat = QueueStat.ParseFromJson(response.Body);
                return(queueStat);
            }
            else
            {
                throw new Exception(response.ToString());
            }
        }