8000 GitHub - MaxGekk/CarAds: Add, delete and view car ads
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MaxGekk/CarAds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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}

About

Add, delete and view car ads

Resources

License

Activity 3F23

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0