Romani Mind, v0.1
Posted on

Web service for a handling of a business logic of conversations.
Implement an interface as a RESTful API.
Features
- working mode:
- run as a web service;
- control via the RESTful API;
- commands:
- handle a part of a history of a thread with an user:
- request data:
- list of messages;
- user info;
- arbitrary auxiliary data;
- response data:
- list of messages;
- probably updated arbitrary auxiliary data.
- request data:
- handle a part of a history of a thread with an user:
Command
Command format in the JSON Schema format:
{
"type": "object",
"required": ["messages", "user", "state"],
"additionalProperties": false,
"properties": {
"messages": {
"type": "array",
"items": {
"type": "object",
"required": ["id", "type", "timestamp", "text"],
"additionalProperties": false,
"properties": {
"id": {"$ref": "#/definitions/numeric_string"},
"type": {"type": "string", "pattern": "^[a-z_]+$"},
"timestamp": {"$ref": "#/definitions/numeric_string"},
"text": {"type": "string"}
}
}
},
"user": {
"type": "object",
"required": [
"id",
"category",
"username",
"full_name",
"gender",
"birthday",
"biography",
"location",
"counters",
"flags"
],
"additionalProperties": false,
"properties": {
"id": {"$ref": "#/definitions/numeric_string"},
"category": {"type": "string"},
"username": {"type": "string"},
"full_name": {"type": "string"},
"gender": {"type": "integer"},
"birthday": {"type": "string"},
"biography": {"type": "string"},
"location": {
"type": "object",
"required": ["geo", "address"],
"additionalProperties": false,
"properties": {
"geo": {
"type": "object",
"required": ["latitude", "longitude"],
"additionalProperties": false,
"properties": {
"latitude": {"type": "number"},
"longitude": {"type": "number"}
}
},
"address": {
"type": "object",
"required": ["street", "city", "zip", "country_code"],
"additionalProperties": false,
"properties": {
"street": {"type": "string"},
"city": {"type": "string"},
"zip": {"type": "string"},
"country_code": {"type": "integer"}
}
}
}
},
"counters": {
"type": "object",
"required": ["media", "followers", "followings"],
"additionalProperties": false,
"properties": {
"media": {"type": "integer"},
"followers": {"type": "integer"},
"followings": {"type": "integer"}
}
},
"flags": {
"type": "object",
"required": ["is_private", "is_business", "is_verified"],
"additionalProperties": false,
"properties": {
"is_private": {"type": "boolean"},
"is_business": {"type": "boolean"},
"is_verified": {"type": "boolean"}
}
}
}
},
"state": {}
},
"definitions": {"numeric_string": {"type": "string", "pattern": "^\\d+$"}}
}
Example:
{
"messages": [
{
"id": "28026277175418219105553115011612672",
"type": "text",
"timestamp": "1519307530013467",
"text": "тест"
},
{
"id": "28026277234757336506980526458929152",
"type": "text",
"timestamp": "1519307533230247",
"text": "тест два"
},
{
"id": "28026277284889112092153215698599936",
"type": "text",
"timestamp": "1519307535947896",
"text": "тест три"
}
],
"user": {
"id": "1599620166",
"category": "Blogger",
"username": "_iren.ica_",
"full_name": "Irenica",
"gender": 0,
"birthday": "",
"biography": "Задротка. http://msk-metro.ru",
"location": {
"geo": {
"latitude": 0,
"longitude": 0
},
"address": {
"street": "",
"city": "",
"zip": "",
"country_code": 0
}
},
"counters": {
"media": 569,
"followers": 6061,
"followings": 83
},
"flags": {
"is_private": false,
"is_business": true,
"is_verified": false
}
},
"state": null
}
API
API description in the Swagger format:
openapi: '3.0.0'
info:
title: romani-mind
version: 0.1.0
servers:
- url: http://localhost:{port}/api/v1
variables:
port:
default: '7070'
paths:
/history:
post:
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/request'
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/response'
400:
$ref: '#/components/responses/error'
404:
$ref: '#/components/responses/error'
405:
$ref: '#/components/responses/error'
500:
$ref: '#/components/responses/error'
components:
schemas:
numeric_string:
type: string
pattern: ^\\d+$
request_message:
type: object
required:
- id
- type
- timestamp
- text
properties:
id:
$ref: '#/components/schemas/numeric_string'
type:
type: string
pattern: ^[a-z_]+$
timestamp:
$ref: '#/components/schemas/numeric_string'
text:
type: string
geo:
type: object
required:
- latitude
- longitude
properties:
latitude:
type: number
longitude:
type: number
address:
type: object
required:
- street
- city
- zip
- country_code
properties:
street:
type: string
city:
type: string
zip:
type: string
country_code:
type: integer
location:
type: object
required:
- geo
- address
properties:
geo:
$ref: '#/components/schemas/geo'
address:
$ref: '#/components/schemas/address'
user:
type: object
required:
- id
- category
- username
- full_name
- gender
- birthday
- biography
- location
- counters
- flags
properties:
id:
$ref: '#/components/schemas/numeric_string'
category:
type: string
username:
type: string
full_name:
type: string
gender:
type: integer
birthday:
type: string
biography:
type: string
location:
$ref: '#/components/schemas/location'
counters:
type: object
required:
- media
- followers
- followings
properties:
media:
type: integer
followers:
type: integer
followings:
type: integer
flags:
type: object
required:
- is_private
- is_business
- is_verified
properties:
is_private:
type: boolean
is_business:
type: boolean
is_verified:
type: boolean
request:
type: object
required:
- messages
- user
- state
properties:
messages:
type: array
items:
$ref: '#/components/schemas/request_message'
user:
$ref: '#/components/schemas/user'
state:
type: object
nullable: true
response_message:
type: object
oneOf:
- required:
- type
- message
properties:
type:
type: string
enum:
- message
message:
type: string
- required:
- type
- filename
properties:
type:
type: string
enum:
- photo
filename:
type: string
response:
type: object
required:
- messages
- state
properties:
messages:
type: array
items:
$ref: '#/components/schemas/response_message'
state:
type: object
nullable: true
responses:
error:
description: Some Error
content:
text/plain:
schema:
type: string
Screenshots
POST /history
