{ "schemes": [ "http", "https" ], "swagger": "2.0", "info": { "description": "Minimal booking API built for integration and performance testing. Callers identify themselves with X-User-Id; payment is a mock selected by token (tok_success, tok_decline, tok_timeout).", "title": "Event Ticket Booking API", "contact": { "name": "Abdan Hafidz" }, "license": { "name": "MIT", "url": "https://opensource.org/licenses/MIT" }, "version": "1.0.0" }, "basePath": "/", "paths": { "/v1/bookings": { "post": { "description": "Reserves tickets all-or-nothing and starts the payment hold", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Booking" ], "summary": "Reserve tickets", "parameters": [ { "type": "string", "description": "Caller user ID", "name": "X-User-Id", "in": "header", "required": true }, { "type": "string", "description": "Idempotency key", "name": "Idempotency-Key", "in": "header", "required": true }, { "description": "Booking request", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.CreateBookingRequest" } } ], "responses": { "201": { "description": "Created", "schema": { "$ref": "#/definitions/dto.SuccessResponse-dto_BookingResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } }, "409": { "description": "Conflict", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } }, "422": { "description": "Unprocessable Entity", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } } } } }, "/v1/bookings/{id}": { "get": { "produces": [ "application/json" ], "tags": [ "Booking" ], "summary": "Get one of your bookings", "parameters": [ { "type": "string", "description": "Caller user ID", "name": "X-User-Id", "in": "header", "required": true }, { "type": "string", "description": "Booking ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.SuccessResponse-dto_BookingResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } } } } }, "/v1/bookings/{id}/cancel": { "post": { "produces": [ "application/json" ], "tags": [ "Booking" ], "summary": "Cancel a pending or confirmed booking before the event starts", "parameters": [ { "type": "string", "description": "Caller user ID", "name": "X-User-Id", "in": "header", "required": true }, { "type": "string", "description": "Booking ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.SuccessResponse-dto_BookingResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } }, "409": { "description": "Conflict", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } } } } }, "/v1/bookings/{id}/pay": { "post": { "description": "tok_success confirms; tok_decline and tok_timeout fail the booking and release its tickets", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Booking" ], "summary": "Pay for a booking with the mock gateway", "parameters": [ { "type": "string", "description": "Caller user ID", "name": "X-User-Id", "in": "header", "required": true }, { "type": "string", "description": "Idempotency key", "name": "Idempotency-Key", "in": "header", "required": true }, { "type": "string", "description": "Booking ID", "name": "id", "in": "path", "required": true }, { "description": "Payment request", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.PayBookingRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.SuccessResponse-dto_BookingResponse" } }, "402": { "description": "Payment Required", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } }, "409": { "description": "Conflict", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } }, "422": { "description": "Unprocessable Entity", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } } } } }, "/v1/events/{id}": { "get": { "description": "Event with its ticket types and live availability", "produces": [ "application/json" ], "tags": [ "Event" ], "summary": "Get an event", "parameters": [ { "type": "string", "description": "Event ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/dto.SuccessResponse-dto_EventResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/dto.ErrorResponse" } } } } } }, "definitions": { "dto.BookingResponse": { "type": "object", "properties": { "created_at": { "type": "string" }, "currency": { "type": "string" }, "event_id": { "type": "string" }, "expires_at": { "type": "string" }, "id": { "type": "string" }, "quantity": { "type": "integer" }, "status": { "type": "string" }, "ticket_type_id": { "type": "string" }, "total_amount": { "type": "integer" }, "unit_price": { "type": "integer" }, "updated_at": { "type": "string" } } }, "dto.CreateBookingRequest": { "type": "object", "required": [ "quantity", "ticket_type_id" ], "properties": { "quantity": { "type": "integer", "maximum": 6, "minimum": 1 }, "ticket_type_id": { "type": "string" } } }, "dto.ErrorResponse": { "type": "object", "properties": { "code": { "type": "string" }, "errors": {}, "message": {}, "meta_data": {}, "status": { "type": "string" } } }, "dto.EventResponse": { "type": "object", "properties": { "currency": { "type": "string" }, "id": { "type": "string" }, "name": { "type": "string" }, "starts_at": { "type": "string" }, "ticket_types": { "type": "array", "items": { "$ref": "#/definitions/dto.TicketTypeResponse" } } } }, "dto.PayBookingRequest": { "type": "object", "required": [ "payment_token" ], "properties": { "payment_token": { "type": "string", "maxLength": 64 } } }, "dto.SuccessResponse-dto_BookingResponse": { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.BookingResponse" }, "message": {}, "meta_data": {}, "status": { "type": "string" } } }, "dto.SuccessResponse-dto_EventResponse": { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.EventResponse" }, "message": {}, "meta_data": {}, "status": { "type": "string" } } }, "dto.TicketTypeResponse": { "type": "object", "properties": { "available": { "type": "integer" }, "capacity": { "type": "integer" }, "id": { "type": "string" }, "name": { "type": "string" }, "price": { "type": "integer" } } } } }