{"action":"created","comment":{"url":"https://api.github.com/repos/adkozlov/scala-2018/pulls/comments/243644662","pull_request_review_id":187476554,"id":243644662,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MzY0NDY2Mg==","diff_hunk":"@@ -0,0 +1,88 @@\n+package ru.hse.spb.kazakov\n+\n+import java.time.format.DateTimeFormatter\n+import java.time.{LocalDate, Month}\n+\n+import scala.io.Source\n+\n+object CurrencyConverter {\n+\n+  object Currency extends Enumeration {\n+    val RUB, USD, EUR = Value\n+  }\n+\n+  object at {\n+    def apply(date: LocalDate): LocalDate = date\n+  }\n+\n+  class Conversion(amount: Double, from: Currency.Value) {\n+    def RUB(date: LocalDate): Double = convert(date, Currency.RUB)\n+\n+    def USD(date: LocalDate): Double = convert(date, Currency.USD)\n+\n+    def EUR(date: LocalDate): Double = convert(date, Currency.EUR)\n+\n+    private def convert(date: LocalDate, to: Currency.Value): Double =\n+      getRateAt(date, to) match {\n+        case rate => amount * rate\n+        case 0 => throw ConversionException(\"Currency rate isn't available for this date\")\n+      }\n+\n+    private def getRateAt(date: LocalDate, to: Currency.Value): Double = {\n+      val url = s\"${Conversion.API_URL}${date.format(Conversion.DATE_FORMATTER)}?base=${from.toString}&symbols=${to.toString}\"\n+      try {\n+        val json = Source.fromURL(url).mkString\n+        json match {\n+          case Conversion.RESPONSE_PATTERN(rate) => rate.toDouble\n+          case _ => 0\n+        }\n+      } catch {\n+        case exception: Exception => throw ConversionException(\"Unable to get data from server\", exception)","path":"src/main/scala/ru/hse/spb/kazakov/CurrencyConverter.scala","position":40,"original_position":40,"commit_id":"010f21dcd1ab2eb3e1b893083df742149e121231","original_commit_id":"010f21dcd1ab2eb3e1b893083df742149e121231","user":{"login":"adkozlov","id":1233785,"node_id":"MDQ6VXNlcjEyMzM3ODU=","avatar_url":"https://avatars3.githubusercontent.com/u/1233785?v=4","gravatar_id":"","url":"https://api.github.com/users/adkozlov","html_url":"https://github.com/adkozlov","followers_url":"https://api.github.com/users/adkozlov/followers","following_url":"https://api.github.com/users/adkozlov/following{/other_user}","gists_url":"https://api.github.com/users/adkozlov/gists{/gist_id}","starred_url":"https://api.github.com/users/adkozlov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adkozlov/subscriptions","organizations_url":"https://api.github.com/users/adkozlov/orgs","repos_url":"https://api.github.com/users/adkozlov/repos","events_url":"https://api.github.com/users/adkozlov/events{/privacy}","received_events_url":"https://api.github.com/users/adkozlov/received_events","type":"User","site_admin":false},"body":"Я предупреждал про `catch exception: Exception`. Вас спасло, что это дополнительное задание.","created_at":"2018-12-21T17:30:55Z","updated_at":"2018-12-21T17:36:24Z","html_url":"https://github.com/adkozlov/scala-2018/pull/108#discussion_r243644662","pull_request_url":"https://api.github.com/repos/adkozlov/scala-2018/pulls/108","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/adkozlov/scala-2018/pulls/comments/243644662"},"html":{"href":"https://github.com/adkozlov/scala-2018/pull/108#discussion_r243644662"},"pull_request":{"href":"https://api.github.com/repos/adkozlov/scala-2018/pulls/108"}}},"pull_request":{"url":"https://api.github.com/repos/adkozlov/scala-2018/pulls/108","id":240359992,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQwMzU5OTky","html_url":"https://github.com/adkozlov/scala-2018/pull/108","diff_url":"https://github.com/adkozlov/scala-2018/pull/108.diff","patch_url":"https://github.com/adkozlov/scala-2018/pull/108.patch","issue_url":"https://api.github.com/repos/adkozlov/scala-2018/issues/108","number":108,"state":"open","locked":false,"title":"HA04, Казаков Дмитрий","user":{"login":"DmKazakov","id":22097444,"node_id":"MDQ6VXNlcjIyMDk3NDQ0","avatar_url":"https://avatars1.githubusercontent.com/u/22097444?v=4","gravatar_id":"","url":"https://api.github.com/users/DmKazakov","html_url":"https://github.com/DmKazakov","followers_url":"https://api.github.com/users/DmKazakov/followers","following_url":"https://api.github.com/users/DmKazakov/following{/other_user}","gists_url":"https://api.github.com/users/DmKazakov/gists{/gist_id}","starred_url":"https://api.github.com/users/DmKazakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DmKazakov/subscriptions","organizations_url":"https://api.github.com/users/DmKazakov/orgs","repos_url":"https://api.github.com/users/DmKazakov/repos","events_url":"https://api.github.com/users/DmKazakov/events{/privacy}","received_events_url":"https://api.github.com/users/DmKazakov/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-12-21T03:04:46Z","updated_at":"2018-12-21T17:36:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a58e6a43b0e7012bc3c52110f7cfc7af86d5aa5b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/adkozlov/scala-2018/pulls/108/commits","review_comments_url":"https://api.github.com/repos/adkozlov/scala-2018/pulls/108/comments","review_comment_url":"https://api.github.com/repos/adkozlov/scala-2018/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adkozlov/scala-2018/issues/108/comments","statuses_url":"https://api.github.com/repos/adkozlov/scala-2018/statuses/010f21dcd1ab2eb3e1b893083df742149e121231","head":{"label":"DmKazakov:04-converter","ref":"04-converter","sha":"010f21dcd1ab2eb3e1b893083df742149e121231","user":{"login":"DmKazakov","id":22097444,"node_id":"MDQ6VXNlcjIyMDk3NDQ0","avatar_url":"https://avatars1.githubusercontent.com/u/22097444?v=4","gravatar_id":"","url":"https://api.github.com/users/DmKazakov","html_url":"https://github.com/DmKazakov","followers_url":"https://api.github.com/users/DmKazakov/followers","following_url":"https://api.github.com/users/DmKazakov/following{/other_user}","gists_url":"https://api.github.com/users/DmKazakov/gists{/gist_id}","starred_url":"https://api.github.com/users/DmKazakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DmKazakov/subscriptions","organizations_url":"https://api.github.com/users/DmKazakov/orgs","repos_url":"https://api.github.com/users/DmKazakov/repos","events_url":"https://api.github.com/users/DmKazakov/events{/privacy}","received_events_url":"https://api.github.com/users/DmKazakov/received_events","type":"User","site_admin":false},"repo":{"id":152411409,"node_id":"MDEwOlJlcG9zaXRvcnkxNTI0MTE0MDk=","name":"scala-2018","full_name":"DmKazakov/scala-2018","private":false,"owner":{"login":"DmKazakov","id":22097444,"node_id":"MDQ6VXNlcjIyMDk3NDQ0","avatar_url":"https://avatars1.githubusercontent.com/u/22097444?v=4","gravatar_id":"","url":"https://api.github.com/users/DmKazakov","html_url":"https://github.com/DmKazakov","followers_url":"https://api.github.com/users/DmKazakov/followers","following_url":"https://api.github.com/users/DmKazakov/following{/other_user}","gists_url":"https://api.github.com/users/DmKazakov/gists{/gist_id}","starred_url":"https://api.github.com/users/DmKazakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DmKazakov/subscriptions","organizations_url":"https://api.github.com/users/DmKazakov/orgs","repos_url":"https://api.github.com/users/DmKazakov/repos","events_url":"https://api.github.com/users/DmKazakov/events{/privacy}","received_events_url":"https://api.github.com/users/DmKazakov/received_events","type":"User","site_admin":false},"html_url":"https://github.com/DmKazakov/scala-2018","description":"Scala course at HSE/ITMO, Fall'18.","fork":true,"url":"https://api.github.com/repos/DmKazakov/scala-2018","forks_url":"https://api.github.com/repos/DmKazakov/scala-2018/forks","keys_url":"https://api.github.com/repos/DmKazakov/scala-2018/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DmKazakov/scala-2018/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DmKazakov/scala-2018/teams","hooks_url":"https://api.github.com/repos/DmKazakov/scala-2018/hooks","issue_events_url":"https://api.github.com/repos/DmKazakov/scala-2018/issues/events{/number}","events_url":"https://api.github.com/repos/DmKazakov/scala-2018/events","assignees_url":"https://api.github.com/repos/DmKazakov/scala-2018/assignees{/user}","branches_url":"https://api.github.com/repos/DmKazakov/scala-2018/branches{/branch}","tags_url":"https://api.github.com/repos/DmKazakov/scala-2018/tags","blobs_url":"https://api.github.com/repos/DmKazakov/scala-2018/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DmKazakov/scala-2018/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DmKazakov/scala-2018/git/refs{/sha}","trees_url":"https://api.github.com/repos/DmKazakov/scala-2018/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DmKazakov/scala-2018/statuses/{sha}","languages_url":"https://api.github.com/repos/DmKazakov/scala-2018/languages","stargazers_url":"https://api.github.com/repos/DmKazakov/scala-2018/stargazers","contributors_url":"https://api.github.com/repos/DmKazakov/scala-2018/contributors","subscribers_url":"https://api.github.com/repos/DmKazakov/scala-2018/subscribers","subscription_url":"https://api.github.com/repos/DmKazakov/scala-2018/subscription","commits_url":"https://api.github.com/repos/DmKazakov/scala-2018/commits{/sha}","git_commits_url":"https://api.github.com/repos/DmKazakov/scala-2018/git/commits{/sha}","comments_url":"https://api.github.com/repos/DmKazakov/scala-2018/comments{/number}","issue_comment_url":"https://api.github.com/repos/DmKazakov/scala-2018/issues/comments{/number}","contents_url":"https://api.github.com/repos/DmKazakov/scala-2018/contents/{+path}","compare_url":"https://api.github.com/repos/DmKazakov/scala-2018/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DmKazakov/scala-2018/merges","archive_url":"https://api.github.com/repos/DmKazakov/scala-2018/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DmKazakov/scala-2018/downloads","issues_url":"https://api.github.com/repos/DmKazakov/scala-2018/issues{/number}","pulls_url":"https://api.github.com/repos/DmKazakov/scala-2018/pulls{/number}","milestones_url":"https://api.github.com/repos/DmKazakov/scala-2018/milestones{/number}","notifications_url":"https://api.github.com/repos/DmKazakov/scala-2018/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DmKazakov/scala-2018/labels{/name}","releases_url":"https://api.github.com/repos/DmKazakov/scala-2018/releases{/id}","deployments_url":"https://api.github.com/repos/DmKazakov/scala-2018/deployments","created_at":"2018-10-10T11:18:15Z","updated_at":"2018-10-10T11:19:41Z","pushed_at":"2018-12-21T03:02:41Z","git_url":"git://github.com/DmKazakov/scala-2018.git","ssh_url":"git@github.com:DmKazakov/scala-2018.git","clone_url":"https://github.com/DmKazakov/scala-2018.git","svn_url":"https://github.com/DmKazakov/scala-2018","homepage":null,"size":41,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"adkozlov:04-converter","ref":"04-converter","sha":"654b44691b65cf5ee0a3054e977a1d95176693a7","user":{"login":"adkozlov","id":1233785,"node_id":"MDQ6VXNlcjEyMzM3ODU=","avatar_url":"https://avatars3.githubusercontent.com/u/1233785?v=4","gravatar_id":"","url":"https://api.github.com/users/adkozlov","html_url":"https://github.com/adkozlov","followers_url":"https://api.github.com/users/adkozlov/followers","following_url":"https://api.github.com/users/adkozlov/following{/other_user}","gists_url":"https://api.github.com/users/adkozlov/gists{/gist_id}","starred_url":"https://api.github.com/users/adkozlov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adkozlov/subscriptions","organizations_url":"https://api.github.com/users/adkozlov/orgs","repos_url":"https://api.github.com/users/adkozlov/repos","events_url":"https://api.github.com/users/adkozlov/events{/privacy}","received_events_url":"https://api.github.com/users/adkozlov/received_events","type":"User","site_admin":false},"repo":{"id":152305721,"node_id":"MDEwOlJlcG9zaXRvcnkxNTIzMDU3MjE=","name":"scala-2018","full_name":"adkozlov/scala-2018","private":false,"owner":{"login":"adkozlov","id":1233785,"node_id":"MDQ6VXNlcjEyMzM3ODU=","avatar_url":"https://avatars3.githubusercontent.com/u/1233785?v=4","gravatar_id":"","url":"https://api.github.com/users/adkozlov","html_url":"https://github.com/adkozlov","followers_url":"https://api.github.com/users/adkozlov/followers","following_url":"https://api.github.com/users/adkozlov/following{/other_user}","gists_url":"https://api.github.com/users/adkozlov/gists{/gist_id}","starred_url":"https://api.github.com/users/adkozlov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adkozlov/subscriptions","organizations_url":"https://api.github.com/users/adkozlov/orgs","repos_url":"https://api.github.com/users/adkozlov/repos","events_url":"https://api.github.com/users/adkozlov/events{/privacy}","received_events_url":"https://api.github.com/users/adkozlov/received_events","type":"User","site_admin":false},"html_url":"https://github.com/adkozlov/scala-2018","description":"Scala course at HSE/ITMO, Fall'18.","fork":false,"url":"https://api.github.com/repos/adkozlov/scala-2018","forks_url":"https://api.github.com/repos/adkozlov/scala-2018/forks","keys_url":"https://api.github.com/repos/adkozlov/scala-2018/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adkozlov/scala-2018/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adkozlov/scala-2018/teams","hooks_url":"https://api.github.com/repos/adkozlov/scala-2018/hooks","issue_events_url":"https://api.github.com/repos/adkozlov/scala-2018/issues/events{/number}","events_url":"https://api.github.com/repos/adkozlov/scala-2018/events","assignees_url":"https://api.github.com/repos/adkozlov/scala-2018/assignees{/user}","branches_url":"https://api.github.com/repos/adkozlov/scala-2018/branches{/branch}","tags_url":"https://api.github.com/repos/adkozlov/scala-2018/tags","blobs_url":"https://api.github.com/repos/adkozlov/scala-2018/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adkozlov/scala-2018/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adkozlov/scala-2018/git/refs{/sha}","trees_url":"https://api.github.com/repos/adkozlov/scala-2018/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adkozlov/scala-2018/statuses/{sha}","languages_url":"https://api.github.com/repos/adkozlov/scala-2018/languages","stargazers_url":"https://api.github.com/repos/adkozlov/scala-2018/stargazers","contributors_url":"https://api.github.com/repos/adkozlov/scala-2018/contributors","subscribers_url":"https://api.github.com/repos/adkozlov/scala-2018/subscribers","subscription_url":"https://api.github.com/repos/adkozlov/scala-2018/subscription","commits_url":"https://api.github.com/repos/adkozlov/scala-2018/commits{/sha}","git_commits_url":"https://api.github.com/repos/adkozlov/scala-2018/git/commits{/sha}","comments_url":"https://api.github.com/repos/adkozlov/scala-2018/comments{/number}","issue_comment_url":"https://api.github.com/repos/adkozlov/scala-2018/issues/comments{/number}","contents_url":"https://api.github.com/repos/adkozlov/scala-2018/contents/{+path}","compare_url":"https://api.github.com/repos/adkozlov/scala-2018/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adkozlov/scala-2018/merges","archive_url":"https://api.github.com/repos/adkozlov/scala-2018/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adkozlov/scala-2018/downloads","issues_url":"https://api.github.com/repos/adkozlov/scala-2018/issues{/number}","pulls_url":"https://api.github.com/repos/adkozlov/scala-2018/pulls{/number}","milestones_url":"https://api.github.com/repos/adkozlov/scala-2018/milestones{/number}","notifications_url":"https://api.github.com/repos/adkozlov/scala-2018/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adkozlov/scala-2018/labels{/name}","releases_url":"https://api.github.com/repos/adkozlov/scala-2018/releases{/id}","deployments_url":"https://api.github.com/repos/adkozlov/scala-2018/deployments","created_at":"2018-10-09T19:01:54Z","updated_at":"2018-12-12T08:55:08Z","pushed_at":"2018-12-21T14:46:57Z","git_url":"git://github.com/adkozlov/scala-2018.git","ssh_url":"git@github.com:adkozlov/scala-2018.git","clone_url":"https://github.com/adkozlov/scala-2018.git","svn_url":"https://github.com/adkozlov/scala-2018","homepage":null,"size":25,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":34,"mirror_url":null,"archived":false,"open_issues_count":45,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":34,"open_issues":45,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/adkozlov/scala-2018/pulls/108"},"html":{"href":"https://github.com/adkozlov/scala-2018/pull/108"},"issue":{"href":"https://api.github.com/repos/adkozlov/scala-2018/issues/108"},"comments":{"href":"https://api.github.com/repos/adkozlov/scala-2018/issues/108/comments"},"review_comments":{"href":"https://api.github.com/repos/adkozlov/scala-2018/pulls/108/comments"},"review_comment":{"href":"https://api.github.com/repos/adkozlov/scala-2018/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adkozlov/scala-2018/pulls/108/commits"},"statuses":{"href":"https://api.github.com/repos/adkozlov/scala-2018/statuses/010f21dcd1ab2eb3e1b893083df742149e121231"}},"author_association":"NONE"}}
{"actor":{"display_login":"adkozlov"}}