From 0be176b6a741502d2e25aa29680cc8e9eaed8ef8 Mon Sep 17 00:00:00 2001 From: 15 <15@mail.ru> Date: Thu, 16 Feb 2023 12:13:29 +0500 Subject: [PATCH] Fixed an issue where the base url was stored in a static variable. --- phpunit.xml | 6 +- src/Route4Me/AddressBookGroup.php | 4 +- src/Route4Me/Enum/Endpoint.php | 116 +++++++-------- src/Route4Me/Geocoding.php | 12 +- src/Route4Me/Members/Member.php | 6 +- src/Route4Me/Members/MemberConfiguration.php | 12 +- .../TelematicsConnection.php | 8 -- .../TelematicsGateway/TelematicsVendor.php | 13 +- src/Route4Me/TelematicsVendor.php | 4 +- .../V5/Routes/AddonRoutesApi/Route.php | 136 +++++++++--------- src/Route4Me/Vehicles/Vehicle.php | 6 +- src/Route4Me/Vehicles/VehicleV4.php | 9 +- 12 files changed, 156 insertions(+), 176 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index dfcefd3..8a0307e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,7 @@ @@ -32,7 +32,9 @@ UnitTestFiles/Test/TrackingTests.php UnitTestFiles/Test/UserTests.php UnitTestFiles/Test/VehicleTests.php - + + + UnitTestFiles/Test diff --git a/src/Route4Me/AddressBookGroup.php b/src/Route4Me/AddressBookGroup.php index efa8e86..a0b524b 100644 --- a/src/Route4Me/AddressBookGroup.php +++ b/src/Route4Me/AddressBookGroup.php @@ -83,7 +83,7 @@ public static function createAddressBookGroup(array $params) return $abGroup; } - public static function searchAddressBookGroups(array $params) + public static function searchAddressBookGroups(array $params) { $allBodyFields = ['fields', 'offset', 'limit', 'filter']; @@ -127,7 +127,7 @@ public static function getRandomAddressBookGroup(array $params) { $abGroups = self::getAddressBookGroups($params); - if (isset($abGroups) && sizeof($abGroups>1)) { + if (isset($abGroups) && sizeof($abGroups) > 1) { $groupsSize = sizeof($abGroups); $randomGroupIndex = rand(0, $groupsSize - 1); diff --git a/src/Route4Me/Enum/Endpoint.php b/src/Route4Me/Enum/Endpoint.php index 2933008..87fef93 100644 --- a/src/Route4Me/Enum/Endpoint.php +++ b/src/Route4Me/Enum/Endpoint.php @@ -4,74 +4,76 @@ class Endpoint { - const BASE_URL = 'https://api.route4me.com'; - const WH_BASE_URL = 'https://wh.route4me.com/modules'; + const BASE_URL = ''; + const BASE_URL_1 = 'https://api.route4me.com'; + const WH_BASE_URL = ''; + const WH_BASE_URL_1 = 'https://wh.route4me.com/modules'; - const AVOIDANCE_ZONE = '/api.v4/avoidance.php'; - const TERRITORY_V4 = '/api.v4/territory.php'; + const AVOIDANCE_ZONE = self::BASE_URL_1 . '/api.v4/avoidance.php'; + const TERRITORY_V4 = self::BASE_URL_1 . '/api.v4/territory.php'; - const GET_ACTIVITIES = '/api/get_activities.php'; - const ACTIVITY_FEED = '/api.v4/activity_feed.php'; + const GET_ACTIVITIES = self::BASE_URL_1 . '/api/get_activities.php'; + const ACTIVITY_FEED = self::BASE_URL_1 . '/api.v4/activity_feed.php'; - const ADDRESS_V4 = '/api.v4/address.php'; - const MOVE_ROUTE_DESTINATION = '/actions/route/move_route_destination.php'; - const MARK_ADDRESS_DEPARTED = '/api/route/mark_address_departed.php'; - const UPDATE_ADDRESS_VISITED = '/actions/address/update_address_visited.php'; + const ADDRESS_V4 = self::BASE_URL_1 . '/api.v4/address.php'; + const MOVE_ROUTE_DESTINATION = self::BASE_URL_1 . '/actions/route/move_route_destination.php'; + const MARK_ADDRESS_DEPARTED = self::BASE_URL_1 . '/api/route/mark_address_departed.php'; + const UPDATE_ADDRESS_VISITED = self::BASE_URL_1 . '/actions/address/update_address_visited.php'; - const ADDRESS_BOOK_V4 = '/api.v4/address_book.php'; - const ADDRESS_BOOK_GROUP = '/api.v4/address_book_group.php'; - const ADDRESS_BOOK_SEARCH = '/api/address_book/get_search_group_addresses.php'; - const MODIFY_CONTACT = '/api/address_book/modify_contact.php'; + const ADDRESS_BOOK_V4 = self::BASE_URL_1 . '/api.v4/address_book.php'; + const ADDRESS_BOOK_GROUP = self::BASE_URL_1 . '/api.v4/address_book_group.php'; + const ADDRESS_BOOK_SEARCH = self::BASE_URL_1 . '/api/address_book/get_search_group_addresses.php'; + //const MODIFY_CONTACT = '/api/address_book/modify_contact.php'; - const GEOCODER = '/api/geocoder.php'; - const JSON_GEOCODE = '/actions/upload/json-geocode.php'; + const GEOCODER = self::BASE_URL_1 . '/api/geocoder.php'; + //const JSON_GEOCODE = '/actions/upload/json-geocode.php'; const STREET_DATA = 'https://rapid.route4me.com/street_data/'; const STREET_DATA_ZIPCODE = 'https://rapid.route4me.com/street_data/zipcode/'; const STREET_DATA_SERVICE = 'https://rapid.route4me.com/street_data/service/'; - const USER_V4 = '/api.v4/user.php'; - const VERIFY_DEVICE_LICENSE = '/api/device/verify_device_license.php'; - const USER_LICENSE = '/api/member/user_license.php'; - const WEBINAR_REGISTER = '/actions/webinar_register.php'; - const EXPIRE_SESSION = '/datafeed/session/expire_session.php'; - const VALIDATE_SESSION = '/datafeed/session/validate_session.php'; - const AUTHENTICATE = '/actions/authenticate.php'; - const REGISTER_ACTION = '/actions/register_action.php'; - const VIEW_USER_LOCATIONS = '/api/track/view_user_locations.php'; - const CONFIGURATION_SETTINGS = '/api.v4/configuration-settings.php'; - - const OPTIMIZATION_PROBLEM = '/api.v4/optimization_problem.php'; - const HYBRID_DATE_OPTIMIZATION = '/api.v4/hybrid_date_optimization.php'; - const CHANGE_HYBRID_OPTIMIZATION_DEPOT = '/api/change_hybrid_optimization_depot.php'; - - const ORDER_V4 = '/api.v4/order.php'; - const ORDER_CUSTOM_FIELDS_V4 = '/api.v4/order_custom_user_fields.php'; - - const ROUTE_V4 = '/api.v4/route.php'; - const ROUTE_DUPLICATE = '/actions/duplicate_route.php'; - const ROUTES_DELETE = '/actions/delete_routes.php'; - const REOPTIMIZE_V3_2 = '/api.v3/route/reoptimize_2.php'; - const ROUTES_MERGE = '/actions/merge_routes.php'; - const ROUTE_SHARE = '/actions/route/share_route.php'; - const ROUTE_NOTES_ADD = '/actions/addRouteNotes.php'; - const STATUS_V4 = '/api.v4/status.php'; - - const GET_DEVICE_LOCATION = '/api/track/get_device_location.php'; - const TRACK_SET = '/track/set.php'; - const USER_LOCATION = '/api/track/view_user_locations.php'; - - const NOTE_CUSTOM_TYPES_V4 = '/api.v4/note_custom_types.php'; - - const ViewVehicles = '/api/vehicles/view_vehicles.php'; - const VEHICLE_V4 = '/api/vehicles'; - const VEHICLE_V4_API = '/api.v4/vehicle.php'; + const USER_V4 = self::BASE_URL_1 . '/api.v4/user.php'; + const VERIFY_DEVICE_LICENSE = self::BASE_URL_1 . '/api/device/verify_device_license.php'; + const USER_LICENSE = self::BASE_URL_1 . '/api/member/user_license.php'; + const WEBINAR_REGISTER = self::BASE_URL_1 . '/actions/webinar_register.php'; + //const EXPIRE_SESSION = '/datafeed/session/expire_session.php'; + const VALIDATE_SESSION = self::BASE_URL_1 . '/datafeed/session/validate_session.php'; + const AUTHENTICATE = self::BASE_URL_1 . '/actions/authenticate.php'; + const REGISTER_ACTION = self::BASE_URL_1 . '/actions/register_action.php'; + const VIEW_USER_LOCATIONS = self::BASE_URL_1 . '/api/track/view_user_locations.php'; + const CONFIGURATION_SETTINGS = self::BASE_URL_1 . '/api.v4/configuration-settings.php'; + + const OPTIMIZATION_PROBLEM = self::BASE_URL_1 . '/api.v4/optimization_problem.php'; + const HYBRID_DATE_OPTIMIZATION = self::BASE_URL_1 . '/api.v4/hybrid_date_optimization.php'; + const CHANGE_HYBRID_OPTIMIZATION_DEPOT = self::BASE_URL_1 . '/api/change_hybrid_optimization_depot.php'; + + const ORDER_V4 = self::BASE_URL_1 . '/api.v4/order.php'; + const ORDER_CUSTOM_FIELDS_V4 = self::BASE_URL_1 . '/api.v4/order_custom_user_fields.php'; + + const ROUTE_V4 = self::BASE_URL_1 . '/api.v4/route.php'; + //const ROUTE_DUPLICATE = '/actions/duplicate_route.php'; + //const ROUTES_DELETE = '/actions/delete_routes.php'; + const REOPTIMIZE_V3_2 = self::BASE_URL_1 . '/api.v3/route/reoptimize_2.php'; + const ROUTES_MERGE = self::BASE_URL_1 . '/actions/merge_routes.php'; + const ROUTE_SHARE = self::BASE_URL_1 . '/actions/route/share_route.php'; + const ROUTE_NOTES_ADD = self::BASE_URL_1 . '/actions/addRouteNotes.php'; + const STATUS_V4 = self::BASE_URL_1 . '/api.v4/status.php'; + + const GET_DEVICE_LOCATION = self::BASE_URL_1 . '/api/track/get_device_location.php'; + const TRACK_SET = self::BASE_URL_1 . '/track/set.php'; + const USER_LOCATION = self::BASE_URL_1 . '/api/track/view_user_locations.php'; + + const NOTE_CUSTOM_TYPES_V4 = self::BASE_URL_1 . '/api.v4/note_custom_types.php'; + + //const ViewVehicles = '/api/vehicles/view_vehicles.php'; + const VEHICLE_V4 = self::WH_BASE_URL_1 . '/api/vehicles'; + const VEHICLE_V4_API = self::BASE_URL_1 . '/api.v4/vehicle.php'; const TELEMATICS_VENDORS = "http://telematics.route4me.com/api/vendors.php"; - const TELEMATICS_REGISTER_MEMBER = "/api.v4/telematics/register.php"; - const TELEMATICS_CONNECTION = "/api.v4/telematics/connections.php"; - const TELEMATICS_VENDORS_INFO = "/api.v4/telematics/vendors.php"; + const TELEMATICS_REGISTER_MEMBER = self::BASE_URL_1 . "/api.v4/telematics/register.php"; + const TELEMATICS_CONNECTION = self::BASE_URL_1 . "/api.v4/telematics/connections.php"; + //const TELEMATICS_VENDORS_INFO = "/api.v4/telematics/vendors.php"; - const MEMBER_CAPABILITIES = "/api/member/capabilities.php"; + const MEMBER_CAPABILITIES = self::BASE_URL_1 . "/api/member/capabilities.php"; - const SCHEDULE_CALENDAR = "/api/schedule_calendar_data.php"; + const SCHEDULE_CALENDAR = self::BASE_URL_1 . "/api/schedule_calendar_data.php"; } diff --git a/src/Route4Me/Geocoding.php b/src/Route4Me/Geocoding.php index 4c1d617..baf21f8 100644 --- a/src/Route4Me/Geocoding.php +++ b/src/Route4Me/Geocoding.php @@ -57,8 +57,6 @@ public static function reverseGeocoding($params) public static function getStreetData($params) { - Route4Me::setBaseUrl(Endpoint::STREET_DATA); - $allPathFields = ['pk', 'offset', 'limit']; $url_query = Route4Me::generateUrlPath($allPathFields, $params); @@ -66,7 +64,7 @@ public static function getStreetData($params) $query = []; $response = Route4Me::makeRequst([ - 'url' => $url_query, + 'url' => Endpoint::STREET_DATA . $url_query, 'method' => 'GET', 'query' => $query, ]); @@ -76,8 +74,6 @@ public static function getStreetData($params) public static function getZipCode($params) { - Route4Me::setBaseUrl(Endpoint::STREET_DATA_ZIPCODE); - $allPathFields = ['zipcode', 'offset', 'limit']; $url_query = Route4Me::generateUrlPath($allPathFields, $params); @@ -85,7 +81,7 @@ public static function getZipCode($params) $query = []; $response = Route4Me::makeRequst([ - 'url' => $url_query, + 'url' => Endpoint::STREET_DATA_ZIPCODE . $url_query, 'method' => 'GET', 'query' => $query, ]); @@ -95,8 +91,6 @@ public static function getZipCode($params) public static function getService($params) { - Route4Me::setBaseUrl(Endpoint::STREET_DATA_SERVICE); - $allPathFields = ['zipcode', 'housenumber', 'offset', 'limit']; $url_query = Route4Me::generateUrlPath($allPathFields, $params); @@ -104,7 +98,7 @@ public static function getService($params) $query = []; $response = Route4Me::makeRequst([ - 'url' => $url_query, + 'url' => Endpoint::STREET_DATA_SERVICE . $url_query, 'method' => 'GET', 'query' => $query, ]); diff --git a/src/Route4Me/Members/Member.php b/src/Route4Me/Members/Member.php index 0594feb..a2ac02d 100644 --- a/src/Route4Me/Members/Member.php +++ b/src/Route4Me/Members/Member.php @@ -206,7 +206,7 @@ public static function deleteMember($body, &$errorText) 'member_id' => isset($body->member_id) ? $body->member_id : null, ], ]); - } catch (Exception $ex) { + } catch (\Exception $ex) { $errorText = $ex->getMessage(); $response = null; } finally { @@ -231,7 +231,7 @@ public static function newAccountRegistration($params, &$errorText) 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), 'HTTPHEADER' => 'Content-Type: multipart/form-data', ]); - } catch (Exception $ex) { + } catch (\Exception $ex) { $response = null; $errorText = "Cannot registrate new account
".$ex->getMessage(); } finally { @@ -279,7 +279,7 @@ public static function webinarRegistration($params) 'method' => 'POST', 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), ]); - } catch (Exception $ex) { + } catch (\Exception $ex) { $response = null; } finally { return $response; diff --git a/src/Route4Me/Members/MemberConfiguration.php b/src/Route4Me/Members/MemberConfiguration.php index baaa9d1..e150c79 100644 --- a/src/Route4Me/Members/MemberConfiguration.php +++ b/src/Route4Me/Members/MemberConfiguration.php @@ -45,7 +45,7 @@ public function __construct() public static function fromArray(array $params) { - $memberConfiguration = new Self(); + $memberConfiguration = new self(); foreach ($params as $key => $value) { if (property_exists($memberConfiguration, $key)) { @@ -77,7 +77,7 @@ public function CreateNewConfigurationData($params, &$errorText) 'method' => 'POST', 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), ]); - } catch (Exception $ex) { + } catch (\Exception $ex) { $errorText = $ex->getMessage(); } finally { return $response; @@ -103,7 +103,7 @@ public function UpdateConfigurationData($params, &$errorText) 'method' => 'PUT', 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) ]); - } catch (Exception $ex) { + } catch (\Exception $ex) { $errorText = $ex->getMessage(); } finally { return $response; @@ -134,7 +134,7 @@ public function RemoveConfigurationData($params, &$errorText) 'config_key' => isset($params['config_key']) ? $params['config_key'] : null ], ]); - } catch (Exception $ex) { + } catch (\Exception $ex) { $errorText = $ex->getMessage(); } finally { return $response; @@ -147,7 +147,7 @@ public function RemoveConfigurationData($params, &$errorText) * If specified, it contains the key 'config_key' and retrieved only corresponding configuration data, * if not, all member configuration data retrieved. */ - public function GetConfigurationData($params=null) + public function GetConfigurationData($params = null) { $allQueryFields = ['config_key']; @@ -161,4 +161,4 @@ public function GetConfigurationData($params=null) return $response; } -} \ No newline at end of file +} diff --git a/src/Route4Me/TelematicsGateway/TelematicsConnection.php b/src/Route4Me/TelematicsGateway/TelematicsConnection.php index bb08d9b..ea0cee0 100644 --- a/src/Route4Me/TelematicsGateway/TelematicsConnection.php +++ b/src/Route4Me/TelematicsGateway/TelematicsConnection.php @@ -178,8 +178,6 @@ public static function fromArray(array $params) */ public function createTelematicsConnection($apiToken, $params) { - Route4Me::setBaseUrl(Endpoint::BASE_URL); - $excludeFields = ['id', 'connection_token']; $allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields); @@ -204,8 +202,6 @@ public function createTelematicsConnection($apiToken, $params) */ public function deleteTelematicsConnection($apiToken, $connectionToken) { - Route4Me::setBaseUrl(Endpoint::BASE_URL); - $result = Route4Me::makeRequst([ 'url' => Endpoint::TELEMATICS_CONNECTION, 'method' => 'DELETE', @@ -226,8 +222,6 @@ public function deleteTelematicsConnection($apiToken, $connectionToken) */ public function getTelematicsConnections($apiToken) { - Route4Me::setBaseUrl(Endpoint::BASE_URL); - $result = Route4Me::makeRequst([ 'url' => Endpoint::TELEMATICS_CONNECTION, 'method' => 'GET', @@ -248,8 +242,6 @@ public function getTelematicsConnections($apiToken) */ public function getTelematicsConnection($apiToken, $connectionToken) { - Route4Me::setBaseUrl(Endpoint::BASE_URL); - $result = Route4Me::makeRequst([ 'url' => Endpoint::TELEMATICS_CONNECTION, 'method' => 'GE', diff --git a/src/Route4Me/TelematicsGateway/TelematicsVendor.php b/src/Route4Me/TelematicsGateway/TelematicsVendor.php index 7947f38..f0b4b12 100644 --- a/src/Route4Me/TelematicsGateway/TelematicsVendor.php +++ b/src/Route4Me/TelematicsGateway/TelematicsVendor.php @@ -3,8 +3,8 @@ namespace Route4Me\TelematicsGateway; use Route4Me\Enum\Endpoint; -use Route4Me\Common As Common; -use Route4Me\Route4Me As Route4Me; +use Route4Me\Common as Common; +use Route4Me\Route4Me as Route4Me; /** * Telematics vendor's data structure. @@ -24,7 +24,7 @@ class TelematicsVendor extends Common public $name; /** - * Vendor slug + * Vendor slug * @var string */ public $slug; @@ -99,12 +99,10 @@ public static function fromArray(array $params) */ public static function GetTelematicsVendors($params) { - Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); - $allQueryFields = ['vendor_id', 'is_integrated', 'page', 'per_page', 'country', 'feature', 'search', 'vendors']; $vendors = Route4Me::makeRequst([ - 'url' => '', + 'url' => Endpoint::TELEMATICS_VENDORS, 'method' => 'GET', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), ]); @@ -152,8 +150,6 @@ public static function GetRandomVendorID($offset, $limit) */ public static function RegisterTelematicsMember($params) { - Route4Me::setBaseUrl(Endpoint::BASE_URL); - $allQueryFields = ['member_id', 'api_key']; $vendors = Route4Me::makeRequst([ @@ -178,5 +174,4 @@ public static function getVendorById($vendorId) return null; } } - } diff --git a/src/Route4Me/TelematicsVendor.php b/src/Route4Me/TelematicsVendor.php index acd9ea3..9ba41ae 100644 --- a/src/Route4Me/TelematicsVendor.php +++ b/src/Route4Me/TelematicsVendor.php @@ -37,12 +37,10 @@ public static function fromArray(array $params) public static function GetTelematicsVendors($params) { - Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); - $allQueryFields = ['vendor_id', 'is_integrated', 'page', 'per_page', 'country', 'feature', 'search', 'vendors']; $vendors = Route4Me::makeRequst([ - 'url' => '', + 'url' => Endpoint::TELEMATICS_VENDORS, 'method' => 'GET', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), ]); diff --git a/src/Route4Me/V5/Routes/AddonRoutesApi/Route.php b/src/Route4Me/V5/Routes/AddonRoutesApi/Route.php index 5b8451d..e6579fc 100644 --- a/src/Route4Me/V5/Routes/AddonRoutesApi/Route.php +++ b/src/Route4Me/V5/Routes/AddonRoutesApi/Route.php @@ -76,57 +76,57 @@ public static function fromArray(array $params) { $route = new self(); - $route->route_id = Common::getValue($params, 'route_id'); - $route->organization_id = Common::getValue($params, 'organization_id'); - $route->route_progress = Common::getValue($params, 'route_progress'); - $route->depot_address_id = Common::getValue($params, 'depot_address_id'); - $route->root_member_id = Common::getValue($params, 'root_member_id'); - $route->day_id = Common::getValue($params, 'day_id'); - $route->addresses_visited_count = Common::getValue($params, 'addresses_visited_count'); - $route->route_start_time = Common::getValue($params, 'route_start_time'); - $route->route_end_time = Common::getValue($params, 'route_end_time'); - $route->user_route_rating = Common::getValue($params, 'user_route_rating'); - $route->member_id = Common::getValue($params, 'member_id'); - $route->member_email = Common::getValue($params, 'member_email'); - $route->member_first_name = Common::getValue($params, 'member_first_name'); - $route->member_last_name = Common::getValue($params, 'member_last_name'); - $route->channel_name = Common::getValue($params, 'channel_name'); - $route->member_picture = Common::getValue($params, 'member_picture'); - $route->member_tracking_subheadline = Common::getValue($params, 'member_tracking_subheadline'); - $route->approved_for_execution = Common::getValue($params, 'approved_for_execution'); - $route->approved_revisions_counter = Common::getValue($params, 'approved_revisions_counter'); - $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); - $route->driver_alias = Common::getValue($params, 'driver_alias'); - $route->mpg = Common::getValue($params, 'mpg'); - $route->trip_distance = Common::getValue($params, 'trip_distance'); - $route->udu_distance_unit = Common::getValue($params, 'udu_distance_unit'); - $route->udu_trip_distance = Common::getValue($params, 'udu_trip_distance'); - $route->is_unrouted = Common::getValue($params, 'is_unrouted'); - $route->gas_price = Common::getValue($params, 'gas_price'); - $route->route_duration_sec = Common::getValue($params, 'route_duration_sec'); - $route->planned_total_route_duration = Common::getValue($params, 'planned_total_route_duration'); - $route->total_wait_time = Common::getValue($params, 'total_wait_time'); - $route->udu_actual_travel_distance = Common::getValue($params, 'udu_actual_travel_distance'); - $route->actual_travel_distance = Common::getValue($params, 'actual_travel_distance'); - $route->actual_travel_time = Common::getValue($params, 'actual_travel_time'); - $route->actual_footsteps = Common::getValue($params, 'actual_footsteps'); - $route->working_time = Common::getValue($params, 'working_time'); - $route->driving_time = Common::getValue($params, 'driving_time'); - $route->idling_time = Common::getValue($params, 'idling_time'); - $route->paying_miles = Common::getValue($params, 'paying_miles'); - $route->geofence_polygon_type = Common::getValue($params, 'geofence_polygon_type'); - $route->geofence_polygon_size = Common::getValue($params, 'geofence_polygon_size'); - $route->destination_count = Common::getValue($params, 'destination_count'); - $route->notes_count = Common::getValue($params, 'notes_count'); - $route->notes = Common::getValue($params, 'notes'); - $route->directions = Common::getValue($params, 'directions'); - $route->path = Common::getValue($params, 'path'); - $route->vehicle = Common::getValue($params, 'vehicle'); - $route->member_config_storage = Common::getValue($params, 'member_config_storage'); - $route->is_master = Common::getValue($params, 'is_master'); - $route->bundle_items = Common::getValue($params, 'bundle_items'); - $route->master_route_id = Common::getValue($params, 'master_route_id'); - $route->route_status = Common::getValue($params, 'route_status'); + $route->route_id = Common::getValue($params, 'route_id'); + $route->organization_id = Common::getValue($params, 'organization_id'); + $route->route_progress = Common::getValue($params, 'route_progress'); + $route->depot_address_id = Common::getValue($params, 'depot_address_id'); + $route->root_member_id = Common::getValue($params, 'root_member_id'); + $route->day_id = Common::getValue($params, 'day_id'); + $route->addresses_visited_count = Common::getValue($params, 'addresses_visited_count'); + $route->route_start_time = Common::getValue($params, 'route_start_time'); + $route->route_end_time = Common::getValue($params, 'route_end_time'); + $route->user_route_rating = Common::getValue($params, 'user_route_rating'); + $route->member_id = Common::getValue($params, 'member_id'); + $route->member_email = Common::getValue($params, 'member_email'); + $route->member_first_name = Common::getValue($params, 'member_first_name'); + $route->member_last_name = Common::getValue($params, 'member_last_name'); + $route->channel_name = Common::getValue($params, 'channel_name'); + $route->member_picture = Common::getValue($params, 'member_picture'); + $route->member_tracking_subheadline = Common::getValue($params, 'member_tracking_subheadline'); + $route->approved_for_execution = Common::getValue($params, 'approved_for_execution'); + $route->approved_revisions_counter = Common::getValue($params, 'approved_revisions_counter'); + $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); + $route->driver_alias = Common::getValue($params, 'driver_alias'); + $route->mpg = Common::getValue($params, 'mpg'); + $route->trip_distance = Common::getValue($params, 'trip_distance'); + $route->udu_distance_unit = Common::getValue($params, 'udu_distance_unit'); + $route->udu_trip_distance = Common::getValue($params, 'udu_trip_distance'); + $route->is_unrouted = Common::getValue($params, 'is_unrouted'); + $route->gas_price = Common::getValue($params, 'gas_price'); + $route->route_duration_sec = Common::getValue($params, 'route_duration_sec'); + $route->planned_total_route_duration = Common::getValue($params, 'planned_total_route_duration'); + $route->total_wait_time = Common::getValue($params, 'total_wait_time'); + $route->udu_actual_travel_distance = Common::getValue($params, 'udu_actual_travel_distance'); + $route->actual_travel_distance = Common::getValue($params, 'actual_travel_distance'); + $route->actual_travel_time = Common::getValue($params, 'actual_travel_time'); + $route->actual_footsteps = Common::getValue($params, 'actual_footsteps'); + $route->working_time = Common::getValue($params, 'working_time'); + $route->driving_time = Common::getValue($params, 'driving_time'); + $route->idling_time = Common::getValue($params, 'idling_time'); + $route->paying_miles = Common::getValue($params, 'paying_miles'); + $route->geofence_polygon_type = Common::getValue($params, 'geofence_polygon_type'); + $route->geofence_polygon_size = Common::getValue($params, 'geofence_polygon_size'); + $route->destination_count = Common::getValue($params, 'destination_count'); + $route->notes_count = Common::getValue($params, 'notes_count'); + $route->notes = Common::getValue($params, 'notes'); + $route->directions = Common::getValue($params, 'directions'); + $route->path = Common::getValue($params, 'path'); + $route->vehicle = Common::getValue($params, 'vehicle'); + $route->member_config_storage = Common::getValue($params, 'member_config_storage'); + $route->is_master = Common::getValue($params, 'is_master'); + $route->bundle_items = Common::getValue($params, 'bundle_items'); + $route->master_route_id = Common::getValue($params, 'master_route_id'); + $route->route_status = Common::getValue($params, 'route_status'); if (isset($params['vehicle'])) { $route->vehicle = new Vehicle(); @@ -205,7 +205,7 @@ public function getAllRoutesWithPagination($params) return $result; } - public function getPaginatedRouteListWithoutElasticSearch($params) + public function getPaginatedRouteListWithoutElasticSearch($params) { $allQueryFields = RouteParametersQuery::getAllProperties(); @@ -354,7 +354,7 @@ public function getRoutePoints($params) $allQueryFields = ['route_id', 'route_path_output', 'compress_path_points', 'directions']; $result = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_V4, + 'url' => EndpointV4::ROUTE_V4, 'method' => 'GET', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), ]); @@ -370,7 +370,7 @@ public function resequenceRoute($params) $allBodyFields = ['addresses']; $result = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_V4, + 'url' => EndpointV4::ROUTE_V4, 'method' => 'PUT', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), @@ -384,7 +384,7 @@ public function resequenceAllAddresses($params) $allQueryFields = ['route_id', 'disable_optimization', 'optimize']; $result = Route4Me::makeRequst([ - 'url' => Endpoint::REOPTIMIZE_V3_2, + 'url' => EndpointV4::REOPTIMIZE_V3_2, 'method' => 'GET', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), ]); @@ -397,7 +397,7 @@ public function mergeRoutes($params) $allBodyFields = ['route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng']; $result = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTES_MERGE, + 'url' => EndpointV4::ROUTES_MERGE, 'method' => 'POST', 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), 'HTTPHEADER' => 'Content-Type: multipart/form-data', @@ -412,7 +412,7 @@ public function shareRoute($params) $allBodyFields = ['recipient_email']; $result = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_SHARE, + 'url' => EndpointV4::ROUTE_SHARE, 'method' => 'POST', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), @@ -450,7 +450,7 @@ public function updateRoute($params) $allBodyFields = ['addresses', 'parameters', 'unlink_from_master_optimization']; $result = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_V4, + 'url' => EndpointV4::ROUTE_V4, 'method' => 'PUT', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), 'body' => (isset($params['addresses']) || isset($params['parameters']) || isset($params['unlink_from_master_optimization'])) @@ -464,7 +464,7 @@ public function updateRoute($params) public function update() { $route = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_V4, + 'url' => EndpointV4::ROUTE_V4, 'method' => 'PUT', 'query' => [ 'route_id' => isset($this->route_id) ? $this->route_id : null, @@ -484,7 +484,7 @@ public function updateAddress($address = null) : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); $result = Route4Me::makeRequst([ - 'url' => Endpoint::ADDRESS_V4, + 'url' => EndpointV4::ADDRESS_V4, 'method' => 'PUT', 'query' => [ 'route_id' => isset($this->route_id) ? $this->route_id : null, @@ -500,7 +500,7 @@ public function updateAddress($address = null) public function updateRouteAddress() { $result = Route4Me::makeRequst([ - 'url' => Endpoint::ADDRESS_V4, + 'url' => EndpointV4::ADDRESS_V4, 'method' => 'PUT', 'query' => [ 'route_id' => isset($this->route_id) ? $this->route_id : null, @@ -522,7 +522,7 @@ public function addAddresses($params) $allBodyFields = ['addresses']; $route = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_V4, + 'url' => EndpointV4::ROUTE_V4, 'method' => 'PUT', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), @@ -538,7 +538,7 @@ public function insertAddressOptimalPosition(array $params) $allBodyFields = ['addresses', 'optimal_position']; $route = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_V4, + 'url' => EndpointV4::ROUTE_V4, 'method' => 'PUT', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), @@ -556,7 +556,7 @@ public function addNoteFile($params) $allBodyFields = ['strUpdateType', 'strFilename', 'strNoteContents']; $result = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_NOTES_ADD, + 'url' => EndpointV4::ROUTE_NOTES_ADD, 'method' => 'POST', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), @@ -569,8 +569,6 @@ public function addNoteFile($params) return $result; } - - public function GetAddressesFromRoute($route_id) { $route1 = self::getRoutes(['route_id' => $route_id]); @@ -612,7 +610,7 @@ public function GetLastLocation(array $params) $allQueryFields = ['route_id', 'device_tracking_history']; $route = Route4Me::makeRequst([ - 'url' => Endpoint::ROUTE_V4, + 'url' => EndpointV4::ROUTE_V4, 'method' => 'GET', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), ]); @@ -625,7 +623,7 @@ public function GetTrackingHistoryFromTimeRange(array $params) $allQueryFields = ['route_id', 'format', 'time_period', 'start_date', 'end_date']; $route = Route4Me::makeRequst([ - 'url' => Endpoint::GET_DEVICE_LOCATION, + 'url' => EndpointV4::GET_DEVICE_LOCATION, 'method' => 'GET', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), ]); @@ -638,7 +636,7 @@ public function GetAssetTracking(array $params) $allQueryFields = ['tracking']; $assetResponse = Route4Me::makeRequst([ - 'url' => Endpoint::STATUS_V4, + 'url' => EndpointV4::STATUS_V4, 'method' => 'GET', 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), ]); diff --git a/src/Route4Me/Vehicles/Vehicle.php b/src/Route4Me/Vehicles/Vehicle.php index 6690ef3..78f51fa 100644 --- a/src/Route4Me/Vehicles/Vehicle.php +++ b/src/Route4Me/Vehicles/Vehicle.php @@ -78,7 +78,9 @@ public static function fromArray(array $params) $vehicle = new self(); foreach ($params as $key => $value) { - if (is_null(Common::getValue($params, $key))) continue; + if (is_null(Common::getValue($params, $key))) { + continue; + } if (property_exists($vehicle, $key)) { $vehicle->$key = $value; } @@ -150,8 +152,6 @@ public function createVehicle($params) $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); - Route4Me::setBaseUrl(Endpoint::BASE_URL); - $response = Route4Me::makeRequst([ 'url' => Endpoint::VEHICLE_V4_API, 'method' => 'POST', diff --git a/src/Route4Me/Vehicles/VehicleV4.php b/src/Route4Me/Vehicles/VehicleV4.php index 081acfb..0c3a696 100644 --- a/src/Route4Me/Vehicles/VehicleV4.php +++ b/src/Route4Me/Vehicles/VehicleV4.php @@ -189,7 +189,9 @@ public static function fromArray(array $params) $vehicle = new self(); foreach ($params as $key => $value) { - if (is_null(Common::getValue($params, $key))) continue; + if (is_null(Common::getValue($params, $key))) { + continue; + } if (property_exists($vehicle, $key)) { $vehicle->$key = $value; } @@ -242,8 +244,6 @@ public function createVehicle($params) $excludeFields = ['vehicle_id','is_deleted','created_time','timestamp_added','timestamp_removed']; $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); - //Route4Me::setBaseUrl(Endpoint::BASE_URL); - $response = Route4Me::makeRequst([ 'url' => Endpoint::VEHICLE_V4, 'method' => 'POST', @@ -266,5 +266,4 @@ public function removeVehicle($params) return $response; } - -} \ No newline at end of file +}