{"action":"created","comment":{"url":"https://api.github.com/repos/teachbase/amorail/pulls/comments/24150799","id":24150799,"diff_hunk":"@@ -85,5 +95,54 @@ def safe_create\n     def reload_model(response)\n     end\n \n+    # this method removes nil values and empty arrays from params hash (deep)\n+    def normalize_params(data)\n+      return data unless data.is_a?(Hash)\n+\n+      compacted = {}\n+      data.each do |key,val|\n+        case val\n+        when Numeric, String\n+          compacted[key]=val\n+        when Array\n+          val.compact!\n+          # handle custom keys\n+          val=normalize_custom_fields(val) if key == :custom_fields\n+          unless val.empty?\n+            compacted[key] = val.map{|el| normalize_params(el) } \n+          end\n+        else\n+          _data = normalize_params(val)\n+          compacted[key] = _data unless _data.nil?\n+        end\n+      end\n+      compacted\n+    end\n+\n+\n+    def normalize_custom_fields(val)\n+      val.reject do |field|\n+        field[:values].all?{ |item| !item[:value] }\n+      end\n+    end\n+\n+    protected\n+      def to_timestamp(val)","path":"lib/amorail/entity.rb","position":81,"original_position":81,"commit_id":"faa475a52adf8f045837d97b6bbba1a11ca470bd","original_commit_id":"faa475a52adf8f045837d97b6bbba1a11ca470bd","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Inconsistent indentation detected.","created_at":"2015-02-05T09:13:43Z","updated_at":"2015-02-05T09:13:43Z","html_url":"https://github.com/teachbase/amorail/pull/2#discussion_r24150799","pull_request_url":"https://api.github.com/repos/teachbase/amorail/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/teachbase/amorail/pulls/comments/24150799"},"html":{"href":"https://github.com/teachbase/amorail/pull/2#discussion_r24150799"},"pull_request":{"href":"https://api.github.com/repos/teachbase/amorail/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/teachbase/amorail/pulls/2","id":28458896,"html_url":"https://github.com/teachbase/amorail/pull/2","diff_url":"https://github.com/teachbase/amorail/pull/2.diff","patch_url":"https://github.com/teachbase/amorail/pull/2.patch","issue_url":"https://api.github.com/repos/teachbase/amorail/issues/2","number":2,"state":"open","locked":false,"title":"Url entities","user":{"login":"alekseenkoss77","id":2551688,"avatar_url":"https://avatars.githubusercontent.com/u/2551688?v=3","gravatar_id":"","url":"https://api.github.com/users/alekseenkoss77","html_url":"https://github.com/alekseenkoss77","followers_url":"https://api.github.com/users/alekseenkoss77/followers","following_url":"https://api.github.com/users/alekseenkoss77/following{/other_user}","gists_url":"https://api.github.com/users/alekseenkoss77/gists{/gist_id}","starred_url":"https://api.github.com/users/alekseenkoss77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alekseenkoss77/subscriptions","organizations_url":"https://api.github.com/users/alekseenkoss77/orgs","repos_url":"https://api.github.com/users/alekseenkoss77/repos","events_url":"https://api.github.com/users/alekseenkoss77/events{/privacy}","received_events_url":"https://api.github.com/users/alekseenkoss77/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-02T10:47:56Z","updated_at":"2015-02-05T09:13:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"860db57e2ed2b775cbdb5dae16247c2a3e3947c1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/teachbase/amorail/pulls/2/commits","review_comments_url":"https://api.github.com/repos/teachbase/amorail/pulls/2/comments","review_comment_url":"https://api.github.com/repos/teachbase/amorail/pulls/comments/{number}","comments_url":"https://api.github.com/repos/teachbase/amorail/issues/2/comments","statuses_url":"https://api.github.com/repos/teachbase/amorail/statuses/faa475a52adf8f045837d97b6bbba1a11ca470bd","head":{"label":"teachbase:url-entities","ref":"url-entities","sha":"faa475a52adf8f045837d97b6bbba1a11ca470bd","user":{"login":"teachbase","id":10232914,"avatar_url":"https://avatars.githubusercontent.com/u/10232914?v=3","gravatar_id":"","url":"https://api.github.com/users/teachbase","html_url":"https://github.com/teachbase","followers_url":"https://api.github.com/users/teachbase/followers","following_url":"https://api.github.com/users/teachbase/following{/other_user}","gists_url":"https://api.github.com/users/teachbase/gists{/gist_id}","starred_url":"https://api.github.com/users/teachbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teachbase/subscriptions","organizations_url":"https://api.github.com/users/teachbase/orgs","repos_url":"https://api.github.com/users/teachbase/repos","events_url":"https://api.github.com/users/teachbase/events{/privacy}","received_events_url":"https://api.github.com/users/teachbase/received_events","type":"Organization","site_admin":false},"repo":{"id":29674544,"name":"amorail","full_name":"teachbase/amorail","owner":{"login":"teachbase","id":10232914,"avatar_url":"https://avatars.githubusercontent.com/u/10232914?v=3","gravatar_id":"","url":"https://api.github.com/users/teachbase","html_url":"https://github.com/teachbase","followers_url":"https://api.github.com/users/teachbase/followers","following_url":"https://api.github.com/users/teachbase/following{/other_user}","gists_url":"https://api.github.com/users/teachbase/gists{/gist_id}","starred_url":"https://api.github.com/users/teachbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teachbase/subscriptions","organizations_url":"https://api.github.com/users/teachbase/orgs","repos_url":"https://api.github.com/users/teachbase/repos","events_url":"https://api.github.com/users/teachbase/events{/privacy}","received_events_url":"https://api.github.com/users/teachbase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/teachbase/amorail","description":"AmoCRM Rails plugin","fork":false,"url":"https://api.github.com/repos/teachbase/amorail","forks_url":"https://api.github.com/repos/teachbase/amorail/forks","keys_url":"https://api.github.com/repos/teachbase/amorail/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teachbase/amorail/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teachbase/amorail/teams","hooks_url":"https://api.github.com/repos/teachbase/amorail/hooks","issue_events_url":"https://api.github.com/repos/teachbase/amorail/issues/events{/number}","events_url":"https://api.github.com/repos/teachbase/amorail/events","assignees_url":"https://api.github.com/repos/teachbase/amorail/assignees{/user}","branches_url":"https://api.github.com/repos/teachbase/amorail/branches{/branch}","tags_url":"https://api.github.com/repos/teachbase/amorail/tags","blobs_url":"https://api.github.com/repos/teachbase/amorail/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teachbase/amorail/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teachbase/amorail/git/refs{/sha}","trees_url":"https://api.github.com/repos/teachbase/amorail/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teachbase/amorail/statuses/{sha}","languages_url":"https://api.github.com/repos/teachbase/amorail/languages","stargazers_url":"https://api.github.com/repos/teachbase/amorail/stargazers","contributors_url":"https://api.github.com/repos/teachbase/amorail/contributors","subscribers_url":"https://api.github.com/repos/teachbase/amorail/subscribers","subscription_url":"https://api.github.com/repos/teachbase/amorail/subscription","commits_url":"https://api.github.com/repos/teachbase/amorail/commits{/sha}","git_commits_url":"https://api.github.com/repos/teachbase/amorail/git/commits{/sha}","comments_url":"https://api.github.com/repos/teachbase/amorail/comments{/number}","issue_comment_url":"https://api.github.com/repos/teachbase/amorail/issues/comments/{number}","contents_url":"https://api.github.com/repos/teachbase/amorail/contents/{+path}","compare_url":"https://api.github.com/repos/teachbase/amorail/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teachbase/amorail/merges","archive_url":"https://api.github.com/repos/teachbase/amorail/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teachbase/amorail/downloads","issues_url":"https://api.github.com/repos/teachbase/amorail/issues{/number}","pulls_url":"https://api.github.com/repos/teachbase/amorail/pulls{/number}","milestones_url":"https://api.github.com/repos/teachbase/amorail/milestones{/number}","notifications_url":"https://api.github.com/repos/teachbase/amorail/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teachbase/amorail/labels{/name}","releases_url":"https://api.github.com/repos/teachbase/amorail/releases{/id}","created_at":"2015-01-22T11:01:40Z","updated_at":"2015-02-02T08:46:14Z","pushed_at":"2015-02-05T09:13:38Z","git_url":"git://github.com/teachbase/amorail.git","ssh_url":"git@github.com:teachbase/amorail.git","clone_url":"https://github.com/teachbase/amorail.git","svn_url":"https://github.com/teachbase/amorail","homepage":null,"size":256,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"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"}},"base":{"label":"teachbase:master","ref":"master","sha":"1c88edab69847d03afa39cee999d679b08810f11","user":{"login":"teachbase","id":10232914,"avatar_url":"https://avatars.githubusercontent.com/u/10232914?v=3","gravatar_id":"","url":"https://api.github.com/users/teachbase","html_url":"https://github.com/teachbase","followers_url":"https://api.github.com/users/teachbase/followers","following_url":"https://api.github.com/users/teachbase/following{/other_user}","gists_url":"https://api.github.com/users/teachbase/gists{/gist_id}","starred_url":"https://api.github.com/users/teachbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teachbase/subscriptions","organizations_url":"https://api.github.com/users/teachbase/orgs","repos_url":"https://api.github.com/users/teachbase/repos","events_url":"https://api.github.com/users/teachbase/events{/privacy}","received_events_url":"https://api.github.com/users/teachbase/received_events","type":"Organization","site_admin":false},"repo":{"id":29674544,"name":"amorail","full_name":"teachbase/amorail","owner":{"login":"teachbase","id":10232914,"avatar_url":"https://avatars.githubusercontent.com/u/10232914?v=3","gravatar_id":"","url":"https://api.github.com/users/teachbase","html_url":"https://github.com/teachbase","followers_url":"https://api.github.com/users/teachbase/followers","following_url":"https://api.github.com/users/teachbase/following{/other_user}","gists_url":"https://api.github.com/users/teachbase/gists{/gist_id}","starred_url":"https://api.github.com/users/teachbase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teachbase/subscriptions","organizations_url":"https://api.github.com/users/teachbase/orgs","repos_url":"https://api.github.com/users/teachbase/repos","events_url":"https://api.github.com/users/teachbase/events{/privacy}","received_events_url":"https://api.github.com/users/teachbase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/teachbase/amorail","description":"AmoCRM Rails plugin","fork":false,"url":"https://api.github.com/repos/teachbase/amorail","forks_url":"https://api.github.com/repos/teachbase/amorail/forks","keys_url":"https://api.github.com/repos/teachbase/amorail/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teachbase/amorail/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teachbase/amorail/teams","hooks_url":"https://api.github.com/repos/teachbase/amorail/hooks","issue_events_url":"https://api.github.com/repos/teachbase/amorail/issues/events{/number}","events_url":"https://api.github.com/repos/teachbase/amorail/events","assignees_url":"https://api.github.com/repos/teachbase/amorail/assignees{/user}","branches_url":"https://api.github.com/repos/teachbase/amorail/branches{/branch}","tags_url":"https://api.github.com/repos/teachbase/amorail/tags","blobs_url":"https://api.github.com/repos/teachbase/amorail/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teachbase/amorail/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teachbase/amorail/git/refs{/sha}","trees_url":"https://api.github.com/repos/teachbase/amorail/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teachbase/amorail/statuses/{sha}","languages_url":"https://api.github.com/repos/teachbase/amorail/languages","stargazers_url":"https://api.github.com/repos/teachbase/amorail/stargazers","contributors_url":"https://api.github.com/repos/teachbase/amorail/contributors","subscribers_url":"https://api.github.com/repos/teachbase/amorail/subscribers","subscription_url":"https://api.github.com/repos/teachbase/amorail/subscription","commits_url":"https://api.github.com/repos/teachbase/amorail/commits{/sha}","git_commits_url":"https://api.github.com/repos/teachbase/amorail/git/commits{/sha}","comments_url":"https://api.github.com/repos/teachbase/amorail/comments{/number}","issue_comment_url":"https://api.github.com/repos/teachbase/amorail/issues/comments/{number}","contents_url":"https://api.github.com/repos/teachbase/amorail/contents/{+path}","compare_url":"https://api.github.com/repos/teachbase/amorail/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teachbase/amorail/merges","archive_url":"https://api.github.com/repos/teachbase/amorail/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teachbase/amorail/downloads","issues_url":"https://api.github.com/repos/teachbase/amorail/issues{/number}","pulls_url":"https://api.github.com/repos/teachbase/amorail/pulls{/number}","milestones_url":"https://api.github.com/repos/teachbase/amorail/milestones{/number}","notifications_url":"https://api.github.com/repos/teachbase/amorail/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teachbase/amorail/labels{/name}","releases_url":"https://api.github.com/repos/teachbase/amorail/releases{/id}","created_at":"2015-01-22T11:01:40Z","updated_at":"2015-02-02T08:46:14Z","pushed_at":"2015-02-05T09:13:38Z","git_url":"git://github.com/teachbase/amorail.git","ssh_url":"git@github.com:teachbase/amorail.git","clone_url":"https://github.com/teachbase/amorail.git","svn_url":"https://github.com/teachbase/amorail","homepage":null,"size":256,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"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/teachbase/amorail/pulls/2"},"html":{"href":"https://github.com/teachbase/amorail/pull/2"},"issue":{"href":"https://api.github.com/repos/teachbase/amorail/issues/2"},"comments":{"href":"https://api.github.com/repos/teachbase/amorail/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/teachbase/amorail/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/teachbase/amorail/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/teachbase/amorail/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/teachbase/amorail/statuses/faa475a52adf8f045837d97b6bbba1a11ca470bd"}}}}