<?php

namespace SHServ\Routes;

trait ScriptsRESTAPI_v1 {
	protected function scripts_restapi_uri_routes() {
		$this -> router -> uri("/api/v1/scripts/actions/list", "{$this -> cn}\\ScriptsRESTAPIController@actions_scripts_list");
		$this -> router -> uri('/api/v1/scripts/actions/alias/$uniq_name', "{$this -> cn}\\ScriptsRESTAPIController@action_script");
		$this -> router -> uri("/api/v1/scripts/scopes/list", "{$this -> cn}\\ScriptsRESTAPIController@scope_list");
		$this -> router -> uri("/api/v1/scripts/regular/list", "{$this -> cn}\\ScriptsRESTAPIController@regular_scripts_list");
		$this -> router -> uri('/api/v1/scripts/scopes/name/$name', "{$this -> cn}\\ScriptsRESTAPIController@scope_file");

		$this -> router -> uri('/api/v1/scripts/actions/alias/$uniq_name/$state', "{$this -> cn}\\ScriptsRESTAPIController@set_action_script_state");
		$this -> router -> uri('/api/v1/scripts/scopes/name/$uniq_name/$state', "{$this -> cn}\\ScriptsRESTAPIController@set_scope_state");
		$this -> router -> uri('/api/v1/scripts/regular/alias/$uniq_name/$state', "{$this -> cn}\\ScriptsRESTAPIController@set_regular_script_state");
		$this -> router -> uri('/api/v1/scripts/id/$target_id/unassign-from-area', "{$this -> cn}\\ScriptsRESTAPIController@unassign_from_area");
		$this -> router -> uri('/api/v1/scripts/timers/list', "{$this -> cn}\\ScriptsRESTAPIController@timers_list");
	}

	protected function scripts_restapi_post_routes() {
		$this -> router -> post(
			[ "alias", "params" ],
			"{$this -> cn}\\ScriptsRESTAPIController@run_action_script",
			'/api/v1/scripts/actions/run'
		);

		$this -> router -> post(
			[ "target_id", "place_in_area_id" ],
			"{$this -> cn}\\ScriptsRESTAPIController@place_in_area",
			"/api/v1/scripts/place-in-area"
		);

		$this -> router -> post(
			[ "name", "source" ],
			"{$this -> cn}\\ScriptsRESTAPIController@scope_update",
			'/api/v1/scripts/scopes/update'
		);

		$this -> router -> post(
			[ "timer_alias" ],
			"{$this -> cn}\\ScriptsRESTAPIController@timers_cancel",
			'/api/v1/scripts/timers/cancel'
		);
	}

	protected function scripts_restapi_get_routes() {
	
	}
}