{"action":"created","comment":{"url":"https://api.github.com/repos/Aurielle/ares/pulls/comments/35492727","id":35492727,"diff_hunk":"@@ -0,0 +1,130 @@\n+<?php\n+/**\n+ * This file is part of Ares.\n+ * Copyright (c) 2015 Václav Vrbka (http://aurielle.cz)\n+ */\n+\n+namespace Grifart\\Ares;\n+\n+use Kdyby\\Curl;\n+use Nette;\n+\n+\n+/**\n+ * Information fetching layer for Ares. Do not use standalone.\n+ */\n+class HttpDriver extends Nette\\Object implements IDriver\n+{\n+\t/** URL for API requests */\n+\tconst URL = 'http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi';\n+\n+\t/** @var Curl\\CurlSender */\n+\tprivate $curlSender;\n+\n+\n+\tpublic function __construct()\n+\t{\n+\t\t$this->curlSender = new Curl\\CurlSender();\n+\t}\n+\n+\t/**\n+\t * Fetches data of one subject identified by his IN from the ARES database.\n+\t *\n+\t * @see http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_answer_basic/v_1.0.3/ares_answer_basic_v_1.0.3.xsd\n+\t * @see http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_datatypes/v_1.0.3/ares_datatypes_v_1.0.3.xsd\n+\t * @see http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/uvis_datatypes/v_1.0.3/uvis_datatypes_v_1.0.3.xsd\n+\t *\n+\t * @param string $in\n+\t * @param bool $includeExpired\n+\t * @return SubjectInfo\n+\t * @throws FailedRequestException\n+\t * @throws UnknownSubjectException\n+\t * @throws XmlParsingException\n+\t */\n+\tpublic function fetch($in, $includeExpired = FALSE)\n+\t{\n+\t\ttry {\n+\t\t\t$request = new Curl\\Request($this->buildUrl($in, $includeExpired));\n+\t\t\t$response = $this->curlSender->send($request);\n+\t\t} catch (\\Exception $e) {\n+\t\t\tthrow new FailedRequestException('Querying ARES database failed: ' . $e->getMessage(), $e->getCode(), $e);\n+\t\t}\n+\n+\t\t$xml = $this->parseXml($response->getResponse());\n+\t\t$ns = $xml->getDocNamespaces();\n+\t\t$info = $xml->children($ns['are'])->children($ns['D']);\n+\n+\t\t// Subject wasn't found, parse the error code and description\n+\t\tif ((string) $info->VH->K === '2') {\n+\t\t\t$code = (string) $info->E->EK;\n+\t\t\t$message = (string) $info->E->ET;\n+\n+\t\t\tthrow new UnknownSubjectException(\"Subject wasn't found.\", $code, new NoResultException($message, $code));\n+\t\t}\n+\n+\t\t// Parse infos\n+\t\t$subject = $info->VBAS;\n+\t\t$street = (string) $subject->AD->UC;\n+\t\tif (is_numeric($street)) {\n+\t\t\t$street = $subject->AA->NCO . ' ' . $street;\n+\t\t}\n+\n+\t\tif (isset($subject->AA->CO)) {\n+\t\t\t$street .= '/' . $subject->AA->CO;\n+\t\t}\n+\n+\t\treturn new SubjectInfo([\n+\t\t\t'identificationNumber' => $subject->ICO,\n+\t\t\t'vatIdentificationNumber' => $subject->DIC ?: NULL,\n+\t\t\t'vatPayer' => !empty($subject->DIC),\n+\t\t\t'name' => $subject->OF,\n+\t\t\t'city' => $subject->AA->N,\n+\t\t\t'street' => $street,\n+\t\t\t'zipCode' => $subject->AA->PSC,\n+\t\t\t'person' => ((int) $subject->PF->KPF) <= 108,\n+\t\t\t'createdAt' => new \\DateTime((string) $subject->DV, new \\DateTimeZone('Europe/Prague')),\n+\t\t]);\n+\t}\n+\n+\t/**\n+\t * Builds request URL.\n+\t * @see http://wwwinfo.mfcr.cz/ares/ares_xml_basic.html.cz for more information about possible query string params\n+\t * @param string $in Subject identification number\n+\t * @param bool $includeExpired Search among expired subjects as well\n+\t * @return Nette\\Http\\Url\n+\t */\n+\tprivate function buildUrl($in, $includeExpired)\n+\t{\n+\t\t$url = new Nette\\Http\\Url(self::URL);","path":"src/HttpDriver.php","position":98,"original_position":98,"commit_id":"679cbf88b982bfd7978f757300012a00b302bcb3","original_commit_id":"679cbf88b982bfd7978f757300012a00b302bcb3","user":{"login":"Aurielle","id":144428,"avatar_url":"https://avatars.githubusercontent.com/u/144428?v=3","gravatar_id":"","url":"https://api.github.com/users/Aurielle","html_url":"https://github.com/Aurielle","followers_url":"https://api.github.com/users/Aurielle/followers","following_url":"https://api.github.com/users/Aurielle/following{/other_user}","gists_url":"https://api.github.com/users/Aurielle/gists{/gist_id}","starred_url":"https://api.github.com/users/Aurielle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aurielle/subscriptions","organizations_url":"https://api.github.com/users/Aurielle/orgs","repos_url":"https://api.github.com/users/Aurielle/repos","events_url":"https://api.github.com/users/Aurielle/events{/privacy}","received_events_url":"https://api.github.com/users/Aurielle/received_events","type":"User","site_admin":false},"body":"I don't understand, is there any reason to import solely `Nette\\Http\\Url`? (I do `use Nette` basically on every file)","created_at":"2015-07-26T13:02:48Z","updated_at":"2015-07-26T13:02:48Z","html_url":"https://github.com/Aurielle/ares/pull/1#discussion_r35492727","pull_request_url":"https://api.github.com/repos/Aurielle/ares/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/Aurielle/ares/pulls/comments/35492727"},"html":{"href":"https://github.com/Aurielle/ares/pull/1#discussion_r35492727"},"pull_request":{"href":"https://api.github.com/repos/Aurielle/ares/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/Aurielle/ares/pulls/1","id":40831374,"html_url":"https://github.com/Aurielle/ares/pull/1","diff_url":"https://github.com/Aurielle/ares/pull/1.diff","patch_url":"https://github.com/Aurielle/ares/pull/1.patch","issue_url":"https://api.github.com/repos/Aurielle/ares/issues/1","number":1,"state":"open","locked":false,"title":"Refactor under Grifart, removed old tests for now","user":{"login":"jkuchar","id":133822,"avatar_url":"https://avatars.githubusercontent.com/u/133822?v=3","gravatar_id":"","url":"https://api.github.com/users/jkuchar","html_url":"https://github.com/jkuchar","followers_url":"https://api.github.com/users/jkuchar/followers","following_url":"https://api.github.com/users/jkuchar/following{/other_user}","gists_url":"https://api.github.com/users/jkuchar/gists{/gist_id}","starred_url":"https://api.github.com/users/jkuchar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkuchar/subscriptions","organizations_url":"https://api.github.com/users/jkuchar/orgs","repos_url":"https://api.github.com/users/jkuchar/repos","events_url":"https://api.github.com/users/jkuchar/events{/privacy}","received_events_url":"https://api.github.com/users/jkuchar/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-25T05:20:17Z","updated_at":"2015-07-26T13:02:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"25a24174050d8c0c66b87084981921b4b1259d58","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Aurielle/ares/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Aurielle/ares/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Aurielle/ares/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Aurielle/ares/issues/1/comments","statuses_url":"https://api.github.com/repos/Aurielle/ares/statuses/679cbf88b982bfd7978f757300012a00b302bcb3","head":{"label":"Aurielle:grifart-rework","ref":"grifart-rework","sha":"679cbf88b982bfd7978f757300012a00b302bcb3","user":{"login":"Aurielle","id":144428,"avatar_url":"https://avatars.githubusercontent.com/u/144428?v=3","gravatar_id":"","url":"https://api.github.com/users/Aurielle","html_url":"https://github.com/Aurielle","followers_url":"https://api.github.com/users/Aurielle/followers","following_url":"https://api.github.com/users/Aurielle/following{/other_user}","gists_url":"https://api.github.com/users/Aurielle/gists{/gist_id}","starred_url":"https://api.github.com/users/Aurielle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aurielle/subscriptions","organizations_url":"https://api.github.com/users/Aurielle/orgs","repos_url":"https://api.github.com/users/Aurielle/repos","events_url":"https://api.github.com/users/Aurielle/events{/privacy}","received_events_url":"https://api.github.com/users/Aurielle/received_events","type":"User","site_admin":false},"repo":{"id":39387701,"name":"ares","full_name":"Aurielle/ares","owner":{"login":"Aurielle","id":144428,"avatar_url":"https://avatars.githubusercontent.com/u/144428?v=3","gravatar_id":"","url":"https://api.github.com/users/Aurielle","html_url":"https://github.com/Aurielle","followers_url":"https://api.github.com/users/Aurielle/followers","following_url":"https://api.github.com/users/Aurielle/following{/other_user}","gists_url":"https://api.github.com/users/Aurielle/gists{/gist_id}","starred_url":"https://api.github.com/users/Aurielle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aurielle/subscriptions","organizations_url":"https://api.github.com/users/Aurielle/orgs","repos_url":"https://api.github.com/users/Aurielle/repos","events_url":"https://api.github.com/users/Aurielle/events{/privacy}","received_events_url":"https://api.github.com/users/Aurielle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Aurielle/ares","description":"Provides information about subjects by their identification number from the ARES database (in Czech Republic).","fork":true,"url":"https://api.github.com/repos/Aurielle/ares","forks_url":"https://api.github.com/repos/Aurielle/ares/forks","keys_url":"https://api.github.com/repos/Aurielle/ares/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Aurielle/ares/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Aurielle/ares/teams","hooks_url":"https://api.github.com/repos/Aurielle/ares/hooks","issue_events_url":"https://api.github.com/repos/Aurielle/ares/issues/events{/number}","events_url":"https://api.github.com/repos/Aurielle/ares/events","assignees_url":"https://api.github.com/repos/Aurielle/ares/assignees{/user}","branches_url":"https://api.github.com/repos/Aurielle/ares/branches{/branch}","tags_url":"https://api.github.com/repos/Aurielle/ares/tags","blobs_url":"https://api.github.com/repos/Aurielle/ares/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Aurielle/ares/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Aurielle/ares/git/refs{/sha}","trees_url":"https://api.github.com/repos/Aurielle/ares/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Aurielle/ares/statuses/{sha}","languages_url":"https://api.github.com/repos/Aurielle/ares/languages","stargazers_url":"https://api.github.com/repos/Aurielle/ares/stargazers","contributors_url":"https://api.github.com/repos/Aurielle/ares/contributors","subscribers_url":"https://api.github.com/repos/Aurielle/ares/subscribers","subscription_url":"https://api.github.com/repos/Aurielle/ares/subscription","commits_url":"https://api.github.com/repos/Aurielle/ares/commits{/sha}","git_commits_url":"https://api.github.com/repos/Aurielle/ares/git/commits{/sha}","comments_url":"https://api.github.com/repos/Aurielle/ares/comments{/number}","issue_comment_url":"https://api.github.com/repos/Aurielle/ares/issues/comments{/number}","contents_url":"https://api.github.com/repos/Aurielle/ares/contents/{+path}","compare_url":"https://api.github.com/repos/Aurielle/ares/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Aurielle/ares/merges","archive_url":"https://api.github.com/repos/Aurielle/ares/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Aurielle/ares/downloads","issues_url":"https://api.github.com/repos/Aurielle/ares/issues{/number}","pulls_url":"https://api.github.com/repos/Aurielle/ares/pulls{/number}","milestones_url":"https://api.github.com/repos/Aurielle/ares/milestones{/number}","notifications_url":"https://api.github.com/repos/Aurielle/ares/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Aurielle/ares/labels{/name}","releases_url":"https://api.github.com/repos/Aurielle/ares/releases{/id}","created_at":"2015-07-20T14:13:36Z","updated_at":"2015-07-20T16:53:51Z","pushed_at":"2015-07-25T12:38:13Z","git_url":"git://github.com/Aurielle/ares.git","ssh_url":"git@github.com:Aurielle/ares.git","clone_url":"https://github.com/Aurielle/ares.git","svn_url":"https://github.com/Aurielle/ares","homepage":"","size":119,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"Aurielle:master","ref":"master","sha":"3f71483f1539cc702caef7254f18a69c5b151880","user":{"login":"Aurielle","id":144428,"avatar_url":"https://avatars.githubusercontent.com/u/144428?v=3","gravatar_id":"","url":"https://api.github.com/users/Aurielle","html_url":"https://github.com/Aurielle","followers_url":"https://api.github.com/users/Aurielle/followers","following_url":"https://api.github.com/users/Aurielle/following{/other_user}","gists_url":"https://api.github.com/users/Aurielle/gists{/gist_id}","starred_url":"https://api.github.com/users/Aurielle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aurielle/subscriptions","organizations_url":"https://api.github.com/users/Aurielle/orgs","repos_url":"https://api.github.com/users/Aurielle/repos","events_url":"https://api.github.com/users/Aurielle/events{/privacy}","received_events_url":"https://api.github.com/users/Aurielle/received_events","type":"User","site_admin":false},"repo":{"id":39387701,"name":"ares","full_name":"Aurielle/ares","owner":{"login":"Aurielle","id":144428,"avatar_url":"https://avatars.githubusercontent.com/u/144428?v=3","gravatar_id":"","url":"https://api.github.com/users/Aurielle","html_url":"https://github.com/Aurielle","followers_url":"https://api.github.com/users/Aurielle/followers","following_url":"https://api.github.com/users/Aurielle/following{/other_user}","gists_url":"https://api.github.com/users/Aurielle/gists{/gist_id}","starred_url":"https://api.github.com/users/Aurielle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aurielle/subscriptions","organizations_url":"https://api.github.com/users/Aurielle/orgs","repos_url":"https://api.github.com/users/Aurielle/repos","events_url":"https://api.github.com/users/Aurielle/events{/privacy}","received_events_url":"https://api.github.com/users/Aurielle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Aurielle/ares","description":"Provides information about subjects by their identification number from the ARES database (in Czech Republic).","fork":true,"url":"https://api.github.com/repos/Aurielle/ares","forks_url":"https://api.github.com/repos/Aurielle/ares/forks","keys_url":"https://api.github.com/repos/Aurielle/ares/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Aurielle/ares/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Aurielle/ares/teams","hooks_url":"https://api.github.com/repos/Aurielle/ares/hooks","issue_events_url":"https://api.github.com/repos/Aurielle/ares/issues/events{/number}","events_url":"https://api.github.com/repos/Aurielle/ares/events","assignees_url":"https://api.github.com/repos/Aurielle/ares/assignees{/user}","branches_url":"https://api.github.com/repos/Aurielle/ares/branches{/branch}","tags_url":"https://api.github.com/repos/Aurielle/ares/tags","blobs_url":"https://api.github.com/repos/Aurielle/ares/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Aurielle/ares/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Aurielle/ares/git/refs{/sha}","trees_url":"https://api.github.com/repos/Aurielle/ares/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Aurielle/ares/statuses/{sha}","languages_url":"https://api.github.com/repos/Aurielle/ares/languages","stargazers_url":"https://api.github.com/repos/Aurielle/ares/stargazers","contributors_url":"https://api.github.com/repos/Aurielle/ares/contributors","subscribers_url":"https://api.github.com/repos/Aurielle/ares/subscribers","subscription_url":"https://api.github.com/repos/Aurielle/ares/subscription","commits_url":"https://api.github.com/repos/Aurielle/ares/commits{/sha}","git_commits_url":"https://api.github.com/repos/Aurielle/ares/git/commits{/sha}","comments_url":"https://api.github.com/repos/Aurielle/ares/comments{/number}","issue_comment_url":"https://api.github.com/repos/Aurielle/ares/issues/comments{/number}","contents_url":"https://api.github.com/repos/Aurielle/ares/contents/{+path}","compare_url":"https://api.github.com/repos/Aurielle/ares/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Aurielle/ares/merges","archive_url":"https://api.github.com/repos/Aurielle/ares/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Aurielle/ares/downloads","issues_url":"https://api.github.com/repos/Aurielle/ares/issues{/number}","pulls_url":"https://api.github.com/repos/Aurielle/ares/pulls{/number}","milestones_url":"https://api.github.com/repos/Aurielle/ares/milestones{/number}","notifications_url":"https://api.github.com/repos/Aurielle/ares/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Aurielle/ares/labels{/name}","releases_url":"https://api.github.com/repos/Aurielle/ares/releases{/id}","created_at":"2015-07-20T14:13:36Z","updated_at":"2015-07-20T16:53:51Z","pushed_at":"2015-07-25T12:38:13Z","git_url":"git://github.com/Aurielle/ares.git","ssh_url":"git@github.com:Aurielle/ares.git","clone_url":"https://github.com/Aurielle/ares.git","svn_url":"https://github.com/Aurielle/ares","homepage":"","size":119,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Aurielle/ares/pulls/1"},"html":{"href":"https://github.com/Aurielle/ares/pull/1"},"issue":{"href":"https://api.github.com/repos/Aurielle/ares/issues/1"},"comments":{"href":"https://api.github.com/repos/Aurielle/ares/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Aurielle/ares/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Aurielle/ares/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Aurielle/ares/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Aurielle/ares/statuses/679cbf88b982bfd7978f757300012a00b302bcb3"}}}}