DTI-Purwadhika / eventhop-be

0 stars 0 forks source link

Event Endpoints #11

Open ripisopol opened 2 weeks ago

ripisopol commented 2 weeks ago
### Event Endpoints
baseurl http://localhost:8080/api/v1
- [x] Get All baseurl/events
- [x] Get by Category baseurl/events/category/music
- [x] Get by Location baseurl/events/location/kajarta
- [x] Get by sorted baseurl/events/sorted
- [x] get by search baseurl/events/search?keyword=wkwkwkwk (from title & desc)
- [x] get by id baseurl/events/1
protected route
- [x] Create Event
- [x] Update Event
- [x] Delete Event:
overal:
working
mainimage handling needs discussion
params not fixed yet

- [x] get categories baseurl/categories get
overall: working
category enum not fixed yet (currently use category in fe)

precedence user auth integration/sync with fe for protected route
currently by pass events/**
need to review the role
ripisopol commented 6 days ago

Documentation

Overview

The Event Management API provides a set of endpoints for managing events in the system. It supports CRUD operations for events, including the ability to create, read, update, and delete events. Additionally, the API allows querying events based on categories, locations, and search keywords.

Base URL

/api/v1/events

Endpoints

  1. Get All Upcoming Events Request

    Method: GET Endpoint: /api/v1/events Query Parameters: page (optional): Page number for pagination. size (optional): Page size for pagination. sort (optional): Sorting criteria.

Response

Status Code: 200 OK
Response Body:

json

{
  "status": "success",
  "message": "Upcoming events retrieved successfully",
  "data": {
    "content": [
      {
        "id": 1,
        "code": "EVENT001",
        "title": "Sample Event",
        "eventCategory": "MUSIC",
        "mainImage": "http://example.com/image.jpg",
        "location": "New York",
        "startTime": "2024-07-01T10:00:00Z",
        "price": 50.00,
        "isFree": false
      }
      ...
    ],
    "totalPages": 1,
    "totalElements": 1,
    "last": true,
    "size": 10,
    "number": 0,
    "sort": {
      "sorted": false,
      "unsorted": true,
      "empty": true
    },
    "first": true,
    "numberOfElements": 1,
    "empty": false
  }
}
  1. Get Upcoming Events by Category Request

    Method: GET Endpoint: /api/v1/events/category/{category} Path Parameters: category: Event category (e.g., MUSIC, TECHNOLOGY). Query Parameters: page (optional): Page number for pagination. size (optional): Page size for pagination. sort (optional): Sorting criteria.

Response

Status Code: 200 OK
Response Body: Same as the "Get All Upcoming Events" endpoint, but filtered by the specified category.
  1. Get Upcoming Events by Location Request

    Method: GET Endpoint: /api/v1/events/location/{location} Query Parameters: page (optional): Page number for pagination. size (optional): Page size for pagination. sort (optional): Sorting criteria.

Response

Status Code: 200 OK
Response Body: Same as the "Get All Upcoming Events" endpoint, but filtered by the specified location.
  1. Search Upcoming Events Request

    Method: GET Endpoint: /api/v1/events/search Query Parameters: keyword: Keyword to search in event titles and descriptions. page (optional): Page number for pagination. size (optional): Page size for pagination. sort (optional): Sorting criteria.

Response

Status Code: 200 OK
Response Body: Same as the "Get All Upcoming Events" endpoint, but filtered by the specified keyword(target title and desc).
  1. Get Upcoming Events Sorted by Closest Time Request

    Method: GET Endpoint: /api/v1/events/sorted Query Parameters: page (optional): Page number for pagination. size (optional): Page size for pagination. sort (optional): Sorting criteria.

Response

Status Code: 200 OK
Response Body: Same as the "Get All Upcoming Events" endpoint, but sorted by the closest start time.
  1. Get Event by ID Request

    Method: GET Endpoint: /api/v1/events/{id} Path Parameters: id: ID of the event to retrieve.

Response

Status Code: 200 OK
Response Body:

json

{
  "status": "success",
  "message": "Event retrieved successfully",
  "data": {
    "id": 1,
    "code": "EVENT001",
    "title": "Sample Event",
    "eventCategory": "MUSIC",
    "description": "This is a sample event description.",
    "mainImage": "http://example.com/image.jpg",
    "imageUrls": ["http://example.com/image1.jpg", "http://example.com/image2.jpg"],
    "address": "123 Main St, New York, NY",
    "location": "New York",
    "startTime": "2024-07-01T10:00:00Z",
    "endTime": "2024-07-01T12:00:00Z",
    "price": 50.00,
    "isFree": false,
    "availableSeats": 100,
    "url": "http://example.com/event"
  }
}
  1. Create Event Request

    Method: POST Endpoint: /api/v1/events Request Body:

    json

    { "title": "Sample Event", "code": "EVENT001", "eventCategory": "MUSIC", "description": "This is a sample event description.", "mainImage": "http://example.com/image.jpg", "imageUrls": ["http://example.com/image1.jpg", "http://example.com/image2.jpg"], "address": "123 Main St, New York, NY", "location": "New York", "startTime": "2024-07-01T10:00:00Z", "endTime": "2024-07-01T12:00:00Z", "price": 50.00, "isFree": false, "availableSeats": 100, "url": "http://example.com/event" }

    Query Parameters: userId: ID of the user creating the event.

Response

Status Code: 201 Created
Response Body:

json

{
  "id": 1,
  "code": "EVENT001",
  "title": "Sample Event",
  "eventCategory": "MUSIC",
  "description": "This is a sample event description.",
  "mainImage": "http://example.com/image.jpg",
  "imageUrls": ["http://example.com/image1.jpg", "http://example.com/image2.jpg"],
  "address": "123 Main St, New York, NY",
  "location": "New York",
  "startTime": "2024-07-01T10:00:00Z",
  "endTime": "2024-07-01T12:00:00Z",
  "price": 50.00,
  "isFree": false,
  "availableSeats": 100,
  "url": "http://example.com/event"
}
  1. Update Event Request

    Method: PUT Endpoint: /api/v1/events/{id} Path Parameters: id: ID of the event to update. Request Body:

    json

    { "title": "Updated Event", "code": "EVENT001", "eventCategory": "MUSIC", "description": "This is an updated event description.", "mainImage": "http://example.com/image.jpg", "imageUrls": ["http://example.com/image1.jpg", "http://example.com/image2.jpg"], "address": "123 Main St, New York, NY", "location": "New York", "startTime": "2024-07-01T10:00:00Z", "endTime": "2024-07-01T12:00:00Z", "price": 50.00, "isFree": false, "availableSeats": 100, "url": "http://example.com/event" }

Response

Status Code: 200 OK
Response Body:

json

{
  "status": "success",
  "message": "Event updated successfully",
  "data": {
    "id": 1,
    "code": "EVENT001",
    "title": "Updated Event",
    "eventCategory": "MUSIC",
    "description": "This is an updated event description.",
    "mainImage": "http://example.com/image.jpg",
    "imageUrls": ["http://example.com/image1.jpg", "http://example.com/image2.jpg"],
    "address": "123 Main St, New York, NY",
    "location": "New York",
    "startTime": "2024-07-01T10:00:00Z",
    "endTime": "2024-07-01T12:00:00Z",
    "price": 50.00,
    "isFree": false,
    "availableSeats": 100,
    "url": "http://example.com/event"
  }
}
  1. Delete Event Request

    Method: DELETE Endpoint: /api/v1/events/{id} Path Parameters: id: ID of the event to delete.

Response

Status Code: 204 No Content

Example Usage Get All Upcoming Events

curl -X GET "https://example.com/api/v1/events"

Get Upcoming Events by Category


curl -X GET "https://example.com/api/v1/events/category/MUSIC"

Get Upcoming Events by Location


curl -X GET "https://example.com/api/v1/events/location/New%20York"

Search Upcoming Events


curl -X GET "https://example.com/api/v1/events/search?keyword=sample"

Get Upcoming Events Sorted by Closest Time

curl -X GET "https://example.com/api/v1/events/sorted"

Get Event by ID


curl -X GET "https://example.com/api/v1/events/1"

Create Event


curl -X POST "https://example.com/api/v1/events?userId=user_2iIOwrBExqn9LzMShOE4XPAL0gE" \
-H "Content-Type: application/json" \
-d '{
  "title": "Sample Event",
  "code": "EVENT001",
  "eventCategory": "MUSIC",
  "description": "This is a sample event description.",
  "mainImage": "http://example.com/image.jpg",
  "imageUrls": ["http://example.com/image1.jpg", "http://example.com/image2.jpg"],
  "address": "123 Main St, New York, NY",
  "location": "New York",
  "startTime": "2024-07-01T10:00:00Z",
  "endTime": "2024-07-01T12:00:00Z",
  "price": 50.00,
  "isFree": false,
  "availableSeats": 100,
  "url": "http://example.com/event"
}'

Update Event

curl -X PUT "https://example.com/api/v1/events/1" \
-H "Content-Type: application/json" \
-d '{
  "title": "Updated Event",
  "code": "EVENT001",
  "eventCategory": "MUSIC",
  "description": "This is an updated event description.",
  "mainImage": "http://example.com/image.jpg",
  "imageUrls": ["http://example.com/image1.jpg", "http://example.com/image2.jpg"],
  "address": "123 Main St, New York, NY",
  "location": "New York",
  "startTime": "2024-07-01T10:00:00Z",
  "endTime": "2024-07-01T12:00:00Z",
  "price": 50.00,
  "isFree": false,
  "availableSeats": 100,
  "url": "http://example.com/event"
}'

Delete Event


curl -X DELETE "https://example.com/api/v1/events/1"

This documentation provides an overview of the available endpoints in the Event Management API. Each endpoint supports various parameters to filter and sort event data, ensuring a flexible and powerful API for event management.

im-rindu commented 2 days ago
/get-events?_limit=:limit&_page=:page&_sort=:sort&price_gte=:minprice&price_lte=:maxprice&date_gte=:fromDate&date_lte=:untilDate&location=:location&userid=:userId

:limit = size :page = page :sort = "asc | desc" :min_price :max_price :fromDate :untilDate :location :userId

endpoint yang dipakai di front end ke server dummy