@@ -8,131 +8,131 @@ |
||
| 8 | 8 | |
| 9 | 9 | class OptimizationProblemParams extends \Route4Me\Common |
| 10 | 10 | { |
| 11 | - public $optimization_problem_id; |
|
| 12 | - public $reoptimize; |
|
| 13 | - public $addresses = []; |
|
| 14 | - public $depots = []; |
|
| 15 | - public $parameters; |
|
| 16 | - public $directions; |
|
| 17 | - public $format; |
|
| 18 | - public $route_path_output; |
|
| 19 | - public $optimized_callback_url; |
|
| 20 | - public $redirect = true; |
|
| 21 | - |
|
| 22 | - public static function fromArray($params) |
|
| 23 | - { |
|
| 24 | - $param = new self(); |
|
| 25 | - if (!isset($params['addresses'])) { |
|
| 26 | - throw new BadParam('addresses must be provided.'); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - if (!isset($params['parameters'])) { |
|
| 30 | - throw new BadParam('parameters must be provided.'); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - if ($params['parameters'] instanceof RouteParameters) { |
|
| 34 | - $param->setParameters($params['parameters']); |
|
| 35 | - } else { |
|
| 36 | - $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - foreach ($params['addresses'] as $address) { |
|
| 40 | - if (!($address instanceof AddressV5)) { |
|
| 41 | - $address = AddressV5::fromArray($address); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $param->addAddress($address); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - if (isset($params['depots'] )) { |
|
| 48 | - foreach ($params['depots'] as $depot) { |
|
| 49 | - if (!($depot instanceof AddressV5)) { |
|
| 50 | - $depot = AddressV5::fromArray($depot); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - $param->addAddress($address); |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $param->directions = self::getValue($params, 'directions'); |
|
| 58 | - $param->format = self::getValue($params, 'format'); |
|
| 59 | - $param->route_path_output = self::getValue($params, 'route_path_output'); |
|
| 60 | - $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url'); |
|
| 61 | - $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id'); |
|
| 62 | - $param->reoptimize = self::getValue($params, 'reoptimize'); |
|
| 63 | - $param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN); |
|
| 64 | - |
|
| 65 | - return $param; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - public function __construct() |
|
| 69 | - { |
|
| 70 | - $this->parameters = new RouteParameters(); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - public function setParameters(RouteParameters $params) |
|
| 74 | - { |
|
| 75 | - $this->parameters = $params; |
|
| 76 | - |
|
| 77 | - return $this; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - public function addAddress(AddressV5 $address) |
|
| 81 | - { |
|
| 82 | - $this->addresses[] = $address; |
|
| 83 | - |
|
| 84 | - return $this; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - public function addDepot(AddressV5 $depot) |
|
| 88 | - { |
|
| 89 | - $this->depots[] = $depot; |
|
| 90 | - |
|
| 91 | - return $this; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - public function getAddressesArray() |
|
| 95 | - { |
|
| 96 | - $addresses = []; |
|
| 97 | - |
|
| 98 | - foreach ($this->addresses as $address) { |
|
| 99 | - $addresses[] = $address->toArray(); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - return $addresses; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - public function getDepotsArray() |
|
| 106 | - { |
|
| 107 | - $depots = []; |
|
| 108 | - |
|
| 109 | - foreach ($this->depots as $depot) { |
|
| 110 | - $depots[] = $depot->toArray(); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - return $depots; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - public function getParametersArray() |
|
| 117 | - { |
|
| 118 | - return $this->parameters->toArray(); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - public function setAddresses(array $addresses) |
|
| 122 | - { |
|
| 123 | - foreach ($addresses as $address) { |
|
| 124 | - $this->addAddress($address); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - return $this; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - public function setDepots(array $depots) |
|
| 131 | - { |
|
| 132 | - foreach ($depots as $depot) { |
|
| 133 | - $this->addDepot($depot); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - return $this; |
|
| 137 | - } |
|
| 11 | + public $optimization_problem_id; |
|
| 12 | + public $reoptimize; |
|
| 13 | + public $addresses = []; |
|
| 14 | + public $depots = []; |
|
| 15 | + public $parameters; |
|
| 16 | + public $directions; |
|
| 17 | + public $format; |
|
| 18 | + public $route_path_output; |
|
| 19 | + public $optimized_callback_url; |
|
| 20 | + public $redirect = true; |
|
| 21 | + |
|
| 22 | + public static function fromArray($params) |
|
| 23 | + { |
|
| 24 | + $param = new self(); |
|
| 25 | + if (!isset($params['addresses'])) { |
|
| 26 | + throw new BadParam('addresses must be provided.'); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + if (!isset($params['parameters'])) { |
|
| 30 | + throw new BadParam('parameters must be provided.'); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + if ($params['parameters'] instanceof RouteParameters) { |
|
| 34 | + $param->setParameters($params['parameters']); |
|
| 35 | + } else { |
|
| 36 | + $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + foreach ($params['addresses'] as $address) { |
|
| 40 | + if (!($address instanceof AddressV5)) { |
|
| 41 | + $address = AddressV5::fromArray($address); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $param->addAddress($address); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + if (isset($params['depots'] )) { |
|
| 48 | + foreach ($params['depots'] as $depot) { |
|
| 49 | + if (!($depot instanceof AddressV5)) { |
|
| 50 | + $depot = AddressV5::fromArray($depot); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + $param->addAddress($address); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $param->directions = self::getValue($params, 'directions'); |
|
| 58 | + $param->format = self::getValue($params, 'format'); |
|
| 59 | + $param->route_path_output = self::getValue($params, 'route_path_output'); |
|
| 60 | + $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url'); |
|
| 61 | + $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id'); |
|
| 62 | + $param->reoptimize = self::getValue($params, 'reoptimize'); |
|
| 63 | + $param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN); |
|
| 64 | + |
|
| 65 | + return $param; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + public function __construct() |
|
| 69 | + { |
|
| 70 | + $this->parameters = new RouteParameters(); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + public function setParameters(RouteParameters $params) |
|
| 74 | + { |
|
| 75 | + $this->parameters = $params; |
|
| 76 | + |
|
| 77 | + return $this; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + public function addAddress(AddressV5 $address) |
|
| 81 | + { |
|
| 82 | + $this->addresses[] = $address; |
|
| 83 | + |
|
| 84 | + return $this; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + public function addDepot(AddressV5 $depot) |
|
| 88 | + { |
|
| 89 | + $this->depots[] = $depot; |
|
| 90 | + |
|
| 91 | + return $this; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + public function getAddressesArray() |
|
| 95 | + { |
|
| 96 | + $addresses = []; |
|
| 97 | + |
|
| 98 | + foreach ($this->addresses as $address) { |
|
| 99 | + $addresses[] = $address->toArray(); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + return $addresses; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + public function getDepotsArray() |
|
| 106 | + { |
|
| 107 | + $depots = []; |
|
| 108 | + |
|
| 109 | + foreach ($this->depots as $depot) { |
|
| 110 | + $depots[] = $depot->toArray(); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + return $depots; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + public function getParametersArray() |
|
| 117 | + { |
|
| 118 | + return $this->parameters->toArray(); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + public function setAddresses(array $addresses) |
|
| 122 | + { |
|
| 123 | + foreach ($addresses as $address) { |
|
| 124 | + $this->addAddress($address); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + return $this; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + public function setDepots(array $depots) |
|
| 131 | + { |
|
| 132 | + foreach ($depots as $depot) { |
|
| 133 | + $this->addDepot($depot); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + return $this; |
|
| 137 | + } |
|
| 138 | 138 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | $param->addAddress($address); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (isset($params['depots'] )) { |
|
| 47 | + if (isset($params['depots'])) { |
|
| 48 | 48 | foreach ($params['depots'] as $depot) { |
| 49 | 49 | if (!($depot instanceof AddressV5)) { |
| 50 | 50 | $depot = AddressV5::fromArray($depot); |
@@ -13,154 +13,154 @@ |
||
| 13 | 13 | |
| 14 | 14 | class OptimizationProblem extends Common |
| 15 | 15 | { |
| 16 | - /** @var int $state |
|
| 17 | - * An optimization problem state. |
|
| 18 | - * Available values: |
|
| 19 | - * OptimizationStateNew = 0, |
|
| 20 | - * Initial = 1, |
|
| 21 | - * MatrixProcessing = 2, |
|
| 22 | - * Optimizing = 3, |
|
| 23 | - * Optimized = 4, |
|
| 24 | - * Error = 5, |
|
| 25 | - * ComputingDirections = 6, |
|
| 26 | - * OptimizationStateInQueue = 7 |
|
| 27 | - */ |
|
| 28 | - public $state; |
|
| 29 | - |
|
| 30 | - /** @var string[] $user_errors |
|
| 31 | - * An array of the user errors. |
|
| 32 | - */ |
|
| 33 | - public $user_errors; |
|
| 34 | - |
|
| 35 | - /** @var string[] $optimization_errors |
|
| 36 | - * An array of the optimization errors. |
|
| 37 | - */ |
|
| 38 | - public $optimization_errors; |
|
| 39 | - |
|
| 40 | - /** @var boolean $sent_to_background |
|
| 41 | - * If true it means the solution was not returned (it is being computed in the background). |
|
| 42 | - */ |
|
| 43 | - public $sent_to_background; |
|
| 44 | - |
|
| 45 | - /** @var long $scheduled_for |
|
| 46 | - * An Unix Timestamp the Optimization Problem was scheduled for. |
|
| 47 | - */ |
|
| 48 | - public $scheduled_for; |
|
| 49 | - |
|
| 50 | - /** @var Route[] $routes |
|
| 51 | - * An array ot the DataObjectRoute type objects. |
|
| 52 | - * The routes included in the optimization problem. |
|
| 53 | - */ |
|
| 54 | - public $routes; |
|
| 55 | - |
|
| 56 | - /** @var integer $total_addresses |
|
| 57 | - * Total number of the addresses in the optimization problem. |
|
| 58 | - */ |
|
| 59 | - public $total_addresses; |
|
| 60 | - |
|
| 61 | - public function __construct() |
|
| 62 | - { |
|
| 63 | - /** |
|
| 64 | - * TO DO: Replace endpoint after finishing Optimization Wrapper in API 5 |
|
| 65 | - */ |
|
| 66 | - \Route4Me\Route4Me::setBaseUrl(EndpointV4::BASE_URL); |
|
| 67 | - $this->parameters = new RouteParameters(); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public static function fromArray(array $params) |
|
| 71 | - { |
|
| 72 | - $problem = new self(); |
|
| 73 | - $routeClass = new Route(); |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
| 77 | - $problem->user_errors = Common::getValue($params, 'user_errors', []); |
|
| 78 | - $problem->state = Common::getValue($params, 'state', []); |
|
| 79 | - $problem->sent_to_background = Common::getValue($params, 'sent_to_background', []); |
|
| 80 | - $problem->links = Common::getValue($params, 'links', []); |
|
| 81 | - |
|
| 82 | - if (isset($params['parameters'])) { |
|
| 83 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - if (isset($params['addresses'])) { |
|
| 87 | - $addresses = []; |
|
| 88 | - |
|
| 89 | - foreach ($params['addresses'] as $address) { |
|
| 90 | - $addresses[] = Address::fromArray($address); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $problem->addresses = $addresses; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if (isset($params['routes'])) { |
|
| 97 | - $routes = []; |
|
| 98 | - |
|
| 99 | - foreach ($params['routes'] as $route) { |
|
| 100 | - $routes[] = $routeClass::fromArray($route); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - $problem->routes = $routes; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return $problem; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - public static function optimize(OptimizationProblemParams $params) |
|
| 110 | - { |
|
| 111 | - $allQueryFields = ['redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url']; |
|
| 112 | - |
|
| 113 | - $optimize = Route4Me::makeRequst([ |
|
| 114 | - 'url' => \Route4Me\Enum\Endpoint::OPTIMIZATION_PROBLEM, |
|
| 115 | - 'method' => 'POST', |
|
| 116 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 117 | - 'body' => [ |
|
| 118 | - 'addresses' => $params->getAddressesArray(), |
|
| 119 | - 'depots' => $params->getDepotsArray(), |
|
| 120 | - 'parameters' => $params->getParametersArray(), |
|
| 121 | - ], |
|
| 122 | - ]); |
|
| 123 | - |
|
| 124 | - return self::fromArray($optimize); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - public static function get($params) |
|
| 128 | - { |
|
| 129 | - $allQueryFields = ['state', 'limit', 'format', 'offset', |
|
| 130 | - 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
| 131 | - |
|
| 132 | - $result = Route4Me::makeRequst([ |
|
| 133 | - 'url' => \Route4Me\Enum\Endpoint::OPTIMIZATION_PROBLEM, |
|
| 134 | - 'method' => 'GET', |
|
| 135 | - 'query' => \Route4Me\Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 136 | - ]); |
|
| 137 | - |
|
| 138 | - if (isset($result['optimizations'])) { |
|
| 139 | - $problems = []; |
|
| 140 | - |
|
| 141 | - foreach ($result['optimizations'] as $problem) { |
|
| 142 | - $problems[] = self::fromArray($problem); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - return $problems; |
|
| 146 | - } else { |
|
| 147 | - return self::fromArray($result); |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - public function removeOptimization($params) |
|
| 152 | - { |
|
| 153 | - $allQueryFields = ['redirect']; |
|
| 154 | - $allBodyFields = ['optimization_problem_ids']; |
|
| 155 | - |
|
| 156 | - $response = Route4Me::makeRequst([ |
|
| 157 | - 'url' => \Route4Me\Enum\Endpoint::OPTIMIZATION_PROBLEM, |
|
| 158 | - 'method' => 'DELETE', |
|
| 159 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 160 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 161 | - ]); |
|
| 162 | - |
|
| 163 | - return $response; |
|
| 164 | - } |
|
| 16 | + /** @var int $state |
|
| 17 | + * An optimization problem state. |
|
| 18 | + * Available values: |
|
| 19 | + * OptimizationStateNew = 0, |
|
| 20 | + * Initial = 1, |
|
| 21 | + * MatrixProcessing = 2, |
|
| 22 | + * Optimizing = 3, |
|
| 23 | + * Optimized = 4, |
|
| 24 | + * Error = 5, |
|
| 25 | + * ComputingDirections = 6, |
|
| 26 | + * OptimizationStateInQueue = 7 |
|
| 27 | + */ |
|
| 28 | + public $state; |
|
| 29 | + |
|
| 30 | + /** @var string[] $user_errors |
|
| 31 | + * An array of the user errors. |
|
| 32 | + */ |
|
| 33 | + public $user_errors; |
|
| 34 | + |
|
| 35 | + /** @var string[] $optimization_errors |
|
| 36 | + * An array of the optimization errors. |
|
| 37 | + */ |
|
| 38 | + public $optimization_errors; |
|
| 39 | + |
|
| 40 | + /** @var boolean $sent_to_background |
|
| 41 | + * If true it means the solution was not returned (it is being computed in the background). |
|
| 42 | + */ |
|
| 43 | + public $sent_to_background; |
|
| 44 | + |
|
| 45 | + /** @var long $scheduled_for |
|
| 46 | + * An Unix Timestamp the Optimization Problem was scheduled for. |
|
| 47 | + */ |
|
| 48 | + public $scheduled_for; |
|
| 49 | + |
|
| 50 | + /** @var Route[] $routes |
|
| 51 | + * An array ot the DataObjectRoute type objects. |
|
| 52 | + * The routes included in the optimization problem. |
|
| 53 | + */ |
|
| 54 | + public $routes; |
|
| 55 | + |
|
| 56 | + /** @var integer $total_addresses |
|
| 57 | + * Total number of the addresses in the optimization problem. |
|
| 58 | + */ |
|
| 59 | + public $total_addresses; |
|
| 60 | + |
|
| 61 | + public function __construct() |
|
| 62 | + { |
|
| 63 | + /** |
|
| 64 | + * TO DO: Replace endpoint after finishing Optimization Wrapper in API 5 |
|
| 65 | + */ |
|
| 66 | + \Route4Me\Route4Me::setBaseUrl(EndpointV4::BASE_URL); |
|
| 67 | + $this->parameters = new RouteParameters(); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public static function fromArray(array $params) |
|
| 71 | + { |
|
| 72 | + $problem = new self(); |
|
| 73 | + $routeClass = new Route(); |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
| 77 | + $problem->user_errors = Common::getValue($params, 'user_errors', []); |
|
| 78 | + $problem->state = Common::getValue($params, 'state', []); |
|
| 79 | + $problem->sent_to_background = Common::getValue($params, 'sent_to_background', []); |
|
| 80 | + $problem->links = Common::getValue($params, 'links', []); |
|
| 81 | + |
|
| 82 | + if (isset($params['parameters'])) { |
|
| 83 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + if (isset($params['addresses'])) { |
|
| 87 | + $addresses = []; |
|
| 88 | + |
|
| 89 | + foreach ($params['addresses'] as $address) { |
|
| 90 | + $addresses[] = Address::fromArray($address); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $problem->addresses = $addresses; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if (isset($params['routes'])) { |
|
| 97 | + $routes = []; |
|
| 98 | + |
|
| 99 | + foreach ($params['routes'] as $route) { |
|
| 100 | + $routes[] = $routeClass::fromArray($route); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + $problem->routes = $routes; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return $problem; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + public static function optimize(OptimizationProblemParams $params) |
|
| 110 | + { |
|
| 111 | + $allQueryFields = ['redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url']; |
|
| 112 | + |
|
| 113 | + $optimize = Route4Me::makeRequst([ |
|
| 114 | + 'url' => \Route4Me\Enum\Endpoint::OPTIMIZATION_PROBLEM, |
|
| 115 | + 'method' => 'POST', |
|
| 116 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 117 | + 'body' => [ |
|
| 118 | + 'addresses' => $params->getAddressesArray(), |
|
| 119 | + 'depots' => $params->getDepotsArray(), |
|
| 120 | + 'parameters' => $params->getParametersArray(), |
|
| 121 | + ], |
|
| 122 | + ]); |
|
| 123 | + |
|
| 124 | + return self::fromArray($optimize); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + public static function get($params) |
|
| 128 | + { |
|
| 129 | + $allQueryFields = ['state', 'limit', 'format', 'offset', |
|
| 130 | + 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
| 131 | + |
|
| 132 | + $result = Route4Me::makeRequst([ |
|
| 133 | + 'url' => \Route4Me\Enum\Endpoint::OPTIMIZATION_PROBLEM, |
|
| 134 | + 'method' => 'GET', |
|
| 135 | + 'query' => \Route4Me\Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 136 | + ]); |
|
| 137 | + |
|
| 138 | + if (isset($result['optimizations'])) { |
|
| 139 | + $problems = []; |
|
| 140 | + |
|
| 141 | + foreach ($result['optimizations'] as $problem) { |
|
| 142 | + $problems[] = self::fromArray($problem); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + return $problems; |
|
| 146 | + } else { |
|
| 147 | + return self::fromArray($result); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + public function removeOptimization($params) |
|
| 152 | + { |
|
| 153 | + $allQueryFields = ['redirect']; |
|
| 154 | + $allBodyFields = ['optimization_problem_ids']; |
|
| 155 | + |
|
| 156 | + $response = Route4Me::makeRequst([ |
|
| 157 | + 'url' => \Route4Me\Enum\Endpoint::OPTIMIZATION_PROBLEM, |
|
| 158 | + 'method' => 'DELETE', |
|
| 159 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 160 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 161 | + ]); |
|
| 162 | + |
|
| 163 | + return $response; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | \ No newline at end of file |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | public static function get($params) |
| 128 | 128 | { |
| 129 | 129 | $allQueryFields = ['state', 'limit', 'format', 'offset', |
| 130 | - 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
| 130 | + 'optimization_problem_id', 'wait_for_final_state', 'start_date', 'end_date', ]; |
|
| 131 | 131 | |
| 132 | 132 | $result = Route4Me::makeRequst([ |
| 133 | 133 | 'url' => \Route4Me\Enum\Endpoint::OPTIMIZATION_PROBLEM, |
@@ -11,37 +11,37 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class ResultResponse extends \Route4Me\Common |
| 13 | 13 | { |
| 14 | - /** Status (true/false) |
|
| 15 | - * @var boolean $status |
|
| 16 | - */ |
|
| 17 | - public $status; |
|
| 18 | - |
|
| 19 | - /** Status code |
|
| 20 | - * @var integer $code |
|
| 21 | - */ |
|
| 22 | - public $code; |
|
| 23 | - |
|
| 24 | - /** Exit code |
|
| 25 | - * @var integer $exit_code |
|
| 26 | - */ |
|
| 27 | - public $exit_code; |
|
| 28 | - |
|
| 29 | - /** An array of the error messages. |
|
| 30 | - * @var Array $messages |
|
| 31 | - */ |
|
| 32 | - public $messages; |
|
| 33 | - |
|
| 34 | - public static function fromArray(array $params) |
|
| 35 | - { |
|
| 36 | - $resultResponse = new self(); |
|
| 37 | - |
|
| 38 | - foreach ($params as $key => $value) { |
|
| 39 | - if (property_exists($resultResponse, $key)) { |
|
| 40 | - $resultResponse->{$key} = $value; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - return $resultResponse; |
|
| 45 | - } |
|
| 14 | + /** Status (true/false) |
|
| 15 | + * @var boolean $status |
|
| 16 | + */ |
|
| 17 | + public $status; |
|
| 18 | + |
|
| 19 | + /** Status code |
|
| 20 | + * @var integer $code |
|
| 21 | + */ |
|
| 22 | + public $code; |
|
| 23 | + |
|
| 24 | + /** Exit code |
|
| 25 | + * @var integer $exit_code |
|
| 26 | + */ |
|
| 27 | + public $exit_code; |
|
| 28 | + |
|
| 29 | + /** An array of the error messages. |
|
| 30 | + * @var Array $messages |
|
| 31 | + */ |
|
| 32 | + public $messages; |
|
| 33 | + |
|
| 34 | + public static function fromArray(array $params) |
|
| 35 | + { |
|
| 36 | + $resultResponse = new self(); |
|
| 37 | + |
|
| 38 | + foreach ($params as $key => $value) { |
|
| 39 | + if (property_exists($resultResponse, $key)) { |
|
| 40 | + $resultResponse->{$key} = $value; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + return $resultResponse; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |
@@ -11,31 +11,31 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class AddressBundling extends Common |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Address bundling mode |
|
| 16 | - * @see Enum\AddressBundlingModes\Mode |
|
| 17 | - * @var integer |
|
| 18 | - */ |
|
| 19 | - public $mode; |
|
| 14 | + /** |
|
| 15 | + * Address bundling mode |
|
| 16 | + * @see Enum\AddressBundlingModes\Mode |
|
| 17 | + * @var integer |
|
| 18 | + */ |
|
| 19 | + public $mode; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Address bundling mode parameters: |
|
| 23 | - * - If Mode=3, contains an array of the field names of the Address object; |
|
| 24 | - * - If Mode=4, contains an array of the custom fields of the Address object. |
|
| 25 | - * @var string[] |
|
| 26 | - */ |
|
| 27 | - public $mode_params; |
|
| 21 | + /** |
|
| 22 | + * Address bundling mode parameters: |
|
| 23 | + * - If Mode=3, contains an array of the field names of the Address object; |
|
| 24 | + * - If Mode=4, contains an array of the custom fields of the Address object. |
|
| 25 | + * @var string[] |
|
| 26 | + */ |
|
| 27 | + public $mode_params; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Address bundling merge mode |
|
| 31 | - * @see Enum\AddressBundlingModes\MergeMode |
|
| 32 | - * @var integer |
|
| 33 | - */ |
|
| 34 | - public $merge_mode; |
|
| 29 | + /** |
|
| 30 | + * Address bundling merge mode |
|
| 31 | + * @see Enum\AddressBundlingModes\MergeMode |
|
| 32 | + * @var integer |
|
| 33 | + */ |
|
| 34 | + public $merge_mode; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Service time rules of the address bundling |
|
| 38 | - * @var ServiceTimeRulesClass |
|
| 39 | - */ |
|
| 40 | - public $service_time_rules; |
|
| 36 | + /** |
|
| 37 | + * Service time rules of the address bundling |
|
| 38 | + * @var ServiceTimeRulesClass |
|
| 39 | + */ |
|
| 40 | + public $service_time_rules; |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -12,223 +12,223 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class AddressNote extends Common |
| 14 | 14 | { |
| 15 | - /** An unique ID of a note |
|
| 16 | - * @var integer $note_id |
|
| 17 | - */ |
|
| 18 | - public $note_id; |
|
| 19 | - |
|
| 20 | - /** The route ID |
|
| 21 | - * @var string $route_id |
|
| 22 | - */ |
|
| 23 | - public $route_id; |
|
| 24 | - |
|
| 25 | - /** The route destination ID |
|
| 26 | - * @var integer $route_destination_id |
|
| 27 | - */ |
|
| 28 | - public $route_destination_id; |
|
| 29 | - |
|
| 30 | - /** An unique ID of an uploaded file |
|
| 31 | - * @var string $upload_id |
|
| 32 | - */ |
|
| 33 | - public $upload_id; |
|
| 34 | - |
|
| 35 | - /** When the note was added |
|
| 36 | - * @var integer $ts_added |
|
| 37 | - */ |
|
| 38 | - public $ts_added; |
|
| 39 | - |
|
| 40 | - /** The position latitude where the address note was added |
|
| 41 | - * @var double $lat |
|
| 42 | - */ |
|
| 43 | - public $lat; |
|
| 44 | - |
|
| 45 | - /** The position longitude where the address note was added |
|
| 46 | - * @var double $lng |
|
| 47 | - */ |
|
| 48 | - public $lng; |
|
| 49 | - |
|
| 50 | - /** The activity type |
|
| 51 | - * @var string $activity_type |
|
| 52 | - */ |
|
| 53 | - public $activity_type; |
|
| 54 | - |
|
| 55 | - /** The note text contents |
|
| 56 | - * @var string $contents |
|
| 57 | - */ |
|
| 58 | - public $contents; |
|
| 59 | - |
|
| 60 | - /** An upload type of the note |
|
| 61 | - * @var string $upload_type |
|
| 62 | - */ |
|
| 63 | - public $upload_type; |
|
| 64 | - |
|
| 65 | - /** An upload url - where a file-note was uploaded. |
|
| 66 | - * @var string $upload_url |
|
| 67 | - */ |
|
| 68 | - public $upload_url; |
|
| 69 | - |
|
| 70 | - /** An extension of the uploaded file. |
|
| 71 | - * @var string $upload_extension |
|
| 72 | - */ |
|
| 73 | - public $upload_extension; |
|
| 74 | - |
|
| 75 | - /** The device a note was uploaded from |
|
| 76 | - * @var string $device_type |
|
| 77 | - */ |
|
| 78 | - public $device_type; |
|
| 79 | - |
|
| 80 | - /** Array of the custom type notes |
|
| 81 | - * @var AddressCustomNote[] $custom_types |
|
| 82 | - */ |
|
| 83 | - public $custom_types = []; |
|
| 84 | - |
|
| 85 | - public function __construct() |
|
| 86 | - { |
|
| 87 | - |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - public static function fromArray(array $params) |
|
| 91 | - { |
|
| 92 | - $addressNote = new self(); |
|
| 93 | - |
|
| 94 | - foreach ($params as $key => $value) { |
|
| 95 | - if (property_exists($addressNote, $key)) { |
|
| 96 | - $addressNote->{$key} = $value; |
|
| 97 | - } else { |
|
| 98 | - throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key"); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - return $addressNote; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /*Get notes from the specified route destination |
|
| 15 | + /** An unique ID of a note |
|
| 16 | + * @var integer $note_id |
|
| 17 | + */ |
|
| 18 | + public $note_id; |
|
| 19 | + |
|
| 20 | + /** The route ID |
|
| 21 | + * @var string $route_id |
|
| 22 | + */ |
|
| 23 | + public $route_id; |
|
| 24 | + |
|
| 25 | + /** The route destination ID |
|
| 26 | + * @var integer $route_destination_id |
|
| 27 | + */ |
|
| 28 | + public $route_destination_id; |
|
| 29 | + |
|
| 30 | + /** An unique ID of an uploaded file |
|
| 31 | + * @var string $upload_id |
|
| 32 | + */ |
|
| 33 | + public $upload_id; |
|
| 34 | + |
|
| 35 | + /** When the note was added |
|
| 36 | + * @var integer $ts_added |
|
| 37 | + */ |
|
| 38 | + public $ts_added; |
|
| 39 | + |
|
| 40 | + /** The position latitude where the address note was added |
|
| 41 | + * @var double $lat |
|
| 42 | + */ |
|
| 43 | + public $lat; |
|
| 44 | + |
|
| 45 | + /** The position longitude where the address note was added |
|
| 46 | + * @var double $lng |
|
| 47 | + */ |
|
| 48 | + public $lng; |
|
| 49 | + |
|
| 50 | + /** The activity type |
|
| 51 | + * @var string $activity_type |
|
| 52 | + */ |
|
| 53 | + public $activity_type; |
|
| 54 | + |
|
| 55 | + /** The note text contents |
|
| 56 | + * @var string $contents |
|
| 57 | + */ |
|
| 58 | + public $contents; |
|
| 59 | + |
|
| 60 | + /** An upload type of the note |
|
| 61 | + * @var string $upload_type |
|
| 62 | + */ |
|
| 63 | + public $upload_type; |
|
| 64 | + |
|
| 65 | + /** An upload url - where a file-note was uploaded. |
|
| 66 | + * @var string $upload_url |
|
| 67 | + */ |
|
| 68 | + public $upload_url; |
|
| 69 | + |
|
| 70 | + /** An extension of the uploaded file. |
|
| 71 | + * @var string $upload_extension |
|
| 72 | + */ |
|
| 73 | + public $upload_extension; |
|
| 74 | + |
|
| 75 | + /** The device a note was uploaded from |
|
| 76 | + * @var string $device_type |
|
| 77 | + */ |
|
| 78 | + public $device_type; |
|
| 79 | + |
|
| 80 | + /** Array of the custom type notes |
|
| 81 | + * @var AddressCustomNote[] $custom_types |
|
| 82 | + */ |
|
| 83 | + public $custom_types = []; |
|
| 84 | + |
|
| 85 | + public function __construct() |
|
| 86 | + { |
|
| 87 | + |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + public static function fromArray(array $params) |
|
| 91 | + { |
|
| 92 | + $addressNote = new self(); |
|
| 93 | + |
|
| 94 | + foreach ($params as $key => $value) { |
|
| 95 | + if (property_exists($addressNote, $key)) { |
|
| 96 | + $addressNote->{$key} = $value; |
|
| 97 | + } else { |
|
| 98 | + throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key"); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + return $addressNote; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /*Get notes from the specified route destination |
|
| 106 | 106 | * Returns an address object with notes, if an address exists, otherwise - return null. |
| 107 | 107 | */ |
| 108 | - public static function GetAddressesNotes($noteParams) |
|
| 109 | - { |
|
| 110 | - $address = Route4Me::makeRequst([ |
|
| 111 | - 'url' => Endpoint::ADDRESS_V4, |
|
| 112 | - 'method' => 'GET', |
|
| 113 | - 'query' => [ |
|
| 114 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
| 115 | - 'route_destination_id' => isset($noteParams['route_destination_id']) |
|
| 116 | - ? $noteParams['route_destination_id'] : null, |
|
| 117 | - 'notes' => 1, |
|
| 118 | - ], |
|
| 119 | - ]); |
|
| 120 | - |
|
| 121 | - return $address; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - public function createCustomNoteType($params) |
|
| 125 | - { |
|
| 126 | - $allBodyFields = ['type', 'values']; |
|
| 127 | - |
|
| 128 | - $result = Route4Me::makeRequst([ |
|
| 129 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
| 130 | - 'method' => 'POST', |
|
| 131 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 132 | - ]); |
|
| 133 | - |
|
| 134 | - return $result; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - public function removeCustomNoteType($params) |
|
| 138 | - { |
|
| 139 | - $result = Route4Me::makeRequst([ |
|
| 140 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
| 141 | - 'method' => 'DELETE', |
|
| 142 | - 'body' => [ |
|
| 143 | - 'id' => isset($params['id']) ? $params['id'] : null, |
|
| 144 | - ], |
|
| 145 | - ]); |
|
| 146 | - |
|
| 147 | - return $result; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - public function getAllCustomNoteTypes() |
|
| 151 | - { |
|
| 152 | - $result = Route4Me::makeRequst([ |
|
| 153 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
| 154 | - 'method' => 'GET', |
|
| 155 | - ]); |
|
| 156 | - |
|
| 157 | - return $result; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - public function getCustomNoteTypeByKey($params) |
|
| 161 | - { |
|
| 162 | - $result = Route4Me::makeRequst([ |
|
| 163 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
| 164 | - 'method' => 'GET', |
|
| 165 | - ]); |
|
| 166 | - |
|
| 167 | - if (is_null($result) || !is_array($result)) return null; |
|
| 168 | - |
|
| 169 | - foreach ($result as $custNoteType) { |
|
| 170 | - if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"] == $params) { |
|
| 171 | - return $custNoteType; |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - public function AddAddressNote($params) |
|
| 177 | - { |
|
| 178 | - $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type']; |
|
| 179 | - $allBodyFields = ['strNoteContents', 'strUpdateType']; |
|
| 180 | - |
|
| 181 | - $result = Route4Me::makeRequst([ |
|
| 182 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 183 | - 'method' => 'POST', |
|
| 184 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 185 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 186 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
| 187 | - ]); |
|
| 188 | - |
|
| 189 | - return $result; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - public function AddNoteFile($params) |
|
| 193 | - { |
|
| 194 | - $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
| 195 | - |
|
| 196 | - $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type']; |
|
| 197 | - $allBodyFields = ['strFilename', 'strUpdateType', 'strNoteContents']; |
|
| 198 | - |
|
| 199 | - $result = Route4Me::makeRequst([ |
|
| 200 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 201 | - 'method' => 'POST', |
|
| 202 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 203 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 204 | - 'FILE' => $fname, |
|
| 205 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 206 | - ]); |
|
| 207 | - |
|
| 208 | - return $result; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - public function addCustomNoteToRoute($params) |
|
| 212 | - { |
|
| 213 | - $customArray = []; |
|
| 214 | - |
|
| 215 | - foreach ($params as $key => $value) { |
|
| 216 | - if (false !== strpos($key, 'custom_note_type')) { |
|
| 217 | - $customArray[$key] = $value; |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - $allQueryFields = ['route_id', 'address_id', 'format', 'dev_lat', 'dev_lng']; |
|
| 222 | - $allBodyFields = ['strUpdateType', 'strUpdateType', 'strNoteContents']; |
|
| 223 | - |
|
| 224 | - $result = Route4Me::makeRequst([ |
|
| 225 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 226 | - 'method' => 'POST', |
|
| 227 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 228 | - 'body' => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray), |
|
| 229 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
| 230 | - ]); |
|
| 231 | - |
|
| 232 | - return $result; |
|
| 233 | - } |
|
| 108 | + public static function GetAddressesNotes($noteParams) |
|
| 109 | + { |
|
| 110 | + $address = Route4Me::makeRequst([ |
|
| 111 | + 'url' => Endpoint::ADDRESS_V4, |
|
| 112 | + 'method' => 'GET', |
|
| 113 | + 'query' => [ |
|
| 114 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
| 115 | + 'route_destination_id' => isset($noteParams['route_destination_id']) |
|
| 116 | + ? $noteParams['route_destination_id'] : null, |
|
| 117 | + 'notes' => 1, |
|
| 118 | + ], |
|
| 119 | + ]); |
|
| 120 | + |
|
| 121 | + return $address; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + public function createCustomNoteType($params) |
|
| 125 | + { |
|
| 126 | + $allBodyFields = ['type', 'values']; |
|
| 127 | + |
|
| 128 | + $result = Route4Me::makeRequst([ |
|
| 129 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
| 130 | + 'method' => 'POST', |
|
| 131 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 132 | + ]); |
|
| 133 | + |
|
| 134 | + return $result; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + public function removeCustomNoteType($params) |
|
| 138 | + { |
|
| 139 | + $result = Route4Me::makeRequst([ |
|
| 140 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
| 141 | + 'method' => 'DELETE', |
|
| 142 | + 'body' => [ |
|
| 143 | + 'id' => isset($params['id']) ? $params['id'] : null, |
|
| 144 | + ], |
|
| 145 | + ]); |
|
| 146 | + |
|
| 147 | + return $result; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + public function getAllCustomNoteTypes() |
|
| 151 | + { |
|
| 152 | + $result = Route4Me::makeRequst([ |
|
| 153 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
| 154 | + 'method' => 'GET', |
|
| 155 | + ]); |
|
| 156 | + |
|
| 157 | + return $result; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + public function getCustomNoteTypeByKey($params) |
|
| 161 | + { |
|
| 162 | + $result = Route4Me::makeRequst([ |
|
| 163 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
| 164 | + 'method' => 'GET', |
|
| 165 | + ]); |
|
| 166 | + |
|
| 167 | + if (is_null($result) || !is_array($result)) return null; |
|
| 168 | + |
|
| 169 | + foreach ($result as $custNoteType) { |
|
| 170 | + if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"] == $params) { |
|
| 171 | + return $custNoteType; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + public function AddAddressNote($params) |
|
| 177 | + { |
|
| 178 | + $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type']; |
|
| 179 | + $allBodyFields = ['strNoteContents', 'strUpdateType']; |
|
| 180 | + |
|
| 181 | + $result = Route4Me::makeRequst([ |
|
| 182 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 183 | + 'method' => 'POST', |
|
| 184 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 185 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 186 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
| 187 | + ]); |
|
| 188 | + |
|
| 189 | + return $result; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + public function AddNoteFile($params) |
|
| 193 | + { |
|
| 194 | + $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
| 195 | + |
|
| 196 | + $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type']; |
|
| 197 | + $allBodyFields = ['strFilename', 'strUpdateType', 'strNoteContents']; |
|
| 198 | + |
|
| 199 | + $result = Route4Me::makeRequst([ |
|
| 200 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 201 | + 'method' => 'POST', |
|
| 202 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 203 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 204 | + 'FILE' => $fname, |
|
| 205 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 206 | + ]); |
|
| 207 | + |
|
| 208 | + return $result; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + public function addCustomNoteToRoute($params) |
|
| 212 | + { |
|
| 213 | + $customArray = []; |
|
| 214 | + |
|
| 215 | + foreach ($params as $key => $value) { |
|
| 216 | + if (false !== strpos($key, 'custom_note_type')) { |
|
| 217 | + $customArray[$key] = $value; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + $allQueryFields = ['route_id', 'address_id', 'format', 'dev_lat', 'dev_lng']; |
|
| 222 | + $allBodyFields = ['strUpdateType', 'strUpdateType', 'strNoteContents']; |
|
| 223 | + |
|
| 224 | + $result = Route4Me::makeRequst([ |
|
| 225 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 226 | + 'method' => 'POST', |
|
| 227 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 228 | + 'body' => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray), |
|
| 229 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
| 230 | + ]); |
|
| 231 | + |
|
| 232 | + return $result; |
|
| 233 | + } |
|
| 234 | 234 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | if (is_null($result) || !is_array($result)) return null; |
| 182 | 182 | |
| 183 | 183 | foreach ($result as $custNoteType) { |
| 184 | - if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"] == $params) { |
|
| 184 | + if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"]==$params) { |
|
| 185 | 185 | return $custNoteType; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $customArray = []; |
| 228 | 228 | |
| 229 | 229 | foreach ($params as $key => $value) { |
| 230 | - if (false !== strpos($key, 'custom_note_type')) { |
|
| 230 | + if (false!==strpos($key, 'custom_note_type')) { |
|
| 231 | 231 | $customArray[$key] = $value; |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -178,7 +178,9 @@ |
||
| 178 | 178 | 'method' => 'GET', |
| 179 | 179 | ]); |
| 180 | 180 | |
| 181 | - if (is_null($result) || !is_array($result)) return null; |
|
| 181 | + if (is_null($result) || !is_array($result)) { |
|
| 182 | + return null; |
|
| 183 | + } |
|
| 182 | 184 | |
| 183 | 185 | foreach ($result as $custNoteType) { |
| 184 | 186 | if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"] == $params) { |
@@ -11,72 +11,72 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class RouteAdvancedConstraints extends Common |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Maximum cargo volume per route. |
|
| 16 | - * @var double |
|
| 17 | - */ |
|
| 18 | - public $max_cargo_volume; |
|
| 14 | + /** |
|
| 15 | + * Maximum cargo volume per route. |
|
| 16 | + * @var double |
|
| 17 | + */ |
|
| 18 | + public $max_cargo_volume; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Vehicle capacity.<br> |
|
| 22 | - * How much total cargo can be transported per route (units, e.g. cubic meters) |
|
| 23 | - * @var integer |
|
| 24 | - */ |
|
| 25 | - public $max_capacity; |
|
| 20 | + /** |
|
| 21 | + * Vehicle capacity.<br> |
|
| 22 | + * How much total cargo can be transported per route (units, e.g. cubic meters) |
|
| 23 | + * @var integer |
|
| 24 | + */ |
|
| 25 | + public $max_capacity; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Legacy feature which permits a user to request an example number of optimized routes. |
|
| 29 | - * @var integer |
|
| 30 | - */ |
|
| 31 | - public $members_count; |
|
| 27 | + /** |
|
| 28 | + * Legacy feature which permits a user to request an example number of optimized routes. |
|
| 29 | + * @var integer |
|
| 30 | + */ |
|
| 31 | + public $members_count; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * An array of the available time windows (e.g. [ [25200, 75000 ] ) |
|
| 35 | - * @var integer[] |
|
| 36 | - */ |
|
| 37 | - public $available_time_windows; |
|
| 33 | + /** |
|
| 34 | + * An array of the available time windows (e.g. [ [25200, 75000 ] ) |
|
| 35 | + * @var integer[] |
|
| 36 | + */ |
|
| 37 | + public $available_time_windows; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * The driver tags specified in a team member's custom data.<br> |
|
| 41 | - * e.g. "driver skills":<br> |
|
| 42 | - * ["Class A CDL", "Class B CDL", "Forklift", "Skid Steer Loader", "Independent Contractor"] |
|
| 43 | - * @var string[] |
|
| 44 | - */ |
|
| 45 | - public $tags; |
|
| 39 | + /** |
|
| 40 | + * The driver tags specified in a team member's custom data.<br> |
|
| 41 | + * e.g. "driver skills":<br> |
|
| 42 | + * ["Class A CDL", "Class B CDL", "Forklift", "Skid Steer Loader", "Independent Contractor"] |
|
| 43 | + * @var string[] |
|
| 44 | + */ |
|
| 45 | + public $tags; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * An array of the skilled driver IDs. |
|
| 49 | - * @var integer[] |
|
| 50 | - */ |
|
| 51 | - public $route4me_members_id; |
|
| 47 | + /** |
|
| 48 | + * An array of the skilled driver IDs. |
|
| 49 | + * @var integer[] |
|
| 50 | + */ |
|
| 51 | + public $route4me_members_id; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * An array containing Address objects. |
|
| 55 | - * @var Address |
|
| 56 | - */ |
|
| 57 | - public $depot_address; |
|
| 53 | + /** |
|
| 54 | + * An array containing Address objects. |
|
| 55 | + * @var Address |
|
| 56 | + */ |
|
| 57 | + public $depot_address; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * An array of locations. |
|
| 61 | - * @var object[] |
|
| 62 | - */ |
|
| 63 | - public $location_sequence_pattern; |
|
| 59 | + /** |
|
| 60 | + * An array of locations. |
|
| 61 | + * @var object[] |
|
| 62 | + */ |
|
| 63 | + public $location_sequence_pattern; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Group. |
|
| 67 | - * @var string |
|
| 68 | - */ |
|
| 69 | - public $group; |
|
| 65 | + /** |
|
| 66 | + * Group. |
|
| 67 | + * @var string |
|
| 68 | + */ |
|
| 69 | + public $group; |
|
| 70 | 70 | |
| 71 | - public static function fromArray(array $params) |
|
| 72 | - { |
|
| 73 | - $routeParams = new self(); |
|
| 74 | - foreach ($params as $key => $value) { |
|
| 75 | - if (property_exists($routeParams, $key)) { |
|
| 76 | - $routeParams->{$key} = $value; |
|
| 77 | - } |
|
| 78 | - } |
|
| 71 | + public static function fromArray(array $params) |
|
| 72 | + { |
|
| 73 | + $routeParams = new self(); |
|
| 74 | + foreach ($params as $key => $value) { |
|
| 75 | + if (property_exists($routeParams, $key)) { |
|
| 76 | + $routeParams->{$key} = $value; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - return $routeParams; |
|
| 81 | - } |
|
| 80 | + return $routeParams; |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -12,69 +12,69 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class BundledItemResponse extends \Route4Me\Common |
| 14 | 14 | { |
| 15 | - /** Summary cube value of the bundled addresses |
|
| 16 | - * @var double $cube |
|
| 17 | - */ |
|
| 18 | - public $cube; |
|
| 19 | - |
|
| 20 | - /** Summary revenue value of the bundled addresses |
|
| 21 | - * @var double $revenue |
|
| 22 | - */ |
|
| 23 | - public $revenue; |
|
| 24 | - |
|
| 25 | - /** Summary pieces value of the bundled addresses |
|
| 26 | - * @var integer $pieces |
|
| 27 | - */ |
|
| 28 | - public $pieces; |
|
| 29 | - |
|
| 30 | - /** Summary weight value of the bundled addresses |
|
| 31 | - * @var double $weight |
|
| 32 | - */ |
|
| 33 | - public $weight; |
|
| 34 | - |
|
| 35 | - /** Summary cost value of the bundled addresses |
|
| 36 | - * @var double $cost |
|
| 37 | - */ |
|
| 38 | - public $cost; |
|
| 39 | - |
|
| 40 | - /** Service time of the bundled addresses |
|
| 41 | - * @var integer $service_time |
|
| 42 | - */ |
|
| 43 | - public $service_time; |
|
| 44 | - |
|
| 45 | - /** Time window start of the bundled addresses |
|
| 46 | - * @var integer $time_window_start |
|
| 47 | - */ |
|
| 48 | - public $time_window_start; |
|
| 49 | - |
|
| 50 | - /** Time window emd of the bundled addresses |
|
| 51 | - * @var integer $time_window_end |
|
| 52 | - */ |
|
| 53 | - public $time_window_end; |
|
| 54 | - |
|
| 55 | - /** TO DO: Adjust description |
|
| 56 | - * @var array $custom_data |
|
| 57 | - */ |
|
| 58 | - public $custom_data = []; |
|
| 59 | - |
|
| 60 | - /** Array of the IDs of the bundeld addresses. |
|
| 61 | - * @var integer[] $addresses_id |
|
| 62 | - */ |
|
| 63 | - public $addresses_id = []; |
|
| 64 | - |
|
| 65 | - public static function fromArray(array $params) |
|
| 66 | - { |
|
| 67 | - $boundedItemResp = new self(); |
|
| 68 | - |
|
| 69 | - foreach ($params as $key => $value) { |
|
| 70 | - if (property_exists($boundedItemResp, $key)) { |
|
| 71 | - $boundedItemResp->{$key} = $value; |
|
| 72 | - } else { |
|
| 73 | - throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key"); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - return $boundedItemResp; |
|
| 78 | - } |
|
| 15 | + /** Summary cube value of the bundled addresses |
|
| 16 | + * @var double $cube |
|
| 17 | + */ |
|
| 18 | + public $cube; |
|
| 19 | + |
|
| 20 | + /** Summary revenue value of the bundled addresses |
|
| 21 | + * @var double $revenue |
|
| 22 | + */ |
|
| 23 | + public $revenue; |
|
| 24 | + |
|
| 25 | + /** Summary pieces value of the bundled addresses |
|
| 26 | + * @var integer $pieces |
|
| 27 | + */ |
|
| 28 | + public $pieces; |
|
| 29 | + |
|
| 30 | + /** Summary weight value of the bundled addresses |
|
| 31 | + * @var double $weight |
|
| 32 | + */ |
|
| 33 | + public $weight; |
|
| 34 | + |
|
| 35 | + /** Summary cost value of the bundled addresses |
|
| 36 | + * @var double $cost |
|
| 37 | + */ |
|
| 38 | + public $cost; |
|
| 39 | + |
|
| 40 | + /** Service time of the bundled addresses |
|
| 41 | + * @var integer $service_time |
|
| 42 | + */ |
|
| 43 | + public $service_time; |
|
| 44 | + |
|
| 45 | + /** Time window start of the bundled addresses |
|
| 46 | + * @var integer $time_window_start |
|
| 47 | + */ |
|
| 48 | + public $time_window_start; |
|
| 49 | + |
|
| 50 | + /** Time window emd of the bundled addresses |
|
| 51 | + * @var integer $time_window_end |
|
| 52 | + */ |
|
| 53 | + public $time_window_end; |
|
| 54 | + |
|
| 55 | + /** TO DO: Adjust description |
|
| 56 | + * @var array $custom_data |
|
| 57 | + */ |
|
| 58 | + public $custom_data = []; |
|
| 59 | + |
|
| 60 | + /** Array of the IDs of the bundeld addresses. |
|
| 61 | + * @var integer[] $addresses_id |
|
| 62 | + */ |
|
| 63 | + public $addresses_id = []; |
|
| 64 | + |
|
| 65 | + public static function fromArray(array $params) |
|
| 66 | + { |
|
| 67 | + $boundedItemResp = new self(); |
|
| 68 | + |
|
| 69 | + foreach ($params as $key => $value) { |
|
| 70 | + if (property_exists($boundedItemResp, $key)) { |
|
| 71 | + $boundedItemResp->{$key} = $value; |
|
| 72 | + } else { |
|
| 73 | + throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key"); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + return $boundedItemResp; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -10,28 +10,28 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class AddressCustomNote extends \Route4Me\Common |
| 12 | 12 | { |
| 13 | - /** A unique ID (40 chars) of a custom note entry. |
|
| 14 | - * @var string $note_custom_entry_id |
|
| 15 | - */ |
|
| 16 | - public $note_custom_entry_id; |
|
| 13 | + /** A unique ID (40 chars) of a custom note entry. |
|
| 14 | + * @var string $note_custom_entry_id |
|
| 15 | + */ |
|
| 16 | + public $note_custom_entry_id; |
|
| 17 | 17 | |
| 18 | - /** The custom note ID. |
|
| 19 | - * @var string $note_id |
|
| 20 | - */ |
|
| 21 | - public $note_id; |
|
| 18 | + /** The custom note ID. |
|
| 19 | + * @var string $note_id |
|
| 20 | + */ |
|
| 21 | + public $note_id; |
|
| 22 | 22 | |
| 23 | - /** The custom note type ID. |
|
| 24 | - * @var string $note_custom_type_id |
|
| 25 | - */ |
|
| 26 | - public $note_custom_type_id; |
|
| 23 | + /** The custom note type ID. |
|
| 24 | + * @var string $note_custom_type_id |
|
| 25 | + */ |
|
| 26 | + public $note_custom_type_id; |
|
| 27 | 27 | |
| 28 | - /** The custom note value. |
|
| 29 | - * @var string $note_custom_value |
|
| 30 | - */ |
|
| 31 | - public $note_custom_value; |
|
| 28 | + /** The custom note value. |
|
| 29 | + * @var string $note_custom_value |
|
| 30 | + */ |
|
| 31 | + public $note_custom_value; |
|
| 32 | 32 | |
| 33 | - /** The custom note type. |
|
| 34 | - * @var string $note_custom_type |
|
| 35 | - */ |
|
| 36 | - public $note_custom_type; |
|
| 33 | + /** The custom note type. |
|
| 34 | + * @var string $note_custom_type |
|
| 35 | + */ |
|
| 36 | + public $note_custom_type; |
|
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -9,60 +9,60 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class Geocoding extends \Route4Me\Common |
| 11 | 11 | { |
| 12 | - /** A unique identifier for the geocoding |
|
| 13 | - * @var string $key |
|
| 14 | - */ |
|
| 15 | - public $key; |
|
| 12 | + /** A unique identifier for the geocoding |
|
| 13 | + * @var string $key |
|
| 14 | + */ |
|
| 15 | + public $key; |
|
| 16 | 16 | |
| 17 | - /** Specific description of the geocoding result |
|
| 18 | - * @var string $name |
|
| 19 | - */ |
|
| 20 | - public $name; |
|
| 17 | + /** Specific description of the geocoding result |
|
| 18 | + * @var string $name |
|
| 19 | + */ |
|
| 20 | + public $name; |
|
| 21 | 21 | |
| 22 | - /** Boundary box |
|
| 23 | - * @var double[] $bbox |
|
| 24 | - */ |
|
| 25 | - public $bbox = []; |
|
| 22 | + /** Boundary box |
|
| 23 | + * @var double[] $bbox |
|
| 24 | + */ |
|
| 25 | + public $bbox = []; |
|
| 26 | 26 | |
| 27 | - /** The latitude of the geocoded address |
|
| 28 | - * @var double $lat |
|
| 29 | - */ |
|
| 30 | - public $lat; |
|
| 27 | + /** The latitude of the geocoded address |
|
| 28 | + * @var double $lat |
|
| 29 | + */ |
|
| 30 | + public $lat; |
|
| 31 | 31 | |
| 32 | - /** The longitude of the geocoded address |
|
| 33 | - * @var double $lng |
|
| 34 | - */ |
|
| 35 | - public $lng; |
|
| 32 | + /** The longitude of the geocoded address |
|
| 33 | + * @var double $lng |
|
| 34 | + */ |
|
| 35 | + public $lng; |
|
| 36 | 36 | |
| 37 | - /** Confidance level in the address geocoding: |
|
| 38 | - * <para>high, medium, low</para> |
|
| 39 | - * @var string $confidence |
|
| 40 | - */ |
|
| 41 | - public $confidence; |
|
| 37 | + /** Confidance level in the address geocoding: |
|
| 38 | + * <para>high, medium, low</para> |
|
| 39 | + * @var string $confidence |
|
| 40 | + */ |
|
| 41 | + public $confidence; |
|
| 42 | 42 | |
| 43 | - /** The postal code of the geocoded address |
|
| 44 | - * @var string $postalCode |
|
| 45 | - */ |
|
| 46 | - public $postalCode; |
|
| 43 | + /** The postal code of the geocoded address |
|
| 44 | + * @var string $postalCode |
|
| 45 | + */ |
|
| 46 | + public $postalCode; |
|
| 47 | 47 | |
| 48 | - /** Country region |
|
| 49 | - * @var string $countryRegion |
|
| 50 | - */ |
|
| 51 | - public $countryRegion; |
|
| 48 | + /** Country region |
|
| 49 | + * @var string $countryRegion |
|
| 50 | + */ |
|
| 51 | + public $countryRegion; |
|
| 52 | 52 | |
| 53 | - /** The address curbside coordinates |
|
| 54 | - * @var GeoPoint $curbside_coordinates |
|
| 55 | - */ |
|
| 56 | - public $curbside_coordinates = []; |
|
| 53 | + /** The address curbside coordinates |
|
| 54 | + * @var GeoPoint $curbside_coordinates |
|
| 55 | + */ |
|
| 56 | + public $curbside_coordinates = []; |
|
| 57 | 57 | |
| 58 | - /** The address without number |
|
| 59 | - * @var string $address_without_number |
|
| 60 | - */ |
|
| 61 | - public $address_without_number; |
|
| 58 | + /** The address without number |
|
| 59 | + * @var string $address_without_number |
|
| 60 | + */ |
|
| 61 | + public $address_without_number; |
|
| 62 | 62 | |
| 63 | - /** The place ID |
|
| 64 | - * @var string $place_id |
|
| 65 | - */ |
|
| 66 | - public $place_id; |
|
| 63 | + /** The place ID |
|
| 64 | + * @var string $place_id |
|
| 65 | + */ |
|
| 66 | + public $place_id; |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | \ No newline at end of file |