/// <summary> /// Returns true if PaymentErrorResponse instances are equal /// </summary> /// <param name="other">Instance of PaymentErrorResponse to be compared</param> /// <returns>Boolean</returns> public bool Equals(PaymentErrorResponse other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ErrorId == other.ErrorId || ErrorId != null && ErrorId.Equals(other.ErrorId) ) && ( Errors == other.Errors || Errors != null && Errors.SequenceEqual(other.Errors) ) && ( PaymentResult == other.PaymentResult || PaymentResult != null && PaymentResult.Equals(other.PaymentResult) )); }
public TaskResultResponse(dynamic json) { ErrorId = JsonHelper.ExtractInt(json, "errorId"); if (ErrorId != null) { if (ErrorId.Equals(0)) { Status = ParseStatus(JsonHelper.ExtractStr(json, "status")); if (Status.Equals(StatusType.Ready)) { Cost = JsonHelper.ExtractDouble(json, "cost"); Ip = JsonHelper.ExtractStr(json, "ip", null, true); SolveCount = JsonHelper.ExtractInt(json, "solveCount", null, true); CreateTime = UnixTimeStampToDateTime(JsonHelper.ExtractDouble(json, "createTime")); EndTime = UnixTimeStampToDateTime(JsonHelper.ExtractDouble(json, "endTime")); Solution = new SolutionData { Token = JsonHelper.ExtractStr(json, "solution", "token", true), GRecaptchaResponse = JsonHelper.ExtractStr(json, "solution", "gRecaptchaResponse", silent: true), GRecaptchaResponseMd5 = JsonHelper.ExtractStr(json, "solution", "gRecaptchaResponseMd5", silent: true), Text = JsonHelper.ExtractStr(json, "solution", "text", silent: true), Url = JsonHelper.ExtractStr(json, "solution", "url", silent: true) }; try { Solution.Answers = json.solution.answers; } catch { Solution.Answers = null; } if (Solution.GRecaptchaResponse == null && Solution.Text == null && Solution.Answers == null && Solution.Token == null) { DebugHelper.Out("Got no 'solution' field from API", DebugHelper.Type.Error); } } } else { ErrorCode = JsonHelper.ExtractStr(json, "errorCode"); ErrorDescription = JsonHelper.ExtractStr(json, "errorDescription") ?? "(no error description)"; DebugHelper.Out(ErrorDescription, DebugHelper.Type.Error); } } else { DebugHelper.Out("Unknown error", DebugHelper.Type.Error); } }
public TaskResultResponse(dynamic json) { ErrorId = JsonHelper.ExtractInt(json, "errorId"); if (ErrorId != null) { if (ErrorId.Equals(0)) { Status = ParseStatus(JsonHelper.ExtractStr(json, "status")); if (Status.Equals(StatusType.Ready)) { Cost = JsonHelper.ExtractDouble(json, "cost"); Ip = JsonHelper.ExtractStr(json, "ip"); SolveCount = JsonHelper.ExtractInt(json, "solveCount"); CreateTime = UnixTimeStampToDateTime(JsonHelper.ExtractDouble(json, "createTime")); EndTime = UnixTimeStampToDateTime(JsonHelper.ExtractDouble(json, "endTime")); Solution = new SolutionData { GRecaptchaResponse = JsonHelper.ExtractStr(json, "solution", "gRecaptchaResponse"), GRecaptchaResponseMd5 = JsonHelper.ExtractStr(json, "solution", "gRecaptchaResponseMd5"), Text = JsonHelper.ExtractStr(json, "solution", "text"), Url = JsonHelper.ExtractStr(json, "solution", "url") }; if (Solution.GRecaptchaResponse == null && Solution.Text == null) { throw new Exception("Got no 'solution' field from API"); } } } else { ErrorCode = JsonHelper.ExtractStr(json, "errorCode"); ErrorDescription = JsonHelper.ExtractStr(json, "errorDescription") ?? "(no error description)"; } } else { throw new Exception("Unknown error"); } }
public BalanceResponse(dynamic json) { ErrorId = JsonHelper.ExtractInt(json, "errorId"); if (ErrorId != null) { if (ErrorId.Equals(0)) { Balance = JsonHelper.ExtractDouble(json, "balance"); } else { ErrorCode = JsonHelper.ExtractStr(json, "errorCode"); ErrorDescription = JsonHelper.ExtractStr(json, "errorDescription") ?? "(no error description)"; } } else { DebugHelper.Out("Unknown error", DebugHelper.Type.Error); } }
public CreateTaskResponse(dynamic json) { ErrorId = JsonHelper.ExtractInt(json, "errorId"); if (ErrorId != null) { if (ErrorId.Equals(0)) { TaskId = JsonHelper.ExtractInt(json, "taskId"); } else { ErrorCode = JsonHelper.ExtractStr(json, "errorCode"); ErrorDescription = JsonHelper.ExtractStr(json, "errorDescription") ?? "(no error description)"; } } else { DebugHelper.Out(DebugHelper.Severity.Error, "Unknown error"); } }