-
Notifications
You must be signed in to change notification settings - Fork 75
Add support for new Admin endpoints and attributes (Closes: #196) #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
intercom-java/src/main/java/io/intercom/api/AdminAwayMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package io.intercom.api; | ||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| @SuppressWarnings("UnusedDeclaration") | ||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| @JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
| public class AdminAwayMode extends TypedData { | ||
|
|
||
| @JsonProperty("id") | ||
| private String id; | ||
|
|
||
| @JsonProperty("away_mode_enabled") | ||
| private boolean awayModeEnabled; | ||
|
|
||
| @JsonProperty("away_mode_reassign") | ||
| private boolean awayModeReassign; | ||
|
|
||
| public AdminAwayMode(String Id, boolean awayModeEnabled, boolean awayModeReassign) { | ||
| this.id = id; | ||
| this.awayModeEnabled = awayModeEnabled; | ||
| this.awayModeReassign = awayModeReassign; | ||
| } | ||
| String getId() { | ||
| return id; | ||
| } | ||
| public boolean getAwayModeEnabled(){ | ||
| return awayModeEnabled; | ||
| } | ||
|
|
||
| public boolean getAwayModeReassign(){ | ||
| return awayModeReassign; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "AdminAwayMode{" + | ||
| "id='" + id + '\'' + | ||
| ", awayModeEnabled=" + awayModeEnabled + | ||
| ", awayModeReassign=" + awayModeReassign + | ||
| "} " + super.toString(); | ||
| } | ||
| } |
78 changes: 78 additions & 0 deletions
78
intercom-java/src/test/java/io/intercom/api/AdminTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package io.intercom.api; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.google.common.collect.Lists; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static io.intercom.api.TestSupport.load; | ||
| import static org.junit.Assert.*; | ||
|
|
||
| public class AdminTest { | ||
|
|
||
| private static ObjectMapper mapper; | ||
|
|
||
| @BeforeClass | ||
| public static void beforeClass() { | ||
| mapper = MapperSupport.objectMapper(); | ||
| } | ||
|
|
||
| @Test | ||
| public void TestAdminParseJson() throws Exception { | ||
| String json = load("admin.json"); | ||
| final Admin admin = mapper.readValue(json, Admin.class); | ||
| assertEquals("admin", admin.getType()); | ||
| assertEquals("123456", admin.getId()); | ||
| assertEquals("Admin Name", admin.getName()); | ||
| assertEquals("admin@domain.com", admin.getEmail()); | ||
| assertTrue(admin.getAwayModeEnabled()); | ||
| assertFalse(admin.getAwayModeReassign()); | ||
| assertEquals( "https://avatarurl.com/image.jpg", admin.getAvatar().getImageURL().toString()); | ||
| assertNotNull(admin.getTeamIds()); | ||
| assertEquals(3, admin.getTeamIds().size()); | ||
| assertTrue(admin.getTeamIds().contains("123")); | ||
| assertTrue(admin.getTeamIds().contains("456")); | ||
| assertTrue(admin.getTeamIds().contains("789")); | ||
| } | ||
|
|
||
| @Test | ||
| public void TestAdminTeamParseJson() throws Exception { | ||
| String json = load("admin_team.json"); | ||
| final Admin admin = mapper.readValue(json, Admin.class); | ||
| assertEquals("team", admin.getType()); | ||
| assertEquals("654321", admin.getId()); | ||
| assertEquals("A Team", admin.getName()); | ||
| assertEquals("team-email@teams.intercom.io", admin.getEmail()); | ||
| assertFalse(admin.getAwayModeEnabled()); | ||
| assertFalse(admin.getAwayModeReassign()); | ||
| assertEquals("https://domain.com/avatar", admin.getAvatar().getImageURL().toString()); | ||
| assertNotNull(admin.getAdminIds()); | ||
| assertEquals(3, admin.getAdminIds().size()); | ||
| assertTrue(admin.getAdminIds().contains("321")); | ||
| assertTrue(admin.getAdminIds().contains("654")); | ||
| assertTrue(admin.getAdminIds().contains("987")); | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| public void TestAdminParseAdminList() throws Exception { | ||
| String json = load("admins.json"); | ||
| final AdminCollection adminCollection = mapper.readValue(json, AdminCollection.class); | ||
|
|
||
| assertEquals(6, adminCollection.getPage().size()); | ||
| } | ||
|
|
||
| @Test | ||
| public void TestAdminSerialiseDeserialise() throws Exception { | ||
| String json = load("admin.json"); | ||
| final Admin admin = mapper.readValue(json, Admin.class); | ||
| final String json1 = mapper.writeValueAsString(admin); | ||
| System.out.println(json1); | ||
| final Admin admin1 = mapper.readValue(json1, Admin.class); | ||
| assertTrue(admin.equals(admin1)); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "type": "admin", | ||
| "id": "123456", | ||
| "name": "Admin Name", | ||
| "email": "admin@domain.com", | ||
| "away_mode_enabled": true, | ||
| "away_mode_reassign": false, | ||
| "avatar": { | ||
| "image_url": "https://avatarurl.com/image.jpg" | ||
| }, | ||
| "team_ids": [ | ||
| 123, | ||
| 456, | ||
| 789 | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "type": "team", | ||
| "id": "654321", | ||
| "name": "A Team", | ||
| "email": "team-email@teams.intercom.io", | ||
| "away_mode_enabled": false, | ||
| "away_mode_reassign": false, | ||
| "avatar": { | ||
| "image_url": "https://domain.com/avatar" | ||
| }, | ||
| "admin_ids": [ | ||
| 987, | ||
| 654, | ||
| 321 | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| { | ||
| "type": "admin.list", | ||
| "admins": [ | ||
| { | ||
| "type": "admin", | ||
| "id": "123456", | ||
| "name": "Admin Name", | ||
| "email": "admin@domain.com", | ||
| "away_mode_enabled": true, | ||
| "away_mode_reassign": false, | ||
| "avatar": { | ||
| "image_url": "https://avatarurl.com/image.jpg" | ||
| }, | ||
| "team_ids": [ | ||
| 123, | ||
| 456, | ||
| 789 | ||
| ] | ||
| }, | ||
| { | ||
| "type": "admin", | ||
| "id": "234567", | ||
| "name": "Admin2 Name", | ||
| "email": "admin2@domain.com", | ||
| "away_mode_enabled": false, | ||
| "away_mode_reassign": false, | ||
| "avatar": { | ||
| "image_url": "https://avatarurl.com/image2.jpg" | ||
| }, | ||
| "team_ids": [ | ||
| 456, | ||
| 789 | ||
| ] | ||
| }, | ||
| { | ||
| "type": "team", | ||
| "id": "123", | ||
| "name": "A Team", | ||
| "email": "team-email@teams.intercom.io", | ||
| "away_mode_enabled": false, | ||
| "away_mode_reassign": false, | ||
| "avatar": { | ||
| "image_url": "https://domain.com/avatar" | ||
| }, | ||
| "admin_ids": [ | ||
| 123456, | ||
| 234567 | ||
| ] | ||
| }, | ||
| { | ||
| "type": "team", | ||
| "id": "456", | ||
| "name": "B Team", | ||
| "email": "team-email2@teams.intercom.io", | ||
| "away_mode_enabled": false, | ||
| "away_mode_reassign": false, | ||
| "avatar": { | ||
| "image_url": "https://domain.com/avatar2" | ||
| }, | ||
| "admin_ids": [ | ||
| 123456 | ||
| ] | ||
| }, | ||
| { | ||
| "type": "team", | ||
| "id": "789", | ||
| "name": "C Team", | ||
| "email": "team-email3@teams.intercom.io", | ||
| "away_mode_enabled": false, | ||
| "away_mode_reassign": false, | ||
| "avatar": { | ||
| "image_url": "https://domain.com/avatar3" | ||
| }, | ||
| "admin_ids": [ | ||
| ] | ||
| }, | ||
| { | ||
| "type": "admin", | ||
| "email": "bot-123123123@bots.intercom.io", | ||
| "id": "807", | ||
| "name": "A bot", | ||
| "away_mode_enabled": false, | ||
| "away_mode_reassign": false | ||
| } | ||
| ] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we need a quick test for the find?
Just wanted to check if you think this is needed or not