Skip to content

Commit be52345

Browse files
committed
Merge pull request cloudbees-oss#73 from sandeepkaul/develop
Develop
2 parents 2465fb7 + 390e7d3 commit be52345

File tree

5 files changed

+241
-1
lines changed

5 files changed

+241
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Here is the status of the various API components:
6060
* [Activity Stream](http://developer.zendesk.com/documentation/rest_api/activity_stream.html)
6161
* [Attachments](http://developer.zendesk.com/documentation/rest_api/attachments.html)
6262
* [Autocompletion](http://developer.zendesk.com/documentation/rest_api/autocomplete.html)
63-
* [Automations](http://developer.zendesk.com/documentation/rest_api/automations.html)
63+
* [Automations](http://developer.zendesk.com/documentation/rest_api/automations.html)
6464
* [Job Statuses](http://developer.zendesk.com/documentation/rest_api/job_statuses.html)
6565
* [Locales](http://developer.zendesk.com/documentation/rest_api/locales.html)
6666
* [Macros](http://developer.zendesk.com/documentation/rest_api/macros.html)*except for restrictions*

src/main/java/org/zendesk/client/v2/Zendesk.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.slf4j.LoggerFactory;
2020
import org.zendesk.client.v2.model.Attachment;
2121
import org.zendesk.client.v2.model.Audit;
22+
import org.zendesk.client.v2.model.Automation;
2223
import org.zendesk.client.v2.model.Comment;
2324
import org.zendesk.client.v2.model.Field;
2425
import org.zendesk.client.v2.model.Forum;
@@ -525,12 +526,48 @@ public Trigger createTrigger(Trigger trigger) {
525526
return complete(submit(req("POST", cnst("/triggers.json"), JSON, json(Collections.singletonMap("trigger", trigger))),
526527
handle(Trigger.class, "trigger")));
527528
}
529+
530+
public Trigger updateTrigger(Long triggerId, Trigger trigger) {
531+
return complete(submit(req("PUT", tmpl("/triggers/{id}.json").set("id", triggerId), JSON, json(Collections.singletonMap("trigger", trigger))),
532+
handle(Trigger.class, "trigger")));
533+
}
528534

529535
public void deleteTrigger(long triggerId) {
530536
complete(submit(req("DELETE", tmpl("/triggers/{id}.json").set("id", triggerId)), handleStatus()));
531537
}
532538

533539

540+
// Automations
541+
public Iterable<Automation> getAutomations() {
542+
return new PagedIterable<Automation>(cnst("/automations.json"),
543+
handleList(Automation.class, "automations"));
544+
}
545+
546+
public Automation getAutomation(long id) {
547+
return complete(submit(req("GET", tmpl("/automations/{id}.json").set("id", id)),
548+
handle(Automation.class, "automation")));
549+
}
550+
551+
public Automation createAutomation(Automation automation) {
552+
return complete(submit(
553+
req("POST", cnst("/automations.json"), JSON,
554+
json(Collections.singletonMap("automation", automation))),
555+
handle(Automation.class, "automation")));
556+
}
557+
558+
public Automation updateAutomation(Long automationId, Automation automation) {
559+
return complete(submit(
560+
req("PUT", tmpl("/automations/{id}.json").set("id", automationId), JSON,
561+
json(Collections.singletonMap("automation", automation))),
562+
handle(Automation.class, "automation")));
563+
}
564+
565+
public void deleteAutomation(long automationId) {
566+
complete(submit(req("DELETE", tmpl("/automations/{id}.json").set("id", automationId)),
567+
handleStatus()));
568+
}
569+
570+
534571
public Iterable<TwitterMonitor> getTwitterMonitors() {
535572
return new PagedIterable<TwitterMonitor>(cnst("/channels/twitter/monitored_twitter_handles.json"),
536573
handleList(TwitterMonitor.class, "monitored_twitter_handles"));
@@ -961,6 +998,23 @@ public Iterable<Macro> getMacros(){
961998
return new PagedIterable<Macro>(cnst("/macros.json"),
962999
handleList(Macro.class, "macros"));
9631000
}
1001+
1002+
public Macro getMacro(long macroId){
1003+
1004+
return complete(submit(req("GET", tmpl("/macros/{id}.json").set("id", macroId)), handle(Macro.class, "macro")));
1005+
}
1006+
1007+
public Macro createMacro(Macro macro) {
1008+
return complete(submit(
1009+
req("POST", cnst("/macros.json"), JSON, json(Collections.singletonMap("macro", macro))),
1010+
handle(Macro.class, "macro")));
1011+
}
1012+
1013+
public Macro updateMacro(Long macroId, Macro macro) {
1014+
return complete(submit(req("PUT", tmpl("/macros/{id}.json").set("id", macroId), JSON,
1015+
json(Collections.singletonMap("macro", macro))), handle(Macro.class, "macro")));
1016+
}
1017+
9641018

9651019
public List<String> addTagToTicket(long id, String... tags) {
9661020
return complete(submit(
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
*
3+
*/
4+
package org.zendesk.client.v2.model;
5+
6+
import java.util.Date;
7+
import java.util.List;
8+
9+
10+
/**
11+
* https://developer.zendesk.com/rest_api/docs/core/automations
12+
*
13+
* @author Sandeep Kaul ([email protected])
14+
*
15+
*/
16+
public class Automation {
17+
18+
private Long id;
19+
private String title;
20+
private Boolean active;
21+
private List<Action> actions;
22+
private Conditions conditions;
23+
private int position;
24+
private Date createdAt;
25+
private Date updatedAt;
26+
27+
public Long getId() {
28+
return id;
29+
}
30+
public void setId(Long id) {
31+
this.id = id;
32+
}
33+
public String getTitle() {
34+
return title;
35+
}
36+
public void setTitle(String title) {
37+
this.title = title;
38+
}
39+
public Boolean getActive() {
40+
return active;
41+
}
42+
public void setActive(Boolean active) {
43+
this.active = active;
44+
}
45+
public List<Action> getActions() {
46+
return actions;
47+
}
48+
public void setActions(List<Action> actions) {
49+
this.actions = actions;
50+
}
51+
public Conditions getConditions() {
52+
return conditions;
53+
}
54+
public void setConditions(Conditions conditions) {
55+
this.conditions = conditions;
56+
}
57+
public Date getCreatedAt() {
58+
return createdAt;
59+
}
60+
public void setCreatedAt(Date createdAt) {
61+
this.createdAt = createdAt;
62+
}
63+
public Date getUpdatedAt() {
64+
return updatedAt;
65+
}
66+
public void setUpdatedAt(Date updatedAt) {
67+
this.updatedAt = updatedAt;
68+
}
69+
public int getPosition() {
70+
return position;
71+
}
72+
public void setPosition(int position) {
73+
this.position = position;
74+
}
75+
@Override
76+
public String toString() {
77+
return "Automation [id=" + id + ", title=" + title + ", active=" + active + ", actions="
78+
+ actions + ", conditions=" + conditions + ", position=" + position + ", createdAt="
79+
+ createdAt + ", updatedAt=" + updatedAt + "]";
80+
}
81+
82+
83+
84+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
*
3+
*/
4+
package org.zendesk.client.v2.model;
5+
6+
/**
7+
* @author Sandeep Kaul ([email protected])
8+
*
9+
*/
10+
public class Condition {
11+
private String field;
12+
private String operator;
13+
private String value;
14+
15+
public Condition() {}
16+
17+
public Condition(String field, String operator, String value) {
18+
this.field = field;
19+
this.operator = operator;
20+
this.value = value;
21+
}
22+
23+
public String getField() {
24+
return field;
25+
}
26+
27+
public void setField(String field) {
28+
this.field = field;
29+
}
30+
31+
public String getOperator() {
32+
return operator;
33+
}
34+
35+
public void setOperator(String operator) {
36+
this.operator = operator;
37+
}
38+
39+
public String getValue() {
40+
return value;
41+
}
42+
43+
public void setValue(String value) {
44+
this.value = value;
45+
}
46+
47+
@Override
48+
public String toString() {
49+
final StringBuilder sb = new StringBuilder();
50+
sb.append("Condition");
51+
sb.append("{field=").append(field);
52+
sb.append(", operator=").append(operator);
53+
sb.append(", value=").append(value);
54+
sb.append('}');
55+
return sb.toString();
56+
}
57+
58+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
*/
4+
package org.zendesk.client.v2.model;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
10+
/**
11+
* @author Sandeep Kaul([email protected])
12+
*
13+
*/
14+
public class Conditions {
15+
private List<Condition> all = new ArrayList<Condition>();
16+
private List<Condition> any = new ArrayList<Condition>();
17+
18+
public List<Condition> getAll() {
19+
return all;
20+
}
21+
22+
public void setAll(List<Condition> all) {
23+
this.all = all;
24+
}
25+
26+
public List<Condition> getAny() {
27+
return any;
28+
}
29+
30+
public void setAny(List<Condition> any) {
31+
this.any = any;
32+
}
33+
34+
@Override
35+
public String toString() {
36+
final StringBuilder sb = new StringBuilder();
37+
sb.append("Conditions");
38+
sb.append("{all=").append(all);
39+
sb.append(", any=").append(any);
40+
sb.append('}');
41+
return sb.toString();
42+
}
43+
44+
}

0 commit comments

Comments
 (0)