unee-t / enterprise-rest-api

RestFUL API on Unee-T enterprise
https://eapi.dev.unee-t.com/
0 stars 1 forks source link

API to check if a unit has been created #10

Open franck-boullier opened 5 years ago

franck-boullier commented 5 years ago

As part of #3 we also need an endpoint so that the 3rd party can check if the unit has been correctly created:

How it should work:

Background information:

The information is available in the UNTE Database in the table unte_api_add_unit. From this table, it is possible to retrieve the following information

The different ways to retrieve the information:

Option 1:

In this option the 3rd party only needs the information from it's internal source of truth

User Input:

The user sends the following information as part of the payload:

Output:

Based on the value specified in infoNeeded

All or [unspecified]:

return all the information:

mefeUnitId:

return the information:

createdDatetime:

return the information:

status:

return the information:

errorMessage:

return the information:

Option 2:

In this option the 3rd party only need to have stored the requestId that was generated when the unit creation was request (see #3)

User Input:

The user sends the following information as part of the payload:

Output:

Based on the value specified in infoNeeded

All or [unspecified]:

return all the information:

mefeUnitId:

return the information:

createdDatetime:

return the information:

status:

return the information:

errorMessage:

return the information:

How to get the information from the UNTE DB:

This is done by passing some SQL variables and calling a specific procedure

The variables:

@organization_key: This can NOT be NULL @request_id:

The SQL syntax:

SET @organization_key = [organizationKey];
SET @request_id = [requestId];
SET @external_id = [externalId];
SET @external_system = [externalSystem OR NULL];
SET @table_in_external_system = [tableInExternalSystem OR NULL];
SET @info_needed = [infoNeeded OR NULL];
CALL `proc_unte_api_check_unit_creation` ;
kaihendry commented 5 years ago

Is the mandatory organizationKey really necessary? We could look it up with the unguessable external_id/request_id. We already use a bearer token to authenticate the unit create API call. Or is organizationKey meant to authenticate the calls?

Since usually the -H "Authorization: Bearer ...secret.." is used for API authentication. But if it's not the case with these APIs I'll update.

kaihendry commented 5 years ago

Do you have an example of the output of

  `CALL `proc_unte_api_check_unit_creation` ;`?

I hoped I could just lookup the row with external_id/request_id and return it verbatim. I don't quite understand why we need to call a routine to check the status of the job.

Also I'm confused as to the structure of the response. Ideally it maps as closely to the existing unte_api_add_unit table structure. i.e.

Otherwise another layer of mappings need to be written.

franck-boullier commented 5 years ago

is organizationKey meant to authenticate the calls?

That is correct: organizationKey is meant to authenticate the calls and make sure that the user calling the API is allowed to make the call.

kaihendry commented 5 years ago

Let me know when proc_unte_api_check_unit_creation is ready to go so I can resume this work.