Skip to content

Commit 55ff6cf

Browse files
author
Matt Tucker
committed
Custom Agent Roles
1 parent 87b2632 commit 55ff6cf

File tree

4 files changed

+120
-26
lines changed

4 files changed

+120
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Here is the status of the various API components:
4545
* [User Identities](http://developer.zendesk.com/documentation/rest_api/user_identities.html)
4646
* [Groups](http://developer.zendesk.com/documentation/rest_api/groups.html)
4747
* [Group Membership](http://developer.zendesk.com/documentation/rest_api/group_memberships.html)
48-
* [Custom Agent Roles](http://developer.zendesk.com/documentation/rest_api/custom_roles.html)
48+
* [Custom Agent Roles](http://developer.zendesk.com/documentation/rest_api/custom_roles.html)
4949
* [Organizations](http://developer.zendesk.com/documentation/rest_api/organizations.html)*except for related info*
5050
* [Search](http://developer.zendesk.com/documentation/rest_api/search.html)*except for topics and sort ordering*
5151
* [Tags](http://developer.zendesk.com/documentation/rest_api/tags.html)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.slf4j.Logger;
2121
import org.slf4j.LoggerFactory;
22+
import org.zendesk.client.v2.model.AgentRole;
2223
import org.zendesk.client.v2.model.Attachment;
2324
import org.zendesk.client.v2.model.Audit;
2425
import org.zendesk.client.v2.model.Automation;
@@ -855,6 +856,11 @@ public Identity createUserIdentity(User user, Identity identity) {
855856
json(Collections.singletonMap("identity", identity))), handle(Identity.class, "identity")));
856857
}
857858

859+
public Iterable<AgentRole> getCustomAgentRoles() {
860+
return new PagedIterable<AgentRole>(cnst("/custom_roles.json"),
861+
handleList(AgentRole.class, "custom_roles"));
862+
}
863+
858864
public Iterable<org.zendesk.client.v2.model.Request> getRequests() {
859865
return new PagedIterable<org.zendesk.client.v2.model.Request>(cnst("/requests.json"),
860866
handleList(org.zendesk.client.v2.model.Request.class, "requests"));
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package org.zendesk.client.v2.model;
2+
3+
import java.util.Date;
4+
import java.util.Map;
5+
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
public class AgentRole {
9+
10+
private Long id;
11+
private String name;
12+
private String description;
13+
private Date createdAt;
14+
private Date updatedAt;
15+
16+
/**
17+
* A series of permissions granted to agents in this role
18+
*/
19+
private Map<String, Object> configuration;
20+
21+
public Long getId() {
22+
return id;
23+
}
24+
25+
public void setId( Long id ) {
26+
this.id = id;
27+
}
28+
29+
public String getName() {
30+
return name;
31+
}
32+
33+
public void setName( String name ) {
34+
this.name = name;
35+
}
36+
37+
public String getDescription() {
38+
return description;
39+
}
40+
41+
public void setDescription( String description ) {
42+
this.description = description;
43+
}
44+
45+
@JsonProperty("created_at")
46+
public Date getCreatedAt() {
47+
return createdAt;
48+
}
49+
50+
public void setCreatedAt( Date createdAt ) {
51+
this.createdAt = createdAt;
52+
}
53+
54+
@JsonProperty("updated_at")
55+
public Date getUpdatedAt() {
56+
return updatedAt;
57+
}
58+
59+
public void setUpdatedAt( Date updatedAt ) {
60+
this.updatedAt = updatedAt;
61+
}
62+
63+
public Map<String, Object> getConfiguration() {
64+
return configuration;
65+
}
66+
67+
public void setConfiguration( Map<String, Object> configuration ) {
68+
this.configuration = configuration;
69+
}
70+
}

src/test/java/org/zendesk/client/v2/RealSmokeTest.java

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
package org.zendesk.client.v2;
22

3+
import static org.hamcrest.CoreMatchers.anyOf;
4+
import static org.hamcrest.CoreMatchers.is;
5+
import static org.hamcrest.CoreMatchers.not;
6+
import static org.hamcrest.CoreMatchers.notNullValue;
7+
import static org.hamcrest.CoreMatchers.nullValue;
8+
import static org.junit.Assert.assertEquals;
9+
import static org.junit.Assert.assertNotEquals;
10+
import static org.junit.Assert.assertNotNull;
11+
import static org.junit.Assert.assertThat;
12+
import static org.junit.Assert.assertTrue;
13+
import static org.junit.Assume.assumeThat;
14+
15+
import java.util.ArrayList;
16+
import java.util.Arrays;
17+
import java.util.Collections;
18+
import java.util.Date;
19+
import java.util.HashMap;
20+
import java.util.List;
21+
import java.util.Properties;
22+
import java.util.UUID;
23+
324
import org.junit.After;
425
import org.junit.BeforeClass;
526
import org.junit.Ignore;
627
import org.junit.Test;
28+
import org.zendesk.client.v2.model.AgentRole;
729
import org.zendesk.client.v2.model.Audit;
830
import org.zendesk.client.v2.model.Collaborator;
931
import org.zendesk.client.v2.model.Comment;
@@ -28,27 +50,6 @@
2850
import org.zendesk.client.v2.model.schedules.Schedule;
2951
import org.zendesk.client.v2.model.targets.Target;
3052

31-
import java.util.ArrayList;
32-
import java.util.Arrays;
33-
import java.util.Collections;
34-
import java.util.Date;
35-
import java.util.List;
36-
import java.util.HashMap;
37-
import java.util.Properties;
38-
import java.util.UUID;
39-
40-
import static org.hamcrest.CoreMatchers.anyOf;
41-
import static org.hamcrest.CoreMatchers.is;
42-
import static org.hamcrest.CoreMatchers.not;
43-
import static org.hamcrest.CoreMatchers.notNullValue;
44-
import static org.hamcrest.CoreMatchers.nullValue;
45-
import static org.junit.Assert.assertNotNull;
46-
import static org.junit.Assert.assertNotEquals;
47-
import static org.junit.Assert.assertEquals;
48-
import static org.junit.Assert.assertThat;
49-
import static org.junit.Assert.assertTrue;
50-
import static org.junit.Assume.assumeThat;
51-
5253
/**
5354
* @author stephenc
5455
* @since 04/04/2013 13:57
@@ -127,7 +128,7 @@ public void getTicketForm() throws Exception {
127128
assertThat(ticketForm, notNullValue());
128129
assertTrue(ticketForm.isEndUserVisible());
129130
}
130-
131+
131132
@Test
132133
public void getTicketForms() throws Exception {
133134
createClientWithTokenOrPassword();
@@ -137,14 +138,14 @@ public void getTicketForms() throws Exception {
137138
assertThat(ticketForm, notNullValue());
138139
}
139140
}
140-
141+
141142
@Test
142143
@Ignore("Needs specfic ticket form instance")
143144
public void getTicketFieldsOnForm() throws Exception {
144145
createClientWithTokenOrPassword();
145146
TicketForm ticketForm = instance.getTicketForm(27562);
146147
for(Integer id :ticketForm.getTicketFieldIds()){
147-
Field f = instance.getTicketField(id);
148+
Field f = instance.getTicketField(id);
148149
assertNotNull(f);
149150
}
150151
assertThat(ticketForm, notNullValue());
@@ -164,7 +165,7 @@ public void getTargets() throws Exception {
164165
}
165166
}
166167
}
167-
168+
168169
@Test
169170
@Ignore("Needs test data setup correctly")
170171
public void getTicketsPagesRequests() throws Exception {
@@ -721,4 +722,21 @@ public void getSchedules() throws Exception {
721722
}
722723
}
723724
}
725+
726+
@Test
727+
public void getCustomAgentRoles() throws Exception {
728+
createClientWithTokenOrPassword();
729+
int count = 0;
730+
for (AgentRole role : instance.getCustomAgentRoles()) {
731+
assertThat(role.getId(), notNullValue());
732+
assertThat(role.getName(), notNullValue());
733+
assertThat(role.getCreatedAt(), notNullValue());
734+
assertThat(role.getUpdatedAt(), notNullValue());
735+
assertThat(role.getConfiguration(), notNullValue());
736+
assertTrue(role.getConfiguration().containsKey("ticket_access"));
737+
if (++count > 10) {
738+
break;
739+
}
740+
}
741+
}
724742
}

0 commit comments

Comments
 (0)