{"id":23066965,"url":"https://github.com/dvsa/recalls-mock-api","last_synced_at":"2025-04-03T09:13:42.261Z","repository":{"id":86167480,"uuid":"590534519","full_name":"dvsa/recalls-mock-api","owner":"dvsa","description":"Mock API for Recalls ","archived":false,"fork":false,"pushed_at":"2025-03-31T08:36:28.000Z","size":473,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-31T09:32:34.596Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/dvsa.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-18T16:29:14.000Z","updated_at":"2024-07-19T13:11:57.000Z","dependencies_parsed_at":"2023-10-16T20:29:48.046Z","dependency_job_id":"405708eb-8bbd-4bd6-8303-b0234202a673","html_url":"https://github.com/dvsa/recalls-mock-api","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Frecalls-mock-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Frecalls-mock-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Frecalls-mock-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Frecalls-mock-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvsa","download_url":"https://codeload.github.com/dvsa/recalls-mock-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246970323,"owners_count":20862509,"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-12-16T05:15:41.618Z","updated_at":"2025-04-03T09:13:42.245Z","avatar_url":"https://github.com/dvsa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MOT Recalls Mock API\n\nThe Recalls Mock API is an application designed to help development teams locally test solutions which use DVSA's MOT Recalls API.\n\nThe purpose of this application is to test the functionality of the API calls, not to emulate the modification of records in the database. Therefore, it should only be used to verify that each call works as expected, subsequent calls will not reflect previous actions.\n\nThe app can be run as an express application or as a sam-local application \n\n## Requirements\n\n- node v18.x\n- npm 8+\n\nIf you would like to run the application using sam-local, you will also need:\n- Docker\n- [SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)\n\n### Prerequisites\n- Create a `.env` in hosted/lambda-handlers\n    ```shell\n    npm run util:copy-env\n    ```\n\n## Build\n\n```shell\n  npm i\n```\n```shell\n  npm run build:dev\n```\n\n# Run\n\n### Run using express\nEnsure build steps have been completed.\n\n```shell\n  npm run start:dev\n```\n\n### Run using sam local\n\nEnsure docker is running and build steps have been completed. \n```shell\n  npm run start:sam\n```\n\n#### The lambdas will be available at `http://localhost:3000/`\n\n##  Testing Recalls Mock API locally\nTo use the recalls mock api locally, send requests to `http://localhost:3000/`. \nYou can use tools such as [Postman](https://www.postman.com/) to do this. A [postman collection](Postman/Recalls Mock API 2.6.0.postman_collection.json) has been included with this repo.\n\n## Sample Calls\n\n### Authentication\n\nThe Recalls API requires users to generate a JWT token to add to the Authorization header of each request. \n\nMake a post request to http://127.0.0.1:3000/oauth2/v2.0/token\n \n form data:\n ```json\n  grant_type: client_credentials\n  client_id: yourdvsaissuedclient_id\n  client_secret: yourdvsaissuedclient_secret\n  scope: http//:dvsaissuedscope.default\n```\n### API Usage Key\nAn API Usage Key will be provided to you when you register for the MOT Recalls API service, this must be provided in the x-api-key header with every request. For the mock api, each request must contain the header 'x-api-key' or 'X-Api-Key' with a 10+ character string. \n\n\n### Create a new recall\n make a POST request to http://127.0.0.1:3000/recalls/\n \n headers:\n ```json\n  \"Authorization\": \"Bearer token\",\n  \"x-api-key\": \"your usage key\"\n```\n body:\n ```json\n {\n  \"vin\": \"ABCD122CBAD11435\",\n  \"manufacturerCampaignReference\": \"string\",\n  \"dvsaCampaignReference\": \"R/2013/121\",\n  \"recallCampaignStartDate\": \"2022-01-31\"\n}\n```\n### Update a recall - Set status to fixed\n make a PUT request to http://127.0.0.1:3000/recalls/vin/ABCD122CBAD11433?dvsaCampaignReference=R/2022/002\n the rectification date must be later than the open recalls campaign start date\n\n headers:\n ```json\n  \"Authorization\": \"Bearer token\",\n  \"x-api-key\": \"your usage key\" \n```\n body:\n ```json\n{\n  \"rectificationDate\": \"2022-09-05\",\n  \"repairStatus\": \"FIXED\"\n}\n```\n\n### Update a recall - Set status to not fixed\n make a PUT request to http://127.0.0.1:3000/recalls/vin/ABCD122CBAD11432?dvsaCampaignReference=R/2022/001\n \n headers:\n ```json\n  \"Authorization\": \"Bearer token\",\n  \"x-api-key\": \"your usage key\" \n```\n body:\n ```json\n{\n  \"repairStatus\": \"NOT_FIXED\"\n}\n```\n### Retrieve a recall\n\n make a GET request to http://127.0.0.1:3000/recalls/vin/ABCD122CBAD11433?dvsaCampaignReference=R/2022/002\n \n headers:\n ```json\n  \"Authorization\": \"Bearer token\",\n  \"x-api-key\": \"your usage key\" \n```\n\n### Delete a recall\n\n make a DELETE request to http://127.0.0.1:3000/recalls/vin/ABCD122CBAD11433?dvsaCampaignReference=R/2022/002\n \n headers:\n ```json\n  \"Authorization\": \"Bearer token\",\n  \"x-api-key\": \"your usage key\" \n```\n\n## Directories\n\n`hosted/lambda-handlers/src/handler/`\nLambda handler methods.\n\n`hosted/lambda-handlers/src/util `\nUtility and helper functions, including the Logger.\n\n`hosted/express-dev-server`\nExpress app. \n\n## Adding Test Data\n\nYou can add more test data to the application by modifying `hosted/lambda-handlers/src/data/vehicles.ts `\nThis file contains a list of vehicle recalls to be used for testing.\nTo add another vehicle recalls, append to the array an object with the following format:\n```\n{\n  vin: 'YOUR VIN',\n  manufacturerCampaignReference: 'YOUR REF',\n  dvsaCampaignReference: 'YOUR REF',\n  recallCampaignStartDate: 'YYYY-MM-DD',\n  manufacturerId: 'YOUR MANUFACTURER NAME',\n  repairStatus: RepairStatus.NOT_FIXED or RepairStatus.FIXED,\n},\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Frecalls-mock-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvsa%2Frecalls-mock-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Frecalls-mock-api/lists"}