{"action":"created","comment":{"url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/comments/40816792","id":40816792,"diff_hunk":"@@ -0,0 +1,78 @@\n+class PackagesController < ApplicationController\n+  skip_before_filter :verify_authenticity_token, only: [:save]\n+\n+  def estimate_request # api endpoint\n+      @betsy_shipping = params\n+      origin\n+      destination\n+      package\n+\n+      begin\n+        ups = ActiveShipping::UPS.new(:login => ENV[\"ACTIVESHIPPING_UPS_LOGIN\"],\n+                                      :password => ENV[\"ACTIVESHIPPING_UPS_PASSWORD\"],\n+                                      :key => ENV[\"ACTIVESHIPPING_UPS_KEY\"])\n+        ups_response = ups.find_rates(@origin, @destination, @package)\n+        ups_rates = ups_response.rates.sort_by(&:price).collect { |rate| [rate.service_name, rate.price, rate.delivery_date] }\n+        usps = ActiveShipping::USPS.new(:login => ENV[\"ACTIVESHIPPING_USPS_LOGIN\"])\n+        usps_response = usps.find_rates(@origin, @destination, @package)\n+        usps_rates = usps_response.rates.sort_by(&:price).collect { |rate| [rate.service_name, rate.price] }\n+\n+        carrier_rates = []\n+        carrier_rates.push(ups_rates, usps_rates)\n+        render json: carrier_rates.as_json\n+      rescue ActiveShipping::ResponseError => error\n+       error_json = { message: error.message }\n+       render json: error_json.as_json, status: 400\n+      end\n+  end\n+\n+  def save\n+    service_array = params[\"order\"][\"estimate\"][\"service\"].split(\" \")\n+    price = service_array.pop.to_f\n+    service_type = service_array.join(\" \")\n+    weight = params[\"order\"][\"estimate\"][\"service_info\"][\"estimate\"][\"total_weight\"].to_i\n+    @box_size = params[\"order\"][\"estimate\"][\"service_info\"][\"estimate\"][\"box_size\"]","path":"app/controllers/packages_controller.rb","position":34,"original_position":34,"commit_id":"d1f3614e3d8150b269c10d8079cd923cc5c27d38","original_commit_id":"d1f3614e3d8150b269c10d8079cd923cc5c27d38","user":{"login":"wangg131","id":10188898,"avatar_url":"https://avatars.githubusercontent.com/u/10188898?v=3","gravatar_id":"","url":"https://api.github.com/users/wangg131","html_url":"https://github.com/wangg131","followers_url":"https://api.github.com/users/wangg131/followers","following_url":"https://api.github.com/users/wangg131/following{/other_user}","gists_url":"https://api.github.com/users/wangg131/gists{/gist_id}","starred_url":"https://api.github.com/users/wangg131/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangg131/subscriptions","organizations_url":"https://api.github.com/users/wangg131/orgs","repos_url":"https://api.github.com/users/wangg131/repos","events_url":"https://api.github.com/users/wangg131/events{/privacy}","received_events_url":"https://api.github.com/users/wangg131/received_events","type":"User","site_admin":false},"body":"Yeah, we definitely wanted to refactor this chunk of code, but ran out of time. Thanks for going through this part even though it might have been a little confusing. ","created_at":"2015-09-30T16:29:33Z","updated_at":"2015-09-30T16:29:33Z","html_url":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping/pull/24#discussion_r40816792","pull_request_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/comments/40816792"},"html":{"href":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping/pull/24#discussion_r40816792"},"pull_request":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/24","id":43092881,"html_url":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping/pull/24","diff_url":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping/pull/24.diff","patch_url":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping/pull/24.patch","issue_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/issues/24","number":24,"state":"open","locked":false,"title":"Shipping- Done","user":{"login":"wangg131","id":10188898,"avatar_url":"https://avatars.githubusercontent.com/u/10188898?v=3","gravatar_id":"","url":"https://api.github.com/users/wangg131","html_url":"https://github.com/wangg131","followers_url":"https://api.github.com/users/wangg131/followers","following_url":"https://api.github.com/users/wangg131/following{/other_user}","gists_url":"https://api.github.com/users/wangg131/gists{/gist_id}","starred_url":"https://api.github.com/users/wangg131/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangg131/subscriptions","organizations_url":"https://api.github.com/users/wangg131/orgs","repos_url":"https://api.github.com/users/wangg131/repos","events_url":"https://api.github.com/users/wangg131/events{/privacy}","received_events_url":"https://api.github.com/users/wangg131/received_events","type":"User","site_admin":false},"body":"Wish we had more time to refactor. We learned a lot from this project. \r\n\r\nJust a note, we hard-coded the origin since we made the decision that the shipping origin is only coming from one place- Primo's warehouse.\r\n\r\nThanks for looking at our code,\r\n@Brennaleker ","created_at":"2015-08-22T00:17:24Z","updated_at":"2015-09-30T16:29:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"67d868619c6fd53391eaabcdef67d2d5e00d29af","assignee":{"login":"jeremywadsack","id":241324,"avatar_url":"https://avatars.githubusercontent.com/u/241324?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremywadsack","html_url":"https://github.com/jeremywadsack","followers_url":"https://api.github.com/users/jeremywadsack/followers","following_url":"https://api.github.com/users/jeremywadsack/following{/other_user}","gists_url":"https://api.github.com/users/jeremywadsack/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremywadsack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremywadsack/subscriptions","organizations_url":"https://api.github.com/users/jeremywadsack/orgs","repos_url":"https://api.github.com/users/jeremywadsack/repos","events_url":"https://api.github.com/users/jeremywadsack/events{/privacy}","received_events_url":"https://api.github.com/users/jeremywadsack/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/24/commits","review_comments_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/24/comments","review_comment_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/issues/24/comments","statuses_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/statuses/d1f3614e3d8150b269c10d8079cd923cc5c27d38","head":{"label":"wangg131:bdl+lw/master","ref":"bdl+lw/master","sha":"d1f3614e3d8150b269c10d8079cd923cc5c27d38","user":{"login":"wangg131","id":10188898,"avatar_url":"https://avatars.githubusercontent.com/u/10188898?v=3","gravatar_id":"","url":"https://api.github.com/users/wangg131","html_url":"https://github.com/wangg131","followers_url":"https://api.github.com/users/wangg131/followers","following_url":"https://api.github.com/users/wangg131/following{/other_user}","gists_url":"https://api.github.com/users/wangg131/gists{/gist_id}","starred_url":"https://api.github.com/users/wangg131/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangg131/subscriptions","organizations_url":"https://api.github.com/users/wangg131/orgs","repos_url":"https://api.github.com/users/wangg131/repos","events_url":"https://api.github.com/users/wangg131/events{/privacy}","received_events_url":"https://api.github.com/users/wangg131/received_events","type":"User","site_admin":false},"repo":{"id":40930385,"name":"C3Projects--Shipping","full_name":"wangg131/C3Projects--Shipping","owner":{"login":"wangg131","id":10188898,"avatar_url":"https://avatars.githubusercontent.com/u/10188898?v=3","gravatar_id":"","url":"https://api.github.com/users/wangg131","html_url":"https://github.com/wangg131","followers_url":"https://api.github.com/users/wangg131/followers","following_url":"https://api.github.com/users/wangg131/following{/other_user}","gists_url":"https://api.github.com/users/wangg131/gists{/gist_id}","starred_url":"https://api.github.com/users/wangg131/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangg131/subscriptions","organizations_url":"https://api.github.com/users/wangg131/orgs","repos_url":"https://api.github.com/users/wangg131/repos","events_url":"https://api.github.com/users/wangg131/events{/privacy}","received_events_url":"https://api.github.com/users/wangg131/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wangg131/C3Projects--Shipping","description":"","fork":true,"url":"https://api.github.com/repos/wangg131/C3Projects--Shipping","forks_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/forks","keys_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/teams","hooks_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/hooks","issue_events_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/issues/events{/number}","events_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/events","assignees_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/assignees{/user}","branches_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/branches{/branch}","tags_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/tags","blobs_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/git/refs{/sha}","trees_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/statuses/{sha}","languages_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/languages","stargazers_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/stargazers","contributors_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/contributors","subscribers_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/subscribers","subscription_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/subscription","commits_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/commits{/sha}","git_commits_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/git/commits{/sha}","comments_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/comments{/number}","issue_comment_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/issues/comments{/number}","contents_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/contents/{+path}","compare_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/merges","archive_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/downloads","issues_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/issues{/number}","pulls_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/pulls{/number}","milestones_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/milestones{/number}","notifications_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/labels{/name}","releases_url":"https://api.github.com/repos/wangg131/C3Projects--Shipping/releases{/id}","created_at":"2015-08-17T21:31:37Z","updated_at":"2015-08-14T21:30:50Z","pushed_at":"2015-08-21T22:49:26Z","git_url":"git://github.com/wangg131/C3Projects--Shipping.git","ssh_url":"git@github.com:wangg131/C3Projects--Shipping.git","clone_url":"https://github.com/wangg131/C3Projects--Shipping.git","svn_url":"https://github.com/wangg131/C3Projects--Shipping","homepage":null,"size":228,"stargazers_count":0,"watchers_count":0,"language":null,"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":"Ada-Developers-Academy:bdl+lw/master","ref":"bdl+lw/master","sha":"24afdb7db7dac9503b91418f9594ff416682ee6c","user":{"login":"Ada-Developers-Academy","id":4689715,"avatar_url":"https://avatars.githubusercontent.com/u/4689715?v=3","gravatar_id":"","url":"https://api.github.com/users/Ada-Developers-Academy","html_url":"https://github.com/Ada-Developers-Academy","followers_url":"https://api.github.com/users/Ada-Developers-Academy/followers","following_url":"https://api.github.com/users/Ada-Developers-Academy/following{/other_user}","gists_url":"https://api.github.com/users/Ada-Developers-Academy/gists{/gist_id}","starred_url":"https://api.github.com/users/Ada-Developers-Academy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ada-Developers-Academy/subscriptions","organizations_url":"https://api.github.com/users/Ada-Developers-Academy/orgs","repos_url":"https://api.github.com/users/Ada-Developers-Academy/repos","events_url":"https://api.github.com/users/Ada-Developers-Academy/events{/privacy}","received_events_url":"https://api.github.com/users/Ada-Developers-Academy/received_events","type":"Organization","site_admin":false},"repo":{"id":40736865,"name":"C3Projects--Shipping","full_name":"Ada-Developers-Academy/C3Projects--Shipping","owner":{"login":"Ada-Developers-Academy","id":4689715,"avatar_url":"https://avatars.githubusercontent.com/u/4689715?v=3","gravatar_id":"","url":"https://api.github.com/users/Ada-Developers-Academy","html_url":"https://github.com/Ada-Developers-Academy","followers_url":"https://api.github.com/users/Ada-Developers-Academy/followers","following_url":"https://api.github.com/users/Ada-Developers-Academy/following{/other_user}","gists_url":"https://api.github.com/users/Ada-Developers-Academy/gists{/gist_id}","starred_url":"https://api.github.com/users/Ada-Developers-Academy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ada-Developers-Academy/subscriptions","organizations_url":"https://api.github.com/users/Ada-Developers-Academy/orgs","repos_url":"https://api.github.com/users/Ada-Developers-Academy/repos","events_url":"https://api.github.com/users/Ada-Developers-Academy/events{/privacy}","received_events_url":"https://api.github.com/users/Ada-Developers-Academy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping","description":"","fork":false,"url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping","forks_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/forks","keys_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/teams","hooks_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/hooks","issue_events_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/issues/events{/number}","events_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/events","assignees_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/assignees{/user}","branches_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/branches{/branch}","tags_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/tags","blobs_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/statuses/{sha}","languages_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/languages","stargazers_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/stargazers","contributors_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/contributors","subscribers_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/subscribers","subscription_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/subscription","commits_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/issues/comments{/number}","contents_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/contents/{+path}","compare_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/merges","archive_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/downloads","issues_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/issues{/number}","pulls_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls{/number}","milestones_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/milestones{/number}","notifications_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/labels{/name}","releases_url":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/releases{/id}","created_at":"2015-08-14T21:30:50Z","updated_at":"2015-08-14T21:30:50Z","pushed_at":"2015-08-22T00:17:24Z","git_url":"git://github.com/Ada-Developers-Academy/C3Projects--Shipping.git","ssh_url":"git@github.com:Ada-Developers-Academy/C3Projects--Shipping.git","clone_url":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping.git","svn_url":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping","homepage":null,"size":825,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":12,"forks":12,"open_issues":12,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/24"},"html":{"href":"https://github.com/Ada-Developers-Academy/C3Projects--Shipping/pull/24"},"issue":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/issues/24"},"comments":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/Ada-Developers-Academy/C3Projects--Shipping/statuses/d1f3614e3d8150b269c10d8079cd923cc5c27d38"}}}}