{"action":"created","comment":{"url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/comments/88250516","pull_request_review_id":8828554,"id":88250516,"diff_hunk":"@@ -544,3 +554,89 @@ def run(self, change_id, **kwargs):\n             return False\n \n validate_implement = ValidateImplement()\n+\n+\n+class PushMomconnectOptoutToJembi(Task):\n+    \"\"\"\n+    Sends a momconnect optout change to Jembi.\n+    \"\"\"\n+    name = \"ndoh_hub.changes.tasks.push_momconnect_optout_to_jembi\"\n+    l = get_task_logger(__name__)\n+    URL = \"%s/optout\" % settings.JEMBI_BASE_URL\n+\n+    def get_today(self):\n+        return datetime.datetime.today()\n+\n+    def get_timestamp(self):\n+        return self.get_today().strftime(\"%Y%m%d%H%M%S\")\n+\n+    def get_identity_address(self, identity, address_type='msisdn'):\n+        \"\"\"\n+        Returns a single address for the identity for the given address\n+        type.\n+        \"\"\"\n+        addresses = identity.get(\n+            'details', {}).get('addresses', {}).get(address_type, {})\n+        address = None\n+        for address, details in iteritems(addresses):\n+            if details.get('default'):\n+                return address\n+        return address\n+\n+    def get_optout_reason(self, reason):\n+        \"\"\"\n+        Returns the numerical Jembi optout reason for the given optout reason.\n+        \"\"\"\n+        return {\n+            'miscarriage': 1,\n+            'stillbirth': 2,\n+            'babyloss': 3,\n+            'not_useful': 4,\n+            'other': 5,\n+            'unknown': 6,\n+            'job_change': 7,\n+            'number_owner_change': 8,\n+            'not_hiv_pos': 9,\n+        }.get(reason)\n+\n+    def build_jembi_json(self, change):\n+        identity = is_client.get_identity(change.registrant_id) or {}\n+        address = self.get_identity_address(identity)\n+        return {\n+            'encdate': self.get_timestamp(),\n+            'mha': 1,\n+            'swt': 1,\n+            'cmsisdn': address,\n+            'dmsisdn': address,","path":"changes/tasks.py","position":90,"original_position":90,"commit_id":"c9de5988a0cdde4f3996d7746dba2420b232e24b","original_commit_id":"c9de5988a0cdde4f3996d7746dba2420b232e24b","user":{"login":"jpaidoussi","id":3963913,"avatar_url":"https://avatars.githubusercontent.com/u/3963913?v=3","gravatar_id":"","url":"https://api.github.com/users/jpaidoussi","html_url":"https://github.com/jpaidoussi","followers_url":"https://api.github.com/users/jpaidoussi/followers","following_url":"https://api.github.com/users/jpaidoussi/following{/other_user}","gists_url":"https://api.github.com/users/jpaidoussi/gists{/gist_id}","starred_url":"https://api.github.com/users/jpaidoussi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpaidoussi/subscriptions","organizations_url":"https://api.github.com/users/jpaidoussi/orgs","repos_url":"https://api.github.com/users/jpaidoussi/repos","events_url":"https://api.github.com/users/jpaidoussi/events{/privacy}","received_events_url":"https://api.github.com/users/jpaidoussi/received_events","type":"User","site_admin":false},"body":"Do opt-outs never come from a health care worker device for a mom?","created_at":"2016-11-16T14:48:18Z","updated_at":"2016-11-16T14:48:18Z","html_url":"https://github.com/praekeltfoundation/ndoh-hub/pull/44#discussion_r88250516","pull_request_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/comments/88250516"},"html":{"href":"https://github.com/praekeltfoundation/ndoh-hub/pull/44#discussion_r88250516"},"pull_request":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/44","id":93949013,"html_url":"https://github.com/praekeltfoundation/ndoh-hub/pull/44","diff_url":"https://github.com/praekeltfoundation/ndoh-hub/pull/44.diff","patch_url":"https://github.com/praekeltfoundation/ndoh-hub/pull/44.patch","issue_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues/44","number":44,"state":"open","locked":false,"title":"Submit momconnect optouts to Jembi","user":{"login":"rudigiesler","id":8234653,"avatar_url":"https://avatars.githubusercontent.com/u/8234653?v=3","gravatar_id":"","url":"https://api.github.com/users/rudigiesler","html_url":"https://github.com/rudigiesler","followers_url":"https://api.github.com/users/rudigiesler/followers","following_url":"https://api.github.com/users/rudigiesler/following{/other_user}","gists_url":"https://api.github.com/users/rudigiesler/gists{/gist_id}","starred_url":"https://api.github.com/users/rudigiesler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudigiesler/subscriptions","organizations_url":"https://api.github.com/users/rudigiesler/orgs","repos_url":"https://api.github.com/users/rudigiesler/repos","events_url":"https://api.github.com/users/rudigiesler/events{/privacy}","received_events_url":"https://api.github.com/users/rudigiesler/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-16T11:34:22Z","updated_at":"2016-11-16T14:48:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f2895e6c2b61ea1c77a5ffa44e09b5ac04995b5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/44/commits","review_comments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/44/comments","review_comment_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/comments{/number}","comments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues/44/comments","statuses_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/statuses/c9de5988a0cdde4f3996d7746dba2420b232e24b","head":{"label":"praekeltfoundation:feature/MOMZA-391-submit-momconnect-optouts","ref":"feature/MOMZA-391-submit-momconnect-optouts","sha":"c9de5988a0cdde4f3996d7746dba2420b232e24b","user":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":61732760,"name":"ndoh-hub","full_name":"praekeltfoundation/ndoh-hub","owner":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekeltfoundation/ndoh-hub","description":null,"fork":false,"url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub","forks_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/forks","keys_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/teams","hooks_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/hooks","issue_events_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues/events{/number}","events_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/events","assignees_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/assignees{/user}","branches_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/branches{/branch}","tags_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/tags","blobs_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/statuses/{sha}","languages_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/languages","stargazers_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/stargazers","contributors_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/contributors","subscribers_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/subscribers","subscription_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/subscription","commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/contents/{+path}","compare_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/merges","archive_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/downloads","issues_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues{/number}","pulls_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls{/number}","milestones_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/milestones{/number}","notifications_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/labels{/name}","releases_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/releases{/id}","deployments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/deployments","created_at":"2016-06-22T16:04:09Z","updated_at":"2016-07-18T16:42:39Z","pushed_at":"2016-11-16T14:40:25Z","git_url":"git://github.com/praekeltfoundation/ndoh-hub.git","ssh_url":"git@github.com:praekeltfoundation/ndoh-hub.git","clone_url":"https://github.com/praekeltfoundation/ndoh-hub.git","svn_url":"https://github.com/praekeltfoundation/ndoh-hub","homepage":null,"size":349,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":0,"default_branch":"develop"}},"base":{"label":"praekeltfoundation:develop","ref":"develop","sha":"c18c4991421d5f95c1b169657f63ce877945e407","user":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":61732760,"name":"ndoh-hub","full_name":"praekeltfoundation/ndoh-hub","owner":{"login":"praekeltfoundation","id":15786759,"avatar_url":"https://avatars.githubusercontent.com/u/15786759?v=3","gravatar_id":"","url":"https://api.github.com/users/praekeltfoundation","html_url":"https://github.com/praekeltfoundation","followers_url":"https://api.github.com/users/praekeltfoundation/followers","following_url":"https://api.github.com/users/praekeltfoundation/following{/other_user}","gists_url":"https://api.github.com/users/praekeltfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/praekeltfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekeltfoundation/subscriptions","organizations_url":"https://api.github.com/users/praekeltfoundation/orgs","repos_url":"https://api.github.com/users/praekeltfoundation/repos","events_url":"https://api.github.com/users/praekeltfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/praekeltfoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekeltfoundation/ndoh-hub","description":null,"fork":false,"url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub","forks_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/forks","keys_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/teams","hooks_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/hooks","issue_events_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues/events{/number}","events_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/events","assignees_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/assignees{/user}","branches_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/branches{/branch}","tags_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/tags","blobs_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/statuses/{sha}","languages_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/languages","stargazers_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/stargazers","contributors_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/contributors","subscribers_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/subscribers","subscription_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/subscription","commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/contents/{+path}","compare_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/merges","archive_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/downloads","issues_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues{/number}","pulls_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls{/number}","milestones_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/milestones{/number}","notifications_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/labels{/name}","releases_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/releases{/id}","deployments_url":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/deployments","created_at":"2016-06-22T16:04:09Z","updated_at":"2016-07-18T16:42:39Z","pushed_at":"2016-11-16T14:40:25Z","git_url":"git://github.com/praekeltfoundation/ndoh-hub.git","ssh_url":"git@github.com:praekeltfoundation/ndoh-hub.git","clone_url":"https://github.com/praekeltfoundation/ndoh-hub.git","svn_url":"https://github.com/praekeltfoundation/ndoh-hub","homepage":null,"size":349,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/44"},"html":{"href":"https://github.com/praekeltfoundation/ndoh-hub/pull/44"},"issue":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues/44"},"comments":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/praekeltfoundation/ndoh-hub/statuses/c9de5988a0cdde4f3996d7746dba2420b232e24b"}}}}
{"actor":{"display_login":"jpaidoussi"}}