diff --git a/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java b/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java index 3a9de41593..4c9e51b74b 100644 --- a/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java +++ b/src/main/java/com/twilio/taskrouter/WorkflowRuleTarget.java @@ -26,18 +26,28 @@ public class WorkflowRuleTarget extends TaskRouterResource { @JsonProperty("timeout") private final Integer timeout; + + @JsonProperty("order_by") + private final String orderBy; + + @JsonProperty("skip_if") + private final String skipIf; @JsonCreator private WorkflowRuleTarget( @JsonProperty("queue") String queue, @JsonProperty("expression") String expression, @JsonProperty("priority") Integer priority, - @JsonProperty("timeout") Integer timeout + @JsonProperty("timeout") Integer timeout, + @JsonProperty("order_by") String orderBy, + @JsonProperty("skip_if") String skipIf ) { this.queue = queue; this.expression = expression; this.priority = priority; this.timeout = timeout; + this.orderBy = orderBy; + this.skipIf = skipIf; } private WorkflowRuleTarget(Builder b) throws IllegalArgumentException { @@ -45,6 +55,8 @@ private WorkflowRuleTarget(Builder b) throws IllegalArgumentException { this.expression = b.expression; this.priority = b.priority; this.timeout = b.timeout; + this.orderBy = b.orderBy; + this.skipIf = b.skipIf; } /** @@ -79,6 +91,22 @@ public Integer getTimeout() { return timeout; } + /** + * Get the orderBy for the workflow rule target. + * @return the orderBy + */ + public String getOrderBy() { + return orderBy; + } + + /** + * Get the skipIf for the workflow rule target. + * @return the skipIf + */ + public String getSkipIf() { + return skipIf; + } + /** * Return a string representation of this workflow rule target. * @return string representation of target @@ -90,6 +118,8 @@ public String toString() { .add("expression", expression) .add("priority", priority) .add("timeout", timeout) + .add("orderBy", orderBy) + .add("skipIf", skipIf) .toString(); } @@ -111,6 +141,8 @@ public static class Builder { private String expression; private Integer priority; private Integer timeout; + private String orderBy; + private String skipIf; public Builder(String queue) { this.queue = queue; @@ -130,6 +162,16 @@ public Builder timeout(Integer timeout) { this.timeout = timeout; return this; } + + public Builder orderBy(String orderBy) { + this.orderBy = orderBy; + return this; + } + + public Builder skipIf(String skipIf) { + this.skipIf = skipIf; + return this; + } public WorkflowRuleTarget build() { return new WorkflowRuleTarget(this); diff --git a/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java b/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java index c887a7de30..9651c50033 100644 --- a/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java +++ b/src/test/java/com/twilio/taskrouter/WorkflowRuleTargetTest.java @@ -16,10 +16,12 @@ public void testToJson() throws IOException { .expression("1==1") .priority(5) .timeout(30) + .orderBy("worker.english_level ASC") + .skipIf("workers.available == 0") .build(); Assert.assertEquals( - "{\"queue\":\"QS123\",\"expression\":\"1==1\",\"priority\":5,\"timeout\":30}", + "{\"queue\":\"QS123\",\"expression\":\"1==1\",\"priority\":5,\"timeout\":30,\"order_by\":\"worker.english_level ASC\",\"skip_if\":\"workers.available == 0\"}", target.toJson() ); } @@ -27,11 +29,13 @@ public void testToJson() throws IOException { @Test public void testFromJson() throws IOException { WorkflowRuleTarget target = - WorkflowRuleTarget.fromJson("{\"queue\":\"QS123\",\"expression\":\"1==1\",\"priority\":5,\"timeout\":30}"); + WorkflowRuleTarget.fromJson("{\"queue\":\"QS123\",\"expression\":\"1==1\",\"priority\":5,\"timeout\":30,\"order_by\":\"worker.english_level ASC\",\"skip_if\":\"workers.available == 0\"}"); Assert.assertEquals("QS123", target.getQueue()); Assert.assertEquals("1==1", target.getExpression()); Assert.assertEquals(5, (int)target.getPriority()); Assert.assertEquals(30, (int)target.getTimeout()); + Assert.assertEquals("worker.english_level ASC", target.getOrderBy()); + Assert.assertEquals("workers.available == 0", target.getSkipIf()); } }