|
| 1 | +<?php |
| 2 | +namespace tests\apis\multiple; |
| 3 | + |
| 4 | +use webfiori\http\AbstractWebService; |
| 5 | +use webfiori\http\ParamType; |
| 6 | +use webfiori\http\ParamOption; |
| 7 | +use webfiori\http\RequestMethod; |
| 8 | + |
| 9 | + |
| 10 | +/** |
| 11 | + * A class that contains the implementation of the web service 'say-hi-service'. |
| 12 | + * This service has the following parameters: |
| 13 | + * <ul> |
| 14 | + * <li><b>first-name</b>: Data type: string.</li> |
| 15 | + * <li><b>last-name</b>: Data type: string.</li> |
| 16 | + * <li><b>age</b>: Data type: integer.</li> |
| 17 | + * </ul> |
| 18 | + */ |
| 19 | +class WebService00 extends AbstractWebService { |
| 20 | + /** |
| 21 | + * Creates new instance of the class. |
| 22 | + */ |
| 23 | + public function __construct() { |
| 24 | + parent::__construct('say-hi-service'); |
| 25 | + $this->setDescription(''); |
| 26 | + $this->setRequestMethods([ |
| 27 | + RequestMethod::GET, |
| 28 | + RequestMethod::POST, |
| 29 | + RequestMethod::PATCH, |
| 30 | + RequestMethod::HEAD |
| 31 | + ]); |
| 32 | + $this->addParameters([ |
| 33 | + 'first-name' => [ |
| 34 | + ParamOption::TYPE => ParamType::STRING, |
| 35 | + ], |
| 36 | + 'last-name' => [ |
| 37 | + ParamOption::TYPE => ParamType::STRING, |
| 38 | + ], |
| 39 | + 'age' => [ |
| 40 | + ParamOption::TYPE => ParamType::INT, |
| 41 | + ParamOption::OPTIONAL => true, |
| 42 | + ], |
| 43 | + ]); |
| 44 | + } |
| 45 | + /** |
| 46 | + * Checks if the client is authorized to call a service or not. |
| 47 | + * |
| 48 | + * @return boolean If the client is authorized, the method will return true. |
| 49 | + */ |
| 50 | + public function isAuthorized() { |
| 51 | + // TODO: Check if the client is authorized to call the service 'say-hi-service'. |
| 52 | + // You can ignore this method or remove it. |
| 53 | + //$authHeader = $this->getAuthHeader(); |
| 54 | + //$authType = $authHeader['type']; |
| 55 | + //$token = $authHeader['credentials']; |
| 56 | + } |
| 57 | + /** |
| 58 | + * Process the request. |
| 59 | + */ |
| 60 | + public function processRequest() { |
| 61 | + // TODO: process the request for the service 'say-hi-service'. |
| 62 | + $this->getManager()->serviceNotImplemented(); |
| 63 | + } |
| 64 | +} |
0 commit comments