{"action":"created","comment":{"url":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/comments/111199259","pull_request_review_id":32427943,"id":111199259,"diff_hunk":"@@ -0,0 +1,47 @@\n+class Checkpoint < ApplicationRecord\n+  validates_presence_of :creator,\n+                        :street_address,\n+                        :city, \n+                        :state,\n+                        :country,\n+                        :lat,\n+                        :lng,\n+                        :zipcode\n+  validates_length_of :ethereum_address, minimum: 42, maximum: 42\n+  validates_uniqueness_of :ethereum_address\n+  validate :ethereum_address_start\n+  validate :ethereum_address_hex\n+  before_validation :generate_ethereum_address\n+\n+  def self.get_details_for(addresses)\n+    all_ethereum_addresses_valid?(addresses) &&\n+      Checkpoint.where(ethereum_address: [addresses])\n+  end\n+\n+  def self.all_ethereum_addresses_valid?(addresses)\n+    addresses.count == Checkpoint.where(ethereum_address: [addresses]).count\n+  end\n+\n+  def self.invalid_addresses(addresses)\n+    addresses.reject { |address| Checkpoint.find_by_ethereum_address(address) }\n+  end\n+\n+  private \n+\n+    def generate_ethereum_address\n+      self.ethereum_address ||= '0x' + SecureRandom.hex(20)\n+    end\n+\n+    def ethereum_address_start\n+      if ethereum_address[0..1] != '0x'\n+        errors.add(:ethereum_address, \"must start with '0x'\")\n+      end\n+    end\n+\n+    def ethereum_address_hex\n+      unless ethereum_address[2..-1].chars.all? { |letter| letter =~ /\\h/ }\n+        errors.add(:ethereum_address, \"must be composed of hexidecimal characters only\")\n+      end\n+    end\n+","path":"app/models/checkpoint.rb","position":46,"original_position":46,"commit_id":"ea29327884e983b71688b9b578e9a2b6438f18b5","original_commit_id":"ea29327884e983b71688b9b578e9a2b6438f18b5","user":{"login":"DavidKnott","id":17552858,"avatar_url":"https://avatars0.githubusercontent.com/u/17552858?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidKnott","html_url":"https://github.com/DavidKnott","followers_url":"https://api.github.com/users/DavidKnott/followers","following_url":"https://api.github.com/users/DavidKnott/following{/other_user}","gists_url":"https://api.github.com/users/DavidKnott/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidKnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidKnott/subscriptions","organizations_url":"https://api.github.com/users/DavidKnott/orgs","repos_url":"https://api.github.com/users/DavidKnott/repos","events_url":"https://api.github.com/users/DavidKnott/events{/privacy}","received_events_url":"https://api.github.com/users/DavidKnott/received_events","type":"User","site_admin":false},"body":"Great job changing the address creation to checkpoint!","created_at":"2017-04-12T16:33:17Z","updated_at":"2017-04-12T16:33:17Z","html_url":"https://github.com/DavidKnott/sourcery-api/pull/8#discussion_r111199259","pull_request_url":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/comments/111199259"},"html":{"href":"https://github.com/DavidKnott/sourcery-api/pull/8#discussion_r111199259"},"pull_request":{"href":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/8","id":115439983,"html_url":"https://github.com/DavidKnott/sourcery-api/pull/8","diff_url":"https://github.com/DavidKnott/sourcery-api/pull/8.diff","patch_url":"https://github.com/DavidKnott/sourcery-api/pull/8.patch","issue_url":"https://api.github.com/repos/DavidKnott/sourcery-api/issues/8","number":8,"state":"open","locked":false,"title":"143539467 ne create checkpoint","user":{"login":"ski-climb","id":19230981,"avatar_url":"https://avatars3.githubusercontent.com/u/19230981?v=3","gravatar_id":"","url":"https://api.github.com/users/ski-climb","html_url":"https://github.com/ski-climb","followers_url":"https://api.github.com/users/ski-climb/followers","following_url":"https://api.github.com/users/ski-climb/following{/other_user}","gists_url":"https://api.github.com/users/ski-climb/gists{/gist_id}","starred_url":"https://api.github.com/users/ski-climb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ski-climb/subscriptions","organizations_url":"https://api.github.com/users/ski-climb/orgs","repos_url":"https://api.github.com/users/ski-climb/repos","events_url":"https://api.github.com/users/ski-climb/events{/privacy}","received_events_url":"https://api.github.com/users/ski-climb/received_events","type":"User","site_admin":false},"body":"@tmikeschu @DavidKnott @ethanbennett @case-eee Ready for review\r\n\r\nBasically we're doing 3 things here:\r\n1) rename Location to Checkpoint\r\n2) move UID logic from Lot to Checkpoint \r\n3) return the new checkpoint object upon successful POST request to '/api/v1/checkpoints' since React front-end will need the ethereum_address to be able to send it to the blockchain\r\n\r\nPlease give it a good once over.  Looking forward to feedback!  Thanks.\r\n\r\n[(Closes) #143539467]","created_at":"2017-04-12T00:04:07Z","updated_at":"2017-04-12T16:33:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1ee8fe32d841c06a4ae6e526799c32227af82f18","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/8/commits","review_comments_url":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/8/comments","review_comment_url":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DavidKnott/sourcery-api/issues/8/comments","statuses_url":"https://api.github.com/repos/DavidKnott/sourcery-api/statuses/ea29327884e983b71688b9b578e9a2b6438f18b5","head":{"label":"DavidKnott:143539467-ne-create-checkpoint","ref":"143539467-ne-create-checkpoint","sha":"ea29327884e983b71688b9b578e9a2b6438f18b5","user":{"login":"DavidKnott","id":17552858,"avatar_url":"https://avatars0.githubusercontent.com/u/17552858?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidKnott","html_url":"https://github.com/DavidKnott","followers_url":"https://api.github.com/users/DavidKnott/followers","following_url":"https://api.github.com/users/DavidKnott/following{/other_user}","gists_url":"https://api.github.com/users/DavidKnott/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidKnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidKnott/subscriptions","organizations_url":"https://api.github.com/users/DavidKnott/orgs","repos_url":"https://api.github.com/users/DavidKnott/repos","events_url":"https://api.github.com/users/DavidKnott/events{/privacy}","received_events_url":"https://api.github.com/users/DavidKnott/received_events","type":"User","site_admin":false},"repo":{"id":86603918,"name":"sourcery-api","full_name":"DavidKnott/sourcery-api","owner":{"login":"DavidKnott","id":17552858,"avatar_url":"https://avatars0.githubusercontent.com/u/17552858?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidKnott","html_url":"https://github.com/DavidKnott","followers_url":"https://api.github.com/users/DavidKnott/followers","following_url":"https://api.github.com/users/DavidKnott/following{/other_user}","gists_url":"https://api.github.com/users/DavidKnott/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidKnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidKnott/subscriptions","organizations_url":"https://api.github.com/users/DavidKnott/orgs","repos_url":"https://api.github.com/users/DavidKnott/repos","events_url":"https://api.github.com/users/DavidKnott/events{/privacy}","received_events_url":"https://api.github.com/users/DavidKnott/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DavidKnott/sourcery-api","description":null,"fork":false,"url":"https://api.github.com/repos/DavidKnott/sourcery-api","forks_url":"https://api.github.com/repos/DavidKnott/sourcery-api/forks","keys_url":"https://api.github.com/repos/DavidKnott/sourcery-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DavidKnott/sourcery-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DavidKnott/sourcery-api/teams","hooks_url":"https://api.github.com/repos/DavidKnott/sourcery-api/hooks","issue_events_url":"https://api.github.com/repos/DavidKnott/sourcery-api/issues/events{/number}","events_url":"https://api.github.com/repos/DavidKnott/sourcery-api/events","assignees_url":"https://api.github.com/repos/DavidKnott/sourcery-api/assignees{/user}","branches_url":"https://api.github.com/repos/DavidKnott/sourcery-api/branches{/branch}","tags_url":"https://api.github.com/repos/DavidKnott/sourcery-api/tags","blobs_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DavidKnott/sourcery-api/statuses/{sha}","languages_url":"https://api.github.com/repos/DavidKnott/sourcery-api/languages","stargazers_url":"https://api.github.com/repos/DavidKnott/sourcery-api/stargazers","contributors_url":"https://api.github.com/repos/DavidKnott/sourcery-api/contributors","subscribers_url":"https://api.github.com/repos/DavidKnott/sourcery-api/subscribers","subscription_url":"https://api.github.com/repos/DavidKnott/sourcery-api/subscription","commits_url":"https://api.github.com/repos/DavidKnott/sourcery-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/DavidKnott/sourcery-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/DavidKnott/sourcery-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/DavidKnott/sourcery-api/contents/{+path}","compare_url":"https://api.github.com/repos/DavidKnott/sourcery-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DavidKnott/sourcery-api/merges","archive_url":"https://api.github.com/repos/DavidKnott/sourcery-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DavidKnott/sourcery-api/downloads","issues_url":"https://api.github.com/repos/DavidKnott/sourcery-api/issues{/number}","pulls_url":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls{/number}","milestones_url":"https://api.github.com/repos/DavidKnott/sourcery-api/milestones{/number}","notifications_url":"https://api.github.com/repos/DavidKnott/sourcery-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DavidKnott/sourcery-api/labels{/name}","releases_url":"https://api.github.com/repos/DavidKnott/sourcery-api/releases{/id}","deployments_url":"https://api.github.com/repos/DavidKnott/sourcery-api/deployments","created_at":"2017-03-29T16:16:29Z","updated_at":"2017-03-29T16:19:07Z","pushed_at":"2017-04-12T16:28:53Z","git_url":"git://github.com/DavidKnott/sourcery-api.git","ssh_url":"git@github.com:DavidKnott/sourcery-api.git","clone_url":"https://github.com/DavidKnott/sourcery-api.git","svn_url":"https://github.com/DavidKnott/sourcery-api","homepage":null,"size":81,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":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":"DavidKnott:master","ref":"master","sha":"c07c820530a5fcf6c5fcbb5c35b98f5bbc33311e","user":{"login":"DavidKnott","id":17552858,"avatar_url":"https://avatars0.githubusercontent.com/u/17552858?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidKnott","html_url":"https://github.com/DavidKnott","followers_url":"https://api.github.com/users/DavidKnott/followers","following_url":"https://api.github.com/users/DavidKnott/following{/other_user}","gists_url":"https://api.github.com/users/DavidKnott/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidKnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidKnott/subscriptions","organizations_url":"https://api.github.com/users/DavidKnott/orgs","repos_url":"https://api.github.com/users/DavidKnott/repos","events_url":"https://api.github.com/users/DavidKnott/events{/privacy}","received_events_url":"https://api.github.com/users/DavidKnott/received_events","type":"User","site_admin":false},"repo":{"id":86603918,"name":"sourcery-api","full_name":"DavidKnott/sourcery-api","owner":{"login":"DavidKnott","id":17552858,"avatar_url":"https://avatars0.githubusercontent.com/u/17552858?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidKnott","html_url":"https://github.com/DavidKnott","followers_url":"https://api.github.com/users/DavidKnott/followers","following_url":"https://api.github.com/users/DavidKnott/following{/other_user}","gists_url":"https://api.github.com/users/DavidKnott/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidKnott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidKnott/subscriptions","organizations_url":"https://api.github.com/users/DavidKnott/orgs","repos_url":"https://api.github.com/users/DavidKnott/repos","events_url":"https://api.github.com/users/DavidKnott/events{/privacy}","received_events_url":"https://api.github.com/users/DavidKnott/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DavidKnott/sourcery-api","description":null,"fork":false,"url":"https://api.github.com/repos/DavidKnott/sourcery-api","forks_url":"https://api.github.com/repos/DavidKnott/sourcery-api/forks","keys_url":"https://api.github.com/repos/DavidKnott/sourcery-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DavidKnott/sourcery-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DavidKnott/sourcery-api/teams","hooks_url":"https://api.github.com/repos/DavidKnott/sourcery-api/hooks","issue_events_url":"https://api.github.com/repos/DavidKnott/sourcery-api/issues/events{/number}","events_url":"https://api.github.com/repos/DavidKnott/sourcery-api/events","assignees_url":"https://api.github.com/repos/DavidKnott/sourcery-api/assignees{/user}","branches_url":"https://api.github.com/repos/DavidKnott/sourcery-api/branches{/branch}","tags_url":"https://api.github.com/repos/DavidKnott/sourcery-api/tags","blobs_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DavidKnott/sourcery-api/statuses/{sha}","languages_url":"https://api.github.com/repos/DavidKnott/sourcery-api/languages","stargazers_url":"https://api.github.com/repos/DavidKnott/sourcery-api/stargazers","contributors_url":"https://api.github.com/repos/DavidKnott/sourcery-api/contributors","subscribers_url":"https://api.github.com/repos/DavidKnott/sourcery-api/subscribers","subscription_url":"https://api.github.com/repos/DavidKnott/sourcery-api/subscription","commits_url":"https://api.github.com/repos/DavidKnott/sourcery-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/DavidKnott/sourcery-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/DavidKnott/sourcery-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/DavidKnott/sourcery-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/DavidKnott/sourcery-api/contents/{+path}","compare_url":"https://api.github.com/repos/DavidKnott/sourcery-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DavidKnott/sourcery-api/merges","archive_url":"https://api.github.com/repos/DavidKnott/sourcery-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DavidKnott/sourcery-api/downloads","issues_url":"https://api.github.com/repos/DavidKnott/sourcery-api/issues{/number}","pulls_url":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls{/number}","milestones_url":"https://api.github.com/repos/DavidKnott/sourcery-api/milestones{/number}","notifications_url":"https://api.github.com/repos/DavidKnott/sourcery-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DavidKnott/sourcery-api/labels{/name}","releases_url":"https://api.github.com/repos/DavidKnott/sourcery-api/releases{/id}","deployments_url":"https://api.github.com/repos/DavidKnott/sourcery-api/deployments","created_at":"2017-03-29T16:16:29Z","updated_at":"2017-03-29T16:19:07Z","pushed_at":"2017-04-12T16:28:53Z","git_url":"git://github.com/DavidKnott/sourcery-api.git","ssh_url":"git@github.com:DavidKnott/sourcery-api.git","clone_url":"https://github.com/DavidKnott/sourcery-api.git","svn_url":"https://github.com/DavidKnott/sourcery-api","homepage":null,"size":81,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":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/DavidKnott/sourcery-api/pulls/8"},"html":{"href":"https://github.com/DavidKnott/sourcery-api/pull/8"},"issue":{"href":"https://api.github.com/repos/DavidKnott/sourcery-api/issues/8"},"comments":{"href":"https://api.github.com/repos/DavidKnott/sourcery-api/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DavidKnott/sourcery-api/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/DavidKnott/sourcery-api/statuses/ea29327884e983b71688b9b578e9a2b6438f18b5"}}}}
{"actor":{"display_login":"DavidKnott"}}