-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghasedak.java
96 lines (64 loc) · 2.82 KB
/
ghasedak.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
84
85
86
87
88
89
90
91
92
93
94
95
96
package services;
import javax.inject.Inject;
import play.mvc.*;
import play.libs.ws.*;
import java.util.concurrent.CompletionStage;
import play.libs.Json;
import com.fasterxml.jackson.databind.JsonNode;
public class GhasedakClient { //implements WSBodyReadables, WSBodyWritables
private final WSClient ws;
private final String baseRestUrl = "https://api.ghasedak.io/v2/";
private String username, password;
public GhasedakClient(final WSClient ws) {
this.ws = ws;
}
public void initCred(String token) {
this.token = username;
}
public CompletionStage<WSResponse> SendSMS(String to, String from, String text, boolean flash) {
JsonNode json = Json.newObject()
.put("token", token)
.put("to", to)
.put("from", from)
.put("text", text)
.put("isFlash", Boolean.toString(flash));
return ws.url(baseRestUrl + "sms/send/simple").addHeader("Content-Type", "application/json")
.post(json);
}
public CompletionStage<WSResponse> GetDeliveries2(long recId) {
JsonNode json = Json.newObject()
.put("token", token)
.put("recId", String.valueOf(recId));
return ws.url(baseRestUrl + "GetDeliveries2").addHeader("Content-Type", "application/json")
.post(json);
}
public CompletionStage<WSResponse> GetMessages(int location, String from, String index, boolean count) {
JsonNode json = Json.newObject()
.put("username", username)
.put("password", password)
.put("location", String.valueOf(location))
.put("from", from)
.put("index", index)
.put("count", Boolean.toString(count));
return ws.url(baseRestUrl + "GetMessages").addHeader("Content-Type", "application/json")
.post(json);
}
public CompletionStage<WSResponse> GetCredit() {
JsonNode json = Json.newObject()
.put("token", token);
return ws.url(baseRestUrl + "GetCredit").addHeader("Content-Type", "application/json")
.post(json);
}
public CompletionStage<WSResponse> GetBasePrice(long recId) {
JsonNode json = Json.newObject()
.put("token", token);
return ws.url(baseRestUrl + "GetBasePrice").addHeader("Content-Type", "application/json")
.post(json);
}
public CompletionStage<WSResponse> GetUserNumbers(long recId) {
JsonNode json = Json.newObject()
.put("token", token);
return ws.url(baseRestUrl + "GetUserNumbers").addHeader("Content-Type", "application/json")
.post(json);
}
}