-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Labels
enhancement in SDKNew feature or request in SDKNew feature or request in SDK
Milestone
Description
Todo
- implementation
- documentation
- example
Description
When creating your own applications for boxed editions, there is a need to add new methods for them to the REST API.
Procedure:
- The OnRestServiceBuildDescription event handler of the rest module is registered.
return array(
'имя_scope' => array(
'method_name' => array(
'callback' => method_handler,
'options' => array(),
),
'method_name' => array(
'callback' => method_handler,
'options' => array(),
),
)
);- The scope name is arbitrary. If you register your own scope, it will be available in the list of permissions for local applications. To add methods to an existing scope, specify the method name. If you add methods that are available to all applications, specify the constant \CRestUtil::GLOBAL_SCOPE instead of the name.
The method name is also arbitrary, both upper and lower case are allowed. But it is recommended to stick to the lower case. The traditional naming is scope_name.entity_name.action.
http://cp.sigurd.bx/rest/sigurdtest.test?auth=qcdfzzjtp8hvcbjl42eg93wuw5n0mvsb&test=222
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"result": {
"myresponse": "My own response",
"yourquery": {
"test": "222"
}
}
}
http://cp.sigurd.bx/rest/sigurdtest.test.xml?auth=qcdfzzjtp8hvcbjl42eg93wuw5n0mvsb&error=1
HTTP/1.1 402 Payment Required
Content-Type: text/xml; charset=utf-8
<?xml version="1.0" ?>
<response>
<error>ERROR_CODE</error>
<error_description>Message</error_description>
</response>Example
- refactor Scope
Metadata
Metadata
Assignees
Labels
enhancement in SDKNew feature or request in SDKNew feature or request in SDK