forked from bianjieai/avata-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrderTest.java
83 lines (76 loc) · 2.74 KB
/
OrderTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import ai.bianjie.avatasdk.AvataClient;
import ai.bianjie.avatasdk.model.order.*;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
public class OrderTest {
AvataClient client = new AvataClient.Builder()
.setDomain("")
.setApiKey("")
.setApiSecret("")
.setHttpTimeout(10000)
.init();
@Test
//请求购买能量值/业务费接口示例
void TestCreateOrder() {
CreateOrderReq req = new CreateOrderReq();
req.setOrderId("sxjtesto_rde2rid0w2");
req.setAccount("iaa1d3fmeputf2h3takuyz68sl42v3r5s3szdx8y80");
req.setAmount(100);
req.setOrderType("gas");
try {
OrderRes res = client.orderClient.createOrder(req);
System.out.println(res.getData().getOrderId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求查询能量值/业务费购买结果接口示例
void TestQueryOrder() {
try {
QueryOrderRes res = client.orderClient.queryOrder("sxjtesto_rde2rid0w2");
System.out.println(res.getData());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求查询能量值/业务费购买结果列表接口示例
void TestQueryOrders() {
QueryOrdersReq req = new QueryOrdersReq();
req.setStatus("success");
try {
QueryOrdersRes res = client.orderClient.queryOrders(req);
System.out.println(res.getData());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求批量购买能量值接口示例
void TestBatchCreatrOrders() {
BatchCreateOrderReq req = new BatchCreateOrderReq();
List<BatchCreateOrderReq.ListDTO> list = new ArrayList<>();
BatchCreateOrderReq.ListDTO dto1 = new BatchCreateOrderReq.ListDTO();
dto1.setAccount("iaa1d3fmeputf2h3takuyz68sl42v3r5s3szdx8y80");
dto1.setAmount(200);
list.add(dto1);
req.setList(list);
req.setOrderId("gaisbc3_b1627");
try {
OrderRes res = client.orderClient.batchCreateOrders(req);
System.out.println(res.getData().getOrderId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
}