|
| 1 | +package pl.smsapi.api.action.subusers; |
| 2 | + |
| 3 | +import org.json.JSONObject; |
| 4 | +import pl.smsapi.api.action.AbstractAction; |
| 5 | + |
| 6 | +public class SubuserEdit extends AbstractAction<Subuser> { |
| 7 | + private final String id; |
| 8 | + |
| 9 | + public SubuserEdit(String id) { |
| 10 | + this.id = id; |
| 11 | + } |
| 12 | + |
| 13 | + @Override |
| 14 | + protected String endPoint() { |
| 15 | + return "subusers/" + id; |
| 16 | + } |
| 17 | + |
| 18 | + @Override |
| 19 | + protected String httpMethod() { |
| 20 | + return "PUT"; |
| 21 | + } |
| 22 | + |
| 23 | + @Override |
| 24 | + protected Subuser createResponse(String data) { |
| 25 | + return new Subuser.SubuserFromJsonFactory().createFrom(new JSONObject(data)); |
| 26 | + } |
| 27 | + |
| 28 | + public void withPassword(String password) { |
| 29 | + params.put("credentials[password]", password); |
| 30 | + } |
| 31 | + |
| 32 | + public void withApiPassword(String apiPassword) { |
| 33 | + params.put("credentials[api_password]", apiPassword); |
| 34 | + } |
| 35 | + |
| 36 | + public void asActive() { |
| 37 | + params.put("active", "1"); |
| 38 | + } |
| 39 | + |
| 40 | + public void asInactive() { |
| 41 | + params.put("active", "0"); |
| 42 | + } |
| 43 | + |
| 44 | + public void withDescription(String description) { |
| 45 | + params.put("description", description); |
| 46 | + } |
| 47 | + |
| 48 | + public void withPointsFromAccount(double pointsFromAccount) { |
| 49 | + params.put("points[from_account]", String.valueOf(pointsFromAccount)); |
| 50 | + } |
| 51 | + |
| 52 | + public void withPointsPerMonth(double pointsPerMonth) { |
| 53 | + params.put("points[per_month]", String.valueOf(pointsPerMonth)); |
| 54 | + } |
| 55 | +} |
0 commit comments