{"action":"created","comment":{"url":"https://api.github.com/repos/mautic/mautic/pulls/comments/57014706","id":57014706,"diff_hunk":"@@ -1133,6 +1133,110 @@ public function populateLeadData($lead, $config = array())\n     }\n \n     /**\n+     * Takes profile data from an integration and maps it to Mautic's lead fields\n+     *\n+     * @param       $data\n+     * @param array $config\n+     *\n+     * @return array\n+     */\n+    public function populateMauticLeadData($data, $config = array())\n+    {\n+        // Glean supported fields from what was returned by the integration\n+        $gleanedData = $this->matchUpData($data);\n+\n+        if (!isset($config['leadFields'])) {\n+            $config = $this->mergeConfigToFeatureSettings($config);\n+\n+            if (empty($config['leadFields'])) {\n+\n+                return array();\n+            }\n+        }\n+\n+        $leadFields      = $config['leadFields'];\n+        $availableFields = $this->getAvailableLeadFields($config);\n+        $matched         = array();\n+        $this->factory->getLogger()->addError(print_r($leadFields, true)); \n+        $this->factory->getLogger()->addError(print_r($gleanedData, true));\n+\n+\n+        foreach ($gleanedData as $key => $field) {\n+            if (isset($leadFields[$key]) && isset($gleanedData[$key])) {\n+                $matched[$leadFields[$key]] = $gleanedData[$key];\n+            }\n+        }\n+        $this->factory->getLogger()->addError(print_r($matched, true));\n+        return $matched;\n+    }\n+\n+    /**\n+     * Create or update existing Mautic lead from the integration's profile data\n+     *\n+     * @param mixed     $data     Profile data from integration\n+     * @param bool|true $persist  Set to false to not persist lead to the database in this method\n+     *\n+     * @return Lead\n+     */\n+    public function getMauticLead($data, $persist = true)\n+    {\n+        if (is_object($data)) {\n+            // Convert to array in all levels\n+            $data = json_encode(json_decode($data));","path":"app/bundles/PluginBundle/Integration/AbstractIntegration.php","position":null,"original_position":53,"commit_id":"e33696429de1c4422d3acd8339b311d6de6d87e7","original_commit_id":"21f848e61474c5dab91e18ecf4ee7cebc9f116d3","user":{"login":"mqueme","id":1496976,"avatar_url":"https://avatars.githubusercontent.com/u/1496976?v=3","gravatar_id":"","url":"https://api.github.com/users/mqueme","html_url":"https://github.com/mqueme","followers_url":"https://api.github.com/users/mqueme/followers","following_url":"https://api.github.com/users/mqueme/following{/other_user}","gists_url":"https://api.github.com/users/mqueme/gists{/gist_id}","starred_url":"https://api.github.com/users/mqueme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqueme/subscriptions","organizations_url":"https://api.github.com/users/mqueme/orgs","repos_url":"https://api.github.com/users/mqueme/repos","events_url":"https://api.github.com/users/mqueme/events{/privacy}","received_events_url":"https://api.github.com/users/mqueme/received_events","type":"User","site_admin":false},"body":"tested, and changed matchup function to treat all data as array as well.","created_at":"2016-03-22T16:06:03Z","updated_at":"2016-03-22T16:06:03Z","html_url":"https://github.com/mautic/mautic/pull/1552#discussion_r57014706","pull_request_url":"https://api.github.com/repos/mautic/mautic/pulls/1552","_links":{"self":{"href":"https://api.github.com/repos/mautic/mautic/pulls/comments/57014706"},"html":{"href":"https://github.com/mautic/mautic/pull/1552#discussion_r57014706"},"pull_request":{"href":"https://api.github.com/repos/mautic/mautic/pulls/1552"}}},"pull_request":{"url":"https://api.github.com/repos/mautic/mautic/pulls/1552","id":63639869,"html_url":"https://github.com/mautic/mautic/pull/1552","diff_url":"https://github.com/mautic/mautic/pull/1552.diff","patch_url":"https://github.com/mautic/mautic/pull/1552.patch","issue_url":"https://api.github.com/repos/mautic/mautic/issues/1552","number":1552,"state":"open","locked":false,"title":"Social login","user":{"login":"mqueme","id":1496976,"avatar_url":"https://avatars.githubusercontent.com/u/1496976?v=3","gravatar_id":"","url":"https://api.github.com/users/mqueme","html_url":"https://github.com/mqueme","followers_url":"https://api.github.com/users/mqueme/followers","following_url":"https://api.github.com/users/mqueme/following{/other_user}","gists_url":"https://api.github.com/users/mqueme/gists{/gist_id}","starred_url":"https://api.github.com/users/mqueme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqueme/subscriptions","organizations_url":"https://api.github.com/users/mqueme/orgs","repos_url":"https://api.github.com/users/mqueme/repos","events_url":"https://api.github.com/users/mqueme/events{/privacy}","received_events_url":"https://api.github.com/users/mqueme/received_events","type":"User","site_admin":false},"body":"## Description\r\nAdded new field options when creating a form for a Facebook login button and a g+ login button\r\nbuttons auto fill matched fields on form with social profile data\r\nwhen form is submitted it creates or updates leads with social profile data\r\n\r\n## Steps to test\r\nFacebook and Google plugins must be enabled.\r\nclient credentials must be entered in the social plugin and authorized\r\nadd new buttons on form","created_at":"2016-03-21T22:03:18Z","updated_at":"2016-03-22T16:06:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0dae9dd75d8c06ffdcf864ccfcfcd5fbf368b855","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mautic/mautic/pulls/1552/commits","review_comments_url":"https://api.github.com/repos/mautic/mautic/pulls/1552/comments","review_comment_url":"https://api.github.com/repos/mautic/mautic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mautic/mautic/issues/1552/comments","statuses_url":"https://api.github.com/repos/mautic/mautic/statuses/e33696429de1c4422d3acd8339b311d6de6d87e7","head":{"label":"mqueme:social-login","ref":"social-login","sha":"e33696429de1c4422d3acd8339b311d6de6d87e7","user":{"login":"mqueme","id":1496976,"avatar_url":"https://avatars.githubusercontent.com/u/1496976?v=3","gravatar_id":"","url":"https://api.github.com/users/mqueme","html_url":"https://github.com/mqueme","followers_url":"https://api.github.com/users/mqueme/followers","following_url":"https://api.github.com/users/mqueme/following{/other_user}","gists_url":"https://api.github.com/users/mqueme/gists{/gist_id}","starred_url":"https://api.github.com/users/mqueme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqueme/subscriptions","organizations_url":"https://api.github.com/users/mqueme/orgs","repos_url":"https://api.github.com/users/mqueme/repos","events_url":"https://api.github.com/users/mqueme/events{/privacy}","received_events_url":"https://api.github.com/users/mqueme/received_events","type":"User","site_admin":false},"repo":{"id":52972139,"name":"mautic","full_name":"mqueme/mautic","owner":{"login":"mqueme","id":1496976,"avatar_url":"https://avatars.githubusercontent.com/u/1496976?v=3","gravatar_id":"","url":"https://api.github.com/users/mqueme","html_url":"https://github.com/mqueme","followers_url":"https://api.github.com/users/mqueme/followers","following_url":"https://api.github.com/users/mqueme/following{/other_user}","gists_url":"https://api.github.com/users/mqueme/gists{/gist_id}","starred_url":"https://api.github.com/users/mqueme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mqueme/subscriptions","organizations_url":"https://api.github.com/users/mqueme/orgs","repos_url":"https://api.github.com/users/mqueme/repos","events_url":"https://api.github.com/users/mqueme/events{/privacy}","received_events_url":"https://api.github.com/users/mqueme/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mqueme/mautic","description":"Mautic: Open Source Marketing Automation Software.","fork":true,"url":"https://api.github.com/repos/mqueme/mautic","forks_url":"https://api.github.com/repos/mqueme/mautic/forks","keys_url":"https://api.github.com/repos/mqueme/mautic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mqueme/mautic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mqueme/mautic/teams","hooks_url":"https://api.github.com/repos/mqueme/mautic/hooks","issue_events_url":"https://api.github.com/repos/mqueme/mautic/issues/events{/number}","events_url":"https://api.github.com/repos/mqueme/mautic/events","assignees_url":"https://api.github.com/repos/mqueme/mautic/assignees{/user}","branches_url":"https://api.github.com/repos/mqueme/mautic/branches{/branch}","tags_url":"https://api.github.com/repos/mqueme/mautic/tags","blobs_url":"https://api.github.com/repos/mqueme/mautic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mqueme/mautic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mqueme/mautic/git/refs{/sha}","trees_url":"https://api.github.com/repos/mqueme/mautic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mqueme/mautic/statuses/{sha}","languages_url":"https://api.github.com/repos/mqueme/mautic/languages","stargazers_url":"https://api.github.com/repos/mqueme/mautic/stargazers","contributors_url":"https://api.github.com/repos/mqueme/mautic/contributors","subscribers_url":"https://api.github.com/repos/mqueme/mautic/subscribers","subscription_url":"https://api.github.com/repos/mqueme/mautic/subscription","commits_url":"https://api.github.com/repos/mqueme/mautic/commits{/sha}","git_commits_url":"https://api.github.com/repos/mqueme/mautic/git/commits{/sha}","comments_url":"https://api.github.com/repos/mqueme/mautic/comments{/number}","issue_comment_url":"https://api.github.com/repos/mqueme/mautic/issues/comments{/number}","contents_url":"https://api.github.com/repos/mqueme/mautic/contents/{+path}","compare_url":"https://api.github.com/repos/mqueme/mautic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mqueme/mautic/merges","archive_url":"https://api.github.com/repos/mqueme/mautic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mqueme/mautic/downloads","issues_url":"https://api.github.com/repos/mqueme/mautic/issues{/number}","pulls_url":"https://api.github.com/repos/mqueme/mautic/pulls{/number}","milestones_url":"https://api.github.com/repos/mqueme/mautic/milestones{/number}","notifications_url":"https://api.github.com/repos/mqueme/mautic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mqueme/mautic/labels{/name}","releases_url":"https://api.github.com/repos/mqueme/mautic/releases{/id}","deployments_url":"https://api.github.com/repos/mqueme/mautic/deployments","created_at":"2016-03-02T15:07:41Z","updated_at":"2016-03-02T15:07:46Z","pushed_at":"2016-03-22T16:03:24Z","git_url":"git://github.com/mqueme/mautic.git","ssh_url":"git@github.com:mqueme/mautic.git","clone_url":"https://github.com/mqueme/mautic.git","svn_url":"https://github.com/mqueme/mautic","homepage":"https://www.mautic.org","size":33058,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"staging"}},"base":{"label":"mautic:staging","ref":"staging","sha":"e146b2eb2a2a153c0097e7ab8bdce201fb5f24ce","user":{"login":"mautic","id":5257677,"avatar_url":"https://avatars.githubusercontent.com/u/5257677?v=3","gravatar_id":"","url":"https://api.github.com/users/mautic","html_url":"https://github.com/mautic","followers_url":"https://api.github.com/users/mautic/followers","following_url":"https://api.github.com/users/mautic/following{/other_user}","gists_url":"https://api.github.com/users/mautic/gists{/gist_id}","starred_url":"https://api.github.com/users/mautic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mautic/subscriptions","organizations_url":"https://api.github.com/users/mautic/orgs","repos_url":"https://api.github.com/users/mautic/repos","events_url":"https://api.github.com/users/mautic/events{/privacy}","received_events_url":"https://api.github.com/users/mautic/received_events","type":"Organization","site_admin":false},"repo":{"id":12204147,"name":"mautic","full_name":"mautic/mautic","owner":{"login":"mautic","id":5257677,"avatar_url":"https://avatars.githubusercontent.com/u/5257677?v=3","gravatar_id":"","url":"https://api.github.com/users/mautic","html_url":"https://github.com/mautic","followers_url":"https://api.github.com/users/mautic/followers","following_url":"https://api.github.com/users/mautic/following{/other_user}","gists_url":"https://api.github.com/users/mautic/gists{/gist_id}","starred_url":"https://api.github.com/users/mautic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mautic/subscriptions","organizations_url":"https://api.github.com/users/mautic/orgs","repos_url":"https://api.github.com/users/mautic/repos","events_url":"https://api.github.com/users/mautic/events{/privacy}","received_events_url":"https://api.github.com/users/mautic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mautic/mautic","description":"Mautic: Open Source Marketing Automation Software.","fork":false,"url":"https://api.github.com/repos/mautic/mautic","forks_url":"https://api.github.com/repos/mautic/mautic/forks","keys_url":"https://api.github.com/repos/mautic/mautic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mautic/mautic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mautic/mautic/teams","hooks_url":"https://api.github.com/repos/mautic/mautic/hooks","issue_events_url":"https://api.github.com/repos/mautic/mautic/issues/events{/number}","events_url":"https://api.github.com/repos/mautic/mautic/events","assignees_url":"https://api.github.com/repos/mautic/mautic/assignees{/user}","branches_url":"https://api.github.com/repos/mautic/mautic/branches{/branch}","tags_url":"https://api.github.com/repos/mautic/mautic/tags","blobs_url":"https://api.github.com/repos/mautic/mautic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mautic/mautic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mautic/mautic/git/refs{/sha}","trees_url":"https://api.github.com/repos/mautic/mautic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mautic/mautic/statuses/{sha}","languages_url":"https://api.github.com/repos/mautic/mautic/languages","stargazers_url":"https://api.github.com/repos/mautic/mautic/stargazers","contributors_url":"https://api.github.com/repos/mautic/mautic/contributors","subscribers_url":"https://api.github.com/repos/mautic/mautic/subscribers","subscription_url":"https://api.github.com/repos/mautic/mautic/subscription","commits_url":"https://api.github.com/repos/mautic/mautic/commits{/sha}","git_commits_url":"https://api.github.com/repos/mautic/mautic/git/commits{/sha}","comments_url":"https://api.github.com/repos/mautic/mautic/comments{/number}","issue_comment_url":"https://api.github.com/repos/mautic/mautic/issues/comments{/number}","contents_url":"https://api.github.com/repos/mautic/mautic/contents/{+path}","compare_url":"https://api.github.com/repos/mautic/mautic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mautic/mautic/merges","archive_url":"https://api.github.com/repos/mautic/mautic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mautic/mautic/downloads","issues_url":"https://api.github.com/repos/mautic/mautic/issues{/number}","pulls_url":"https://api.github.com/repos/mautic/mautic/pulls{/number}","milestones_url":"https://api.github.com/repos/mautic/mautic/milestones{/number}","notifications_url":"https://api.github.com/repos/mautic/mautic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mautic/mautic/labels{/name}","releases_url":"https://api.github.com/repos/mautic/mautic/releases{/id}","deployments_url":"https://api.github.com/repos/mautic/mautic/deployments","created_at":"2013-08-19T00:36:28Z","updated_at":"2016-03-22T09:18:47Z","pushed_at":"2016-03-22T16:03:25Z","git_url":"git://github.com/mautic/mautic.git","ssh_url":"git@github.com:mautic/mautic.git","clone_url":"https://github.com/mautic/mautic.git","svn_url":"https://github.com/mautic/mautic","homepage":"https://www.mautic.org","size":33905,"stargazers_count":615,"watchers_count":615,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":221,"mirror_url":null,"open_issues_count":385,"forks":221,"open_issues":385,"watchers":615,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/mautic/mautic/pulls/1552"},"html":{"href":"https://github.com/mautic/mautic/pull/1552"},"issue":{"href":"https://api.github.com/repos/mautic/mautic/issues/1552"},"comments":{"href":"https://api.github.com/repos/mautic/mautic/issues/1552/comments"},"review_comments":{"href":"https://api.github.com/repos/mautic/mautic/pulls/1552/comments"},"review_comment":{"href":"https://api.github.com/repos/mautic/mautic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mautic/mautic/pulls/1552/commits"},"statuses":{"href":"https://api.github.com/repos/mautic/mautic/statuses/e33696429de1c4422d3acd8339b311d6de6d87e7"}}}}