Create a way to inject promotions into listing results
We require a way of maintaining promoted listings within the API.
Entity
To accomplish data storage of the promotions, a new entity named "Promotion" will be created that will have the following fields:
- id: String - ID of the promotion
- listing_id: String - ID of listing that is being promoted
- start_date: Date - Date the promotion starts
- end_date: Date - Date the promotion ends
Resource
To serve and maintain this entity, a new PromotionResource will be created to serve a new endpoint. OAuth2 users with "marketplace_admin_scope" should be able to create, read, update, and delete promotions within the database. The resource will have the following endpoints:
- Create: POST /promotions
- Read: GET /promotions, GET /promotions/{promotion_id}
- Update: PUT /promotions/{promotion_id}
- Delete: DELETE /promotions/{promotion_id}
The resource reads should allow users to use the following query string parameters to narrow down results:
- listing_id: The listing ID for promotions
- date: the date to check for promotions
Service
To enable usage within other resources, a service layer will be created named PromotionService that will provide promotions given the number to retrieve. The default implementation will interface with the database to retrieve Promotions, and should cache the data.
A new configuration value will be added to the standard MicroProfile configuration named eclipse.promotions.serve-count
. This field will contain the number of promotions that should be served per page of results.