Skip to content

Commit

Permalink
Merge pull request #34 from bianjieai/v1/fix
Browse files Browse the repository at this point in the history
    1. 优化实体类能量值相关接口;2. AvataException CodeSpace="AVATA-SDK"  ;3.修改 NewHTTPException 为 NewClientException ,并添加注释
  • Loading branch information
XiaoHuiBuHui authored Aug 15, 2023
2 parents 96c3321 + d77126d commit 0183701
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
@Data
public class AvataException extends RuntimeException {
private static final String CodeSpace = "AVATA-SDK-JAVA";
private static final String CodeSpace = "AVATA-SDK";
private static final String BadRequest = "BAD_REQUEST";
private static final String UnknownError = "UNKNOWN_ERROR";
private static final String TimeoutError = "TIMEOUT_ERROR";
Expand All @@ -34,20 +34,23 @@ public AvataException(String code, String codeSpace, String message) {
this.code = code;
}

// 来自 Avata SDK 返回的报错信息
public static AvataException NewSDKException(String errorMessage) {
return new AvataException(UnknownError, CodeSpace, errorMessage);
}

public static AvataException NewHTTPException(ErrorResponse.AvataError avataError) {
// 来自 Avata OPEN API 返回的报错信息
public static AvataException NewClientException(ErrorResponse.AvataError avataError) {
return new AvataException(avataError.getCode(), avataError.getCodeSpace(), avataError.getMessage());
}

// 来自 Avata SDK 返回的报错信息,必填参数校验
public static AvataException InvalidParamException(String errorMessage) {
return new AvataException(BadRequest, CodeSpace, errorMessage);
}

// 来自 Avata SDK 返回的报错信息,HTTP 连接超时报错
public static AvataException TimeOutException() {
return new AvataException(TimeoutError, CodeSpace, "request timeout");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public class QueryMtHistoryReq {
@JSONField(name = "limit")
private Integer limit;// 每页记录数,默认为 10,上限为 50
@JSONField(name = "signer")
private Integer signer;// Tx 签名者地址
private String signer;// Tx 签名者地址
@JSONField(name = "tx_hash")
private Integer txHash;// MT 操作 Tx Hash
private String txHash;// MT 操作 Tx Hash
@JSONField(name = "operation")
private Integer operation;// 操作类型: issue(首发MT) / mint(增发MT) / edit(编辑MT) / transfer(转让MT) / burn(销毁MT)
private String operation;// 操作类型: issue(首发MT) / mint(增发MT) / edit(编辑MT) / transfer(转让MT) / burn(销毁MT)
@JSONField(name = "start_date")
private Integer startDate;// MT 操作日期范围 - 开始,yyyy-MM-dd(UTC 时间)
private String startDate;// MT 操作日期范围 - 开始,yyyy-MM-dd(UTC 时间)
@JSONField(name = "end_date")
private Integer endDate;// MT 操作日期范围 - 结束,yyyy-MM-dd(UTC 时间)
private String endDate;// MT 操作日期范围 - 结束,yyyy-MM-dd(UTC 时间)
@JSONField(name = "sort_by")
private Integer sortBy;// 排序规则:DATE_ASC / DATE_DESC
private String sortBy;// 排序规则:DATE_ASC / DATE_DESC
}
18 changes: 0 additions & 18 deletions src/main/java/ai/bianjie/avatasdk/model/order/QueryOrderReq.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package ai.bianjie.avatasdk.model.order;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 查询能量值/业务费购买结果接口返回值
*/
@NoArgsConstructor
@lombok.Data
@Data
public class QueryOrderRes {

@JSONField(name = "data")
private Data data;
private DataDTO data;

@NoArgsConstructor
@lombok.Data
public static class Data {
@Data
public static class DataDTO {
@JSONField(name = "order_id")
private String orderId;// 订单流水号
@JSONField(name = "status")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/bianjie/avatasdk/util/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static void validateResponse(ForestResponse response) {
throw AvataException.NewSDKException(response.getException().getMessage());
}
ErrorResponse res = JSONObject.parseObject(response.getContent(), ErrorResponse.class);
throw AvataException.NewHTTPException(res.getError());
throw AvataException.NewClientException(res.getError());
}
}
}

0 comments on commit 0183701

Please sign in to comment.