{"id":24021066,"url":"https://github.com/zipcodecore/youareell-2","last_synced_at":"2025-04-15T21:14:58.406Z","repository":{"id":94665674,"uuid":"193566112","full_name":"ZipCodeCore/YouAreEll-2","owner":"ZipCodeCore","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-02T21:26:18.000Z","size":39,"stargazers_count":0,"open_issues_count":2,"forks_count":21,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-15T21:14:51.385Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZipCodeCore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-24T19:26:37.000Z","updated_at":"2024-08-01T19:17:13.000Z","dependencies_parsed_at":"2024-08-02T23:46:26.610Z","dependency_job_id":"bcb0b465-f771-475d-b122-74ff4cc51b75","html_url":"https://github.com/ZipCodeCore/YouAreEll-2","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FYouAreEll-2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FYouAreEll-2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FYouAreEll-2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipCodeCore%2FYouAreEll-2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZipCodeCore","download_url":"https://codeload.github.com/ZipCodeCore/YouAreEll-2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249153949,"owners_count":21221330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-08T12:38:23.942Z","updated_at":"2025-04-15T21:14:58.386Z","avatar_url":"https://github.com/ZipCodeCore.png","language":"Java","readme":"# Under-A-Rock\n\n## Client HTTP/REST API for UnderARock\n\nYou'll write a Client to exchange JSON data over HTTP with a Server, in this case, the UnderARock(TM) server. Get POSTMAN, the app, you need it. https://www.getpostman.com/\n\n(or if you are like me, you can use the Milkman.app, which is a little more lightweight and less intrusive)\nGet it at `brew install --cask milkman`\n\nYou really __really__ need to understand the HTTP protocol and the REST API. \nAnd you need to understand JSON.\nAnd youneed to use Milkman or Postman to test your API calls, otherwise, you're just guessing. \nAnd the POST methods are the hardest to get right. \nThey are kinda tricky about what you put in the body of the POST request.\n\na little article on [ModelViewController](https://www.geeksforgeeks.org/mvc-design-pattern/)\n\n#### Breaking News in 2024\n\nKris has made this project more interesting. He's added working code for both the __ids__ command and the __messages__ command. Use the patterns of the way this is done to implement the other commands (below). You will want to start the URLShell class to see how it all works.\n\n### The Point\n\n* You are to write a command interpreter using the provided `URLShell` class.\n* You're going to create a way\n\t* for commands to be typed into your shell,\n\t* to read the typed commands and arguments,\n\t* to send them off to the Under-A-Rock server using a REST API over the HTTP protocol,\n\t* to read the JSON data returned from the URL call,\n\t* to print it out nicely formatted for your user. \n\n* `Under-A-Rock` acts a little (very little) like a twitter server or chat server.\n\t* You register your name and github id by creating an ID JSON payload (see below) and POSTing it to the server.\n\t* You can GET all the ids registered by sending a GET request to the same URL.\n\t* Once you've received all the ids, you can send messages to the world or to a specific `Github_id`.\n\n\n\n* You can send a message to the global timeline by POSTing a Message JSON object to the URL below.\n\t* If you leave the `to id` field empty, the message is `to the world`.\n\t* If you fill out the the JSON template with a valid github_id in the `to id` field of the JSON payload, then that message is addressed to that friend.\n\t* Yes, all messages can be seen by users of the system.\n\t* There are JSON templates below for both Ids and Messages.\n\n\n\n* When you send a new Message or Id JSON object to the server, it records it, and fills in one or two fields. \n\t* A Message gets an assigned sequence number and a timestamp of when it was received by the server.\n\t* An ID object gets a \"user id\" field assigned to it.\n\t* Any sequence number, timestamp or userid you put into a JSON template gets overwritten by the server when you POST it. \n\n\n\n* You're going to create a series of REST API handlers that will each perform a \nspecific command.\n\t* Each one of the command methods will then call a even lower-level method that makes a certain kind of HTTP request (GET, POST, PUT) to specific filled-in URL.\n\n* The Under-A-Rock Server can be reached at `http://zipcode.rocks:8085` Everyone uses the same server. \t\t\n\t* There are two segments to the API and two kinds of commands in the shell, the ID segment and the Messages segment.\n\n\n* You can explore several ways of doing the HTTP URL calls to the server, using the one of these:\n\t* [Apache HTTP Client Library](http://hc.apache.org/httpcomponents-client-ga/index.html)\n\t* [Unirest for Java](http://unirest.io/java.html)\n\t* [Square's OKHttp](https://github.com/square/okhttp)\n\t* Core Java:\n\t\t* [URL](https://docs.oracle.com/javase/8/docs/api/java/net/URL.html)\n\t\t* [HttpURLConnection](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html)\n\n* Be prepared to defend your choice if which HTTP client library you chose, with reasons why you chose it.\n\t* You should also create some unit tests for your REST API handlers.\n\n* It's possible you may also need to understand some of what the [Jackson package](https://github.com/FasterXML/jackson) does.\n\n* You might like this too : https://www.pluralsight.com/courses/rest-fundamentals\n## IDs\n\n#### ID commands in shell\n\n* In the shell, `ids` should return a formatted list of the IDs available to you.\n* `ids your_name your_github_id` command should post your Name and your GithubId to the server.\n* If you do this twice with two different Names, but the name GithubId, the name on the server gets changed.\n\n-\n### The IDs API is:\n\n#### URL: /ids/\n\n* `GET` : Get all github ids registered\n* `POST` : add your github id / name to be registered\n* `PUT` : change the name linked to your github id\n\njson payload for /ids/ - this is a sample\n\n```json\n{\n    \"userid\": \"-\", // gets filled w id\n    \"name\": \"Kris\",\n    \"github\": \"xt0fer\"\n}\n```\n \n#### Example: \n\nIf I type `cmd? ids Kris xt0fer` into the shell, your command processor creates a JSON object which looks like:\n\n ```json\n {\n     \"userid\": \"-\", // gets filled w id\n     \"name\": \"Kris\",\n     \"github\": \"xt0fer\"\n }\n ```\nand send it as the body of a POST request to  `http://zipcode.rocks:8085/ids/`\n\n \n## Messages\n\n#### Message comands in shell\nin the shell\n* `messages` should return the last 20 messages, nicely formatted.\n* `messages your_github_id` should return the last 20 messages sent to you.\n* `send your_github_id 'Hello World' ` should post a new message in the timeline\n* `send your_github_id 'my string message' to some_friend_githubid` should post a message to your friend from you on the timeline.\n\nthe Messages API is:\n\n#### URL: /messages/\n* `GET` : Get last 20 msgs - returns an JSON array of message objects\n\n#### URL: /ids/:mygithubid/messages/\n* `GET` : Get last 20 msgs for myid  - returns an JSON array of message objects\n* `POST` : Create a new message in timeline - need to POST a new message object, and will get back one with a message sequence number and timestamp of the server inserted.\n\n#### URL: /ids/:mygithubid/messages/:sequence\n* `GET` : Get msg with a sequence  - returns a JSON message object for a sequence number\n\n#### URL: /ids/:mygithubid/from/:friendgithubid\n* `GET` : Get last 20 msgs for myid from friendid\n\njson payload for /messages/ these are samples, one to a specific friend, one to the timeline.\n\n```json\n[\n  {\n    \"sequence\": \"-\",\n    \"timestamp\": \"_\",\n    \"fromid\": \"xt0fer\",\n    \"toid\": \"kristofer\",\n    \"message\": \"Hello, Kristofer!\"\n  },\n\n  {\n    \"sequence\": \"-\",\n    \"timestamp\": \"_\",\n    \"fromid\": \"xt0fer\",\n    \"toid\": \"\",\n    \"message\": \"Hello, World!\"\n  }\n]\n```\n\n#### Example: \n \nif I type \n``` cmd?\nsend xt0fer 'Hello old buddy!' to torvalds\n```\ninto the shell, your command processor creates a JSON object which looks like:\n\n ```json\n{\n\t\"sequence\": \"-\",\n\t\"timestamp\": \"_\",\n\t\"fromid\": \"xt0fer\",\n\t\"toid\": \"torvalds\",\n\t\"message\": \"Hello old buddy!\"\n}\n ```\nand send it as the body of a POST request to  `http://zipcode.rocks:8085/ids/xt0fer/messages/`\n\n\n\n## Part Two\n\nWhat's that ProcessBuilder stuff about? In the URLShell class, take a look. How can that be used\nas a pattern to use threads to make the API calls and wait for the response? Maybe launch a new thread on every request?\n\n## Part Three\n\nBuild a better set of commands. Make the \"fromid\" intrinsic, so it isn't needed on the various shell commands.\nAdd a feature where you can send messages by someone's name. Create a means where the client watches the server for \nany private messages to you and only prints them once. \nAdd another command that watches the global stream and only prints messages once.\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipcodecore%2Fyouareell-2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzipcodecore%2Fyouareell-2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipcodecore%2Fyouareell-2/lists"}