{"id":18158433,"url":"https://github.com/m-farag/discountexchange","last_synced_at":"2025-04-07T03:20:58.263Z","repository":{"id":40438560,"uuid":"489693623","full_name":"M-Farag/discountExchange","owner":"M-Farag","description":"an elegant discounts exchange manager","archived":false,"fork":false,"pushed_at":"2022-05-09T01:24:57.000Z","size":545,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T08:15:06.488Z","etag":null,"topics":["coupons","discounts","loyaltyprogram"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/M-Farag.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-07T14:19:18.000Z","updated_at":"2022-09-01T21:56:25.000Z","dependencies_parsed_at":"2022-08-09T20:21:09.726Z","dependency_job_id":null,"html_url":"https://github.com/M-Farag/discountExchange","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Farag%2FdiscountExchange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Farag%2FdiscountExchange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Farag%2FdiscountExchange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Farag%2FdiscountExchange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/M-Farag","download_url":"https://codeload.github.com/M-Farag/discountExchange/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247584329,"owners_count":20962110,"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":["coupons","discounts","loyaltyprogram"],"created_at":"2024-11-02T07:06:39.073Z","updated_at":"2025-04-07T03:20:58.234Z","avatar_url":"https://github.com/M-Farag.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Discount Exchange\nan elegant API driven discounts exchange manager.\n\n\n## How to set up the application on your machine ?!\n\n_You can watch the quick video I attached below or go over the following steps_\n\n### Quick 🏃 Video\n\n- https://www.loom.com/share/c224b435be9f4e449173cd9397e4a469\n\n### Requirements\n- Composer\n- Docker desktop\n\n\u003cbr\u003e\n\n### Steps in order ✨\n\n#### 1) Clone the repo to your machine\n```\ngit clone https://github.com/M-Farag/discountExchange.git\n```\n\n#### 2) Go to the cloned directory and run composer install\n```\ncd discountExchange\ncomposer install\n```\n\n#### 3) Copy \u0026 create the new .env file\n```\ncp .env.example .env\n```\n\n#### 4) open and edit the DB section in the .env file using any text editor \n```\nDB_CONNECTION=mysql\nDB_HOST=mysql\nDB_PORT=3306\nDB_DATABASE=discount_exchange\nDB_USERNAME=sail\nDB_PASSWORD=password\n```\n\n#### 5) generating a new API key\n```\nphp artisan key:generate\n```\n\n#### 6) booting up the docker env using laravel sail\n- **Please note you must shutdown any local webservers and database server before starting sail**\n```\n./vendor/bin/sail up\n```\n\n#### 7) run the following commands in order\n```\n./vendor/bin/sail artisan migrate:fresh\n./vendor/bin/sail artisan db:seed --class=BootUpSeeder\n```\n\n#### 8) run this command and save the results on a safe place\n```\n./vendor/bin/sail passport:install\n```\n\n\u003chr\u003e\n\n#### Watch the quick setup Video 🚀 🎥\n\n- https://www.loom.com/share/c224b435be9f4e449173cd9397e4a469\n\n\n\u003chr\u003e\n\n### Testing 🔬🧪\n\n- I'm using the PEST framework, you can easily run all the feature tests by running the following command\n\n```\n./vendor/bin/sail test\n```\n\n\u003chr\u003e\n\n## API EndPoints 🦾 🚀\n\n- The API collection is committed to the repo with the file name of [ *api_collection_Insomnia_2022-05-09.json* ]\n\n\u003cbr\u003e\n\n### 1) Brand Create Coupon\n\n- __Group__: Brand\n- __Prefix__: /api/v1/brand\n- __Endpoint__: /coupons\n- __Method__: POST\n- __Full URI__: example-site.test/api/v1/brand/coupons\n- __Authorization__: OAuth2,Bearer token, User Access tokens\n\n#### Parameters \u0026 Data Types\n\n- [Full system design map](https://whimsical.com/system-design-7c7i7qT7WVCGHKeK27Roc3)\n\n#### Request body JSON [Example]\n```\n{\n\t\"name\":\"coupon_3\",\n\t\"brand_id\":1,\n\t\"percentage\":29,\n\t\"percentage_max_rate\":10,\n\t\"max_redemptions\":1000,\n\t\"max_discount_codes\":1000,\n\t\"discount_code_max_length\":12,\n\t\"currency\":\"usd\",\n\t\"discount_code_type\":\"random_string\",\n\t\"trigger\":\"customer_created\",\n\t\"expires_at\":\"2022-05-31 11:00:00\"\n\n}\n```\n\n#### CURL CALL\n\n```\ncurl --request POST \\\n  --url http://discountexchange.test/api/v1/brand/coupons \\\n  --header 'Accept: application/json' \\\n  --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5NjQwZTdiNC03MDRmLTRlZGMtOTRkOC1mNTZhODkxNmIwOGQiLCJqdGkiOiIyMGU4ODRjMzg2YzQ4ZGQwZTJhZTI4NWEzZjhmYzllMmZjMzVhZTdkZWIxMmVhMTgzYWRkODBiMTIyYjlkYmY3NzhmNzExOTViZDQwMDExMyIsImlhdCI6MTY1MjA1NTE0Mi45MjkyMywibmJmIjoxNjUyMDU1MTQyLjkyOTIzOSwiZXhwIjoxNjgzNTkxMTQyLjgzNjIyNiwic3ViIjoiMSIsInNjb3BlcyI6W119.fru2CxpNSlJl6X_TQXghpDBXWONMVKZFFgfgMZnDztdhN-2VzR5d-606PKeMf1GUSlT1BO9Cw-AJN__m5xohPNW6jwNyVI1L4pUm2fA3UU62Cjrt_BmPh_iB5X-GzSh1M0ut3ktGxB01kCDg_xIr2tiVf9TOl-H2uZOJLbSSovvJzcUWqwA5ASeyNT6vXu4zLmIDOxI0VuFCpdnrQ253sCv-9khpXNE9GXWzJrTKFinUKBs5IEpPukcbZaaPYZCBF8CBOKo83sKIiasgm01OsfaihhntWLbOGFx-FeU9oLUAaJSN0h1Nujq0VMoTQNsmpriYiq1mg0JyxSKSEXmlEOldv68vvQS9DKdzfJVXmvzceVZEG1p3rxlCS5DG_qO3L69ymdbrcSfBsIUMCxoj4QGd1hFKiOYVAyFvtiGdfNhCG_PfyHaQREpTiAmb9zJyD1ZpNR5l41kIpx6Tg5cn0JKWtSjshjxRlJX_Fi_T1Wb-GPq-uwiA7fLBIlSMo0rMRjuPICwuHGtbMhlQzijqtDXLTKwuweaHozEjPOoOR9aXZsmNCmg0z6gllCNPMHBNNvOK5APeDA15L56xi-Y-1SD8jmdssyQI5AAa7sceKELcEXu4SkEh-WYDbzPY5aSZU4A6HHvqIXUDmC0LkTktyPsiW7t9_PE2BCuH7vhTm6Y' \\\n  --header 'Content-Type: application/json' \\\n  --data '{\n\t\"name\":\"coupon_3\",\n\t\"brand_id\":1,\n\t\"percentage\":29,\n\t\"percentage_max_rate\":10,\n\t\"max_redemptions\":1000,\n\t\"max_discount_codes\":1000,\n\t\"discount_code_max_length\":12,\n\t\"currency\":\"usd\",\n\t\"discount_code_type\":\"random_string\",\n\t\"trigger\":\"customer_created\",\n\t\"expires_at\":\"2022-05-31 11:00:00\"\n\n}'\n```\n\n\u003chr\u003e\n\n\n\n### 2) User get discount\n\n- __Group__: User\n- __Prefix__: /api/v1/user\n- __Endpoint__: /discounts\n- __Method__: POST\n- __Full URI__: example-site.test/api/v1/user/discounts\n- __Authorization__: OAuth2,Bearer token, User Access tokens\n\n#### Parameters \u0026 Data Types\n\n- [Full system design map](https://whimsical.com/system-design-7c7i7qT7WVCGHKeK27Roc3)\n\n\n#### Request body JSON [example]\n```\n{\n\t\"coupon_id\":3,\n\t\"brand_id\":2\n}\n```\n\n#### CURL CALL\n\n```\ncurl --request POST \\\n  --url http://discountexchange.test/api/v1/user/discounts \\\n  --header 'Accept: application/json' \\\n  --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5NjQwZDA0YS0zMzU1LTQxMGUtYTBiZS03YmY4YmI4OWZlNDMiLCJqdGkiOiI4ZDQ5YjgyOWNmMmYzODZhYWQzNjdkYzM5ZmViMmFmZDczOGU2NzMwNGIzNzhiNGMzMjhiNTQ5NGIxNDE2YzU0ODdkNjBkNjZkMDIwODhmMSIsImlhdCI6MTY1MjA1MTE4My4zMzgzMjcsIm5iZiI6MTY1MjA1MTE4My4zMzgzMzMsImV4cCI6MTY4MzU4NzE4My4zMDQzNzUsInN1YiI6IjEiLCJzY29wZXMiOltdfQ.TdTDfMyC_hPsS8eCtvBpHEkD5L63clf8vfix75tkvPKzl9wMjYlLXJiaPh1mT3-chyE1NshfeOi41smkigFfZsV1K5G1xTPMF4XjPldKCZQiLzzMZjhbm7WyIHtTIGHlJwgfQSFPg3lU9fHWhM_bzUcKeAilqt7WCXZCJyNxHEj0o5EEhFQgGFvmgaF3XMfyPEsUoiiyrB0PU3UnxUCc_tosHWyHKIU_hLLarpe9teGgDniBFJRHPRQirlACFTty5CjIYb2crMwFevywou-3Ru9HxIDV10F5J2w3PlIHsO-c8nkoBjNfzswO1Di38ZVqSUjVp8DQqcHBe4GJTIQig7ZEA-2KAuwaBFhBueft0Wbh4cm6NOYfDpARCHN5ipGQBAefsjYsuEYidrDBY41CurmjLyfOtQM8dWAs0VO30JGKuK5Y_ny3fFVQvfnGVxfEdDyr7uoyzWp6hvf7UW_mAyol2jSWMFa52h2plSK0U8yNJMg0xREt9GQZWljK1l2CNKkWqmxNe7zfQAKOmX9MX8FxHqaItv29Sn-VXYV-BzEOJa2Dv8O-51x47Sx6WIuJpNrP29j3qOcfKYG2L28Gh6x0x7Z3MZ28lfRt5njN-_VjLZHX7cZ3wf5Y7m4Z2egpVcXoUmHyusvkuN26T3ve_ljLAwb1kKcNSPiUWk8KNAA' \\\n  --header 'Content-Type: application/json' \\\n  --data '{\n\t\"coupon_id\":3,\n\t\"brand_id\":2\n}'\n```\n\n\u003chr\u003e\n\n\n### 3) User login and exchange token\n\n- __Group__: Auth\n- __Prefix__: oauth\n- __Endpoint__: /token\n- __Method__: POST\n- __Full URI__: example-site.test/oauth/token\n- __Authorization__: Password Grant Access\n\n#### Request body JSON [example]\n```\n{\n\t\"grant_type\" : \"password\",\n    \"client_id\" : \"9640e7b4-704f-4edc-94d8-f56a8916b08d\",\n    \"client_secret\" : \"gVOuVsJrffFaR83bzVju7JIEaDPRM6cSGSbZFGWV\",\n    \"username\" : \"user1@users.com\",\n    \"password\" : \"password\",\n    \"scope\" : \"\"\n}\n```\n\n#### CURL CALL\n\n```\ncurl --request POST \\\n  --url http://discountexchange.test/oauth/token \\\n  --header 'Content-Type: application/json' \\\n  --data '{\n\t\t\"grant_type\" : \"password\",\n    \"client_id\" : \"9640e7b4-704f-4edc-94d8-f56a8916b08d\",\n    \"client_secret\" : \"gVOuVsJrffFaR83bzVju7JIEaDPRM6cSGSbZFGWV\",\n    \"username\" : \"user1@users.com\",\n    \"password\" : \"password\",\n    \"scope\" : \"\"\n}'\n```\n\n\u003chr\u003e\n\n## System Design snapshot\n\n![System_design_snapshot](https://user-images.githubusercontent.com/42836754/167325326-672fc5d9-b00d-49bb-a737-ba68e88d2e6d.png)\n\n\n\u003chr\u003e\n\n_Thanks for your time_  👋 \u003cbr\u003e\n_Mina_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-farag%2Fdiscountexchange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm-farag%2Fdiscountexchange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-farag%2Fdiscountexchange/lists"}