api/docs/requests.yaml
components:
### SCHEMAS ###
schemas:
ReimbursementRequestObject:
type: object
description: The base reimbursement request. All requests should have these properties.
properties:
firstName:
type: string
example: Joe
lastName:
type: string
example: Smith
employeeId:
type: integer
example: 123456
idir:
type: string
example: W0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0
purchases:
type: array
items:
type: object
properties:
supplier:
type: string
example: Walmart
purchaseDate:
type: string
example: 2023-05-01T00:00:00-07:00
cost:
type: number
example: 49.99
fileObj:
type: object
properties:
name:
type: string
example: my_receipt.pdf
size:
type: number
example: 94702
file:
type: string
example: base64EncodedFile
additionalComments:
type: string
example: Have a good day!
required:
- firstName
- lastName
- employeeId
- purchases
- idir
- approvalDate
ReimbursementRequestReceived:
type: object
description: The received form data.
properties:
data:
allOf:
- $ref: '#/components/schemas/ReimbursementRequestObject'
- type: object
properties:
lateEntry:
type: boolean
example: false
submit:
type: boolean
example: true
ReimbursementRequest:
allOf:
- $ref: '#/components/schemas/ReimbursementRequestObject'
- type: object
description: The received form data.
properties:
submissionDate:
type: string
example: 2023-04-25T16:51:31.929Z
state:
type: number
example: 0
_id:
type: string
example: 64480513a30c8be7b83d9593
approvals:
type: array
items:
type: object
properties:
approvalDate:
type: string
example: '2023-05-24T20:08:34.000Z'
fileObj:
type: object
properties:
name:
type: string
example: my_approval.pdf
size:
type: number
example: 94702
date:
type: string
example: '2023-06-05T20:08:38.709Z'
file:
type: string
example: base64EncodedFile
responses:
400BadRequestID:
description: Bad request response.
content:
text/plain:
schema:
type: string
example: 'ID was malformed. Cannot complete request.'
403ForbiddenRecord:
description: The record was called for by a user who does not own the record or is not an admin.
content:
text/plain:
schema:
type: string
example: 'Forbidden: User does not match requested record.'
404NoRecords:
description: No records were found.
content:
text/plain:
schema:
type: string
example: 'No record. || No records found. || No matching records found.'
### PATHS ###
paths:
/requests:
post:
tags:
- Requests
summary: Receives a request from a CHEFS form.
description: Receives a request from a CHEFS form.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ReimbursementRequestReceived'
responses:
'201':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ReimbursementRequest'
'429':
$ref: '#/components/responses/429TooManyRequests'
get:
security:
- bearerAuth: []
tags:
- Requests
summary: Returns all request documents from the database.
description: Returns all request documents from the database.
parameters:
- in: query
name: minimal
schema:
type: boolean
example: true
description: Boolean to determine if a minimal version of each document is returned.
- in: query
name: before
schema:
type: string
example: '2023-06-30'
description: The farthest future date from when records should be retrieved. Not inclusive.
- in: query
name: after
schema:
type: string
example: '2023-06-01'
description: The farthest past date from when records should be retrieved. Inclusive.
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ReimbursementRequest'
'400':
$ref: '#/components/responses/400BadRequest'
'404':
$ref: '#/components/responses/404NoRecords'
'429':
$ref: '#/components/responses/429TooManyRequests'
/requests/idir:
get:
security:
- bearerAuth: []
tags:
- Requests
summary: Returns all request records originating from a provided IDIR.
description: Returns all request records originating from a provided IDIR.
parameters:
- in: query
name: minimal
schema:
type: boolean
example: true
description: Boolean to determine if a minimal version of each document is returned.
- in: query
name: idir
schema:
type: string
example: W0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0
description: The IDIR of an employee used to retrieve request records.
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ReimbursementRequest'
'400':
$ref: '#/components/responses/400BadRequest'
'403':
description: Forbidden
content:
text/plain:
schema:
type: string
example: 'Forbidden: User does not match requested IDIR.'
'404':
$ref: '#/components/responses/404NoRecords'
'429':
$ref: '#/components/responses/429TooManyRequests'
/requests/{id}:
get:
security:
- bearerAuth: []
tags:
- Requests
summary: Returns a single request record that matches a specific ID.
description: Returns a single request record that matches a specific ID.
parameters:
- in: path
name: id
schema:
type: string
example: 64480513a30c8be7b83d9593
description: The document ID of the request record.
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ReimbursementRequest'
'400':
$ref: '#/components/responses/400BadRequestID'
'403':
$ref: '#/components/responses/403ForbiddenRecord'
'404':
$ref: '#/components/responses/404NoRecords'
'429':
$ref: '#/components/responses/429TooManyRequests'
patch:
security:
- bearerAuth: []
tags:
- Requests
summary: Updates the state of a single request record that matches a specific ID.
description: Updates the state of a single request record that matches a specific ID.
parameters:
- in: path
name: id
schema:
type: string
example: 64480513a30c8be7b83d9593
description: The document ID of the request record.
requestBody:
content:
application/json:
schema:
type: object
properties:
approvals:
type: array
items:
type: object
properties:
approvalDate:
type: string
example: '2023-05-24T20:08:34.000Z'
fileObj:
type: object
properties:
name:
type: string
example: my_approval.pdf
size:
type: number
example: 94702
date:
type: string
example: '2023-06-05T20:08:38.709Z'
file:
type: string
example: base64EncodedFile
purchases:
type: array
items:
type: object
properties:
supplier:
type: string
example: Walmart
purchaseDate:
type: string
example: 2023-05-01T00:00:00-07:00
cost:
type: number
example: 49.99
fileObj:
type: object
properties:
name:
type: string
example: my_receipt.pdf
size:
type: number
example: 94702
file:
type: string
example: base64EncodedFile
additionalComments:
type: string
example: These are the updated comments.
employeeId:
type: number
example: 123456
state:
type: number
example: 1
responses:
'200':
description: OK
content:
text/plain:
schema:
type: string
example: 'Record state updated to DENIED.'
'400':
$ref: '#/components/responses/400BadRequestID'
'403':
description: Forbidden
content:
text/plain:
schema:
type: string
example: 'An invalid state was requested. || Forbidden: User does not match requested record.'
'429':
$ref: '#/components/responses/429TooManyRequests'
/requests/{id}/files:
get:
security:
- bearerAuth: []
tags:
- Requests
summary: Returns a single file from a specific request record.
description: Returns a single file from a specific request record.
parameters:
- in: path
name: id
schema:
type: string
example: 64480513a30c8be7b83d9593
description: The document ID of the request record.
- in: query
name: date
schema:
type: string
example: 2023-07-03T19:50:22.310Z
description: The upload date of the desired file.
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
file:
type: string
example: base64encodedFile
'400':
description: Bad Request
content:
text/plain:
schema:
type: string
example: 'ID was malformed. Cannot complete request. || Request could not be processed.'
'403':
description: Forbidden
content:
text/plain:
schema:
type: string
example: 'Forbidden: User does not match requested record.'
'404':
description: Not Found
content:
text/plain:
schema:
type: string
example: 'No file matching that request. || No record with that ID found.'
'429':
$ref: '#/components/responses/429TooManyRequests'