{"action":"created","comment":{"url":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/comments/29336678","id":29336678,"diff_hunk":"@@ -1,23 +1,80 @@\n-﻿/**\n+﻿\t/**\n  * Input for reading device state from the Server API\n  */\n using System;\n+using System.Net;\n+using System.Threading.Tasks;\n+using System.Net.Http;\n+using System.Text;\n+using System.Diagnostics;\n+using PortableRest;\n+using Newtonsoft.Json;\n+\n \n namespace api\n {\n public class ServerInput : IDeviceInput\n {\n-\tpublic ServerInput() \n+\tstring _server_uri;\n+\n+\tpublic ServerInput(string server_uri) \n \t{\n+\t\t_server_uri= server_uri;\n \t}\n \n \t/**\n \t * Updates device from the server\n \t */\n \tpublic bool read(Device dev)\n-\t{\n-\t\t//TODO: Implement this function\n-\t\treturn true;\n+\t{ \n+\t\tbool server_input_status = false; //The variable tracks the successful updataion of state for the app and decision making\n+\n+\n+\t\t//this try block tries to get a deserialized string of the state from the server\n+\t\ttry\n+\t\t{\n+\t\tvar client = new RestClient();\n+\t\tclient.BaseUrl = _server_uri;\n+\t\tvar request = new RestRequest(\"api/storage/device/{house}/{space}/{device}\");//the default request is GET\n+\t\trequest.AddUrlSegment(\"house\", dev.ID.HouseID.ToString());\n+\t\trequest.AddUrlSegment(\"space\", dev.ID.HouseID.ToString());\n+\t\trequest.AddUrlSegment(\"device\", dev.ID.HouseID.ToString());\n+\t\tvar response = client.ExecuteAsync<string>(request);//tries to get a deserialized string of device state as the response.\n+\t\t \n+\t\t\tif(response.Status ==TaskStatus.Created)//condition check for a successful completion of the GET request\n+\t\t\t{\t\n+\t\t\tbool update_status = Interfaces.UpdateDevice(dev, response.Result);// updating the device state obtained from server\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//the assumption is that response.Result has the deserialized device state\n+\t\t\tif(update_status == true)\n+\t\t\t\t{\n+\t\t\t\tserver_input_status = true;\n+\t\t\t\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\telse \n+\t\t\t{\n+\t\t\t\tDebug.WriteLine(\"Trouble querying the server\"+response.Status);\n+\t\t\t}\n+\t\treturn server_input_status;\n+\t\t}\n+\t\tcatch (Exception e)\n+\t\t{\n+\t\t\tDebug.WriteLine(\"Server Input Error: \" + e.Message);\n+\t\t\tDebug.WriteLine(\"Server Input Error: \" + e.InnerException.Message);\n+\t\t}\n+\t\treturn server_input_status;\n+\t\t//return response;\n+\t\t//var blob = JsonConvert.DeserializeObject(dev);\n+\t\t//RestResponse response; //= client.ExecuteAsync(request);\n+\t\t//RestResponse response = client.ExecuteAsync(request);\n+\t\t//Assert.AreEqual(HttpStatusCode.OK, resp.StatusCode);\n+\t\t//Device dev1= response.Result;\n+\t\t//dev = dev1;\n+\t\t//var content = response.Result;\n+\n+\t\t//Device DeserializeDevice(string info, IDeviceInput inp, IDeviceOutput outp, TimeFrame frame)\n+\t\t//POST api/house/device/state\n+\t\t//return true;","path":"api/ServerInput.cs","position":82,"original_position":82,"commit_id":"7f2962ad1050b5de6cf3477e9c76936b6bd3b0a9","original_commit_id":"7f2962ad1050b5de6cf3477e9c76936b6bd3b0a9","user":{"login":"jasedit","id":53046,"avatar_url":"https://avatars.githubusercontent.com/u/53046?v=3","gravatar_id":"","url":"https://api.github.com/users/jasedit","html_url":"https://github.com/jasedit","followers_url":"https://api.github.com/users/jasedit/followers","following_url":"https://api.github.com/users/jasedit/following{/other_user}","gists_url":"https://api.github.com/users/jasedit/gists{/gist_id}","starred_url":"https://api.github.com/users/jasedit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasedit/subscriptions","organizations_url":"https://api.github.com/users/jasedit/orgs","repos_url":"https://api.github.com/users/jasedit/repos","events_url":"https://api.github.com/users/jasedit/events{/privacy}","received_events_url":"https://api.github.com/users/jasedit/received_events","type":"User","site_admin":false},"body":"You can likely nuke the scar tissue.","created_at":"2015-04-29T13:48:47Z","updated_at":"2015-04-29T13:48:47Z","html_url":"https://github.com/ECE4574-5574/Devices/pull/57#discussion_r29336678","pull_request_url":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/57","_links":{"self":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/comments/29336678"},"html":{"href":"https://github.com/ECE4574-5574/Devices/pull/57#discussion_r29336678"},"pull_request":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/57"}}},"pull_request":{"url":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/57","id":34299606,"html_url":"https://github.com/ECE4574-5574/Devices/pull/57","diff_url":"https://github.com/ECE4574-5574/Devices/pull/57.diff","patch_url":"https://github.com/ECE4574-5574/Devices/pull/57.patch","issue_url":"https://api.github.com/repos/ECE4574-5574/Devices/issues/57","number":57,"state":"open","locked":false,"title":"Adding ServerInput class functionality using PortableRest","user":{"login":"arunkt1","id":11579501,"avatar_url":"https://avatars.githubusercontent.com/u/11579501?v=3","gravatar_id":"","url":"https://api.github.com/users/arunkt1","html_url":"https://github.com/arunkt1","followers_url":"https://api.github.com/users/arunkt1/followers","following_url":"https://api.github.com/users/arunkt1/following{/other_user}","gists_url":"https://api.github.com/users/arunkt1/gists{/gist_id}","starred_url":"https://api.github.com/users/arunkt1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arunkt1/subscriptions","organizations_url":"https://api.github.com/users/arunkt1/orgs","repos_url":"https://api.github.com/users/arunkt1/repos","events_url":"https://api.github.com/users/arunkt1/events{/privacy}","received_events_url":"https://api.github.com/users/arunkt1/received_events","type":"User","site_admin":false},"body":"I have to make further tests to ascertain whether response.Result returns the deserialized string representation of the device state from the server which can be directly passed to the updateDevice() function","created_at":"2015-04-28T18:59:32Z","updated_at":"2015-04-29T13:48:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":{"login":"jasedit","id":53046,"avatar_url":"https://avatars.githubusercontent.com/u/53046?v=3","gravatar_id":"","url":"https://api.github.com/users/jasedit","html_url":"https://github.com/jasedit","followers_url":"https://api.github.com/users/jasedit/followers","following_url":"https://api.github.com/users/jasedit/following{/other_user}","gists_url":"https://api.github.com/users/jasedit/gists{/gist_id}","starred_url":"https://api.github.com/users/jasedit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasedit/subscriptions","organizations_url":"https://api.github.com/users/jasedit/orgs","repos_url":"https://api.github.com/users/jasedit/repos","events_url":"https://api.github.com/users/jasedit/events{/privacy}","received_events_url":"https://api.github.com/users/jasedit/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/57/commits","review_comments_url":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/57/comments","review_comment_url":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ECE4574-5574/Devices/issues/57/comments","statuses_url":"https://api.github.com/repos/ECE4574-5574/Devices/statuses/7f2962ad1050b5de6cf3477e9c76936b6bd3b0a9","head":{"label":"ECE4574-5574:enum_dev_io","ref":"enum_dev_io","sha":"7f2962ad1050b5de6cf3477e9c76936b6bd3b0a9","user":{"login":"ECE4574-5574","id":11506935,"avatar_url":"https://avatars.githubusercontent.com/u/11506935?v=3","gravatar_id":"","url":"https://api.github.com/users/ECE4574-5574","html_url":"https://github.com/ECE4574-5574","followers_url":"https://api.github.com/users/ECE4574-5574/followers","following_url":"https://api.github.com/users/ECE4574-5574/following{/other_user}","gists_url":"https://api.github.com/users/ECE4574-5574/gists{/gist_id}","starred_url":"https://api.github.com/users/ECE4574-5574/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ECE4574-5574/subscriptions","organizations_url":"https://api.github.com/users/ECE4574-5574/orgs","repos_url":"https://api.github.com/users/ECE4574-5574/repos","events_url":"https://api.github.com/users/ECE4574-5574/events{/privacy}","received_events_url":"https://api.github.com/users/ECE4574-5574/received_events","type":"Organization","site_admin":false},"repo":{"id":32696270,"name":"Devices","full_name":"ECE4574-5574/Devices","owner":{"login":"ECE4574-5574","id":11506935,"avatar_url":"https://avatars.githubusercontent.com/u/11506935?v=3","gravatar_id":"","url":"https://api.github.com/users/ECE4574-5574","html_url":"https://github.com/ECE4574-5574","followers_url":"https://api.github.com/users/ECE4574-5574/followers","following_url":"https://api.github.com/users/ECE4574-5574/following{/other_user}","gists_url":"https://api.github.com/users/ECE4574-5574/gists{/gist_id}","starred_url":"https://api.github.com/users/ECE4574-5574/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ECE4574-5574/subscriptions","organizations_url":"https://api.github.com/users/ECE4574-5574/orgs","repos_url":"https://api.github.com/users/ECE4574-5574/repos","events_url":"https://api.github.com/users/ECE4574-5574/events{/privacy}","received_events_url":"https://api.github.com/users/ECE4574-5574/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ECE4574-5574/Devices","description":"Device API for components in the HATS system","fork":false,"url":"https://api.github.com/repos/ECE4574-5574/Devices","forks_url":"https://api.github.com/repos/ECE4574-5574/Devices/forks","keys_url":"https://api.github.com/repos/ECE4574-5574/Devices/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ECE4574-5574/Devices/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ECE4574-5574/Devices/teams","hooks_url":"https://api.github.com/repos/ECE4574-5574/Devices/hooks","issue_events_url":"https://api.github.com/repos/ECE4574-5574/Devices/issues/events{/number}","events_url":"https://api.github.com/repos/ECE4574-5574/Devices/events","assignees_url":"https://api.github.com/repos/ECE4574-5574/Devices/assignees{/user}","branches_url":"https://api.github.com/repos/ECE4574-5574/Devices/branches{/branch}","tags_url":"https://api.github.com/repos/ECE4574-5574/Devices/tags","blobs_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/refs{/sha}","trees_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ECE4574-5574/Devices/statuses/{sha}","languages_url":"https://api.github.com/repos/ECE4574-5574/Devices/languages","stargazers_url":"https://api.github.com/repos/ECE4574-5574/Devices/stargazers","contributors_url":"https://api.github.com/repos/ECE4574-5574/Devices/contributors","subscribers_url":"https://api.github.com/repos/ECE4574-5574/Devices/subscribers","subscription_url":"https://api.github.com/repos/ECE4574-5574/Devices/subscription","commits_url":"https://api.github.com/repos/ECE4574-5574/Devices/commits{/sha}","git_commits_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/commits{/sha}","comments_url":"https://api.github.com/repos/ECE4574-5574/Devices/comments{/number}","issue_comment_url":"https://api.github.com/repos/ECE4574-5574/Devices/issues/comments{/number}","contents_url":"https://api.github.com/repos/ECE4574-5574/Devices/contents/{+path}","compare_url":"https://api.github.com/repos/ECE4574-5574/Devices/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ECE4574-5574/Devices/merges","archive_url":"https://api.github.com/repos/ECE4574-5574/Devices/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ECE4574-5574/Devices/downloads","issues_url":"https://api.github.com/repos/ECE4574-5574/Devices/issues{/number}","pulls_url":"https://api.github.com/repos/ECE4574-5574/Devices/pulls{/number}","milestones_url":"https://api.github.com/repos/ECE4574-5574/Devices/milestones{/number}","notifications_url":"https://api.github.com/repos/ECE4574-5574/Devices/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ECE4574-5574/Devices/labels{/name}","releases_url":"https://api.github.com/repos/ECE4574-5574/Devices/releases{/id}","created_at":"2015-03-22T21:23:14Z","updated_at":"2015-04-28T15:15:17Z","pushed_at":"2015-04-29T13:46:13Z","git_url":"git://github.com/ECE4574-5574/Devices.git","ssh_url":"git@github.com:ECE4574-5574/Devices.git","clone_url":"https://github.com/ECE4574-5574/Devices.git","svn_url":"https://github.com/ECE4574-5574/Devices","homepage":"","size":932,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":15,"forks":0,"open_issues":15,"watchers":0,"default_branch":"master"}},"base":{"label":"ECE4574-5574:master","ref":"master","sha":"f999bbe2c48efe627cd8f2bca43718bc1aa3476c","user":{"login":"ECE4574-5574","id":11506935,"avatar_url":"https://avatars.githubusercontent.com/u/11506935?v=3","gravatar_id":"","url":"https://api.github.com/users/ECE4574-5574","html_url":"https://github.com/ECE4574-5574","followers_url":"https://api.github.com/users/ECE4574-5574/followers","following_url":"https://api.github.com/users/ECE4574-5574/following{/other_user}","gists_url":"https://api.github.com/users/ECE4574-5574/gists{/gist_id}","starred_url":"https://api.github.com/users/ECE4574-5574/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ECE4574-5574/subscriptions","organizations_url":"https://api.github.com/users/ECE4574-5574/orgs","repos_url":"https://api.github.com/users/ECE4574-5574/repos","events_url":"https://api.github.com/users/ECE4574-5574/events{/privacy}","received_events_url":"https://api.github.com/users/ECE4574-5574/received_events","type":"Organization","site_admin":false},"repo":{"id":32696270,"name":"Devices","full_name":"ECE4574-5574/Devices","owner":{"login":"ECE4574-5574","id":11506935,"avatar_url":"https://avatars.githubusercontent.com/u/11506935?v=3","gravatar_id":"","url":"https://api.github.com/users/ECE4574-5574","html_url":"https://github.com/ECE4574-5574","followers_url":"https://api.github.com/users/ECE4574-5574/followers","following_url":"https://api.github.com/users/ECE4574-5574/following{/other_user}","gists_url":"https://api.github.com/users/ECE4574-5574/gists{/gist_id}","starred_url":"https://api.github.com/users/ECE4574-5574/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ECE4574-5574/subscriptions","organizations_url":"https://api.github.com/users/ECE4574-5574/orgs","repos_url":"https://api.github.com/users/ECE4574-5574/repos","events_url":"https://api.github.com/users/ECE4574-5574/events{/privacy}","received_events_url":"https://api.github.com/users/ECE4574-5574/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ECE4574-5574/Devices","description":"Device API for components in the HATS system","fork":false,"url":"https://api.github.com/repos/ECE4574-5574/Devices","forks_url":"https://api.github.com/repos/ECE4574-5574/Devices/forks","keys_url":"https://api.github.com/repos/ECE4574-5574/Devices/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ECE4574-5574/Devices/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ECE4574-5574/Devices/teams","hooks_url":"https://api.github.com/repos/ECE4574-5574/Devices/hooks","issue_events_url":"https://api.github.com/repos/ECE4574-5574/Devices/issues/events{/number}","events_url":"https://api.github.com/repos/ECE4574-5574/Devices/events","assignees_url":"https://api.github.com/repos/ECE4574-5574/Devices/assignees{/user}","branches_url":"https://api.github.com/repos/ECE4574-5574/Devices/branches{/branch}","tags_url":"https://api.github.com/repos/ECE4574-5574/Devices/tags","blobs_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/refs{/sha}","trees_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ECE4574-5574/Devices/statuses/{sha}","languages_url":"https://api.github.com/repos/ECE4574-5574/Devices/languages","stargazers_url":"https://api.github.com/repos/ECE4574-5574/Devices/stargazers","contributors_url":"https://api.github.com/repos/ECE4574-5574/Devices/contributors","subscribers_url":"https://api.github.com/repos/ECE4574-5574/Devices/subscribers","subscription_url":"https://api.github.com/repos/ECE4574-5574/Devices/subscription","commits_url":"https://api.github.com/repos/ECE4574-5574/Devices/commits{/sha}","git_commits_url":"https://api.github.com/repos/ECE4574-5574/Devices/git/commits{/sha}","comments_url":"https://api.github.com/repos/ECE4574-5574/Devices/comments{/number}","issue_comment_url":"https://api.github.com/repos/ECE4574-5574/Devices/issues/comments{/number}","contents_url":"https://api.github.com/repos/ECE4574-5574/Devices/contents/{+path}","compare_url":"https://api.github.com/repos/ECE4574-5574/Devices/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ECE4574-5574/Devices/merges","archive_url":"https://api.github.com/repos/ECE4574-5574/Devices/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ECE4574-5574/Devices/downloads","issues_url":"https://api.github.com/repos/ECE4574-5574/Devices/issues{/number}","pulls_url":"https://api.github.com/repos/ECE4574-5574/Devices/pulls{/number}","milestones_url":"https://api.github.com/repos/ECE4574-5574/Devices/milestones{/number}","notifications_url":"https://api.github.com/repos/ECE4574-5574/Devices/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ECE4574-5574/Devices/labels{/name}","releases_url":"https://api.github.com/repos/ECE4574-5574/Devices/releases{/id}","created_at":"2015-03-22T21:23:14Z","updated_at":"2015-04-28T15:15:17Z","pushed_at":"2015-04-29T13:46:13Z","git_url":"git://github.com/ECE4574-5574/Devices.git","ssh_url":"git@github.com:ECE4574-5574/Devices.git","clone_url":"https://github.com/ECE4574-5574/Devices.git","svn_url":"https://github.com/ECE4574-5574/Devices","homepage":"","size":932,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":15,"forks":0,"open_issues":15,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/57"},"html":{"href":"https://github.com/ECE4574-5574/Devices/pull/57"},"issue":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/issues/57"},"comments":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/issues/57/comments"},"review_comments":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/57/comments"},"review_comment":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/pulls/57/commits"},"statuses":{"href":"https://api.github.com/repos/ECE4574-5574/Devices/statuses/7f2962ad1050b5de6cf3477e9c76936b6bd3b0a9"}}}}