Button
API endpoint: /plugin/button
Allows you to create a button (link with URL) in the administration of the e-shop for a custom action. Parameters can be added to the called URL depending on the nature of the button (e.g. list of selected orders)
Possible extension:
Selector | Parameters | Description |
---|---|---|
admin:orders:export | order=1,2,3 | Transmits a list of selected orders in the administration. |
Creating a button
POST /plugin/button
{ "selector": "admin:orders:export", "actionUrl": "https://plugin.tdl/action?eshop=_ESHOP_CODE_", "label": "Doplněk test", "icon": "https://plugin.tld/images/icon.png" }
Example:
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.webareal.cz/plugin/button', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode([ "selector" => "admin:orders:export", "actionUrl" => "https://plugin.tdl/action?eshop=_ESHOP_CODE_", "label" => "Doplněk test", "icon" => "https://plugin.tld/images/icon.png" ]) CURLOPT_HTTPHEADER => array( 'X-Wa-api-token: ' . $api_token, // apiToken získáte při instalaci doplňku, viz. nápověda 'Authorization: Bearer ' . $bearer, // access token získáte zde, údaje zde (záložka API přístup) 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
Removing the button
DELETE /plugin/button/{id}
Example:
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.webareal.cz/plugin/button/{id}', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'DELETE', CURLOPT_HTTPHEADER => array( 'X-Wa-api-token: ' . $api_token, // apiToken získáte při instalaci doplňku, viz. nápověda 'Authorization: Bearer ' . $bearer, // access token získáte zde, údaje zde (záložka API přístup) 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;