Refactory
[smsapi-java.git] / src / pl / smsapi / api / response / UsersResponse.java
blob78e819e155f1df67ff12629734f5d00945931a19
1 package pl.smsapi.api.response;
3 import java.util.ArrayList;
4 import org.json.JSONArray;
5 import org.json.JSONObject;
7 public class UsersResponse implements Response {
9 private ArrayList<UserResponse> list = new ArrayList<UserResponse>();
11 public UsersResponse(String data) {
13 if (data != null && !data.isEmpty()) {
15 JSONArray aData = new JSONArray(data);
16 final int n = aData.length();
17 if (n > 0) {
18 for (int i = 0; i < n; i++) {
19 JSONObject tmp = aData.getJSONObject(i);
20 list.add(new UserResponse(tmp.optString("username"), tmp.optDouble("limit"), tmp.optDouble("month_limit"), tmp.optInt("senders"), tmp.optInt("phonebook"), tmp.optInt("active"), tmp.optString("info")));
27 public ArrayList<UserResponse> getList() {
28 return list;