Data provider class
In the Hub API Designer, each Hub API is connected to one data provider class
(DPC). To make a class available in the Hub API Designer, the DPC needs to
implement the /neptune/if_dxp_api_dpc interface.
If the system supports setting the ABAP Language Version, set it to ABAP for Cloud Development and release the class for use in Cloud Development.
Neptune support the following way of class instantiation:
-
A
get_instancemethod without mandatory importing parameters, which returns an instance of the class. -
A
create_instancemethod without mandatory importing parameters, which returns an instance of the class. -
The classical way of creating an instance publicly via
create objectwithout mandatory constructor parameters.
Methods and bindings
In the Hub API Designer, each operation is connected to one public method in the API DPC.
Bindings can be set up using method signature parameters, public attributes in the DPC, or a combination thereof. These are populated automatically with matching data sent in the call to the Hub API Operation. Conversely, the response is automatically populated with the corresponding data from the DPC.
There is also the possibility to handle the data manually for the request, the response, or both.
Request data
When a Hub API operation is called, data related to the call is populated into the
/neptune/if_dxp_api_dpc~data_request structure`. In typical use cases with regular
DPC bindings, there is no need to read and react to this data manually. However,
for manual use cases, accessing this structure is required.
The available data is:
Request data table
| Field | Content |
|---|---|
|
API path set in Hub API Designer |
|
Operation path set in Hub API Designer |
|
HTTP method used for this call |
|
Table of all form (query) fields in the request |
|
Table of all header fields in the request |
|
String body data (when data is in text format) |
|
Binary body data (when data is in binary format) |
|
Table of multiparts (when data is in multipart format) |
Response data
It is possible to manually set the response data for a Hub API operation call by
populating the /neptune/if_dxp_api_dpc~data_response structure. In typical use
cases with regular DPC bindings on the response, this is not necessary. However,
for manual use cases, it is required.
The available data is:
Request data table
| Field | Content |
|---|---|
|
Text response content |
|
Binary response content |
|
Response content type |
|
HTTP response status code |
|
HTTP response status text |
|
Status message |
|
Table of cookie adjustments |
|
Table of header adjustments |
Manually setting content, even if a DPC response binding is specified, will
override the binding and send the manual content in the response. Set either the
text based content or binary content_x based on the response content-type.
If no status code is manually set, the default 200 OK will be sent.
If a status code is set but the content is left empty, the content will be set to
a JSON representation of the status_code, status_text, and status_message
(formatted as errorCode).
It is also possible to define the /neptune/cx_dxp_http exception in your method
signature and raise it with the status_code, status_text, and status_message
values that make sense for your use case. This will abort execution, set the specified
HTTP status, and return the errorCode JSON in the response.
The cookies and headers tables can be used to add or delete cookies and headers at the client.