@@ -6,93 +6,93 @@ |
||
6 | 6 | |
7 | 7 | class Endpoint |
8 | 8 | { |
9 | - const API_VERSION = "5"; |
|
9 | + const API_VERSION = "5"; |
|
10 | 10 | |
11 | - const MAIN_HOST = "https://wh.route4me.com/modules/api/v5.0"; |
|
11 | + const MAIN_HOST = "https://wh.route4me.com/modules/api/v5.0"; |
|
12 | 12 | |
13 | - const MAIN_HOST_WEB = "https://wh.route4me.com/modules/webapi/v5.0"; |
|
13 | + const MAIN_HOST_WEB = "https://wh.route4me.com/modules/webapi/v5.0"; |
|
14 | 14 | |
15 | - // <editor-fold defaultstate="collapsed" desc="region Routes"> |
|
15 | + // <editor-fold defaultstate="collapsed" desc="region Routes"> |
|
16 | 16 | |
17 | - const Routes = self::MAIN_HOST . "/routes"; |
|
18 | - const RoutesDuplicate = self::MAIN_HOST . "/routes/duplicate"; |
|
19 | - const RoutesMerge = self::MAIN_HOST . "/routes/merge"; |
|
20 | - const RoutesPaginate = self::MAIN_HOST . "/routes/paginate"; |
|
21 | - const RoutesFallbackPaginate = self::MAIN_HOST . "/routes/fallback/paginate"; |
|
22 | - const RoutesFallbackDatatable = self::MAIN_HOST . "/routes/fallback/datatable"; |
|
23 | - const RoutesFallback = self::MAIN_HOST . "/routes/fallback"; |
|
24 | - const RoutesReindexCallback = self::MAIN_HOST . "/routes/reindex-callback"; |
|
25 | - const RoutesDatatable = self::MAIN_HOST . "/routes/datatable"; |
|
26 | - const RoutesDatatableConfig = self::MAIN_HOST . "/routes/datatable/config"; |
|
27 | - const RoutesDatatableConfigFallback = self::MAIN_HOST . "/routes/fallback/datatable/config"; |
|
17 | + const Routes = self::MAIN_HOST . "/routes"; |
|
18 | + const RoutesDuplicate = self::MAIN_HOST . "/routes/duplicate"; |
|
19 | + const RoutesMerge = self::MAIN_HOST . "/routes/merge"; |
|
20 | + const RoutesPaginate = self::MAIN_HOST . "/routes/paginate"; |
|
21 | + const RoutesFallbackPaginate = self::MAIN_HOST . "/routes/fallback/paginate"; |
|
22 | + const RoutesFallbackDatatable = self::MAIN_HOST . "/routes/fallback/datatable"; |
|
23 | + const RoutesFallback = self::MAIN_HOST . "/routes/fallback"; |
|
24 | + const RoutesReindexCallback = self::MAIN_HOST . "/routes/reindex-callback"; |
|
25 | + const RoutesDatatable = self::MAIN_HOST . "/routes/datatable"; |
|
26 | + const RoutesDatatableConfig = self::MAIN_HOST . "/routes/datatable/config"; |
|
27 | + const RoutesDatatableConfigFallback = self::MAIN_HOST . "/routes/fallback/datatable/config"; |
|
28 | 28 | |
29 | - // </editor-fold> |
|
29 | + // </editor-fold> |
|
30 | 30 | |
31 | - // <editor-fold defaultstate="collapsed" desc="Team Users"> |
|
31 | + // <editor-fold defaultstate="collapsed" desc="Team Users"> |
|
32 | 32 | |
33 | - const TeamUsers = self::MAIN_HOST . "/team/users"; |
|
34 | - const TeamUsersBulkCreate = self::MAIN_HOST . "/team/bulk-insert"; |
|
35 | - const DriverReview = self::MAIN_HOST . "/driver-reviews"; |
|
33 | + const TeamUsers = self::MAIN_HOST . "/team/users"; |
|
34 | + const TeamUsersBulkCreate = self::MAIN_HOST . "/team/bulk-insert"; |
|
35 | + const DriverReview = self::MAIN_HOST . "/driver-reviews"; |
|
36 | 36 | |
37 | - // </editor-fold> |
|
37 | + // </editor-fold> |
|
38 | 38 | |
39 | - const ACCOUNT_PROFILE = self::MAIN_HOST . "/profile-api"; |
|
39 | + const ACCOUNT_PROFILE = self::MAIN_HOST . "/profile-api"; |
|
40 | 40 | |
41 | - // <editor-fold defaultstate="collapsed" desc="Vehicles"> |
|
41 | + // <editor-fold defaultstate="collapsed" desc="Vehicles"> |
|
42 | 42 | |
43 | - const Vehicles = self::MAIN_HOST . "/vehicles"; |
|
44 | - const VehicleTemporary = self::MAIN_HOST . "/vehicles/assign"; |
|
45 | - const VehicleExecuteOrder = self::MAIN_HOST . "/vehicles/execute"; |
|
46 | - const VehicleLocation = self::MAIN_HOST . "/vehicles/location"; |
|
47 | - const VehicleProfiles = self::MAIN_HOST . "/vehicle-profiles"; |
|
48 | - const VehicleLicense = self::MAIN_HOST . "/vehicles/license"; |
|
49 | - const VehicleSearch = self::MAIN_HOST . "/vehicles/search"; |
|
43 | + const Vehicles = self::MAIN_HOST . "/vehicles"; |
|
44 | + const VehicleTemporary = self::MAIN_HOST . "/vehicles/assign"; |
|
45 | + const VehicleExecuteOrder = self::MAIN_HOST . "/vehicles/execute"; |
|
46 | + const VehicleLocation = self::MAIN_HOST . "/vehicles/location"; |
|
47 | + const VehicleProfiles = self::MAIN_HOST . "/vehicle-profiles"; |
|
48 | + const VehicleLicense = self::MAIN_HOST . "/vehicles/license"; |
|
49 | + const VehicleSearch = self::MAIN_HOST . "/vehicles/search"; |
|
50 | 50 | |
51 | - // </editor-fold> |
|
51 | + // </editor-fold> |
|
52 | 52 | |
53 | - // <editor-fold defaultstate="collapsed" desc="Telematicx Platform"> |
|
53 | + // <editor-fold defaultstate="collapsed" desc="Telematicx Platform"> |
|
54 | 54 | |
55 | - const STAGING_HOST = "https://virtserver.swaggerhub.com/Route4Me/telematics-gateway/1.0.0"; |
|
55 | + const STAGING_HOST = "https://virtserver.swaggerhub.com/Route4Me/telematics-gateway/1.0.0"; |
|
56 | 56 | |
57 | - const TELEMATICS_CONNECTION = self::STAGING_HOST."/connections"; |
|
58 | - const TELEMATICS_CONNECTION_VEHICLES = self::STAGING_HOST . "/connections/{connection_token}/vehicles"; |
|
57 | + const TELEMATICS_CONNECTION = self::STAGING_HOST."/connections"; |
|
58 | + const TELEMATICS_CONNECTION_VEHICLES = self::STAGING_HOST . "/connections/{connection_token}/vehicles"; |
|
59 | 59 | |
60 | - const TELEMATICS_ACCESS_TOKEN = self::STAGING_HOST . "/access-tokens"; |
|
61 | - const TELEMATICS_ACCESS_TOKEN_SCHEDULES = self::STAGING_HOST . "/access-token-schedules"; |
|
62 | - const TELEMATICS_ACCESS_TOKEN_SCHEDULE_ITEMS = self::STAGING_HOST . "/access-token-schedules/{schedule_id}/items"; |
|
60 | + const TELEMATICS_ACCESS_TOKEN = self::STAGING_HOST . "/access-tokens"; |
|
61 | + const TELEMATICS_ACCESS_TOKEN_SCHEDULES = self::STAGING_HOST . "/access-token-schedules"; |
|
62 | + const TELEMATICS_ACCESS_TOKEN_SCHEDULE_ITEMS = self::STAGING_HOST . "/access-token-schedules/{schedule_id}/items"; |
|
63 | 63 | |
64 | - const TELEMATICS_VEHICLE_GROUPS = self::STAGING_HOST . "/vehicle-groups"; |
|
65 | - const TELEMATICS_VEHICLE_GROUPS_RELATION = self::STAGING_HOST . "/vehicle-groups/{vehicle_group_id}/{relation}"; |
|
66 | - const TELEMATICS_VEHICLES_RESLATION = self::STAGING_HOST . "/vehicles/{vehicle_id}/{relation}"; |
|
64 | + const TELEMATICS_VEHICLE_GROUPS = self::STAGING_HOST . "/vehicle-groups"; |
|
65 | + const TELEMATICS_VEHICLE_GROUPS_RELATION = self::STAGING_HOST . "/vehicle-groups/{vehicle_group_id}/{relation}"; |
|
66 | + const TELEMATICS_VEHICLES_RESLATION = self::STAGING_HOST . "/vehicles/{vehicle_id}/{relation}"; |
|
67 | 67 | |
68 | - const TELEMATICS_INFO_MEMBERS = self::STAGING_HOST . "/info/members"; |
|
69 | - const TELEMATICS_INFO_VEHICLES = self::STAGING_HOST . "/info/vehicles"; |
|
70 | - const TELEMATICS_INFO_VEHICLE = self::STAGING_HOST . "/info/vehicle/{vehicle_id}/track"; |
|
71 | - const TELEMATICS_INFO_MODULES = self::STAGING_HOST . "/info/members"; |
|
68 | + const TELEMATICS_INFO_MEMBERS = self::STAGING_HOST . "/info/members"; |
|
69 | + const TELEMATICS_INFO_VEHICLES = self::STAGING_HOST . "/info/vehicles"; |
|
70 | + const TELEMATICS_INFO_VEHICLE = self::STAGING_HOST . "/info/vehicle/{vehicle_id}/track"; |
|
71 | + const TELEMATICS_INFO_MODULES = self::STAGING_HOST . "/info/members"; |
|
72 | 72 | |
73 | - const TELEMATICS_ADDRESSES = self::STAGING_HOST . "/addresses"; |
|
73 | + const TELEMATICS_ADDRESSES = self::STAGING_HOST . "/addresses"; |
|
74 | 74 | |
75 | - const TELEMATICS_Errors = self::STAGING_HOST . "/errors"; |
|
75 | + const TELEMATICS_Errors = self::STAGING_HOST . "/errors"; |
|
76 | 76 | |
77 | - const TELEMATICS_CUSTOMER_NOTIFICATIONS = self::STAGING_HOST . "/customers/{customer_id}/notifications"; |
|
78 | - const TELEMATICS_CUSTOMERS = self::STAGING_HOST . "/customers"; |
|
79 | - const TELEMATICS_CUSTOMER_ID = self::STAGING_HOST . "/customers/{customer_id}"; |
|
77 | + const TELEMATICS_CUSTOMER_NOTIFICATIONS = self::STAGING_HOST . "/customers/{customer_id}/notifications"; |
|
78 | + const TELEMATICS_CUSTOMERS = self::STAGING_HOST . "/customers"; |
|
79 | + const TELEMATICS_CUSTOMER_ID = self::STAGING_HOST . "/customers/{customer_id}"; |
|
80 | 80 | |
81 | - const TELEMATICS_NOTIFICATION_SCHEDULE_ITEMS = self::STAGING_HOST . "/notification-schedules/{notification_schedule_id}/items"; |
|
82 | - const TELEMATICS_NOTIFICATION_SCHEDULES = self::STAGING_HOST . "/notification-schedules"; |
|
83 | - const TELEMATICS_NOTIFICATION_SCHEDULE_IS = self::STAGING_HOST . "/notification-schedules/{schedule_id}"; |
|
84 | - const TELEMATICS_ONETIME_NOTIFICATIONS = self::STAGING_HOST . "/one-time-notifications"; |
|
81 | + const TELEMATICS_NOTIFICATION_SCHEDULE_ITEMS = self::STAGING_HOST . "/notification-schedules/{notification_schedule_id}/items"; |
|
82 | + const TELEMATICS_NOTIFICATION_SCHEDULES = self::STAGING_HOST . "/notification-schedules"; |
|
83 | + const TELEMATICS_NOTIFICATION_SCHEDULE_IS = self::STAGING_HOST . "/notification-schedules/{schedule_id}"; |
|
84 | + const TELEMATICS_ONETIME_NOTIFICATIONS = self::STAGING_HOST . "/one-time-notifications"; |
|
85 | 85 | |
86 | - const TELEMATICS_MEMBER = self::STAGING_HOST; |
|
86 | + const TELEMATICS_MEMBER = self::STAGING_HOST; |
|
87 | 87 | |
88 | - const TELEMATICS_MEMBER_MODULES = self::STAGING_HOST . "/user-activated-modules"; |
|
88 | + const TELEMATICS_MEMBER_MODULES = self::STAGING_HOST . "/user-activated-modules"; |
|
89 | 89 | |
90 | - const TELEMATICS_MEMBER_MODULE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}"; |
|
91 | - const TELEMATICS_MEMBER_MODULE_VEHICLES = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles"; |
|
92 | - const TELEMATICS_MEMBER_MODULE_VEHICLE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles/{vehicle_id}"; |
|
90 | + const TELEMATICS_MEMBER_MODULE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}"; |
|
91 | + const TELEMATICS_MEMBER_MODULE_VEHICLES = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles"; |
|
92 | + const TELEMATICS_MEMBER_MODULE_VEHICLE_ID = self::STAGING_HOST . "/user-activated-modules/{module_id}/vehicles/{vehicle_id}"; |
|
93 | 93 | |
94 | - const TELEMATICS_VENDORS = self::STAGING_HOST . "/vendors"; |
|
95 | - const TELEMATICS_VENDOR_ID = self::STAGING_HOST . "/vendors/{vendor_id}"; |
|
94 | + const TELEMATICS_VENDORS = self::STAGING_HOST . "/vendors"; |
|
95 | + const TELEMATICS_VENDOR_ID = self::STAGING_HOST . "/vendors/{vendor_id}"; |
|
96 | 96 | |
97 | - // </editor-fold> |
|
97 | + // </editor-fold> |
|
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -6,17 +6,17 @@ |
||
6 | 6 | /** Enumeration of the fuel types. */ |
7 | 7 | class FuelTypes |
8 | 8 | { |
9 | - const UNLEADED_87 = "unleaded 87"; |
|
9 | + const UNLEADED_87 = "unleaded 87"; |
|
10 | 10 | |
11 | - const UNLEADED_89 = "unleaded 89"; |
|
11 | + const UNLEADED_89 = "unleaded 89"; |
|
12 | 12 | |
13 | - const UNLEADED_91 = "unleaded 91"; |
|
13 | + const UNLEADED_91 = "unleaded 91"; |
|
14 | 14 | |
15 | - const UNLEADED_93 = "unleaded 93"; |
|
15 | + const UNLEADED_93 = "unleaded 93"; |
|
16 | 16 | |
17 | - const DIESEL = "diesel"; |
|
17 | + const DIESEL = "diesel"; |
|
18 | 18 | |
19 | - const ELECTRIC = "electric"; |
|
19 | + const ELECTRIC = "electric"; |
|
20 | 20 | |
21 | - const HYBRID = "hybrid"; |
|
21 | + const HYBRID = "hybrid"; |
|
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -4,6 +4,6 @@ |
||
4 | 4 | |
5 | 5 | class DistanceUnit |
6 | 6 | { |
7 | - const MILES = 'mi'; |
|
8 | - const KILOMETERS = 'km'; |
|
7 | + const MILES = 'mi'; |
|
8 | + const KILOMETERS = 'km'; |
|
9 | 9 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | class OptimizationType |
6 | 6 | { |
7 | - const DISTANCE = 'Distance'; |
|
8 | - const TIME = 'Time'; |
|
9 | - const TIME_WITH_TRAFFIC = 'timeWithTraffic'; |
|
7 | + const DISTANCE = 'Distance'; |
|
8 | + const TIME = 'Time'; |
|
9 | + const TIME_WITH_TRAFFIC = 'timeWithTraffic'; |
|
10 | 10 | } |
@@ -10,67 +10,67 @@ |
||
10 | 10 | */ |
11 | 11 | class OrderInventory extends \Route4Me\Common |
12 | 12 | { |
13 | - /** Unique inventory ID |
|
14 | - * @var integer $inventory_id |
|
15 | - */ |
|
16 | - public $inventory_id; |
|
17 | - |
|
18 | - /** Unique order ID |
|
19 | - * @var integer $order_id |
|
20 | - */ |
|
21 | - public $order_id; |
|
22 | - |
|
23 | - /** Order inventory name |
|
24 | - * @var string $name |
|
25 | - */ |
|
26 | - public $name; |
|
27 | - |
|
28 | - /** Order inventory quantity |
|
29 | - * @var integer $quantity |
|
30 | - */ |
|
31 | - public $quantity; |
|
32 | - |
|
33 | - /** Total weight of the order inventory. |
|
34 | - * @var double $total_weight |
|
35 | - */ |
|
36 | - public $total_weight; |
|
37 | - |
|
38 | - /** Total volume of the inventory. |
|
39 | - * @var double $total_volume |
|
40 | - */ |
|
41 | - public $total_volume; |
|
42 | - |
|
43 | - /** Total cost of the inventory. |
|
44 | - * @var double $total_cost |
|
45 | - */ |
|
46 | - public $total_cost; |
|
47 | - |
|
48 | - /** Total price of the inventory. |
|
49 | - * @var double $total_price |
|
50 | - */ |
|
51 | - public $total_price; |
|
52 | - |
|
53 | - /** When the inventory created. |
|
54 | - * @var string $created_at |
|
55 | - */ |
|
56 | - public $created_at; |
|
57 | - |
|
58 | - /** When the inventory updated. |
|
59 | - * @var string $updated_at |
|
60 | - */ |
|
61 | - public $updated_at; |
|
62 | - |
|
63 | - public static function fromArray(array $params) |
|
64 | - { |
|
65 | - $orderInventory = new self(); |
|
66 | - |
|
67 | - foreach ($params as $key => $value) { |
|
68 | - if (property_exists($orderInventory, $key)) { |
|
69 | - $orderInventory->{$key} = $value; |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - return $orderInventory; |
|
74 | - } |
|
13 | + /** Unique inventory ID |
|
14 | + * @var integer $inventory_id |
|
15 | + */ |
|
16 | + public $inventory_id; |
|
17 | + |
|
18 | + /** Unique order ID |
|
19 | + * @var integer $order_id |
|
20 | + */ |
|
21 | + public $order_id; |
|
22 | + |
|
23 | + /** Order inventory name |
|
24 | + * @var string $name |
|
25 | + */ |
|
26 | + public $name; |
|
27 | + |
|
28 | + /** Order inventory quantity |
|
29 | + * @var integer $quantity |
|
30 | + */ |
|
31 | + public $quantity; |
|
32 | + |
|
33 | + /** Total weight of the order inventory. |
|
34 | + * @var double $total_weight |
|
35 | + */ |
|
36 | + public $total_weight; |
|
37 | + |
|
38 | + /** Total volume of the inventory. |
|
39 | + * @var double $total_volume |
|
40 | + */ |
|
41 | + public $total_volume; |
|
42 | + |
|
43 | + /** Total cost of the inventory. |
|
44 | + * @var double $total_cost |
|
45 | + */ |
|
46 | + public $total_cost; |
|
47 | + |
|
48 | + /** Total price of the inventory. |
|
49 | + * @var double $total_price |
|
50 | + */ |
|
51 | + public $total_price; |
|
52 | + |
|
53 | + /** When the inventory created. |
|
54 | + * @var string $created_at |
|
55 | + */ |
|
56 | + public $created_at; |
|
57 | + |
|
58 | + /** When the inventory updated. |
|
59 | + * @var string $updated_at |
|
60 | + */ |
|
61 | + public $updated_at; |
|
62 | + |
|
63 | + public static function fromArray(array $params) |
|
64 | + { |
|
65 | + $orderInventory = new self(); |
|
66 | + |
|
67 | + foreach ($params as $key => $value) { |
|
68 | + if (property_exists($orderInventory, $key)) { |
|
69 | + $orderInventory->{$key} = $value; |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + return $orderInventory; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | \ No newline at end of file |
@@ -9,130 +9,130 @@ |
||
9 | 9 | */ |
10 | 10 | class Connection extends Common |
11 | 11 | { |
12 | - /** |
|
13 | - * Telemetics connection name |
|
14 | - * @var type string |
|
15 | - */ |
|
16 | - public $name; |
|
17 | - |
|
18 | - /** |
|
19 | - * Telemetics connection type |
|
20 | - * @var type string |
|
21 | - */ |
|
22 | - public $vendor; |
|
12 | + /** |
|
13 | + * Telemetics connection name |
|
14 | + * @var type string |
|
15 | + */ |
|
16 | + public $name; |
|
17 | + |
|
18 | + /** |
|
19 | + * Telemetics connection type |
|
20 | + * @var type string |
|
21 | + */ |
|
22 | + public $vendor; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Telematics connection access host |
|
26 | - * @var type string |
|
27 | - */ |
|
28 | - public $host; |
|
29 | - |
|
30 | - /** |
|
31 | - * Telematics connection access api_key |
|
32 | - * @var type string |
|
33 | - */ |
|
34 | - public $api_key; |
|
35 | - |
|
36 | - /** |
|
37 | - * Telematics connection access account ID. |
|
38 | - * @var type string |
|
39 | - */ |
|
40 | - public $account_id; |
|
41 | - |
|
42 | - /** |
|
43 | - * Telematics connection access username |
|
44 | - * @var type string |
|
45 | - */ |
|
46 | - public $username; |
|
47 | - |
|
48 | - /** |
|
49 | - * Telematics connection access password |
|
50 | - * @var type string |
|
51 | - */ |
|
52 | - public $password; |
|
53 | - |
|
54 | - /** |
|
55 | - * Telematics connection access token |
|
56 | - * @var type string |
|
57 | - */ |
|
58 | - public $connection_token; |
|
59 | - |
|
60 | - /** |
|
61 | - * Telemetics connection type ID |
|
62 | - * @var type integer |
|
63 | - */ |
|
64 | - public $vendor_id; |
|
65 | - |
|
66 | - /** |
|
67 | - * Disable/enable vehicle tracking |
|
68 | - * @var type Boolean |
|
69 | - */ |
|
70 | - public $is_enabled; |
|
71 | - |
|
72 | - /** |
|
73 | - * Vehicle tracking interval in seconds |
|
74 | - * @var type integer |
|
75 | - */ |
|
76 | - public $vehicle_position_refresh_rate; |
|
77 | - |
|
78 | - /** |
|
79 | - * Maximum idle time |
|
80 | - * @var type integer |
|
81 | - */ |
|
82 | - public $max_idle_time; |
|
83 | - |
|
84 | - /** |
|
85 | - * Syncronized vehicles count |
|
86 | - * @var type integer |
|
87 | - */ |
|
88 | - public $synced_vehicles_count; |
|
89 | - |
|
90 | - /** |
|
91 | - * Total vehicles count |
|
92 | - * @var type integer |
|
93 | - */ |
|
94 | - public $total_vehicles_count; |
|
95 | - |
|
96 | - /** |
|
97 | - * Total addresses count |
|
98 | - * @var type integer |
|
99 | - */ |
|
100 | - public $total_addresses_count; |
|
101 | - |
|
102 | - /** |
|
103 | - * The last timestamp the vehicles reloaded |
|
104 | - * @var type string |
|
105 | - */ |
|
106 | - public $last_vehicles_reload; |
|
107 | - |
|
108 | - /** |
|
109 | - * The last timestamp the addresses reloaded |
|
110 | - * @var type string |
|
111 | - */ |
|
112 | - public $last_addresses_reload; |
|
113 | - |
|
114 | - /** |
|
115 | - * The last timestamp the postions reloaded |
|
116 | - * @var type string |
|
117 | - */ |
|
118 | - public $last_position_reload; |
|
119 | - |
|
120 | - /** |
|
121 | - * Metadata, custom key-value storage. |
|
122 | - * @var type array |
|
123 | - */ |
|
124 | - public $metadata = []; |
|
125 | - |
|
126 | - public static function fromArray(array $params) |
|
127 | - { |
|
128 | - $thisParams = new self(); |
|
24 | + /** |
|
25 | + * Telematics connection access host |
|
26 | + * @var type string |
|
27 | + */ |
|
28 | + public $host; |
|
29 | + |
|
30 | + /** |
|
31 | + * Telematics connection access api_key |
|
32 | + * @var type string |
|
33 | + */ |
|
34 | + public $api_key; |
|
35 | + |
|
36 | + /** |
|
37 | + * Telematics connection access account ID. |
|
38 | + * @var type string |
|
39 | + */ |
|
40 | + public $account_id; |
|
41 | + |
|
42 | + /** |
|
43 | + * Telematics connection access username |
|
44 | + * @var type string |
|
45 | + */ |
|
46 | + public $username; |
|
47 | + |
|
48 | + /** |
|
49 | + * Telematics connection access password |
|
50 | + * @var type string |
|
51 | + */ |
|
52 | + public $password; |
|
53 | + |
|
54 | + /** |
|
55 | + * Telematics connection access token |
|
56 | + * @var type string |
|
57 | + */ |
|
58 | + public $connection_token; |
|
59 | + |
|
60 | + /** |
|
61 | + * Telemetics connection type ID |
|
62 | + * @var type integer |
|
63 | + */ |
|
64 | + public $vendor_id; |
|
65 | + |
|
66 | + /** |
|
67 | + * Disable/enable vehicle tracking |
|
68 | + * @var type Boolean |
|
69 | + */ |
|
70 | + public $is_enabled; |
|
71 | + |
|
72 | + /** |
|
73 | + * Vehicle tracking interval in seconds |
|
74 | + * @var type integer |
|
75 | + */ |
|
76 | + public $vehicle_position_refresh_rate; |
|
77 | + |
|
78 | + /** |
|
79 | + * Maximum idle time |
|
80 | + * @var type integer |
|
81 | + */ |
|
82 | + public $max_idle_time; |
|
83 | + |
|
84 | + /** |
|
85 | + * Syncronized vehicles count |
|
86 | + * @var type integer |
|
87 | + */ |
|
88 | + public $synced_vehicles_count; |
|
89 | + |
|
90 | + /** |
|
91 | + * Total vehicles count |
|
92 | + * @var type integer |
|
93 | + */ |
|
94 | + public $total_vehicles_count; |
|
95 | + |
|
96 | + /** |
|
97 | + * Total addresses count |
|
98 | + * @var type integer |
|
99 | + */ |
|
100 | + public $total_addresses_count; |
|
101 | + |
|
102 | + /** |
|
103 | + * The last timestamp the vehicles reloaded |
|
104 | + * @var type string |
|
105 | + */ |
|
106 | + public $last_vehicles_reload; |
|
107 | + |
|
108 | + /** |
|
109 | + * The last timestamp the addresses reloaded |
|
110 | + * @var type string |
|
111 | + */ |
|
112 | + public $last_addresses_reload; |
|
113 | + |
|
114 | + /** |
|
115 | + * The last timestamp the postions reloaded |
|
116 | + * @var type string |
|
117 | + */ |
|
118 | + public $last_position_reload; |
|
119 | + |
|
120 | + /** |
|
121 | + * Metadata, custom key-value storage. |
|
122 | + * @var type array |
|
123 | + */ |
|
124 | + public $metadata = []; |
|
125 | + |
|
126 | + public static function fromArray(array $params) |
|
127 | + { |
|
128 | + $thisParams = new self(); |
|
129 | 129 | |
130 | - foreach ($params as $key => $value) { |
|
131 | - if (property_exists($thisParams, $key)) { |
|
132 | - $thisParams->{$key} = $value; |
|
133 | - } |
|
134 | - } |
|
130 | + foreach ($params as $key => $value) { |
|
131 | + if (property_exists($thisParams, $key)) { |
|
132 | + $thisParams->{$key} = $value; |
|
133 | + } |
|
134 | + } |
|
135 | 135 | |
136 | - return $thisParams; |
|
137 | - } |
|
136 | + return $thisParams; |
|
137 | + } |
|
138 | 138 | } |
@@ -10,96 +10,96 @@ |
||
10 | 10 | */ |
11 | 11 | class ConnectionParameters extends Common |
12 | 12 | { |
13 | - /** |
|
14 | - * Telemetics connection type |
|
15 | - * @var type string |
|
16 | - */ |
|
17 | - public $vendor; |
|
13 | + /** |
|
14 | + * Telemetics connection type |
|
15 | + * @var type string |
|
16 | + */ |
|
17 | + public $vendor; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Telemetics connection type ID |
|
21 | - * @var type integer |
|
22 | - */ |
|
23 | - public $vendor_id; |
|
19 | + /** |
|
20 | + * Telemetics connection type ID |
|
21 | + * @var type integer |
|
22 | + */ |
|
23 | + public $vendor_id; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Telemetics connection name |
|
27 | - * Required for telematics connection registration. |
|
28 | - * @var type string |
|
29 | - */ |
|
30 | - public $name; |
|
25 | + /** |
|
26 | + * Telemetics connection name |
|
27 | + * Required for telematics connection registration. |
|
28 | + * @var type string |
|
29 | + */ |
|
30 | + public $name; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Telematics connection access host. |
|
34 | - * @var type string |
|
35 | - */ |
|
36 | - public $host; |
|
32 | + /** |
|
33 | + * Telematics connection access host. |
|
34 | + * @var type string |
|
35 | + */ |
|
36 | + public $host; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Telematics connection access api_key. |
|
40 | - * @var type string |
|
41 | - */ |
|
42 | - public $api_key; |
|
38 | + /** |
|
39 | + * Telematics connection access api_key. |
|
40 | + * @var type string |
|
41 | + */ |
|
42 | + public $api_key; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Telematics connection access account_id. |
|
46 | - * @var type string |
|
47 | - */ |
|
48 | - public $account_id; |
|
44 | + /** |
|
45 | + * Telematics connection access account_id. |
|
46 | + * @var type string |
|
47 | + */ |
|
48 | + public $account_id; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Telematics connection access username |
|
52 | - * @var type string |
|
53 | - */ |
|
54 | - public $username; |
|
50 | + /** |
|
51 | + * Telematics connection access username |
|
52 | + * @var type string |
|
53 | + */ |
|
54 | + public $username; |
|
55 | 55 | |
56 | - /** |
|
57 | - * Telematics connection access password. |
|
58 | - * @var type string |
|
59 | - */ |
|
60 | - public $password; |
|
56 | + /** |
|
57 | + * Telematics connection access password. |
|
58 | + * @var type string |
|
59 | + */ |
|
60 | + public $password; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Vehicle tracking interval in seconds (default value 60). |
|
64 | - * @var type integer |
|
65 | - */ |
|
66 | - public $vehicle_position_refresh_rate; |
|
62 | + /** |
|
63 | + * Vehicle tracking interval in seconds (default value 60). |
|
64 | + * @var type integer |
|
65 | + */ |
|
66 | + public $vehicle_position_refresh_rate; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Validate connections credentials. |
|
70 | - * @var type Boolean |
|
71 | - */ |
|
72 | - public $validate_remote_credentials; |
|
68 | + /** |
|
69 | + * Validate connections credentials. |
|
70 | + * @var type Boolean |
|
71 | + */ |
|
72 | + public $validate_remote_credentials; |
|
73 | 73 | |
74 | - /** |
|
75 | - * Disable/enable vehicle tracking. |
|
76 | - * @var type Boolean |
|
77 | - */ |
|
78 | - public $is_enabled; |
|
74 | + /** |
|
75 | + * Disable/enable vehicle tracking. |
|
76 | + * @var type Boolean |
|
77 | + */ |
|
78 | + public $is_enabled; |
|
79 | 79 | |
80 | - /** |
|
81 | - * Metadata |
|
82 | - * @var type string |
|
83 | - */ |
|
84 | - public $metadata; |
|
80 | + /** |
|
81 | + * Metadata |
|
82 | + * @var type string |
|
83 | + */ |
|
84 | + public $metadata; |
|
85 | 85 | |
86 | - /** |
|
87 | - * Telematics connection access token. |
|
88 | - * Required to show specified connection. |
|
89 | - * @var type string |
|
90 | - */ |
|
91 | - public $connection_token; |
|
86 | + /** |
|
87 | + * Telematics connection access token. |
|
88 | + * Required to show specified connection. |
|
89 | + * @var type string |
|
90 | + */ |
|
91 | + public $connection_token; |
|
92 | 92 | |
93 | - public static function fromArray(array $params) |
|
94 | - { |
|
95 | - $thisParams = new self(); |
|
93 | + public static function fromArray(array $params) |
|
94 | + { |
|
95 | + $thisParams = new self(); |
|
96 | 96 | |
97 | - foreach ($params as $key => $value) { |
|
98 | - if (property_exists($thisParams, $key)) { |
|
99 | - $thisParams->{$key} = $value; |
|
100 | - } |
|
101 | - } |
|
97 | + foreach ($params as $key => $value) { |
|
98 | + if (property_exists($thisParams, $key)) { |
|
99 | + $thisParams->{$key} = $value; |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - return $thisParams; |
|
104 | - } |
|
103 | + return $thisParams; |
|
104 | + } |
|
105 | 105 | } |
@@ -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 | } |
@@ -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 |