2022-12-22 18:41:19 +01:00
|
|
|
import {
|
|
|
|
jwt,
|
|
|
|
key,
|
|
|
|
fields,
|
|
|
|
parameters,
|
|
|
|
response,
|
|
|
|
errorExamples,
|
|
|
|
jsonResponse,
|
|
|
|
uploadImg,
|
|
|
|
} from './lib.mjs'
|
|
|
|
|
|
|
|
const common = {
|
2023-02-26 16:04:12 +01:00
|
|
|
tags: ['Measurements Sets'],
|
2022-12-22 18:41:19 +01:00
|
|
|
security: [jwt, key],
|
|
|
|
}
|
|
|
|
|
|
|
|
const local = {
|
|
|
|
params: {
|
|
|
|
id: {
|
|
|
|
in: 'path',
|
|
|
|
name: 'id',
|
|
|
|
required: true,
|
2023-02-26 16:04:12 +01:00
|
|
|
description: "The Set's unique ID",
|
2022-12-22 18:41:19 +01:00
|
|
|
schema: {
|
|
|
|
example: 666,
|
|
|
|
type: 'integer',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paths
|
|
|
|
export const paths = {}
|
|
|
|
|
2023-02-26 16:04:12 +01:00
|
|
|
// Create set
|
|
|
|
paths['/sets/{auth}'] = {
|
2022-12-22 18:41:19 +01:00
|
|
|
post: {
|
|
|
|
...common,
|
2023-02-26 16:04:12 +01:00
|
|
|
summary: 'Create a new Measurements Set',
|
|
|
|
description: 'Creates a new Measurements Set and returns it.',
|
2022-12-22 18:41:19 +01:00
|
|
|
parameters: [parameters.auth],
|
|
|
|
requestBody: {
|
|
|
|
required: true,
|
|
|
|
content: {
|
|
|
|
'application/json': {
|
|
|
|
schema: {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
img: uploadImg,
|
2023-02-26 16:04:12 +01:00
|
|
|
imperial: response.body.set.properties.imperial,
|
|
|
|
name: response.body.set.properties.name,
|
|
|
|
notes: response.body.set.properties.notes,
|
|
|
|
public: response.body.set.properties.public,
|
|
|
|
measies: response.body.set.properties.measies,
|
2022-12-22 18:41:19 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
responses: {
|
|
|
|
201: {
|
|
|
|
...response.status['201'],
|
|
|
|
...jsonResponse({
|
|
|
|
result: fields.result,
|
2023-02-26 16:04:12 +01:00
|
|
|
set: response.body.set,
|
2022-12-22 18:41:19 +01:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
400: {
|
|
|
|
...response.status['400'],
|
|
|
|
description:
|
|
|
|
response.status['400'].description + errorExamples(['postBodyMissing', 'nameMissing']),
|
|
|
|
},
|
|
|
|
401: response.status['401'],
|
|
|
|
403: {
|
|
|
|
...response.status['403'],
|
|
|
|
description:
|
|
|
|
response.status['403'].description +
|
|
|
|
errorExamples(['accountStatusLacking', 'insufficientAccessLevel']),
|
|
|
|
},
|
|
|
|
500: response.status['500'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-02-26 16:04:12 +01:00
|
|
|
// Get/Remove Set
|
|
|
|
paths['/sets/{id}/{auth}'] = {
|
|
|
|
// Get a Set
|
2022-12-22 18:41:19 +01:00
|
|
|
get: {
|
|
|
|
...common,
|
2023-02-26 16:04:12 +01:00
|
|
|
summary: 'Retrieve a Measurements Set',
|
|
|
|
description: 'Retrieves information about Measurements Set `id`.',
|
2022-12-22 18:41:19 +01:00
|
|
|
parameters: [parameters.auth, local.params.id],
|
|
|
|
responses: {
|
|
|
|
200: {
|
|
|
|
description:
|
2023-02-26 16:04:12 +01:00
|
|
|
'**Success - Measurements Set returned**\n\n' +
|
2022-12-22 18:41:19 +01:00
|
|
|
'Status code `200` indicates that the resource was returned successfully.',
|
|
|
|
...jsonResponse({
|
|
|
|
result: {
|
|
|
|
...fields.result,
|
|
|
|
example: 'success',
|
|
|
|
},
|
2023-02-26 16:04:12 +01:00
|
|
|
set: response.body.set,
|
2022-12-22 18:41:19 +01:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
401: response.status['401'],
|
|
|
|
403: {
|
|
|
|
...response.status['403'],
|
|
|
|
description:
|
|
|
|
response.status['403'].description +
|
|
|
|
errorExamples(['accountStatusLacking', 'insufficientAccessLevel']),
|
|
|
|
},
|
|
|
|
404: response.status['404'],
|
|
|
|
500: response.status['500'],
|
|
|
|
},
|
|
|
|
},
|
2023-02-26 16:04:12 +01:00
|
|
|
// Update a Set
|
2022-12-22 18:41:19 +01:00
|
|
|
patch: {
|
|
|
|
...common,
|
2023-02-26 16:04:12 +01:00
|
|
|
summary: 'Update a Measurements Set',
|
|
|
|
description: 'Updates information about Measurements Set `id`.',
|
2022-12-22 18:41:19 +01:00
|
|
|
parameters: [parameters.auth, local.params.id],
|
|
|
|
requestBody: {
|
|
|
|
required: true,
|
|
|
|
content: {
|
|
|
|
'application/json': {
|
|
|
|
schema: {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
img: uploadImg,
|
2023-02-26 16:04:12 +01:00
|
|
|
imperial: response.body.set.properties.imperial,
|
|
|
|
name: response.body.set.properties.name,
|
|
|
|
notes: response.body.set.properties.notes,
|
|
|
|
public: response.body.set.properties.public,
|
|
|
|
measies: response.body.set.properties.measies,
|
2022-12-22 18:41:19 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
responses: {
|
|
|
|
200: {
|
|
|
|
description:
|
2023-02-26 16:04:12 +01:00
|
|
|
'**Success - Measurements Set returned**\n\n' +
|
2022-12-22 18:41:19 +01:00
|
|
|
'Status code `200` indicates that the resource was returned successfully.',
|
|
|
|
...jsonResponse({
|
|
|
|
result: {
|
|
|
|
...fields.result,
|
|
|
|
example: 'success',
|
|
|
|
},
|
2023-02-26 16:04:12 +01:00
|
|
|
set: response.body.set,
|
2022-12-22 18:41:19 +01:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
401: response.status['401'],
|
|
|
|
403: {
|
|
|
|
...response.status['403'],
|
|
|
|
description:
|
|
|
|
response.status['403'].description +
|
|
|
|
errorExamples(['accountStatusLacking', 'insufficientAccessLevel']),
|
|
|
|
},
|
|
|
|
404: response.status['404'],
|
|
|
|
500: response.status['500'],
|
|
|
|
},
|
|
|
|
},
|
2023-02-26 16:04:12 +01:00
|
|
|
// Remove a Set
|
2022-12-22 18:41:19 +01:00
|
|
|
delete: {
|
|
|
|
...common,
|
2023-02-26 16:04:12 +01:00
|
|
|
summary: 'Remove a Set',
|
|
|
|
description: 'Removes the Measurements Set `id`.',
|
2022-12-22 18:41:19 +01:00
|
|
|
parameters: [parameters.auth, local.params.id],
|
|
|
|
responses: {
|
|
|
|
204: response.status['204'],
|
|
|
|
401: response.status['401'],
|
|
|
|
403: {
|
|
|
|
...response.status['403'],
|
|
|
|
description:
|
|
|
|
response.status['403'].description +
|
|
|
|
errorExamples(['accountStatusLacking', 'insufficientAccessLevel']),
|
|
|
|
},
|
|
|
|
404: response.status['404'],
|
|
|
|
500: response.status['500'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-02-26 16:04:12 +01:00
|
|
|
// Clone a Set
|
|
|
|
paths['/sets/{id}/clone/{auth}'] = {
|
2022-12-22 18:41:19 +01:00
|
|
|
post: {
|
|
|
|
...common,
|
2023-02-26 16:04:12 +01:00
|
|
|
summary: 'Clone a Measurements Set',
|
|
|
|
description: 'Creates a new Measurments Set by cloning an existing one.',
|
2022-12-22 18:41:19 +01:00
|
|
|
parameters: [parameters.auth],
|
|
|
|
responses: {
|
|
|
|
201: {
|
|
|
|
...response.status['201'],
|
|
|
|
...jsonResponse({
|
|
|
|
result: fields.result,
|
2023-02-26 16:04:12 +01:00
|
|
|
set: response.body.set,
|
2022-12-22 18:41:19 +01:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
401: response.status['401'],
|
|
|
|
403: {
|
|
|
|
...response.status['403'],
|
|
|
|
description:
|
|
|
|
response.status['403'].description +
|
|
|
|
errorExamples(['accountStatusLacking', 'insufficientAccessLevel']),
|
|
|
|
},
|
|
|
|
500: response.status['500'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|