|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace OpenCloud\Common\Api; |
| 4 | + |
| 5 | +abstract class AbstractParams |
| 6 | +{ |
| 7 | + // locations |
| 8 | + const QUERY = 'query'; |
| 9 | + const HEADER = 'header'; |
| 10 | + const URL = 'url'; |
| 11 | + const JSON = 'json'; |
| 12 | + const RAW = 'raw'; |
| 13 | + |
| 14 | + // types |
| 15 | + const STRING_TYPE = "string"; |
| 16 | + const BOOL_TYPE = "boolean"; |
| 17 | + const BOOLEAN_TYPE = self::BOOL_TYPE; |
| 18 | + const OBJECT_TYPE = "object"; |
| 19 | + const ARRAY_TYPE = "array"; |
| 20 | + const NULL_TYPE = "NULL"; |
| 21 | + const INT_TYPE = 'integer'; |
| 22 | + const INTEGER_TYPE = self::INT_TYPE; |
| 23 | + |
| 24 | + public static function isSupportedLocation($val) |
| 25 | + { |
| 26 | + return in_array($val, [self::QUERY, self::HEADER, self::URL, self::JSON, self::RAW]); |
| 27 | + } |
| 28 | + |
| 29 | + public function limit() |
| 30 | + { |
| 31 | + return [ |
| 32 | + 'type' => self::INT_TYPE, |
| 33 | + 'location' => 'query', |
| 34 | + 'description' => <<<DESC |
| 35 | +This will limit the total amount of elements returned in a list up to the number specified. For example, specifying a |
| 36 | +limit of 10 will return 10 elements, regardless of the actual count. |
| 37 | +DESC |
| 38 | + ]; |
| 39 | + } |
| 40 | + |
| 41 | + public function marker() |
| 42 | + { |
| 43 | + return [ |
| 44 | + 'type' => 'string', |
| 45 | + 'location' => 'query', |
| 46 | + 'description' => <<<DESC |
| 47 | +Specifying a marker will begin the list from the value specified. Elements will have a particular attribute that |
| 48 | +identifies them, such as a name or ID. The marker value will search for an element whose identifying attribute matches |
| 49 | +the marker value, and begin the list from there. |
| 50 | +DESC |
| 51 | + ]; |
| 52 | + } |
| 53 | + |
| 54 | + public function id($type) |
| 55 | + { |
| 56 | + return [ |
| 57 | + 'description' => sprintf("The unique ID, or identifier, for the %s", $type), |
| 58 | + 'type' => self::STRING_TYPE, |
| 59 | + 'location' => self::JSON, |
| 60 | + ]; |
| 61 | + } |
| 62 | + |
| 63 | + public function idPath() |
| 64 | + { |
| 65 | + return [ |
| 66 | + 'type' => self::STRING_TYPE, |
| 67 | + 'location' => self::URL, |
| 68 | + 'description' => 'The unique ID of the resource', |
| 69 | + ]; |
| 70 | + } |
| 71 | + |
| 72 | + public function name($resource) |
| 73 | + { |
| 74 | + return [ |
| 75 | + 'description' => sprintf("The name of the %s", $resource), |
| 76 | + 'type' => self::STRING_TYPE, |
| 77 | + 'location' => self::JSON, |
| 78 | + ]; |
| 79 | + } |
| 80 | + |
| 81 | + |
| 82 | + public function sortDir() |
| 83 | + { |
| 84 | + return [ |
| 85 | + 'type' => self::STRING_TYPE, |
| 86 | + 'location' => self::QUERY, |
| 87 | + 'description' => "Sorts by one or more sets of attribute and sort direction combinations.", |
| 88 | + 'enum' => ['asc', 'desc'] |
| 89 | + ]; |
| 90 | + } |
| 91 | + |
| 92 | + public function sortKey() |
| 93 | + { |
| 94 | + return [ |
| 95 | + 'type' => self::STRING_TYPE, |
| 96 | + 'location' => self::QUERY, |
| 97 | + 'description' => "Sorts by one or more sets of attribute and sort direction combinations.", |
| 98 | + ]; |
| 99 | + } |
| 100 | +} |
0 commit comments