{"id":15465230,"url":"https://github.com/cleicar/zssn_api","last_synced_at":"2025-11-12T01:30:17.493Z","repository":{"id":168338987,"uuid":"99361396","full_name":"cleicar/zssn_api","owner":"cleicar","description":"ZSSN  - Zombie Survival Social Network Project","archived":false,"fork":false,"pushed_at":"2021-08-11T20:55:21.000Z","size":52,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T13:43:22.551Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://zssn-rest-api.herokuapp.com/survivors","language":"Ruby","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/cleicar.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":"2017-08-04T16:32:02.000Z","updated_at":"2019-02-24T09:30:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"7634876a-c7a6-4cd3-8dcd-14d459304748","html_url":"https://github.com/cleicar/zssn_api","commit_stats":null,"previous_names":["cleicar/zssn_api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleicar%2Fzssn_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleicar%2Fzssn_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleicar%2Fzssn_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleicar%2Fzssn_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cleicar","download_url":"https://codeload.github.com/cleicar/zssn_api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239598598,"owners_count":19665902,"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":"2024-10-02T01:00:38.398Z","updated_at":"2025-11-12T01:30:17.438Z","avatar_url":"https://github.com/cleicar.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZSSN (Zombie Survival Social Network)\n\nZSSN Is a system created to help the human to survive an apocalypse zombie. Using only REST API requests, survivors can share resources with others non-infected humans.\n\n## Table of Contents\n\n* [Installation](#installation)\n* [API Documentation](#api-documentation)\n  * [List Survivors](#list-survivors)\n  * [Add Survivors](#add-survivors)\n  * [Update Survivor Location](#update-survivor-location)\n  * [Flag Survivor as Infected](#flag-survivor-as-infected)\n  * [Trade Resources](#trade-resources)\n* [Reports](#reports)\n  * [Percentage of infected survivors](#percentage-of-infected-survivors)\n  * [Percentage of non-infected survivors](#percentage-of-non-infected-survivors)\n  * [Average Resources By Survivor](#average-resources-by-survivor)\n  * [Points lost because of infected survivors](#points-lost-because-of-infected-survivors)\n* [Testing with RSpec](#testing-with-rspec)\n* [Credits](#credits)\n\n## Installation\n\n**Dependention note**: Before installation make sure to have MongoDB (3.4) and Ruby (2.3) installed and up. \n\n1. Clone the project.\n\n\t~~~ sh\n\t$ https://github.com/cleicar/zssn_api.git\n\t~~~\n\n2. Bundle the Gems.\n\n\t~~~ sh\n\t$ bundle install\n\t~~~\n\n3. Set the database connection at the config file `config/mongoid.yml`.\n\n4. Start the application\n\n\t~~~ sh\n\t$ rails s\n\t~~~\n\nApplication will be runing at [localhost:3000](http://localhost:3000).\n\n## API Documentation\n\n### List Survivors\n\n##### Request \n\n```sh\nGET  /survivors`\n```\n\n##### Response\n\n```sh\nstatus: 200 Ok\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n```sh\nBody:\n[\n    {\n        \"_id\": {\n            \"$oid\": \"598c6da62a43161f3eb5bb66\"\n        },\n        \"age\": \"25\",\n        \"gender\": \"male\",\n        \"last_location\": {\n            \"latitude\": \"-16.680353\",\n            \"longitude\": \"-49.256302\"\n        },\n        \"name\": \"Survivor\",\n        \"resources\": [\n            {\n                \"_id\": {\n                    \"$oid\": \"598c6da62a43161f3eb5bb67\"\n                },\n                \"points\": null,\n                \"quantity\": 10,\n                \"type\": \"Water\"\n            },\n            {\n                \"_id\": {\n                    \"$oid\": \"598c6da62a43161f3eb5bb68\"\n                },\n                \"points\": null,\n                \"quantity\": 6,\n                \"type\": \"Food\"\n            }\n        ]\n    }\n]\n```\n\n### Add Survivors\n\n##### Request \n\n```sh\nPOST  /survivors`\n```\n\n```sh\nParameters:\n{\n    \"survivor\": \n    {\n        \"name\": \"Survivor Test\", \n        \"age\": \"43\", \n        \"gender\": \"M\", \n        \"last_location\": {\"latitude\": \"89809809809\", \"longitude\": \"-88983982100\"},\n        \"resources\": [\n        {\n            \"type\": \"Water\", \n            \"quantity\": 10\n            \n        }, \n        { \n            \"type\":\"Food\", \n            \"quantity\": 6\n            \n        }]\n    }\n}\n```\n\n##### Response\n\n```sh\nstatus: 201 created\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n```sh\nBody:\n{\n    \"_id\": {\n        \"$oid\": \"5990f7357b6ee2652e9e581a\"\n    },\n    \"age\": \"43\",\n    \"gender\": \"M\",\n    \"infection_count\": 0,\n    \"last_location\": {\n        \"latitude\": \"89809809809\",\n        \"longitude\": \"-88983982100\"\n    },\n    \"name\": \"Survivor Test\"\n}\n```\n\n##### Errors\nStatus | Error                | Message\n------ | ---------------------|--------\n422    | Unprocessable Entity |   \n409    | Conflict             | survivor need to declare its own resources\n\n### Update Survivor Location\n\n##### Request \n\n```sh\nPATCH/PUT /survivors/:id\n```\n\n```sh\nParameters:\n{\n    \"survivor\": \n    {\n        \"latitude\": \"-16.6868824\", \n        \"longitude\": \"-49.2647885\"\n    }\n}\n```\n\n##### Response\n\n```sh\nstatus: 204 no_content\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n##### Errors\nStatus | Error      |\n------ | -----------|\n404    | Not Found  |\n\n### Flag Survivor as Infected\n\n##### Request \n\n```sh\nPOST   /survivors/:id/flag_infection\n```\n\n##### Response\n\n```sh\nstatus: 200 ok\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n```sh\nBody:\n{\n    \"message\": \"Attention! Survivor was reported as infected x time(s)!\"\n    \"message\": \"Warning! Survivor was reported as infected x time(s)\"\n}\n```\n\n##### Errors\nStatus | Error      |\n------ | -----------|\n404    | Not Found  |\n\n\n### Trade Resources\n\nSurvivors can trade items among themselves, respecting a price table.\n\n##### Request \n\n```sh\nPOST   /trade_resources\n```\n\n```sh\nParameters:\n{\n  \"trade\": {\n    \"survivor_1\": {\n      \"id\": \"5991814f2a43166a43c27b48\",\n      \"resources\": [\n        {\n          \"type\": \"Water\",\n          \"quantity\": 1\n        },\n        {\n          \"type\": \"Medication\",\n          \"quantity\": 1\n        }\n      ]\n    },\n    \"survivor_2\": {\n      \"id\": \"5991814f2a43166a43c27b4b\",\n      \"resources\": [\n        {\n          \"type\": \"Ammunition\",\n          \"quantity\": 6\n        }\n      ]\n    }\n  }\n}\n```\n\n##### Response\n\n```sh\nstatus: 200 ok\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n```sh\nBody:\n{\n    \"message\": \"Trade successfully completed\"\n}\n```\n\n##### Errors\nStatus | Error                | Message\n------ | ---------------------|--------\n404    | Not Found            | Survivor with id xxxxx does not exist \n409    | Conflict             | Survivor X is infected\n409    | Conflict             | Survivor X doesn't have enough resources\n409    | Conflict             | Resources points is not balanced both sides\n\n\n## Reports\n\n### Percentage of infected survivors\n\n##### Request \n\n```sh\nGET   /reports/infected_survivors\n```\n\n##### Response\n\n```sh\nstatus: 200 ok\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n```sh\nBody:\n{\n    \"data\": \"X%\"\n}\n```\n\n### Percentage of non-infected survivors\n\n##### Request \n\n```sh\nGET   /reports/not_infected_survivors\n```\n\n##### Response\n\n```sh\nstatus: 200 ok\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n```sh\nBody:\n{\n    \"data\": \"X%\"\n}\n```\n\n### Average Resources By Survivor\n\n##### Request \n\n```sh\nGET   /reports/resources_by_survivor\n```\n\n##### Response\n\n```sh\nstatus: 200 ok\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n```sh\nBody:\n{\n    \"averages\": {\n        \"water\": 5,\n        \"food\": 7,\n        \"medication\": 1.5,\n        \"ammunition\": 0\n    }\n}\n```\n\n### Points lost because of infected survivors\n\n##### Request \n\n```sh\nGET   /reports/lost_infected_points\n```\n\n##### Response\n\n```sh\nstatus: 200 ok\n```\n\n```sh\nContent-Type: \"application/json\"\n```\n\n```sh\nBody:\n{\n    \"lost_points\": 30\n}\n```\n\n## Testing with RSpec\n\nThe project was build with TDD (Test Driven Development). To execute the tests just run the tests with RSpec.\n\n1. Execute all tests\n\n    ~~~ sh\n    $ bundle exec rspec\n    ~~~\n\nTo see the test cover percent open the file `coverage/index.html` at your browser.\n\n## Credits\n\n- [Cleiviane](https://about.me/cleiviane) (last survivor who knows how to code) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleicar%2Fzssn_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleicar%2Fzssn_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleicar%2Fzssn_api/lists"}