Sample project that expose Products/Catalogs Rest APIs and perform math operations on old English Currencies
Requirements
"Fino al 1970 nel Regno Unito il sistema monetario prevedeva pence, shilling e pound. Un pound valeva 20 shilling e uno shilling 12 pence (quindi un pound 240 pence)."
Si chiede di realizzare un'API REST che permetta di:
Inserire, modificare e rimuovere articoli da un catalogo (un articolo ha un codice identificativo, un nome e un costo)
Ottenere la lista degli articoli del catalogo o di un singolo articolo (dato il suo codice identificativo)
Eseguire le principali operazioni aritmetiche:
somma - esempio => 5p 17s 8d + 3p 4s 10d= 9p 2s 6d
moltiplicazione con un intero (no decimali) - esempio => 5p 17s 8d 2 = 11p 15 s 4d
divisione resto (da indicare tra parentesi) con un intero (no decimali) - esempio => 18p 16s 1d/15 = 1p 5s Od (1s 1d)
Attenzione: gli endpoint devono poter ricevere e produrre i valori monetari come stringa, usando lo stesso formato degli esempi ovvero "Xp Ys Zd". Nel caso della divisione, se è presente un resto questo sarà indicato tra parentesi usando lo stesso formato "Xp Ys Zd" (vedi esempio 3.iv).
Tech Stack
Client: Stimulus, Bootstrap
Server: Symfony 5.2
Install
bash dev/make/install.sh
Install script contain also loading "fake" data for Article and Catalog
Array of objects with format {"slug": "string"} where "slug" is catalog slug
Remove article from catalogs
DELETE /api/v1/articles/{code}/catalogs
Parameter
Type
Description
code
string
Required. Slug of item to update
catalogs
array
Array of objects with format {"slug": "string"} where "slug" is catalog slug
Set article image
POST /api/v1/articles/{code}/image
Parameter
Type
Description
code
string
Required. Slug of item to update
photo
File
Required. Image to upload
Get all catalogs
GET /api/v1/catalogs
Parameter
Type
Description
page
integer
Required. Page from which to start listing items
limit
integer
Required. How many items to return
Get catalog
GET /api/v1/catalogs/{slug}
Parameter
Type
Description
slug
string
Required. Slug of item to fetch
Create catalog
POST /api/v1/catalogs
Parameter
Type
Description
name
string
Required. Name of catalog
description
string
Description of catalog
Update catalog
PUT /api/v1/catalogs/{slug}
Parameter
Type
Description
slug
string
Required. Slug of item to update
name
string
Required. Name of catalog
description
string
Description of catalog
Delete catalog
DELETE /api/v1/catalogs/{slug}
Parameter
Type
Description
slug
string
Required. Slug of item to update
Sum prices
POST /api/v1/math/sum
Parameter
Type
Description
addend1
string
Required. First operand of sum
addend2
string
Required. First operand of sum
Subtract prices
POST /api/v1/math/sub
Parameter
Type
Description
minuend
string
Required. First operand of sub
subtrahend
string
Required. First operand of sub
Multiply prices
POST /api/v1/math/mul
Parameter
Type
Description
factor1
string
Required. First operand of mul
factor2
string or int
Required. First operand of mul
Divide prices
POST /api/v1/math/div
Parameter
Type
Description
dividend
string
Required. First operand of div
divisor
string or int
Required. First operand of div
Usage
After you create catalogs and articles, you can see results of yours API inserts into /products endpoint;
also you can use math calculator APIs through /calculator endpoint.