aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-10-29 01:43:09 +0300
committerValentin Popov <info@valentineus.link>2018-10-29 01:43:09 +0300
commit0a44411f980ba8f36d6f4e71f42bf7c723847648 (patch)
treebb7869114902c52786575e4340ea4c656d1b5e36
parentb8e61c44ac2af52b4b3daa70f32e478e369dc140 (diff)
downloadlocal_webhooks-0a44411f980ba8f36d6f4e71f42bf7c723847648.tar.xz
local_webhooks-0a44411f980ba8f36d6f4e71f42bf7c723847648.zip
External service search function by event
Signed-off-by: Valentin Popov <info@valentineus.link>
-rw-r--r--externallib.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/externallib.php b/externallib.php
index 2b43d34..279ffbd 100644
--- a/externallib.php
+++ b/externallib.php
@@ -155,4 +155,70 @@ class local_webhooks_external extends external_api {
)
);
}
+
+ /**
+ * Returns description of method parameters.
+ *
+ * @return \external_function_parameters
+ *
+ * @since Moodle 2.2
+ * @since Moodle 2.9 Options available
+ */
+ public static function get_services_by_event_parameters() {
+ return new external_function_parameters(
+ array(
+ 'eventname' => new external_value(PARAM_RAW, 'Event name.'),
+ )
+ );
+ }
+
+ /**
+ * Get the list of services subscribed to the event.
+ *
+ * @param $eventname
+ *
+ * @return array
+ *
+ * @since Moodle 2.2
+ * @since Moodle 2.9 Options available
+ *
+ * @throws \dml_exception
+ * @throws \invalid_parameter_exception
+ * @throws \moodle_exception
+ * @throws \restricted_context_exception
+ */
+ public static function get_services_by_event($eventname) {
+ $parameters = self::validate_parameters(self::get_services_by_event_parameters(), array('eventname' => $eventname));
+
+ $context = context_system::instance();
+ self::validate_context($context);
+
+ return local_webhooks_api::get_services_by_event($parameters['eventname']);
+ }
+
+ /**
+ * Returns description of method result value.
+ *
+ * @return \external_multiple_structure
+ *
+ * @since Moodle 2.2
+ * @since Moodle 2.9 Options available
+ */
+ public static function get_services_by_event_returns() {
+ return new external_multiple_structure(
+ new external_single_structure(
+ array(
+ 'id' => new external_value(PARAM_INT, 'Service ID.'),
+ 'header' => new external_value(PARAM_RAW, 'Type of outgoing header.'),
+ 'name' => new external_value(PARAM_RAW, 'Name of the service.'),
+ 'point' => new external_value(PARAM_URL, 'Point of delivery of notifications.'),
+ 'status' => new external_value(PARAM_BOOL, 'Current status of the service.'),
+ 'token' => new external_value(PARAM_RAW, 'Token for verification of requests.'),
+ 'events' => new external_multiple_structure(
+ new external_value(PARAM_RAW, 'Event name.'), 'List of events.'
+ ),
+ )
+ )
+ );
+ }
} \ No newline at end of file