fetchdocs.io - Fetch UI API documentation version v1
https://ui.fetchdocs.io
Overview
fetchdocs.io - Fetch UI API documentation provides details for UI Plug&Play Integration. All access is restricted by a customer access token.
You can also download the documentation in RAML-Format..
SAMPLE PHP CODE
====================================
$data_string = json_encode(array(
"api_key" => "XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX" // This is the default fetchdocs.io API Test-Key. Please put your personal key here.
));
$ch = curl_init("https://api.fetchdocs.io/fetch/v1/createCustomer");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Content-Length: ".strlen($data_string))
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$return_data = curl_exec($ch);
curl_close($ch);
// Return data will have a json data like
{
"success": true,
"data": {
"prim_uid": 1, // Our unique customer id. This is needed to update the customer or assign any downloaded documents.
"customer_secret": "this_is_the_customer_secret_token", // a secret token you have to use to get data for the customer that was just created
"access_token": "customer_access_token" // Access token used to authenticate the ui dialogs if they are used.
}
}
Use the access_token to implement the UI Plug&Play Integration.
UI-Urls:
- Production: https://ui.fetchdocs.io
- Stage: https://ui.stage.fetchdocs.io
Please note that the api key provided is only valid for either stage or production.
Redirect:
If you want a automatic redirect back to your system with some additional values you can use the "ui_redirect_url" at a /createEnvironment. After the user added or updated a customer supplier via the UI we will redirect to the url from "ui_redirect_url" and add some get parameters:
- success = true/false
- customer_id = the id of the customer
- supplier_id = the supplier id
- customer_supplier_id = the new or updated customer supplier id
- timestamp = current timestamp
- checksum = a unique checksum for the get parameters
The checksum is generated based on the get parameter values.
hash_value = success.':'.customer_id.':'.supplier_id.':'.customer_supplier_id.':'.timestamp.':'.shared_key_from_the_environment
checksum = hash_hmac('sha256', hash_value, shared_hash_key_from_the_environment);
Redirect Codes:
In case the UI is requested with missing or invalid parameters the customer is redirected back to the redirect url and a error code is added. The possible values for error_code are:
- USER_CANCELLED = User has clicked on cancel and is therefore redirected back.
- INVALID_RECORD = Record like customer supplier does not exist or is not valid for this session.
- INVALID_STATE = Customer supplier is found but no input request. (Can only occur on fill-input-request.php when loaded with parameter customer_supplier_prim_uid )
- INVALID_SESSION = Unknown or invalid session.
- MISSING_REQUIRED_PARAMETERS = A required parameter is missing
General Pointers
- HTTPS only: All requests are done over HTTPS.
- UTF-8 encoding: All strings are sent and received in UTF-8.
Add customer supplier
Load and show dialog for a customer to add a customer supplier. Notes: Adding a customer supplier will not instantly validate the credentials. They will be validated later during download and a notification is created in case that they are invalid.
Edit customer supplier
Load and show dialog for a customer to update a customer supplier. Notes: Updating a customer supplier will not instantly validate the credentials. They will be validated later during download and a notification is created in case that they are invalid.
List customer suppliers
Load and show dialog for a customer to list all connected suppliers
Fill input request
Load and show dialog for a customer to fill a input request
Usage of UI Plug&Play Integration is restricted by customer access token.