{"id":17180778,"url":"https://github.com/jsok/vending","last_synced_at":"2025-06-23T10:37:31.766Z","repository":{"id":23305018,"uuid":"26664535","full_name":"jsok/vending","owner":"jsok","description":"Vending machine","archived":false,"fork":false,"pushed_at":"2015-01-06T03:12:05.000Z","size":247,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T00:41:39.539Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-15T01:04:38.000Z","updated_at":"2022-10-06T11:09:15.000Z","dependencies_parsed_at":"2022-08-21T23:10:20.348Z","dependency_job_id":null,"html_url":"https://github.com/jsok/vending","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsok/vending","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fvending","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fvending/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fvending/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fvending/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsok","download_url":"https://codeload.github.com/jsok/vending/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsok%2Fvending/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261463078,"owners_count":23162079,"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-15T00:31:43.867Z","updated_at":"2025-06-23T10:37:26.755Z","avatar_url":"https://github.com/jsok.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"vending\n=======\n\nVending machine in golang\n\nConfiguration\n-------------\n\nYou should create a JSON file of the form:\n\n```json\n{\n    \"denominations\": [1, 5, 20, 50],\n    \"slots\": {\n        \"A1\": {\"item\": {\"name\": \"Coke Cola\", \"price\": 180}, \"inventory\": 20},\n        \"etc\": {}\n    }\n}\n```\n\nHTTP API\n--------\n\n###  POST `/api/purchase`\n\nPurchase an item.\n\nExample request:\n\n```\ncurl http://localhost:5000/api/purchase \\\n -d \"coins[]=100\" \\\n -d \"coins[]=50\" \\\n -d \"coins[]=50\" \\\n -d \"choice=A1\"\n```\n\nExample response:\n\n```json\n{\n    \"id\": \"e13b7f80-6d58-11e4-9803-0800200c9a66\",\n    \"item\": \"Coke Cola\",\n    \"change\": {\"20\": 1}\n}\n```\n\n### GET `/api/items`\n\nList all the items in the vending machine.\n\nExample request:\n\n```\ncurl http://localhost:5000/api/items\n```\n\nExample response:\n\n```json\n{\n    \"slots\": {\n        \"A1\": {\"item\": \"Coke Cola\", \"price\": 180, \"available\": true},\n        \"A2\": {\"item\": \"Water\", \"price\": 120, \"available\": false}\n    }\n}\n```\n\n### POST `/api/items/\u003cchoice\u003e`\n\nStock a new item. Creates a new slot if it doesn't exist, otherwise replaces the existing item stocked in that slot.\n\nExample request:\n\n```\ncurl http://localhost:5000/api/items/A1 \\\n -d \"name='Coke Cola'\" \\\n -d \"price=180\" \\\n -d \"inventory=20\"\n```\n\nExample response:\n\n```json\n{\n    \"status\": \"OK\"\n}\n```\n\n### PUT `/api/items/\u003cchoice\u003e`\n\nRefills an item.\n\nExample request:\n\n```\ncurl -X PUT http://localhost:5000/api/items/A1 \\\n  -d inventory=1\n```\n\nExample response:\n\n```json\n{\n    \"status\": \"OK\"\n}\n```\n\n###  DELETE `/api/items/\u003cchoice\u003e`\n\nSets an item as *OUT OF ORDER*. Will fail if the choice does not exist.\n\nExample request:\n\n```\ncurl -X DELETE http://localhost:5000/api/items/A1\n```\n\nExample response:\n\n```json\n{\n    \"status\": \"OK\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsok%2Fvending","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsok%2Fvending","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsok%2Fvending/lists"}