321 lines
10 KiB
YAML
321 lines
10 KiB
YAML
openapi: 3.1.0
|
|
info:
|
|
title: Ekomat demo API
|
|
version: 1.0.0
|
|
description: >
|
|
Contract of the demo server. Amounts are integer KZT, volumes are millilitres
|
|
and timestamps are Unix milliseconds. Devices, login codes and balances are simulated.
|
|
servers:
|
|
- url: /
|
|
security:
|
|
- bearer: []
|
|
paths:
|
|
/healthz:
|
|
get:
|
|
security: []
|
|
responses:
|
|
'200': {description: Server ready}
|
|
/v1/machines:
|
|
get:
|
|
security: []
|
|
responses:
|
|
'200': {description: Machines with status, address, coordinates, tariffs and products}
|
|
/v1/auth/otp/request:
|
|
post:
|
|
security: []
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [phone, mockProfileKey]
|
|
properties:
|
|
phone: {type: string, example: '+77000123478'}
|
|
mockProfileKey: {type: string, minLength: 48, maxLength: 128}
|
|
responses:
|
|
'200':
|
|
description: Challenge and test code
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [challengeId, mockOtp, retryAfter]
|
|
properties:
|
|
challengeId: {type: string, format: uuid}
|
|
mockOtp: {type: string}
|
|
retryAfter: {type: integer}
|
|
'429': {description: A code was requested in the last minute}
|
|
/v1/auth/otp/verify:
|
|
post:
|
|
security: []
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [challengeId, otp, accepted]
|
|
properties:
|
|
challengeId: {type: string, format: uuid}
|
|
otp: {type: string}
|
|
accepted: {const: true}
|
|
responses:
|
|
'200': {description: A bearer token in the token property}
|
|
'400': {description: Demo consent required}
|
|
'401': {description: Invalid code}
|
|
'410': {description: Expired or exhausted challenge}
|
|
/v1/auth/logout:
|
|
post:
|
|
responses:
|
|
'200': {description: Token revoked}
|
|
/v1/me:
|
|
get:
|
|
responses:
|
|
'200': {description: Signed-in user identifier}
|
|
/v1/overview:
|
|
get:
|
|
responses:
|
|
'200': {description: Selected machine, wallet with available and held balances, intake sessions, orders, tickets and ledger}
|
|
/v1/machines/pair:
|
|
post:
|
|
parameters:
|
|
- $ref: '#/components/parameters/idempotency'
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [scanToken]
|
|
properties:
|
|
scanToken: {type: string, example: 'ekomat:demo:garden'}
|
|
responses:
|
|
'200': {description: Selected machineId}
|
|
'404': {description: Unknown QR text}
|
|
'409': {description: Busy or unavailable machine}
|
|
/v1/intake-sessions:
|
|
post:
|
|
parameters:
|
|
- $ref: '#/components/parameters/idempotency'
|
|
responses:
|
|
'200': {description: Active session with rates and an empty item list}
|
|
'409': {description: Busy or unavailable machine}
|
|
/v1/intake-sessions/{id}:
|
|
parameters:
|
|
- $ref: '#/components/parameters/id'
|
|
get:
|
|
responses:
|
|
'200': {description: Session status and recorded items}
|
|
'404': {description: Session unavailable to caller}
|
|
/v1/intake-sessions/{id}/mock-event:
|
|
parameters:
|
|
- $ref: '#/components/parameters/id'
|
|
post:
|
|
parameters:
|
|
- $ref: '#/components/parameters/idempotency'
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [eventId, material]
|
|
properties:
|
|
eventId: {type: string}
|
|
material: {enum: [pet, aluminium, rejected, close]}
|
|
responses:
|
|
'200': {description: Current session after accepting or deduplicating the event}
|
|
'409': {description: Invalid session state or event conflict}
|
|
/v1/products:
|
|
get:
|
|
responses:
|
|
'200': {description: Products for the paired machine with amounts in stock and available volumes}
|
|
/v1/orders/quote:
|
|
post:
|
|
parameters:
|
|
- $ref: '#/components/parameters/idempotency'
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [productId, volumeMl]
|
|
properties:
|
|
productId: {type: string}
|
|
volumeMl: {type: integer}
|
|
responses:
|
|
'200': {description: Quote with price and expiry, and available wallet balance}
|
|
'409': {description: The requested volume or machine is unavailable}
|
|
/v1/orders:
|
|
post:
|
|
parameters:
|
|
- $ref: '#/components/parameters/idempotency'
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [quoteId]
|
|
properties:
|
|
quoteId: {type: string, format: uuid}
|
|
responses:
|
|
'200': {description: Order created with the quoted amount held}
|
|
'409': {description: Quote expired, balance too low or machine unavailable}
|
|
/v1/orders/{id}:
|
|
parameters:
|
|
- $ref: '#/components/parameters/id'
|
|
get:
|
|
responses:
|
|
'200': {description: Order status, command if started, and actual volume and charged amount if settled}
|
|
'404': {description: Order unavailable to caller}
|
|
/v1/orders/{id}/dispense:
|
|
parameters:
|
|
- $ref: '#/components/parameters/id'
|
|
post:
|
|
parameters:
|
|
- $ref: '#/components/parameters/idempotency'
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [confirmedContainerReady]
|
|
properties:
|
|
confirmedContainerReady: {const: true}
|
|
responses:
|
|
'200': {description: Order with one commandId, including when the command already exists}
|
|
'409': {description: Invalid payment state, missing confirmation, stock or device unavailable}
|
|
/v1/orders/{id}/mock-event:
|
|
parameters:
|
|
- $ref: '#/components/parameters/id'
|
|
post:
|
|
parameters:
|
|
- $ref: '#/components/parameters/idempotency'
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [eventId, commandId, outcome]
|
|
properties:
|
|
eventId: {type: string}
|
|
commandId: {type: string, format: uuid}
|
|
outcome: {enum: [lost, measured]}
|
|
actualMl: {type: integer, minimum: 0, description: Required when outcome is measured}
|
|
responses:
|
|
'200': {description: Order after confirming measurement or marking it for reconciliation}
|
|
'409': {description: Invalid order state, command mismatch or event conflict}
|
|
/v1/support/tickets:
|
|
post:
|
|
parameters:
|
|
- $ref: '#/components/parameters/idempotency'
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [message]
|
|
properties:
|
|
message: {type: string, minLength: 3, maxLength: 1000}
|
|
operationId: {type: string, format: uuid}
|
|
responses:
|
|
'200': {description: Support request with received status}
|
|
'404': {description: Operation unavailable to caller}
|
|
/v1/operator:
|
|
get:
|
|
responses:
|
|
'200': {description: Machines, intake sessions, orders, ledger, support requests, reconciliation proposals and role audit}
|
|
'403': {description: Operator or reviewer credentials needed}
|
|
/v1/operator/machine:
|
|
post:
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [machineId]
|
|
properties:
|
|
machineId: {type: string}
|
|
status: {enum: [available, offline, maintenance, fault]}
|
|
tariffs:
|
|
type: object
|
|
required: [pet, aluminium]
|
|
properties:
|
|
pet: {type: integer, minimum: 0}
|
|
aluminium: {type: integer, minimum: 0}
|
|
product:
|
|
type: object
|
|
required: [id, pricePerLitre, remainingMl]
|
|
properties:
|
|
id: {type: string}
|
|
pricePerLitre: {type: integer, minimum: 1}
|
|
remainingMl: {type: integer, minimum: 0}
|
|
responses:
|
|
'200': {description: Point configuration updated}
|
|
'403': {description: Operator credentials needed}
|
|
/v1/operator/ticket:
|
|
post:
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [ticketId, status]
|
|
properties:
|
|
ticketId: {type: string, format: uuid}
|
|
status: {enum: [received, investigating, resolved]}
|
|
responses:
|
|
'200': {description: Support request updated}
|
|
'403': {description: Operator credentials needed}
|
|
/v1/operator/adjustments:
|
|
post:
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [orderId, actualMl]
|
|
properties:
|
|
orderId: {type: string, format: uuid}
|
|
actualMl: {type: integer, minimum: 0}
|
|
responses:
|
|
'200': {description: Proposed reconciliation for review}
|
|
'403': {description: Operator credentials needed}
|
|
/v1/operator/approve:
|
|
post:
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
required: [adjustmentId]
|
|
properties:
|
|
adjustmentId: {type: string, format: uuid}
|
|
responses:
|
|
'200': {description: Adjustment approved and order settled}
|
|
'403': {description: Reviewer credentials needed}
|
|
components:
|
|
securitySchemes:
|
|
bearer: {type: http, scheme: bearer}
|
|
parameters:
|
|
id:
|
|
name: id
|
|
in: path
|
|
required: true
|
|
schema: {type: string, format: uuid}
|
|
idempotency:
|
|
name: Idempotency-Key
|
|
in: header
|
|
required: true
|
|
schema: {type: string, minLength: 8, maxLength: 100}
|