Skip to content

Marketplace is a Spring Boot based project with a RESTful API service for placing bids and offers within a marketplace

Notifications You must be signed in to change notification settings

blucas/marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Marketplace Project

Marketplace is a Spring Boot based project with a RESTful API service for placing bids and offers within a marketplace.

How to build

This is a standard Gradle project, so just run ./gradlew build test and the project will be compiled and the tests will run.

You require the following to build the project:

JDK 8 is required to build and run this project.

Running the Project

The project uses Spring Boot which makes configuring and running a web based application a breeze.

In order to run the project from the command line do the following:

From the project base directory you can run ./gradlew bootRun which will start the application on http://localhost:8080

Using the Project API

The project is configured with three RESTful API operations:

Register Bid

When called, this API operation will register a bid in the system. Registering a bid may result in one or more orders being generated and the bid being removed from the marketplace.

Operation Examples

$ curl -v -X POST -H "Content-Type: application/json" -d '{"quantity": 1,"userId": 2,"pricePerUnit": 19900, "itemId":12345}' http://localhost:8080/marketplace/bids
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /marketplace/bids HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 65
> 
* upload completely sent off: 65 out of 65 bytes
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Length: 0
< Date: Wed, 27 Jul 2016 12:13:27 GMT
< 
* Connection #0 to host localhost left intact

### Register Offer

When called, this API operation will register an offer in the system. Registering an offer may result in one or more orders being generated and the offer being removed from the marketplace.

Operation Examples

$ curl -v -X POST -H "Content-Type: application/json" -d '{"quantity": 1,"userId": 3,"pricePerUnit": 900, "itemId":999}' http://localhost:8080/marketplace/offers
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /marketplace/offers HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 63
> 
* upload completely sent off: 63 out of 63 bytes
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Length: 0
< Date: Wed, 27 Jul 2016 12:15:41 GMT
< 
* Connection #0 to host localhost left intact

Retrieve Bids

When called, this API operation will return all registered bids for the given user.

Operation Examples

$ curl -v http://localhost:8080/marketplace/bids?userId=2
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /marketplace/bids?userId=2 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 27 Jul 2016 12:18:16 GMT
< 
* Connection #0 to host localhost left intact
[{"id":1,"itemId":12345,"userId":2,"quantity":1,"pricePerUnit":19900,"dateCreated":1469621607889}]

Retrieve Offers

When called, this API operation will return all registered offers for the given user.

Operation Examples

$ curl -v http://localhost:8080/marketplace/offers?userId=3
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /marketplace/offers?userId=3 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 27 Jul 2016 12:17:14 GMT
< 
* Connection #0 to host localhost left intact
[{"id":1,"itemId":999,"userId":3,"quantity":1,"pricePerUnit":900,"dateCreated":1469621729993}]

Retrieve Orders

When called, this API operation will return all orders for the given user. If the buyer is supplied, returns all the orders relating to the supplied buyer. If the buyer is omitted and the seller is supplied, the operation will return all orders relating to the supplied seller. If neither is true, an exception is thrown.

Operation Examples

The example below returns all orders for the given buyer.

$ curl -v http://localhost:8080/marketplace/orders?buyerId=2
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /marketplace/orders?buyerId=2 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 27 Jul 2016 12:20:00 GMT
< 
* Connection #0 to host localhost left intact
[{"id":1,"itemId":12345,"buyerId":2,"sellerId":3,"quantity":1,"pricePerUnit":19900}]

The example below returns all orders for the given seller.

$ curl -v http://localhost:8080/marketplace/orders?sellerId=3
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /marketplace/orders?sellerId=3 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 27 Jul 2016 12:20:20 GMT
< 
* Connection #0 to host localhost left intact
[{"id":1,"itemId":12345,"buyerId":2,"sellerId":3,"quantity":1,"pricePerUnit":19900}]

Retrieve Current Bid Price

When called, this API operation will return the highest price of all bids for the given item.

Operation Examples

curl -v http://localhost:8080/marketplace/bids/12345/currentPrice
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /marketplace/bids/12345/currentPrice HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 27 Jul 2016 12:14:38 GMT
< 
* Connection #0 to host localhost left intact
19900

Retrieve Current Offer Price

When called, this API operation will return the lowest price of all offers for the given item.

Operation Examples

curl -v http://localhost:8080/marketplace/offers/999/currentPrice
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /marketplace/offers/999/currentPrice HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 27 Jul 2016 12:16:20 GMT
< 
* Connection #0 to host localhost left intact
900

About

Marketplace is a Spring Boot based project with a RESTful API service for placing bids and offers within a marketplace

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages