https://github.com/maxgekk/carads
Add, delete and view car ads
https://github.com/maxgekk/carads
Last synced: 3 months ago
JSON representation
Add, delete and view car ads
- Host: GitHub
- URL: https://github.com/maxgekk/carads
- Owner: MaxGekk
- License: mit
- Created: 2017-06-01T17:50:37.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-04T12:21:29.000Z (almost 8 years ago)
- Last Synced: 2025-01-19T08:28:24.494Z (4 months ago)
- Language: Scala
- Size: 45.9 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CarAds
CardAds allows to put car advertisements to a persisitent storage and to get the ads back via REST API. To run it with default settings (on localhost:8080 with local dynamo db):
```
$ sbt run 'carads.Service'
```
All other settings are in application.conf## Quick start
```
# Puts new ad
$ curl -X POST -H "Content-Type: application/json"\
http://localhost:8080/put\
-d '{
"id": 13,
"title": "Mercedes",
"fuel": "Gasoline",
"price": 60000,
"new": false,
"mileage": 100000,
"registration": "2010-11-01"
}'
>>> {"isSuccess":true}# Gets an existing ad by its id
$ curl -X POST -H "Content-Type: application/json"\
http://localhost:8080/get\
-d '{
"id": 13
}'
>>> {"isSuccess":true,"record":{"id":13,"title":"Mercedes","fuel":"Gasoline","price":60000,"new":false,"mileage":100000,"registration":"2010-11-01"}}# Modify a field in the ad
$ curl -X POST -H "Content-Type: application/json"\
http://localhost:8080/modify\
-d '{
"id": 13,
"price": 65000
}'
>>> {"isSuccess":true}# Adding a few ads
$ curl -X POST -H "Content-Type: application/json"\
http://localhost:8080/put\
-d '{"id": 14, "title": "MAN", "fuel": "Diesel", "price": 80000, "new": true }'
>>> {"isSuccess":true}
$ curl -X POST -H "Content-Type: application/json"\
http://localhost:8080/put\
-d '{"id": 15, "title": "BMW", "fuel": "Gasoline", "price": 30000, "new": false, "mileage":80000, "registration":"2009-01-19" }'
>>> {"isSuccess":true}# Getting of all ads sorted by price
$ curl -X POST -H "Content-Type: application/json"\
http://localhost:8080/all\
-d '{"sortby": "price", "limit": 10}'
>>> {"isSuccess":true,"records":[
{"id":15,"title":"BMW","fuel":"Gasoline","price":30000,"new":false,"mileage":80000,"registration":"2009-01-19"},
{"id":13,"title":"Mercedes","fuel":"Gasoline","price":60000,"new":false,"mileage":100000,"registration":"2010-11-01"},
{"id":14,"title":"MAN","fuel":"Diesel","price":80000,"new":true}]}# Delete an ad
$ curl -X POST -H "Content-Type: application/json" http://localhost:8080/delete -d '{"id": 13}'
>>> {"isSuccess":true}
```