1 package pl
.smsapi
.api
.action
.user
;
3 import org
.json
.JSONObject
;
4 import pl
.smsapi
.api
.action
.BaseAction
;
5 import pl
.smsapi
.api
.response
.UserResponse
;
8 import java
.net
.URISyntaxException
;
10 public class Add
extends BaseAction
<UserResponse
> {
13 public URI
uri() throws URISyntaxException
{
17 query
+= paramsLoginToQuery();
19 query
+= paramsOther();
21 return new URI(proxy
.getProtocol(), null, proxy
.getHost(), proxy
.getPort(), proxy
.getPath()+"user.do", query
, null);
24 public Add
setUsername(String username
) {
25 params
.put("add_user", username
);
29 public Add
setPassword(String password
) {
30 params
.put("pass", password
);
34 public Add
setPasswordApi(String password
) {
35 params
.put("pass_api", password
);
39 public Add
setLimit(int limit
) {
40 params
.put("limit", Integer
.toString(limit
));
44 public Add
setLimit(double limit
) {
45 params
.put("limit", Double
.toString(limit
));
49 public Add
setMonthLimit(int limit
) {
50 params
.put("month_limit", Integer
.toString(limit
));
54 public Add
setMonthLimit(double limit
) {
55 params
.put("month_limit", Double
.toString(limit
));
59 public Add
setSenders(boolean access
) {
62 params
.put("senders", "1");
64 params
.put("senders", "0");
69 public Add
setPhonebook(boolean access
) {
72 params
.put("phonebook", "1");
74 params
.put("phonebook", "0");
79 public Add
setActive(boolean val
) {
82 params
.put("active", "1");
84 params
.put("active", "0");
89 public Add
setInfo(String info
) {
90 params
.put("info", info
);
94 protected UserResponse
createResponse(String data
) {
95 JSONObject jsonObject
= new JSONObject(data
);
98 jsonObject
.getString("username"),
99 jsonObject
.optDouble("limit"),
100 jsonObject
.optDouble("month_limit"),
101 jsonObject
.optInt("senders"),
102 jsonObject
.optInt("phonebook"),
103 jsonObject
.optInt("active"),
104 jsonObject
.optString("info")