{"id":30887987,"url":"https://github.com/margdaly/tea_subscription","last_synced_at":"2026-05-19T14:36:18.509Z","repository":{"id":186417614,"uuid":"675128717","full_name":"margdaly/tea_subscription","owner":"margdaly","description":"A REST API for a Tea Subscription Service","archived":false,"fork":false,"pushed_at":"2023-08-25T18:12:36.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-23T20:13:28.946Z","etag":null,"topics":["postgresql-database","rails","restful-api","ruby","subscription","tea"],"latest_commit_sha":null,"homepage":"","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/margdaly.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}},"created_at":"2023-08-05T21:59:44.000Z","updated_at":"2023-08-25T18:11:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea42571b-3e9e-4579-b5af-897b496c89e5","html_url":"https://github.com/margdaly/tea_subscription","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"f5c0d866af3f1a27b5df062f18ff449698b3bf01"},"previous_names":["margdaly/tea_subscription"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/margdaly/tea_subscription","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/margdaly%2Ftea_subscription","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/margdaly%2Ftea_subscription/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/margdaly%2Ftea_subscription/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/margdaly%2Ftea_subscription/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/margdaly","download_url":"https://codeload.github.com/margdaly/tea_subscription/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/margdaly%2Ftea_subscription/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274202050,"owners_count":25240362,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["postgresql-database","rails","restful-api","ruby","subscription","tea"],"created_at":"2025-09-08T14:49:20.401Z","updated_at":"2026-05-19T14:36:13.485Z","avatar_url":"https://github.com/margdaly.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n Tea Subscription API ☕\n\u003c/h1\u003e  \n\n\u003cp align=\"center\"\n    \u003ca href=\"https://coveralls.io/github/badges/shields\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/coverage-100%25-lawngreen\"\n            alt=\"coverage\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Project Goals \nCreate a REST API for a Tea Subscription Service\n  - Easily consumed by a Frontend Developer\n  - Restful routes \n  - Well-organized code, following OOP\n  - Test Driven Development \n\nExposes three endpoints to manage tea subscriptions\n  - subscribe a customer to a tea subscription\n  - cancel a customer's tea subscription\n  - see all of a customer's subscriptions (active and cancelled)\n\n## Built With\n* Ruby v 2.7.4\n* Rails v 5.2.8\n* PostgreSQL\n\n## Getting Started\n1. Fork and Clone this repository locally\n2. Install gem packages\n`bundle install`\n4. Set up the database\n`rails db:{drop,create,migrate,seed}`\n4. Make sure all tests are passing by running\n`bundle exec rspec`\n5. Start up your local server by running\n`rails s`\n6. You can make the sample request for each endpoint by running the examples in [Postman](https://app.getpostman.com/run-collection/26085409-1cb627ef-d500-4f6f-b849-9b655205c7ed?action=collection%2Ffork\u0026collection-url=entityId%3D26085409-1cb627ef-d500-4f6f-b849-9b655205c7ed%26entityType%3Dcollection%26workspaceId%3Df402ed1d-531c-4451-ad21-b6367689bff9).\n   \n## Database Diagram\n![Database Diagram](https://github.com/margdaly/tea_subscription/assets/121778028/21a2bcff-9bde-416d-ae8d-830b88f1580f)\n\n## Endpoints\n### POST `/api/v0/subscribe`\n\u003cdetails\u003e\u003csummary\u003e success \u003c/summary\u003e\n \n**create a new subscription**\n\n**Parameters**  \n| Name | Type | Description |\n| ----------- | ----------- | ----------- | \n| **customer_id** | number | customer's id |\n| **tea_id** | number | tea's id |\n| **frequency** | 'weekly', 'monthly', or 'seasonal' | how often |\n\n**Request**\n  ```json\n{\n    \"customer_id\": 3,\n    \"tea_id\": 6,\n    \"frequency\": \"monthly\"\n}\n  ```\n**Response**\nstatus **200**\n```\n{\n    \"data\": {\n        \"id\": \"13\",\n        \"type\": \"subscription\",\n        \"attributes\": {\n            \"customer_id\": 3,\n            \"tea_id\": 6,\n            \"title\": \"Sleepytime Tea\",\n            \"price\": \"$49.56\",\n            \"status\": \"active\",\n            \"frequency\": \"monthly\"\n        }\n    }\n}\n```\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e error \u003c/summary\u003e\n\n**Invalid Tea ID**\n\n**Request**\n  ```json\n{\n    \"customer_id\": 3,\n    \"tea_id\": 0,\n    \"frequency\": \"monthly\"\n}\n  ```\n**Response**\nstatus **404**\n```\n{\n    \"errors\": [\n        {\n            \"status\": \"404\",\n            \"title\": \"Record Invalid\",\n            \"detail\": \"Validation failed: Tea must exist\"\n        }\n    ]\n}\n```\n\u003c/details\u003e\n\n### PATCH `/api/v0/cancel`\n\u003cdetails\u003e\u003csummary\u003e success \u003c/summary\u003e\n \n**cancel a subscription**\n\n**Parameters**  \n| Name | Type | Description |\n| ----------- | ----------- | ----------- | \n| **customer_id** | number | customer's id |\n| **tea_id** | number | tea's id |\n\n**Request**\n  ```json\n{\n    \"customer_id\": 1,\n    \"tea_id\": 1\n}\n  ```\n**Response**\nstatus **200**\n```\n{\n    \"data\": {\n        \"id\": \"1\",\n        \"type\": \"subscription\",\n        \"attributes\": {\n            \"customer_id\": 1,\n            \"tea_id\": 1,\n            \"title\": \"Green Tea\",\n            \"price\": \"$49.56\",\n            \"status\": \"cancelled\",\n            \"frequency\": \"monthly\"\n        }\n    }\n}\n```\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e error \u003c/summary\u003e\n\n**Invalid Customer ID**\n\n**Request**\n  ```json\n{\n    \"customer_id\": 0,\n    \"tea_id\": 1\n}\n  ```\n**Response**\nstatus **404**\n```\n{\n    \"errors\": [\n        {\n            \"status\": \"404\",\n            \"title\": \"Record Invalid\",\n            \"detail\": \"Couldn't find Subscription\"\n        }\n    ]\n}\n```\n\u003c/details\u003e\n\n### GET `/api/v0/customers/:id\n\u003cdetails\u003e\u003csummary\u003e success \u003c/summary\u003e\n \n**get customer details**\n\n**Response**\nstatus **200**\n```\n{\n    \"data\": {\n        \"id\": \"2\",\n        \"type\": \"customer\",\n        \"attributes\": {\n            \"first_name\": \"Harriet\",\n            \"last_name\": \"Murphy\",\n            \"email\": \"haphy@mail.com\",\n            \"address\": \"24 Beachwood Ave\",\n            \"subscriptions\": [\n                {\n                    \"id\": 7,\n                    \"title\": \"Mint Tea\",\n                    \"price\": \"$49.56\",\n                    \"status\": \"active\",\n                    \"frequency\": \"monthly\",\n                    \"customer_id\": 2,\n                    \"tea_id\": 4,\n                    \"created_at\": \"2023-08-06T17:43:10.359Z\",\n                    \"updated_at\": \"2023-08-06T17:43:10.359Z\"\n                },\n                {\n                    \"id\": 8,\n                    \"title\": \"Chamomile Tea\",\n                    \"price\": \"$49.56\",\n                    \"status\": \"active\",\n                    \"frequency\": \"monthly\",\n                    \"customer_id\": 2,\n                    \"tea_id\": 5,\n                    \"created_at\": \"2023-08-06T17:43:10.360Z\",\n                    \"updated_at\": \"2023-08-06T17:43:10.360Z\"\n                },\n                {\n                    \"id\": 9,\n                    \"title\": \"Sleepytime Tea\",\n                    \"price\": \"$214.76\",\n                    \"status\": \"cancelled\",\n                    \"frequency\": \"weekly\",\n                    \"customer_id\": 2,\n                    \"tea_id\": 6,\n                    \"created_at\": \"2023-08-06T17:43:10.361Z\",\n                    \"updated_at\": \"2023-08-06T17:43:10.361Z\"\n                }\n            ]\n        }\n    }\n}\n```\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e error \u003c/summary\u003e\n\n**Invalid Customer ID**\n\n**Response**\nstatus **404**\n```\n{\n    \"errors\": [\n        {\n            \"status\": \"404\",\n            \"title\": \"Record Invalid\",\n            \"detail\": \"Couldn't find Customer with 'id'=0\"\n        }\n    ]\n}\n```\n\u003c/details\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmargdaly%2Ftea_subscription","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmargdaly%2Ftea_subscription","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmargdaly%2Ftea_subscription/lists"}