Added several needs API endpoints.
This commit is contained in:
parent
8d9ebaf8b4
commit
b73aa6b578
@ -3692,3 +3692,4 @@ ClearCursors:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,11 +38,13 @@ Function Returntofab_API(@API)
|
|||||||
|
|
||||||
#pragma precomp SRP_PreCompiler
|
#pragma precomp SRP_PreCompiler
|
||||||
|
|
||||||
Declare function OI_Wizard_Services, Return_To_Fab_Services
|
Declare function OI_Wizard_Services, Return_To_Fab_Services, Database_Services
|
||||||
|
Declare subroutine Return_To_Fab_Services
|
||||||
|
|
||||||
$insert APP_INSERTS
|
$insert APP_INSERTS
|
||||||
$insert API_SETUP
|
$insert API_SETUP
|
||||||
$insert HTTP_INSERTS
|
$insert HTTP_INSERTS
|
||||||
|
$Insert OI_WIZARD_EQUATES
|
||||||
|
|
||||||
GoToAPI else
|
GoToAPI else
|
||||||
// The specific resource endpoint doesn't have a API handler yet.
|
// The specific resource endpoint doesn't have a API handler yet.
|
||||||
@ -90,7 +92,7 @@ API returntofab.POST
|
|||||||
HTTP_Services('SetResponseStatus', 201)
|
HTTP_Services('SetResponseStatus', 201)
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
|
HTTP_Services('SetResponseStatus', 400, Error_Services('GetMessage'))
|
||||||
end
|
end
|
||||||
|
|
||||||
end else
|
end else
|
||||||
@ -150,7 +152,128 @@ end api
|
|||||||
|
|
||||||
|
|
||||||
API returntofab.ID.PATCH
|
API returntofab.ID.PATCH
|
||||||
|
debug
|
||||||
|
// Update reactor reactor and return updated reactor object
|
||||||
|
RTFId = EndpointSegment
|
||||||
|
If RTFId then
|
||||||
|
// Look for the sessionID in the cookie
|
||||||
|
Cookies = HTTP_Services('GetHTTPCookie')
|
||||||
|
For each Cookie in Cookies using ';'
|
||||||
|
Key = Field(Cookie, '=', 1)
|
||||||
|
If Key EQ 'sessionID' then
|
||||||
|
OIWizardID = Field(Cookie, '=', 2)
|
||||||
|
end
|
||||||
|
Next Cookie
|
||||||
|
|
||||||
HTTP_Resource_Services('LoremIpsum')
|
ValidSession = OI_Wizard_Services('ValidateSession', OIWizardID)
|
||||||
|
|
||||||
|
If ValidSession then
|
||||||
|
// Check if payload has the required information to update a field in the reactors record
|
||||||
|
Body = HTTP_Services('GetHTTPPostString')
|
||||||
|
If Body NE '' then
|
||||||
|
JSON = HTTP_Services('DecodePercentString', Body)
|
||||||
|
hJSON = ''
|
||||||
|
ParseResponse = SRP_JSON(hJSON, 'PARSE', JSON)
|
||||||
|
If (ParseResponse EQ '') then
|
||||||
|
UpdateFields = SRP_Json(hJSON, "GetMembers")
|
||||||
|
LSLUser = Database_Services('ReadDataColumn', 'OI_WIZARD', OIWizardID, OI_WIZARD.EMPLOYEE_ID$, True$, 0, False$)
|
||||||
|
for each Field in UpdateFields using @FM
|
||||||
|
Value = SRP_Json(hJSON, "GetValue", Field)
|
||||||
|
Begin Case
|
||||||
|
Case Field EQ "Reason"
|
||||||
|
Return_To_Fab_Services('SetReasonForReturn', RTFId, LSLUser, Value)
|
||||||
|
Case Field EQ 'EvalResultId'
|
||||||
|
Return_To_Fab_Services('SetEvalInfo', RTFId, LSLUser, Value)
|
||||||
|
Case Otherwise$
|
||||||
|
Error_Services('Add', 'Error Updating ' : Field : 'field in RTF Record.')
|
||||||
|
End Case
|
||||||
|
Next Field
|
||||||
|
If Error_Services('NoError') then
|
||||||
|
StatusCode = 200
|
||||||
|
Message = 'Reactor Updated'
|
||||||
|
RTFJson = Return_To_Fab_Services('ConvertReturnToFabRecordToJSON', RTFId)
|
||||||
|
HTTP_Services('SetResponseHeaderField', 'Content-Location', FullEndpointURL)
|
||||||
|
HTTP_Services('SetResponseBody', RTFJson, False$, 'application/hal+json')
|
||||||
|
end else
|
||||||
|
HTTP_Services('SetResponseStatus', 500, Error_Services('GetMessage'))
|
||||||
|
end
|
||||||
|
SRP_JSON(hJSON, 'Release')
|
||||||
|
end else
|
||||||
|
// Error parsing JSON
|
||||||
|
HTTP_Services('SetResponseStatus', 400, 'Unable to parse the JSON data from the request.')
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
// No JSON payload sent with request
|
||||||
|
HTTP_Services('SetResponseStatus', 400, 'JSON object is missing in the body of the request.')
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
HTTP_Services('SetResponseStatus', 401, 'Invalid session. Reauthentication required.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end api
|
end api
|
||||||
|
|
||||||
|
|
||||||
|
API returntofab.evaluationresultoptions.HEAD
|
||||||
|
API returntofab.evaluationresultoptions.GET
|
||||||
|
OIWizardID = ''
|
||||||
|
Cookies = HTTP_Services('GetHTTPCookie')
|
||||||
|
For each Cookie in Cookies using ';'
|
||||||
|
Key = Field(Cookie, '=', 1)
|
||||||
|
If Key EQ 'sessionID' then
|
||||||
|
OIWizardID = Field(Cookie, '=', 2)
|
||||||
|
end
|
||||||
|
Next Cookie
|
||||||
|
|
||||||
|
ValidSession = OI_Wizard_Services('ValidateSession', OIWizardID)
|
||||||
|
|
||||||
|
If ValidSession then
|
||||||
|
GoSub CreateResultOptionCollection
|
||||||
|
end else
|
||||||
|
HTTP_Services('SetResponseStatus', 401, 'Invalid session. Reauthentication required.')
|
||||||
|
end
|
||||||
|
end api
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
// CreateResultOptionCollection
|
||||||
|
//
|
||||||
|
// Creates a HAL+JSON object based on OpenInsight data row representations.
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
CreateResultOptionCollection:
|
||||||
|
|
||||||
|
JSONCollection = ''
|
||||||
|
Abort = False$
|
||||||
|
ResultOptions = Return_To_Fab_Services('GetReturnToFabResultOptions')
|
||||||
|
hJSONCollection = ''
|
||||||
|
If SRP_JSON(hJSONCollection, 'New', 'Object') then
|
||||||
|
hResultOptionCollection = ''
|
||||||
|
If SRP_JSON(hResultOptionCollection, 'New', 'Array') then
|
||||||
|
For each ResultOptionId in ResultOptions<1> using @VM setting fPos
|
||||||
|
hOptionJson = ''
|
||||||
|
if SRP_JSON(hOptionJson, 'New', 'Object') then
|
||||||
|
SRP_JSON(hOptionJson, 'SetValue', 'ResultOptionId', ResultOptionId, 'Number')
|
||||||
|
SRP_JSON(hOptionJson, 'SetValue', 'ResultOptionDesc', ResultOptions<2,fPos>, 'String')
|
||||||
|
SRP_JSON(hResultOptionCollection, 'Add', hOptionJson)
|
||||||
|
SRP_JSON(hOptionJson, 'Release')
|
||||||
|
end
|
||||||
|
Next ResultOptionId
|
||||||
|
SRP_JSON(hJSONCollection, 'Set', 'ResultOptions', hResultOptionCollection)
|
||||||
|
SRP_JSON(hResultOptionCollection, 'Release')
|
||||||
|
end
|
||||||
|
JSONCollection = SRP_JSON(hJSONCollection, 'Stringify', 'Styled')
|
||||||
|
SRP_JSON(hJSONCollection, 'Release')
|
||||||
|
end
|
||||||
|
If Error_Services('NoError') then
|
||||||
|
HTTP_Services('SetResponseHeaderField', 'Content-Location', FullEndpointURL)
|
||||||
|
HTTP_Services('SetResponseBody', JSONCollection, False$, 'application/hal+json')
|
||||||
|
If Assigned(Message) then
|
||||||
|
HTTP_Services('SetResponseStatus', 201, Message)
|
||||||
|
end else
|
||||||
|
HTTP_Services('SetResponseStatus', 201)
|
||||||
|
end
|
||||||
|
end else
|
||||||
|
Message = Error_Services('GetMessage')
|
||||||
|
HTTP_Services('SetResponseStatus', 500, 'Error in the ' : CurrentAPI : ' API. Message: ': Message)
|
||||||
|
end
|
||||||
|
|
||||||
|
return
|
||||||
|
@ -182,7 +182,13 @@ Service ConvertReturnToFabRecordToJSON(RTFId)
|
|||||||
SRP_JSON(objRTF, 'SetValue', 'MHInitDtm', RTFRecord<RETURN_TO_FAB_LOTS_MH_INIT_DTM$>)
|
SRP_JSON(objRTF, 'SetValue', 'MHInitDtm', RTFRecord<RETURN_TO_FAB_LOTS_MH_INIT_DTM$>)
|
||||||
SRP_JSON(objRTF, 'SetValue', 'EvalUserId', RTFRecord<RETURN_TO_FAB_LOTS_EVAL_USER_ID$>)
|
SRP_JSON(objRTF, 'SetValue', 'EvalUserId', RTFRecord<RETURN_TO_FAB_LOTS_EVAL_USER_ID$>)
|
||||||
SRP_JSON(objRTF, 'SetValue', 'EvalResultId', RTFRecord<RETURN_TO_FAB_LOTS_EVAL_RESULT_ID$>, 'Number')
|
SRP_JSON(objRTF, 'SetValue', 'EvalResultId', RTFRecord<RETURN_TO_FAB_LOTS_EVAL_RESULT_ID$>, 'Number')
|
||||||
SRP_JSON(objRTF, 'SetValue', 'EvalDtm', RTFRecord<RETURN_TO_FAB_LOTS_EVAL_DTM$>)
|
if RTFRecord<RETURN_TO_FAB_LOTS_EVAL_RESULT_ID$> NE '' then
|
||||||
|
EvaluationDescription = Database_Services('ReadDataColumn', 'RETURN_TO_FAB_RESULT_OPTION', RTFRecord<RETURN_TO_FAB_LOTS_EVAL_RESULT_ID$>, RETURN_TO_FAB_RESULT_OPTION_RESULT$, True$, 0, False$)
|
||||||
|
end else
|
||||||
|
EvaluationDescription = ''
|
||||||
|
end
|
||||||
|
SRP_JSON(objRTF, 'SetValue', 'EvalDesc', EvaluationDescription)
|
||||||
|
SRP_JSON(objRTF, 'SetValue', 'EvalDtm', OConv(RTFRecord<RETURN_TO_FAB_LOTS_EVAL_DTM$>, 'DT'))
|
||||||
SRP_JSON(objRTF, 'SetValue', 'FinalCompleteUserId', RTFRecord<RETURN_TO_FAB_LOTS_FINAL_COMPLETE_USER_ID$>)
|
SRP_JSON(objRTF, 'SetValue', 'FinalCompleteUserId', RTFRecord<RETURN_TO_FAB_LOTS_FINAL_COMPLETE_USER_ID$>)
|
||||||
SRP_JSON(objRTF, 'SetValue', 'FinalCompleteDtm', RTFRecord<RETURN_TO_FAB_LOTS_FINAL_COMPLETE_DTM$>)
|
SRP_JSON(objRTF, 'SetValue', 'FinalCompleteDtm', RTFRecord<RETURN_TO_FAB_LOTS_FINAL_COMPLETE_DTM$>)
|
||||||
SRP_JSON(objRTF, 'SetValue', 'Completed', RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>, 'Boolean')
|
SRP_JSON(objRTF, 'SetValue', 'Completed', RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>, 'Boolean')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user