diff options
-rw-r--r-- | db/services.php | 53 | ||||
-rw-r--r-- | externallib.php | 46 |
2 files changed, 61 insertions, 38 deletions
diff --git a/db/services.php b/db/services.php index 1a2d41f..864b369 100644 --- a/db/services.php +++ b/db/services.php @@ -17,35 +17,58 @@ /** * This file registers the plugin's external functions. * - * @copyright 2018 'Valentin Popov' <info@valentineus.link> + * @copyright 2019 'Valentin Popov' <info@valentineus.link> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @package local_webhooks */ defined('MOODLE_INTERNAL') || die(); -$functions = array( - 'local_webhooks_get_service' => array( +$functions = [ + 'local_webhooks_add_service' => [ 'classname' => 'local_webhooks_external', 'classpath' => 'local/webhooks/externallib.php', - 'description' => 'Get information about the service.', + 'description' => 'Add a new service.', + 'methodname' => 'add_service', + 'type' => 'write', + ], + + 'local_webhooks_del_service' => [ + 'classname' => 'local_webhooks_external', + 'classpath' => 'local/webhooks/externallib.php', + 'description' => 'Delete the existing service.', + 'methodname' => 'del_service', + 'type' => 'write', + ], + + 'local_webhooks_get_events' => [ + 'classname' => 'local_webhooks_external', + 'classpath' => 'local/webhooks/externallib.php', + 'description' => 'Get the event\'s list.', + 'methodname' => 'get_events', + 'type' => 'read', + ], + + 'local_webhooks_get_service' => [ + 'classname' => 'local_webhooks_external', + 'classpath' => 'local/webhooks/externallib.php', + 'description' => 'Get data by service.', 'methodname' => 'get_service', 'type' => 'read', - ), + ], - 'local_webhooks_get_services' => array( + 'local_webhooks_get_services' => [ 'classname' => 'local_webhooks_external', 'classpath' => 'local/webhooks/externallib.php', - 'description' => 'Get a list of services.', + 'description' => 'Get the service\'s list.', 'methodname' => 'get_services', 'type' => 'read', - ), + ], - 'local_webhooks_get_services_by_event' => array( + 'local_webhooks_set_service' => [ 'classname' => 'local_webhooks_external', 'classpath' => 'local/webhooks/externallib.php', - 'description' => 'Get the list of services subscribed to the event.', - 'methodname' => 'get_services_by_event', - 'type' => 'read', - ), -);
\ No newline at end of file + 'description' => 'Update the existing service.', + 'methodname' => 'set_service', + 'type' => 'write', + ], +];
\ No newline at end of file diff --git a/externallib.php b/externallib.php index 1e4884a..b4a6da8 100644 --- a/externallib.php +++ b/externallib.php @@ -73,8 +73,8 @@ final class local_webhooks_external extends external_api { 'point' => new external_value(PARAM_URL, 'The service\'s endpoint.'), 'status' => new external_value(PARAM_BOOL, 'The service\'s status.', false, true), 'token' => new external_value(PARAM_RAW, 'The service\'s secret key.'), - ], ''), - ], ''); + ], 'The new service\'s data.'), + ]); } /** @@ -116,7 +116,7 @@ final class local_webhooks_external extends external_api { public static function del_service_parameters(): external_function_parameters { return new external_function_parameters([ 'serviceid' => new external_value(PARAM_INT, 'The service\'s ID.'), - ], ''); + ]); } /** @@ -151,7 +151,7 @@ final class local_webhooks_external extends external_api { * @return \external_function_parameters */ public static function get_events_parameters(): external_function_parameters { - return new external_function_parameters([], ''); + return new external_function_parameters([]); } /** @@ -162,14 +162,14 @@ final class local_webhooks_external extends external_api { public static function get_events_returns(): external_multiple_structure { return new external_multiple_structure( new external_single_structure([ - 'action' => new external_value(PARAM_ALPHANUMEXT, ''), - 'component' => new external_value(PARAM_COMPONENT, ''), - 'crud' => new external_value(PARAM_ALPHA, ''), - 'edulevel' => new external_value(PARAM_INT, ''), - 'eventname' => new external_value(PARAM_RAW, ''), - 'objecttable' => new external_value(PARAM_RAW, ''), - 'target' => new external_value(PARAM_RAW, ''), - ], ''), '' + 'action' => new external_value(PARAM_ALPHANUMEXT, 'The action name.'), + 'component' => new external_value(PARAM_COMPONENT, 'The component name.'), + 'crud' => new external_value(PARAM_ALPHA, 'The transaction type.'), + 'edulevel' => new external_value(PARAM_INT, 'The level of educational value.'), + 'eventname' => new external_value(PARAM_RAW, 'The event name.'), + 'objecttable' => new external_value(PARAM_RAW, 'The database table name.'), + 'target' => new external_value(PARAM_RAW, 'The target on which the action.'), + ], 'The event\'s data.'), 'The event\'s list.' ); } @@ -203,7 +203,7 @@ final class local_webhooks_external extends external_api { public static function get_service_parameters(): external_function_parameters { return new external_function_parameters([ 'serviceid' => new external_value(PARAM_INT, 'The service\'s ID.'), - ], ''); + ]); } /** @@ -222,7 +222,7 @@ final class local_webhooks_external extends external_api { 'point' => new external_value(PARAM_URL, 'The service\'s endpoint.'), 'status' => new external_value(PARAM_BOOL, 'The service\'s status.'), 'token' => new external_value(PARAM_RAW, 'The service\'s secret key.'), - ], ''); + ], 'The service\'s data.'); } /** @@ -271,11 +271,11 @@ final class local_webhooks_external extends external_api { 'point' => new external_value(PARAM_URL, 'The service\'s endpoint.', false), 'status' => new external_value(PARAM_BOOL, 'The service\'s status.', false), 'token' => new external_value(PARAM_RAW, 'The service\'s secret key.', false), - ], '', false), - 'sort' => new external_value(PARAM_RAW, '', false), - 'from' => new external_value(PARAM_INT, '', false), - 'limit' => new external_value(PARAM_INT, '', false), - ], ''); + ], 'SQL conditions.', false), + 'sort' => new external_value(PARAM_RAW, 'SQL sort parameters.', false), + 'from' => new external_value(PARAM_INT, 'The start index.', false), + 'limit' => new external_value(PARAM_INT, 'The count elements.', false), + ]); } /** @@ -295,7 +295,7 @@ final class local_webhooks_external extends external_api { 'point' => new external_value(PARAM_URL, 'The service\'s endpoint.'), 'status' => new external_value(PARAM_BOOL, 'The service\'s status.'), 'token' => new external_value(PARAM_RAW, 'The service\'s secret key.'), - ], ''), '' + ], 'The service\'s data.'), 'The service\'s list.' ); } @@ -351,8 +351,8 @@ final class local_webhooks_external extends external_api { 'point' => new external_value(PARAM_URL, 'The service\'s endpoint.', false), 'status' => new external_value(PARAM_BOOL, 'The service\'s status.', false), 'token' => new external_value(PARAM_RAW, 'The service\'s secret key.', false), - ], ''), - ], ''); + ], 'The new service\'s data.'), + ]); } /** @@ -361,6 +361,6 @@ final class local_webhooks_external extends external_api { * @return \external_value */ public static function set_service_returns(): external_value { - return new external_value(PARAM_BOOL, ''); + return new external_value(PARAM_BOOL, 'The result operation.'); } }
\ No newline at end of file |