Skip to content

Commit

Permalink
chore: add raw capture and session docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lbbdeveloper committed Oct 2, 2023
1 parent 7c24fe8 commit 249b052
Show file tree
Hide file tree
Showing 6 changed files with 456 additions and 45 deletions.
35 changes: 15 additions & 20 deletions server/handlers/deviceConfigurationHandler/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const singleDeviceConfigurationResponse = {
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/DeviceConfiguration',
$ref: '#/components/schemas/Device-Configuration',
},
},
},
Expand Down Expand Up @@ -44,7 +44,7 @@ const deviceConfigurationSwagger = {
tags: {
type: 'array',
items: {
$ref: '#/components/schemas/DeviceConfiguration',
$ref: '#/components/schemas/Device-Configuration',
},
},
},
Expand Down Expand Up @@ -96,24 +96,19 @@ const deviceConfigurationComponent = {
type: 'object',
properties: {
id: { type: 'string', format: 'uuid' },
reference_id: { type: 'number' },
tree_id: { type: 'string', format: 'uuid' },
image_url: { type: 'string' },
lat: { type: 'number' },
lon: { type: 'number' },
created_at: { type: 'string', format: 'date-time' },
status: { type: 'string' },
captured_at: { type: 'string', format: 'date-time' },
planting_organization_id: { type: 'string', format: 'uuid' },
tag_array: { type: 'array', items: { type: 'string' } },
grower_account_id: { type: 'string', format: 'uuid' },
morphology: { type: 'string' },
age: { type: 'number' },
note: { type: 'string' },
attributes: { type: 'object' },
species_id: { type: 'string', format: 'uuid' },
session_id: { type: 'string', format: 'uuid' },
device_configuration_id: { type: 'string', format: 'uuid' },
device_identifier: { type: 'string' },
brand: { type: 'string' },
model: { type: 'string' },
device: { type: 'string' },
serial: { type: 'string' },
hardware: { type: 'string' },
manufacturer: { type: 'string' },
app_build: { type: 'string' },
app_version: { type: 'string' },
os_version: { type: 'array' },
sdk_version: { type: 'string' },
logged_at: { type: 'string' },
bulk_pack_file_name: { type: 'string' },
},
};

Expand Down
160 changes: 160 additions & 0 deletions server/handlers/rawCaptureHandler/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
const j2s = require('joi-to-swagger');
const {
rawCaptureSchema: postJoiSchema,
rawCaptureGetQuerySchema: getJoiSchema,
rawCaptureIdParamSchema: getSingleJoiSchema,
rawCaptureRejectionSchema: rejectJoiSchema,
} = require('./schemas');

const { swagger: rawCapturePostSchema } = j2s(postJoiSchema);
const { swagger: rawCaptureGetSchema } = j2s(getJoiSchema);
const { swagger: rawCaptureIdParamSchema } = j2s(getSingleJoiSchema);
const { swagger: rawCaptureRejectSchema } = j2s(rejectJoiSchema);

const singleRawCaptureResponse = {
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Raw-Capture',
},
},
},
};

const rawCaptureSwagger = {
'/raw-captures': {
get: {
tags: ['raw-capture'],
summary:
'Retrieves capture data based on a filtering criteria or without filtering criteria',
parameters: [
{
schema: {
...rawCaptureGetSchema,
},
in: 'query',
name: 'query',
description:
'The status of the capture data, it can be one of the following three \n* unprocessed\n* approved\n* rejected',
},
],
responses: {
200: {
content: {
'application/json': {
schema: {
type: 'object',
properties: {
tags: {
type: 'array',
items: {
$ref: '#/components/schemas/Raw-Capture',
},
},
},
},
},
},
},
},
},
post: {
tags: ['raw-capture'],
summary: 'Create a new raw capture',
requestBody: {
content: {
'application/json': {
schema: { ...rawCapturePostSchema },
},
},
},
responses: {
201: singleRawCaptureResponse,
200: singleRawCaptureResponse,
},
},
},
'/raw-capture/{raw_capture_id}': {
get: {
tags: ['raw-capture'],
summary: 'get a single raw capture',
parameters: [
{
schema: {
...rawCaptureIdParamSchema,
},
in: 'path',
required: true,
name: 'raw_capture_id',
description: 'id of raw_capture_id to return',
},
],
responses: {
200: singleRawCaptureResponse,
},
},
},
'/raw-capture/{raw_capture_id}/reject': {
patch: {
tags: ['raw-capture'],
summary: 'reject a raw capture',
parameters: [
{
schema: {
...rawCaptureRejectSchema,
},
in: 'path',
required: true,
name: 'raw_capture_id',
description: 'ID of the raw capture to be rejected',
},
],
responses: {
200: {
description: 'Raw capture has been rejected successfully',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Raw-Capture',
},
},
},
},
},
},
},
};

const rawCaptureComponent = {
type: 'object',
properties: {
id: { type: 'string', format: 'uuid' },
reference_id: { type: 'string' },
session_id: { type: 'string' },
abs_step_count: { type: 'integer' },
delta_step_count: { type: 'integer' },
rotation_matrix: { type: 'array', items: { type: 'number' } },
image_url: { type: 'string' },
lat: { type: 'number' },
lon: { type: 'number' },
gps_accuracy: { type: 'number' },
note: { type: 'string' },
device_identifier: { type: 'string' },
grower_account_id: { type: 'string' },
wallet: { type: 'string' },
user_photo_url: { type: 'string' },
extra_attributes: { type: 'object' },
status: { type: 'string' },
rejection_reason: { type: 'string' },
bulk_pack_file_name: { type: 'string' },
created_at: { type: 'string', format: 'date-time' },
updated_at: { type: 'string', format: 'date-time' },
captured_at: { type: 'string', format: 'date-time' },
organization_id: { type: 'string' },
},
};

module.exports = {
rawCaptureSwagger,
rawCaptureComponent,
};
27 changes: 27 additions & 0 deletions server/handlers/replayEventHandler/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const replayEventPostSwagger = {
'/replay-event': {
post: {
tags: ['replay-event'],
summary: 'Replay Events',
description: 'Initiates the replay of events.',
responses: {
200: {
description: 'Request accepted',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
request: { type: 'string', example: 'accepted' },
status: { type: 'string', example: 'replay in progress...' },
},
},
},
},
},
},
},
},
};

module.exports = { replayEventPostSwagger };
120 changes: 120 additions & 0 deletions server/handlers/sessionHandler/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
const j2s = require('joi-to-swagger');
const {
sessionPostSchema: postJoiSchema,
sessionGetQuerySchema: getJoiSchema,
sessionIdParamSchema: getSingleJoiSchema,
} = require('./schemas');

const { swagger: sessionPostSchema } = j2s(postJoiSchema);
const { swagger: sessionGetSchema } = j2s(getJoiSchema);
const { swagger: sessionIdParamSchema } = j2s(getSingleJoiSchema);

const singleRawCaptureResponse = {
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Session',
},
},
},
};

const sessionSwagger = {
'/session': {
get: {
tags: ['session'],
summary: 'Retrieves list of session data',
parameters: [
{
schema: {
...sessionGetSchema,
},
in: 'query',
name: 'query',
description: 'Retrieves list of session data',
},
],
responses: {
200: {
content: {
'application/json': {
schema: {
type: 'object',
properties: {
tags: {
type: 'array',
items: {
$ref: '#/components/schemas/Session',
},
},
},
},
},
},
},
},
},
post: {
tags: ['session'],
summary: 'Create a new session',
requestBody: {
content: {
'application/json': {
schema: { ...sessionPostSchema },
},
},
},
responses: {
201: singleRawCaptureResponse,
200: singleRawCaptureResponse,
},
},
},
'/session/{session_id}': {
get: {
tags: ['session'],
summary: 'get a single session',
parameters: [
{
schema: {
...sessionIdParamSchema,
},
in: 'path',
required: true,
name: 'session_id',
description: 'id of session_id to return',
},
],
responses: {
200: singleRawCaptureResponse,
},
},
},
};

const sessionComponent = {
type: 'object',
properties: {
id: { type: 'string', format: 'uuid' },
start_time: { type: 'string', format: 'date-time' },
bulk_pack_version: { type: 'string' },
device_configuration_id: { type: 'string' },
originating_wallet_registration_id: { type: 'string' },
target_wallet: { type: 'string' },
check_in_photo_url: { type: 'string' },
track_url: { type: 'string' },
organization: { type: 'string' },
organization_id: { type: 'string' },
device_identifier: { type: 'string' },
grower_account_id: { type: 'string' },
wallet: { type: 'string' },
user_photo_url: { type: 'string' },
bulk_pack_file_name: { type: 'string' },
created_at: { type: 'string', format: 'date-time' },
},
};

module.exports = {
sessionSwagger,
sessionComponent,
};
Loading

0 comments on commit 249b052

Please sign in to comment.