Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test task

This service provides endpoints for managing images and slideshows, including adding, deleting, and retrieving ordered images in a slideshow, as well as recording proof-of-play events.

Running the server

Build project using maven command: mvn clean install

Run server using Docker compose: docker compose up

The application will be available at http://localhost:8080

API Endpoints

1. Add a New Image

  • Endpoint: POST /images/addImage
  • Description: Adds a new image to the system.

There is validation if URL actually contains an image (JPEG, PNG, WEBP and other).

Sample Request Payload:

{
  "url": "https://xclcamps.com/wp-content/uploads/coding-difference-1.jpg"
}

2. Delete an Image by ID

  • Endpoint: DELETE /images/deleteImage/{id}
  • Path Parameter: id - The ID of the image to be deleted (integer).

Expected Response: HTTP Status: 204 No Content

3. Search for Images

  • Endpoint: GET /images/search
  • Description: Search for images using optional query parameters: keyword and duration.

Sample Request Payload:

GET /images/search?keyword=beach&duration=10

Response Body:

[
  {
    "id": 1,
    "url": "https://xclcamps.com/wp-content/uploads/coding-difference-4.jpg",
    "createdAt": "2025-01-15T17:03:05.473611",
    "slideshowIds": [
      1,
      2,
      3
    ]
  },
  {
    "id": 3,
    "url": "https://xclcamps.com/wp-content/uploads/coding-difference-1.jpg",
    "createdAt": "2025-01-15T19:19:14.926455",
    "slideshowIds": [
      1,
      2,
      3
    ]
  }
]

4. Add a New Slideshow

  • Endpoint: POST /slideshow/addSlideshow
  • Description: Adds a new slideshow to the system.

Sample Request Payload:

{
  "images": [
    { "imageId": 1, "duration": 10 },
    { "imageId": 4, "duration": 15 },
    { "imageId": 5, "duration": 8 }
  ]
}

5. Delete an Slideshow by ID

  • Endpoint: DELETE /slideshow/deleteSlideshow/{id}
  • Path Parameter: id - The ID of the slideshow to be deleted (integer).

Expected Response: HTTP Status: 204 No Content

6. Retrieve Ordered Images in a Slideshow

  • Endpoint: GET /slideshow/{id}/slideshowOrder
  • Description: Retrieves the ordered images in a slideshow by its ID.
  • Path Parameter: id - The ID of the slideshow (integer).

Sample Request Payload:

GET /slideshow/1/slideshowOrder

Response Body:

[
  {
    "id": 1,
    "url": "https://xclcamps.com/wp-content/uploads/coding-difference-4.jpg",
    "createdAt": "2025-01-15T17:03:05.473611",
    "slideshowIds": [
      1,
      2,
      3
    ]
  },
  {
    "id": 3,
    "url": "https://xclcamps.com/wp-content/uploads/coding-difference-1.jpg",
    "createdAt": "2025-01-15T19:19:14.926455",
    "slideshowIds": [
      1,
      2,
      3
    ]
  }
]

7. Record Proof-of-Play for an Image in a Slideshow

  • Endpoint: POST /slideshow/{id}/proof-of-play/{imageId}
  • Description: Simulates the playback of a slideshow and sends a proof-of-play event when an image is played. During the simulation, each image in the slideshow that is tracked in the image-to-track cache is "played" sequentially, and proof-of-play events that are published by SpringEventPublisher are logged for each image.

To verify the event, check the application logs for entries similar to: Proof of Play Event | Slideshow ID: 1 | Image ID: 3.

Sample Request Payload:

POST /slideshow/1/proof-of-play/2

About

The application will enable users to manage a list of image URLs and play a slideshow with transitions. Each image change should trigger a proof-of-play notification.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages