{"action":"created","comment":{"url":"https://api.github.com/repos/marektabor/S4A/pulls/comments/79311585","id":79311585,"diff_hunk":"@@ -0,0 +1,153 @@\n+package pl.parser.nbp.utils;\n+\n+import org.apache.http.HttpResponse;\n+import org.apache.http.ParseException;\n+import org.apache.http.client.HttpClient;\n+import org.apache.http.client.methods.HttpGet;\n+import org.apache.http.impl.client.DefaultHttpClient;\n+import org.w3c.dom.Document;\n+import org.w3c.dom.Node;\n+import org.w3c.dom.NodeList;\n+import org.xml.sax.InputSource;\n+import org.xml.sax.SAXException;\n+import org.xml.sax.SAXParseException;\n+import pl.parser.nbp.calculation.Calculations;\n+import pl.parser.nbp.config.Config;\n+import pl.parser.nbp.validators.CurrencyTypeValidator;\n+import pl.parser.nbp.validators.DateTypeValidator;\n+\n+import javax.xml.parsers.DocumentBuilder;\n+import javax.xml.parsers.DocumentBuilderFactory;\n+import javax.xml.parsers.ParserConfigurationException;\n+import java.io.BufferedReader;\n+import java.io.IOException;\n+import java.io.InputStreamReader;\n+import java.io.StringReader;\n+import java.text.SimpleDateFormat;\n+import java.util.ArrayList;\n+import java.util.Date;\n+\n+/**\n+ * Created by Mark on 9/14/2016.\n+ */\n+public class DataProvider {\n+\n+    private String currencyType;\n+    private String startDate;\n+    private String endDate;\n+    private HttpClient client;\n+    private HttpGet request;\n+    private Date today = new Date();\n+    private StringBuffer result = new StringBuffer();\n+    private static SimpleDateFormat dateFormater = new SimpleDateFormat(Config.DATA_FORMAT);\n+    private static CurrencyTypeValidator currencyTypeValidator = new CurrencyTypeValidator();\n+    private static DateTypeValidator dateTypeValidator = new DateTypeValidator();\n+    private static Calculations doMath = new Calculations();\n+    //{code}/{startDate}/{endDate}/\n+\n+    public DataProvider(String currencyType, String startDate,String endDate ){\n+        this.currencyType = currencyType;\n+        this.startDate = startDate;\n+        this.endDate = endDate;\n+    }\n+\n+    public Boolean isDateInProperFormat(String startDate, String endDate) throws ParseException {\n+        try {\n+            startDate = dateFormater.format(dateFormater.parse(startDate));\n+            endDate = dateFormater.format(dateFormater.parse(endDate));\n+            System.out.println(startDate);\n+            System.out.println(endDate);\n+//            System.out.println(dateFormater.format(today));\n+            return true;\n+        } catch (java.text.ParseException e) {\n+            e.printStackTrace();\n+            return false;\n+        }\n+    }\n+\n+    public Boolean isDateTypeInProperFormatRegex(String startDate,String endDate){\n+        return dateTypeValidator.validatesCurrencyTypeRegex(startDate,endDate);\n+    }\n+\n+    public Boolean isCurrencyTypeInProperFormatRegex(String currencyType){\n+        return currencyTypeValidator.validatesCurrencyTypeRegex(currencyType);\n+    }\n+\n+    //todo zrobic validator blokujacy data wieksza niz dzisiejsza\n+\n+    public void setUpDataProvider() throws Exception{\n+        if(isCurrencyTypeInProperFormatRegex(currencyType) && isDateInProperFormat(startDate, endDate) && isDateTypeInProperFormatRegex(startDate,endDate)){\n+            client = new DefaultHttpClient();\n+            request = new HttpGet(Config.API_URL + currencyType + \"/\" + startDate + \"/\" + endDate + Config.XML_FORMAT);","path":"src/main/java/pl/parser/nbp/utils/DataProvider.java","position":81,"original_position":81,"commit_id":"435771aa841a87112e9e2c4b97e6c52f86b26e6e","original_commit_id":"435771aa841a87112e9e2c4b97e6c52f86b26e6e","user":{"login":"kmikuta","id":11312513,"avatar_url":"https://avatars.githubusercontent.com/u/11312513?v=3","gravatar_id":"","url":"https://api.github.com/users/kmikuta","html_url":"https://github.com/kmikuta","followers_url":"https://api.github.com/users/kmikuta/followers","following_url":"https://api.github.com/users/kmikuta/following{/other_user}","gists_url":"https://api.github.com/users/kmikuta/gists{/gist_id}","starred_url":"https://api.github.com/users/kmikuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmikuta/subscriptions","organizations_url":"https://api.github.com/users/kmikuta/orgs","repos_url":"https://api.github.com/users/kmikuta/repos","events_url":"https://api.github.com/users/kmikuta/events{/privacy}","received_events_url":"https://api.github.com/users/kmikuta/received_events","type":"User","site_admin":false},"body":"przygotuj to w osobnej metodzie a nie sklejaj w jednej linii","created_at":"2016-09-18T18:06:30Z","updated_at":"2016-09-18T18:06:31Z","html_url":"https://github.com/marektabor/S4A/pull/1#discussion_r79311585","pull_request_url":"https://api.github.com/repos/marektabor/S4A/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/marektabor/S4A/pulls/comments/79311585"},"html":{"href":"https://github.com/marektabor/S4A/pull/1#discussion_r79311585"},"pull_request":{"href":"https://api.github.com/repos/marektabor/S4A/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/marektabor/S4A/pulls/1","id":85717580,"html_url":"https://github.com/marektabor/S4A/pull/1","diff_url":"https://github.com/marektabor/S4A/pull/1.diff","patch_url":"https://github.com/marektabor/S4A/pull/1.patch","issue_url":"https://api.github.com/repos/marektabor/S4A/issues/1","number":1,"state":"open","locked":false,"title":"Code review","user":{"login":"kmikuta","id":11312513,"avatar_url":"https://avatars.githubusercontent.com/u/11312513?v=3","gravatar_id":"","url":"https://api.github.com/users/kmikuta","html_url":"https://github.com/kmikuta","followers_url":"https://api.github.com/users/kmikuta/followers","following_url":"https://api.github.com/users/kmikuta/following{/other_user}","gists_url":"https://api.github.com/users/kmikuta/gists{/gist_id}","starred_url":"https://api.github.com/users/kmikuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmikuta/subscriptions","organizations_url":"https://api.github.com/users/kmikuta/orgs","repos_url":"https://api.github.com/users/kmikuta/repos","events_url":"https://api.github.com/users/kmikuta/events{/privacy}","received_events_url":"https://api.github.com/users/kmikuta/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-18T17:59:03Z","updated_at":"2016-09-18T18:06:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7224517f1ec216498c5c648cf22523b344864ae3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/marektabor/S4A/pulls/1/commits","review_comments_url":"https://api.github.com/repos/marektabor/S4A/pulls/1/comments","review_comment_url":"https://api.github.com/repos/marektabor/S4A/pulls/comments{/number}","comments_url":"https://api.github.com/repos/marektabor/S4A/issues/1/comments","statuses_url":"https://api.github.com/repos/marektabor/S4A/statuses/435771aa841a87112e9e2c4b97e6c52f86b26e6e","head":{"label":"marektabor:master","ref":"master","sha":"435771aa841a87112e9e2c4b97e6c52f86b26e6e","user":{"login":"marektabor","id":11422395,"avatar_url":"https://avatars.githubusercontent.com/u/11422395?v=3","gravatar_id":"","url":"https://api.github.com/users/marektabor","html_url":"https://github.com/marektabor","followers_url":"https://api.github.com/users/marektabor/followers","following_url":"https://api.github.com/users/marektabor/following{/other_user}","gists_url":"https://api.github.com/users/marektabor/gists{/gist_id}","starred_url":"https://api.github.com/users/marektabor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marektabor/subscriptions","organizations_url":"https://api.github.com/users/marektabor/orgs","repos_url":"https://api.github.com/users/marektabor/repos","events_url":"https://api.github.com/users/marektabor/events{/privacy}","received_events_url":"https://api.github.com/users/marektabor/received_events","type":"User","site_admin":false},"repo":{"id":68222978,"name":"S4A","full_name":"marektabor/S4A","owner":{"login":"marektabor","id":11422395,"avatar_url":"https://avatars.githubusercontent.com/u/11422395?v=3","gravatar_id":"","url":"https://api.github.com/users/marektabor","html_url":"https://github.com/marektabor","followers_url":"https://api.github.com/users/marektabor/followers","following_url":"https://api.github.com/users/marektabor/following{/other_user}","gists_url":"https://api.github.com/users/marektabor/gists{/gist_id}","starred_url":"https://api.github.com/users/marektabor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marektabor/subscriptions","organizations_url":"https://api.github.com/users/marektabor/orgs","repos_url":"https://api.github.com/users/marektabor/repos","events_url":"https://api.github.com/users/marektabor/events{/privacy}","received_events_url":"https://api.github.com/users/marektabor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marektabor/S4A","description":null,"fork":false,"url":"https://api.github.com/repos/marektabor/S4A","forks_url":"https://api.github.com/repos/marektabor/S4A/forks","keys_url":"https://api.github.com/repos/marektabor/S4A/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marektabor/S4A/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marektabor/S4A/teams","hooks_url":"https://api.github.com/repos/marektabor/S4A/hooks","issue_events_url":"https://api.github.com/repos/marektabor/S4A/issues/events{/number}","events_url":"https://api.github.com/repos/marektabor/S4A/events","assignees_url":"https://api.github.com/repos/marektabor/S4A/assignees{/user}","branches_url":"https://api.github.com/repos/marektabor/S4A/branches{/branch}","tags_url":"https://api.github.com/repos/marektabor/S4A/tags","blobs_url":"https://api.github.com/repos/marektabor/S4A/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marektabor/S4A/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marektabor/S4A/git/refs{/sha}","trees_url":"https://api.github.com/repos/marektabor/S4A/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marektabor/S4A/statuses/{sha}","languages_url":"https://api.github.com/repos/marektabor/S4A/languages","stargazers_url":"https://api.github.com/repos/marektabor/S4A/stargazers","contributors_url":"https://api.github.com/repos/marektabor/S4A/contributors","subscribers_url":"https://api.github.com/repos/marektabor/S4A/subscribers","subscription_url":"https://api.github.com/repos/marektabor/S4A/subscription","commits_url":"https://api.github.com/repos/marektabor/S4A/commits{/sha}","git_commits_url":"https://api.github.com/repos/marektabor/S4A/git/commits{/sha}","comments_url":"https://api.github.com/repos/marektabor/S4A/comments{/number}","issue_comment_url":"https://api.github.com/repos/marektabor/S4A/issues/comments{/number}","contents_url":"https://api.github.com/repos/marektabor/S4A/contents/{+path}","compare_url":"https://api.github.com/repos/marektabor/S4A/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marektabor/S4A/merges","archive_url":"https://api.github.com/repos/marektabor/S4A/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marektabor/S4A/downloads","issues_url":"https://api.github.com/repos/marektabor/S4A/issues{/number}","pulls_url":"https://api.github.com/repos/marektabor/S4A/pulls{/number}","milestones_url":"https://api.github.com/repos/marektabor/S4A/milestones{/number}","notifications_url":"https://api.github.com/repos/marektabor/S4A/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marektabor/S4A/labels{/name}","releases_url":"https://api.github.com/repos/marektabor/S4A/releases{/id}","deployments_url":"https://api.github.com/repos/marektabor/S4A/deployments","created_at":"2016-09-14T16:24:39Z","updated_at":"2016-09-14T16:27:35Z","pushed_at":"2016-09-18T17:59:03Z","git_url":"git://github.com/marektabor/S4A.git","ssh_url":"git@github.com:marektabor/S4A.git","clone_url":"https://github.com/marektabor/S4A.git","svn_url":"https://github.com/marektabor/S4A","homepage":null,"size":22,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"marektabor:RELEASE","ref":"RELEASE","sha":"20cb6252153e6259d775ebcd8dd61fe1fdfbc749","user":{"login":"marektabor","id":11422395,"avatar_url":"https://avatars.githubusercontent.com/u/11422395?v=3","gravatar_id":"","url":"https://api.github.com/users/marektabor","html_url":"https://github.com/marektabor","followers_url":"https://api.github.com/users/marektabor/followers","following_url":"https://api.github.com/users/marektabor/following{/other_user}","gists_url":"https://api.github.com/users/marektabor/gists{/gist_id}","starred_url":"https://api.github.com/users/marektabor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marektabor/subscriptions","organizations_url":"https://api.github.com/users/marektabor/orgs","repos_url":"https://api.github.com/users/marektabor/repos","events_url":"https://api.github.com/users/marektabor/events{/privacy}","received_events_url":"https://api.github.com/users/marektabor/received_events","type":"User","site_admin":false},"repo":{"id":68222978,"name":"S4A","full_name":"marektabor/S4A","owner":{"login":"marektabor","id":11422395,"avatar_url":"https://avatars.githubusercontent.com/u/11422395?v=3","gravatar_id":"","url":"https://api.github.com/users/marektabor","html_url":"https://github.com/marektabor","followers_url":"https://api.github.com/users/marektabor/followers","following_url":"https://api.github.com/users/marektabor/following{/other_user}","gists_url":"https://api.github.com/users/marektabor/gists{/gist_id}","starred_url":"https://api.github.com/users/marektabor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marektabor/subscriptions","organizations_url":"https://api.github.com/users/marektabor/orgs","repos_url":"https://api.github.com/users/marektabor/repos","events_url":"https://api.github.com/users/marektabor/events{/privacy}","received_events_url":"https://api.github.com/users/marektabor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marektabor/S4A","description":null,"fork":false,"url":"https://api.github.com/repos/marektabor/S4A","forks_url":"https://api.github.com/repos/marektabor/S4A/forks","keys_url":"https://api.github.com/repos/marektabor/S4A/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marektabor/S4A/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marektabor/S4A/teams","hooks_url":"https://api.github.com/repos/marektabor/S4A/hooks","issue_events_url":"https://api.github.com/repos/marektabor/S4A/issues/events{/number}","events_url":"https://api.github.com/repos/marektabor/S4A/events","assignees_url":"https://api.github.com/repos/marektabor/S4A/assignees{/user}","branches_url":"https://api.github.com/repos/marektabor/S4A/branches{/branch}","tags_url":"https://api.github.com/repos/marektabor/S4A/tags","blobs_url":"https://api.github.com/repos/marektabor/S4A/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marektabor/S4A/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marektabor/S4A/git/refs{/sha}","trees_url":"https://api.github.com/repos/marektabor/S4A/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marektabor/S4A/statuses/{sha}","languages_url":"https://api.github.com/repos/marektabor/S4A/languages","stargazers_url":"https://api.github.com/repos/marektabor/S4A/stargazers","contributors_url":"https://api.github.com/repos/marektabor/S4A/contributors","subscribers_url":"https://api.github.com/repos/marektabor/S4A/subscribers","subscription_url":"https://api.github.com/repos/marektabor/S4A/subscription","commits_url":"https://api.github.com/repos/marektabor/S4A/commits{/sha}","git_commits_url":"https://api.github.com/repos/marektabor/S4A/git/commits{/sha}","comments_url":"https://api.github.com/repos/marektabor/S4A/comments{/number}","issue_comment_url":"https://api.github.com/repos/marektabor/S4A/issues/comments{/number}","contents_url":"https://api.github.com/repos/marektabor/S4A/contents/{+path}","compare_url":"https://api.github.com/repos/marektabor/S4A/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marektabor/S4A/merges","archive_url":"https://api.github.com/repos/marektabor/S4A/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marektabor/S4A/downloads","issues_url":"https://api.github.com/repos/marektabor/S4A/issues{/number}","pulls_url":"https://api.github.com/repos/marektabor/S4A/pulls{/number}","milestones_url":"https://api.github.com/repos/marektabor/S4A/milestones{/number}","notifications_url":"https://api.github.com/repos/marektabor/S4A/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marektabor/S4A/labels{/name}","releases_url":"https://api.github.com/repos/marektabor/S4A/releases{/id}","deployments_url":"https://api.github.com/repos/marektabor/S4A/deployments","created_at":"2016-09-14T16:24:39Z","updated_at":"2016-09-14T16:27:35Z","pushed_at":"2016-09-18T17:59:03Z","git_url":"git://github.com/marektabor/S4A.git","ssh_url":"git@github.com:marektabor/S4A.git","clone_url":"https://github.com/marektabor/S4A.git","svn_url":"https://github.com/marektabor/S4A","homepage":null,"size":22,"stargazers_count":0,"watchers_count":0,"language":"Java","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/marektabor/S4A/pulls/1"},"html":{"href":"https://github.com/marektabor/S4A/pull/1"},"issue":{"href":"https://api.github.com/repos/marektabor/S4A/issues/1"},"comments":{"href":"https://api.github.com/repos/marektabor/S4A/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/marektabor/S4A/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/marektabor/S4A/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/marektabor/S4A/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/marektabor/S4A/statuses/435771aa841a87112e9e2c4b97e6c52f86b26e6e"}}}}
{"actor":{"display_login":"kmikuta"}}