Refactory
[smsapi-java.git] / src / pl / smsapi / api / action / sms / Delete.java
blob4910e7a026f56d448a406c8c276245d5e2a90e65
1 package pl.smsapi.api.action.sms;
3 import org.json.JSONObject;
4 import pl.smsapi.api.action.BaseAction;
5 import pl.smsapi.api.response.CountableResponse;
7 import java.net.URI;
8 import java.net.URISyntaxException;
9 import java.util.ArrayList;
11 public class Delete extends BaseAction<CountableResponse> {
13 private ArrayList<String> id = new ArrayList<String>();
15 @Override
16 public URI uri() throws URISyntaxException {
18 String query;
20 query = paramsLoginToQuery();
22 query += paramsOther();
24 String tmp[] = new String[this.id.size()];
25 this.id.toArray(tmp);
27 query += "&sch_del=" + join(tmp, "|");
29 return new URI(proxy.getProtocol(), null, proxy.getHost(), proxy.getPort(), proxy.getPath()+"sms.do", query, null);
32 public Delete id(String id) {
33 this.id.add(id);
34 return this;
37 public Delete ids(String[] ids) {
38 for (String item : ids) {
39 id(item);
41 return this;
44 protected CountableResponse createResponse(String data) {
45 JSONObject jsonObject = new JSONObject(data);
46 return new CountableResponse(jsonObject.getInt("count"));