Skip to content
Browse files

added QueueList and QueueFactory

  • Loading branch information...
1 parent a1163fd commit 896e49ccd6f518de9d30f6a8304d8c2a02e06bac @eanderle eanderle committed with ChristerF Aug 8, 2012
View
11 src/main/java/com/twilio/sdk/resource/factory/QueueFactory.java
@@ -0,0 +1,11 @@
+package com.twilio.sdk.resource.factory;
+
+import java.util.Map;
+
+import com.twilio.sdk.TwilioRestException;
+import com.twilio.sdk.resource.instance.Queue;
+
+public interface QueueFactory {
+
+ public Queue create(Map<String, String> params) throws TwilioRestException;
+}
View
4 src/main/java/com/twilio/sdk/resource/instance/Queue.java
@@ -19,6 +19,10 @@ public Queue(final TwilioRestClient client, final String sid) {
this.setProperty(Queue.SID, sid);
}
+ public Queue(TwilioRestClient client, Map<String, Object> params) {
+ super(client, params);
+ }
+
public String getSid() {
return this.getProperty(Queue.SID);
}
View
46 src/main/java/com/twilio/sdk/resource/list/QueueList.java
@@ -0,0 +1,46 @@
+package com.twilio.sdk.resource.list;
+
+import java.util.Map;
+
+import com.twilio.sdk.TwilioRestClient;
+import com.twilio.sdk.TwilioRestException;
+import com.twilio.sdk.TwilioRestResponse;
+import com.twilio.sdk.resource.ListResource;
+import com.twilio.sdk.resource.factory.QueueFactory;
+import com.twilio.sdk.resource.instance.Queue;
+
+public class QueueList extends ListResource<Queue> implements QueueFactory {
+
+ public QueueList(final TwilioRestClient client) {
+ super(client);
+ }
+
+ public QueueList(final TwilioRestClient client,
+ final Map<String, String> filters) {
+ super(client, filters);
+ }
+
+ @Override
+ public Queue create(Map<String, String> params) throws TwilioRestException {
+ TwilioRestResponse response = this.getClient().safeRequest(
+ this.getResourceLocation(), "POST", params);
+ return makeNew(this.getClient(), response.toMap());
+ }
+
+ @Override
+ protected Queue makeNew(TwilioRestClient client, Map<String, Object> params) {
+ return new Queue(client, params);
+ }
+
+ @Override
+ protected String getListKey() {
+ return "queues";
+ }
+
+ @Override
+ protected String getResourceLocation() {
+ return "/" + TwilioRestClient.DEFAULT_VERSION + "/Accounts/"
+ + this.getRequestAccountSid() + "/Queues.json";
+ }
+
+}

0 comments on commit 896e49c

Please sign in to comment.
Something went wrong with that request. Please try again.