-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add raw capture and session docs
- Loading branch information
1 parent
7c24fe8
commit 249b052
Showing
6 changed files
with
456 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
Oops, something went wrong.