{"action":"created","comment":{"url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/comments/67407739","id":67407739,"diff_hunk":"@@ -0,0 +1,119 @@\n+package com.mambu.apisdk.json;\n+\n+import java.lang.reflect.Type;\n+import java.util.Arrays;\n+import java.util.HashSet;\n+import java.util.Set;\n+\n+import com.google.gson.Gson;\n+import com.google.gson.GsonBuilder;\n+import com.google.gson.JsonElement;\n+import com.google.gson.JsonObject;\n+import com.google.gson.JsonSerializationContext;\n+import com.google.gson.JsonSerializer;\n+import com.mambu.apisdk.util.APIData;\n+import com.mambu.apisdk.util.GsonUtils;\n+import com.mambu.clients.shared.model.Group;\n+import com.mambu.clients.shared.model.GroupExpanded;\n+import com.mambu.clients.shared.model.GroupMember;\n+import com.mambu.clients.shared.model.GroupRole;\n+\n+public class GroupExpandedPatchSerializer implements JsonSerializer<GroupExpanded> {\n+\n+\t/**\n+\t * A list of fields from GroupExpanded supported by PATCH Group API. See MBU-12985\n+\t * \n+\t * As of Mambu 4.2 the following fields can be patched: id, groupName, notes, emailAddress, mobilePhone1\n+\t * homePhone, preferredLanguage, assignedBranchKey, assignedCentreKey. And it also allows the replacing of \n+\t * the fields in groupMembers and groupRoles (Warning: these last two are just replacements operations not patch ones).\n+\t * \n+\t */\n+\tprivate final static Set<String> groupExpandedPatchFields = new HashSet<String>(Arrays.asList(\n+\t\t\tAPIData.THE_GROUP, APIData.GROUP_MEMBERS, APIData.GROUP_ROLES\n+\t\t\t));\n+\t\n+\t/**\n+\t * A list of fields from the Group class supported by PATCH group API.\n+\t * \n+\t */\n+\tprivate final static Set<String> groupPatchFields = new HashSet<String>(Arrays.asList(APIData.ID,\n+\t\t\tAPIData.GROUP_NAME, APIData.NOTES, APIData.EMAIL_ADDRESS, APIData.MOBILE_PHONE_1, APIData.HOME_PHONE,\n+\t\t\tAPIData.PREFERRED_LANGUAGE, APIData.ASSIGNED_BRANCH_KEY, APIData.ASSIGNED_CENTRE_KEY \n+\t\t\t));\n+\t\n+\t/**\n+\t * A list of fields from the group roles supported by PATCH group API.\n+\t * \n+\t */\n+\tprivate final static Set<String> groupRolesFields = new HashSet<String>(Arrays.asList(APIData.GROUP_ROLE_NAME_KEY,\n+\t\t\tAPIData.CLIENT_KEY)); \n+\t\n+\t/**\n+\t * A list of fields from the group members supported by PATCH group API.\n+\t * \n+\t */\n+\tprivate final static Set<String> groupMembersFields = new HashSet<String>(Arrays.asList(APIData.CLIENT_KEY));\n+\n+\tprivate final static JsonFieldsInclusionStrategy groupExpandedPatchInclusionStrategy;\n+\t\n+\t// Create inclusion strategy for Group PATCH API. Include allowed Group, GroupMembers  \n+\t// and GroupRoles fields\n+\tstatic{\n+\t\tgroupExpandedPatchInclusionStrategy = new JsonFieldsInclusionStrategy(GroupExpanded.class, groupExpandedPatchFields);\n+\t\tgroupExpandedPatchInclusionStrategy.addInclusion(Group.class, groupPatchFields);\n+\t\tgroupExpandedPatchInclusionStrategy.addInclusion(GroupRole.class, groupRolesFields);\n+\t\tgroupExpandedPatchInclusionStrategy.addInclusion(GroupMember.class, groupMembersFields);\n+\t}\n+\tpublic GroupExpandedPatchSerializer() {\n+\t}\n+\n+\t// Serialize GroupExpanded using custom inclusion strategy as well as helper methods to adjust \n+\t// the \"theGroup\" field.\n+\t@Override\n+\tpublic JsonElement serialize(GroupExpanded groupExpanded, Type type, JsonSerializationContext context) {\n+\t\tGsonBuilder gsonBuilder = GsonUtils.createGsonBuilder();\n+\t\t// Add our groupExpandedPatchInclusionStrategy\n+\t\tgsonBuilder.addSerializationExclusionStrategy(groupExpandedPatchInclusionStrategy);\n+\t\tGson gson = gsonBuilder.create();\n+\t\t\n+\t\tJsonElement groupJsonElement = gson.toJsonTree(groupExpanded, type);\n+\t\tJsonObject groupExpandedObject = groupJsonElement.getAsJsonObject();\n+\t\t\n+\t\t// Adjust format for \"theGroup\" field, replaces it with \"group\" field \n+\t\t// as the group API expects it  \n+\t\tadjustGroupElement(groupExpandedObject);\n+\t\n+\t\treturn groupExpandedObject;\n+\t}\n+\n+\tprivate void adjustGroupElement(JsonObject groupExpandedObject) {","path":"src/com/mambu/apisdk/json/GroupExpandedPatchSerializer.java","position":89,"original_position":89,"commit_id":"6527309a45867792dc6df6cd44824a26b906590f","original_commit_id":"6527309a45867792dc6df6cd44824a26b906590f","user":{"login":"mdanilkis","id":3077634,"avatar_url":"https://avatars.githubusercontent.com/u/3077634?v=3","gravatar_id":"","url":"https://api.github.com/users/mdanilkis","html_url":"https://github.com/mdanilkis","followers_url":"https://api.github.com/users/mdanilkis/followers","following_url":"https://api.github.com/users/mdanilkis/following{/other_user}","gists_url":"https://api.github.com/users/mdanilkis/gists{/gist_id}","starred_url":"https://api.github.com/users/mdanilkis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdanilkis/subscriptions","organizations_url":"https://api.github.com/users/mdanilkis/orgs","repos_url":"https://api.github.com/users/mdanilkis/repos","events_url":"https://api.github.com/users/mdanilkis/events{/privacy}","received_events_url":"https://api.github.com/users/mdanilkis/received_events","type":"User","site_admin":false},"body":"Please add a brief comment or a javadoc for this method","created_at":"2016-06-16T19:20:07Z","updated_at":"2016-06-16T19:20:07Z","html_url":"https://github.com/mdanilkis/Mambu-APIs-Java/pull/1#discussion_r67407739","pull_request_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/comments/67407739"},"html":{"href":"https://github.com/mdanilkis/Mambu-APIs-Java/pull/1#discussion_r67407739"},"pull_request":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/1","id":73697773,"html_url":"https://github.com/mdanilkis/Mambu-APIs-Java/pull/1","diff_url":"https://github.com/mdanilkis/Mambu-APIs-Java/pull/1.diff","patch_url":"https://github.com/mdanilkis/Mambu-APIs-Java/pull/1.patch","issue_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/issues/1","number":1,"state":"open","locked":false,"title":"Please review my fixes for MBU12661, MBU12985 and MBU12629","user":{"login":"acostros","id":18039369,"avatar_url":"https://avatars.githubusercontent.com/u/18039369?v=3","gravatar_id":"","url":"https://api.github.com/users/acostros","html_url":"https://github.com/acostros","followers_url":"https://api.github.com/users/acostros/followers","following_url":"https://api.github.com/users/acostros/following{/other_user}","gists_url":"https://api.github.com/users/acostros/gists{/gist_id}","starred_url":"https://api.github.com/users/acostros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acostros/subscriptions","organizations_url":"https://api.github.com/users/acostros/orgs","repos_url":"https://api.github.com/users/acostros/repos","events_url":"https://api.github.com/users/acostros/events{/privacy}","received_events_url":"https://api.github.com/users/acostros/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-14T08:20:05Z","updated_at":"2016-06-16T19:20:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45900f60a4b9731a88b0be6759e1b431ff60207a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/1/commits","review_comments_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/1/comments","review_comment_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/issues/1/comments","statuses_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/statuses/6527309a45867792dc6df6cd44824a26b906590f","head":{"label":"acostros:master","ref":"master","sha":"6527309a45867792dc6df6cd44824a26b906590f","user":{"login":"acostros","id":18039369,"avatar_url":"https://avatars.githubusercontent.com/u/18039369?v=3","gravatar_id":"","url":"https://api.github.com/users/acostros","html_url":"https://github.com/acostros","followers_url":"https://api.github.com/users/acostros/followers","following_url":"https://api.github.com/users/acostros/following{/other_user}","gists_url":"https://api.github.com/users/acostros/gists{/gist_id}","starred_url":"https://api.github.com/users/acostros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acostros/subscriptions","organizations_url":"https://api.github.com/users/acostros/orgs","repos_url":"https://api.github.com/users/acostros/repos","events_url":"https://api.github.com/users/acostros/events{/privacy}","received_events_url":"https://api.github.com/users/acostros/received_events","type":"User","site_admin":false},"repo":{"id":60098080,"name":"Mambu-APIs-Java","full_name":"acostros/Mambu-APIs-Java","owner":{"login":"acostros","id":18039369,"avatar_url":"https://avatars.githubusercontent.com/u/18039369?v=3","gravatar_id":"","url":"https://api.github.com/users/acostros","html_url":"https://github.com/acostros","followers_url":"https://api.github.com/users/acostros/followers","following_url":"https://api.github.com/users/acostros/following{/other_user}","gists_url":"https://api.github.com/users/acostros/gists{/gist_id}","starred_url":"https://api.github.com/users/acostros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acostros/subscriptions","organizations_url":"https://api.github.com/users/acostros/orgs","repos_url":"https://api.github.com/users/acostros/repos","events_url":"https://api.github.com/users/acostros/events{/privacy}","received_events_url":"https://api.github.com/users/acostros/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/acostros/Mambu-APIs-Java","description":"Java Library for working the the Mambu APIs","fork":true,"url":"https://api.github.com/repos/acostros/Mambu-APIs-Java","forks_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/forks","keys_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/teams","hooks_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/hooks","issue_events_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/issues/events{/number}","events_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/events","assignees_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/assignees{/user}","branches_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/branches{/branch}","tags_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/tags","blobs_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/git/refs{/sha}","trees_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/statuses/{sha}","languages_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/languages","stargazers_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/stargazers","contributors_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/contributors","subscribers_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/subscribers","subscription_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/subscription","commits_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/commits{/sha}","git_commits_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/git/commits{/sha}","comments_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/comments{/number}","issue_comment_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/issues/comments{/number}","contents_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/contents/{+path}","compare_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/merges","archive_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/downloads","issues_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/issues{/number}","pulls_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/pulls{/number}","milestones_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/milestones{/number}","notifications_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/labels{/name}","releases_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/releases{/id}","deployments_url":"https://api.github.com/repos/acostros/Mambu-APIs-Java/deployments","created_at":"2016-05-31T14:45:40Z","updated_at":"2016-05-31T14:45:41Z","pushed_at":"2016-06-16T08:06:05Z","git_url":"git://github.com/acostros/Mambu-APIs-Java.git","ssh_url":"git@github.com:acostros/Mambu-APIs-Java.git","clone_url":"https://github.com/acostros/Mambu-APIs-Java.git","svn_url":"https://github.com/acostros/Mambu-APIs-Java","homepage":"www.mambu.com","size":86900,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mdanilkis:master","ref":"master","sha":"b0d03252ceb24a0d79b4276e28783779de01e19d","user":{"login":"mdanilkis","id":3077634,"avatar_url":"https://avatars.githubusercontent.com/u/3077634?v=3","gravatar_id":"","url":"https://api.github.com/users/mdanilkis","html_url":"https://github.com/mdanilkis","followers_url":"https://api.github.com/users/mdanilkis/followers","following_url":"https://api.github.com/users/mdanilkis/following{/other_user}","gists_url":"https://api.github.com/users/mdanilkis/gists{/gist_id}","starred_url":"https://api.github.com/users/mdanilkis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdanilkis/subscriptions","organizations_url":"https://api.github.com/users/mdanilkis/orgs","repos_url":"https://api.github.com/users/mdanilkis/repos","events_url":"https://api.github.com/users/mdanilkis/events{/privacy}","received_events_url":"https://api.github.com/users/mdanilkis/received_events","type":"User","site_admin":false},"repo":{"id":7281087,"name":"Mambu-APIs-Java","full_name":"mdanilkis/Mambu-APIs-Java","owner":{"login":"mdanilkis","id":3077634,"avatar_url":"https://avatars.githubusercontent.com/u/3077634?v=3","gravatar_id":"","url":"https://api.github.com/users/mdanilkis","html_url":"https://github.com/mdanilkis","followers_url":"https://api.github.com/users/mdanilkis/followers","following_url":"https://api.github.com/users/mdanilkis/following{/other_user}","gists_url":"https://api.github.com/users/mdanilkis/gists{/gist_id}","starred_url":"https://api.github.com/users/mdanilkis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdanilkis/subscriptions","organizations_url":"https://api.github.com/users/mdanilkis/orgs","repos_url":"https://api.github.com/users/mdanilkis/repos","events_url":"https://api.github.com/users/mdanilkis/events{/privacy}","received_events_url":"https://api.github.com/users/mdanilkis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mdanilkis/Mambu-APIs-Java","description":"Java Library for working the the Mambu APIs","fork":true,"url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java","forks_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/forks","keys_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/teams","hooks_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/hooks","issue_events_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/issues/events{/number}","events_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/events","assignees_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/assignees{/user}","branches_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/branches{/branch}","tags_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/tags","blobs_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/statuses/{sha}","languages_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/languages","stargazers_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/stargazers","contributors_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/contributors","subscribers_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/subscribers","subscription_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/subscription","commits_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/contents/{+path}","compare_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/merges","archive_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/downloads","issues_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/issues{/number}","pulls_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls{/number}","milestones_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/milestones{/number}","notifications_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/labels{/name}","releases_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/releases{/id}","deployments_url":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/deployments","created_at":"2012-12-22T00:46:59Z","updated_at":"2015-05-08T04:03:00Z","pushed_at":"2016-06-16T08:06:06Z","git_url":"git://github.com/mdanilkis/Mambu-APIs-Java.git","ssh_url":"git@github.com:mdanilkis/Mambu-APIs-Java.git","clone_url":"https://github.com/mdanilkis/Mambu-APIs-Java.git","svn_url":"https://github.com/mdanilkis/Mambu-APIs-Java","homepage":"www.mambu.com","size":86611,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/1"},"html":{"href":"https://github.com/mdanilkis/Mambu-APIs-Java/pull/1"},"issue":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/issues/1"},"comments":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/mdanilkis/Mambu-APIs-Java/statuses/6527309a45867792dc6df6cd44824a26b906590f"}}}}
{"actor":{"display_login":"mdanilkis"}}