-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPurchasing.java
More file actions
55 lines (47 loc) · 2.14 KB
/
Purchasing.java
File metadata and controls
55 lines (47 loc) · 2.14 KB
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
package examples.market;
// java examples/market/Purchasing.java YOUR_TOKEN ITEM_ID
//
// Покупка аккаунта (только проверка, без реальной покупки).
import com.lolzteam.LolzteamClient;
import com.lolzteam.models.*;
public class Purchasing {
public static void main(String[] args) throws Exception {
String token = args[0];
long itemId = Long.parseLong(args[1]);
LolzteamClient client = LolzteamClient.create(token);
System.out.println("--- информация об аккаунте #" + itemId + " ---");
try {
ManagingGetResponse resp = client.market().managingGet(itemId, null);
Item item = resp.getItem();
System.out.println("title: " + item.getTitle());
System.out.println("price: " + item.getPrice());
} catch (Exception e) {
System.err.println("err: " + e.getMessage());
return;
}
System.out.println("\n--- проверка возможности покупки ---");
try {
client.market().purchasingCheck(itemId);
System.out.println("можно купить");
} catch (Exception e) {
System.err.println("нельзя купить: " + e.getMessage());
return;
}
System.out.println("\n--- запрос скидки ---");
try {
client.market().purchasingDiscountRequest(itemId, 10.0, null);
System.out.println("скидка запрошена");
} catch (Exception e) {
System.err.println("skip: " + e.getMessage());
}
System.out.println("\n--- отмена запроса скидки ---");
try {
client.market().purchasingDiscountCancel(itemId);
System.out.println("скидка отменена");
} catch (Exception e) {
System.err.println("skip: " + e.getMessage());
}
System.out.println("\nНОТА: реальная покупка не выполнена (используй purchasingFastBuy для покупки)");
System.out.println("done");
}
}