@@ -8,154 +8,154 @@ |
||
8 | 8 | */ |
9 | 9 | class FindAssetResponse extends \Route4Me\Common |
10 | 10 | { |
11 | - /** |
|
12 | - * Tracking number |
|
13 | - * @var type string |
|
14 | - */ |
|
15 | - public $tracking_number; |
|
16 | - |
|
17 | - /** |
|
18 | - * A link to a large logo |
|
19 | - * @var type string |
|
20 | - */ |
|
21 | - public $large_logo_uri; |
|
22 | - |
|
23 | - /** |
|
24 | - * A link to a large logo (2x) |
|
25 | - * @var type string |
|
26 | - */ |
|
27 | - public $large_logo_uri_2x; |
|
28 | - |
|
29 | - /** |
|
30 | - * A link to a mobile logo |
|
31 | - * @var type string |
|
32 | - */ |
|
33 | - public $mobile_logo_uri; |
|
34 | - |
|
35 | - /** |
|
36 | - * A link to a mobile logo (2x) |
|
37 | - * @var type string |
|
38 | - */ |
|
39 | - public $mobile_logo_uri_2x; |
|
40 | - |
|
41 | - /** |
|
42 | - * The asset color on a map |
|
43 | - * @var type string |
|
44 | - */ |
|
45 | - public $map_color; |
|
46 | - |
|
47 | - /** |
|
48 | - * An alignment of a large logo |
|
49 | - * @var type string |
|
50 | - */ |
|
51 | - public $large_logo_alignment; |
|
52 | - |
|
53 | - /** |
|
54 | - * An alignment of a mobile logo |
|
55 | - * @var type string |
|
56 | - */ |
|
57 | - public $mobile_logo_alignment; |
|
58 | - |
|
59 | - /** |
|
60 | - * Show map zoom controls |
|
61 | - * @var type Boolean |
|
62 | - */ |
|
63 | - public $show_map_zoom_controls; |
|
64 | - |
|
65 | - /** |
|
66 | - * Customer service phone |
|
67 | - * @var type string |
|
68 | - */ |
|
69 | - public $customer_service_phone; |
|
70 | - |
|
71 | - /** |
|
72 | - * If true, Covid19 warning hidden |
|
73 | - * @var type |
|
74 | - */ |
|
75 | - public $hide_covid19_warning; |
|
76 | - |
|
77 | - /** |
|
78 | - * Driver phone number |
|
79 | - * @var type string |
|
80 | - */ |
|
81 | - public $driver_phone; |
|
82 | - |
|
83 | - /** |
|
84 | - * If true, the route started |
|
85 | - * @var type Boolean |
|
86 | - */ |
|
87 | - public $route_started; |
|
88 | - |
|
89 | - /** |
|
90 | - * Driver name |
|
91 | - * @var type string |
|
92 | - */ |
|
93 | - public $driver_name; |
|
94 | - |
|
95 | - /** |
|
96 | - * A link to a driver picture file |
|
97 | - * @var type string |
|
98 | - */ |
|
99 | - public $driver_picture; |
|
100 | - |
|
101 | - /** |
|
102 | - * A sub-headline of a tracking page |
|
103 | - * @var type string |
|
104 | - */ |
|
105 | - public $tracking_page_subheadline; |
|
106 | - |
|
107 | - /** |
|
108 | - * A first destination address |
|
109 | - * @var type string |
|
110 | - */ |
|
111 | - public $destination_address_1; |
|
112 | - |
|
113 | - /** |
|
114 | - * A second destination address |
|
115 | - * @var type string |
|
116 | - */ |
|
117 | - public $destination_address_2; |
|
118 | - |
|
119 | - /** |
|
120 | - * True if the asset was delivered |
|
121 | - * @var type Boolean |
|
122 | - */ |
|
123 | - public $delivered; |
|
124 | - |
|
125 | - /** |
|
126 | - * Asset status history |
|
127 | - * @var type array |
|
128 | - */ |
|
129 | - public $status_history = []; |
|
130 | - |
|
131 | - /** |
|
132 | - * An array of the asset locations |
|
133 | - * @var type array |
|
134 | - */ |
|
135 | - public $locations = []; |
|
136 | - |
|
137 | - /** |
|
138 | - * Custom data |
|
139 | - * @var type array |
|
140 | - */ |
|
141 | - public $custom_data; |
|
142 | - |
|
143 | - /** |
|
144 | - * An array of the asset arrival times |
|
145 | - * @var type array |
|
146 | - */ |
|
147 | - public $arrival = []; |
|
11 | + /** |
|
12 | + * Tracking number |
|
13 | + * @var type string |
|
14 | + */ |
|
15 | + public $tracking_number; |
|
16 | + |
|
17 | + /** |
|
18 | + * A link to a large logo |
|
19 | + * @var type string |
|
20 | + */ |
|
21 | + public $large_logo_uri; |
|
22 | + |
|
23 | + /** |
|
24 | + * A link to a large logo (2x) |
|
25 | + * @var type string |
|
26 | + */ |
|
27 | + public $large_logo_uri_2x; |
|
28 | + |
|
29 | + /** |
|
30 | + * A link to a mobile logo |
|
31 | + * @var type string |
|
32 | + */ |
|
33 | + public $mobile_logo_uri; |
|
34 | + |
|
35 | + /** |
|
36 | + * A link to a mobile logo (2x) |
|
37 | + * @var type string |
|
38 | + */ |
|
39 | + public $mobile_logo_uri_2x; |
|
40 | + |
|
41 | + /** |
|
42 | + * The asset color on a map |
|
43 | + * @var type string |
|
44 | + */ |
|
45 | + public $map_color; |
|
46 | + |
|
47 | + /** |
|
48 | + * An alignment of a large logo |
|
49 | + * @var type string |
|
50 | + */ |
|
51 | + public $large_logo_alignment; |
|
52 | + |
|
53 | + /** |
|
54 | + * An alignment of a mobile logo |
|
55 | + * @var type string |
|
56 | + */ |
|
57 | + public $mobile_logo_alignment; |
|
58 | + |
|
59 | + /** |
|
60 | + * Show map zoom controls |
|
61 | + * @var type Boolean |
|
62 | + */ |
|
63 | + public $show_map_zoom_controls; |
|
64 | + |
|
65 | + /** |
|
66 | + * Customer service phone |
|
67 | + * @var type string |
|
68 | + */ |
|
69 | + public $customer_service_phone; |
|
70 | + |
|
71 | + /** |
|
72 | + * If true, Covid19 warning hidden |
|
73 | + * @var type |
|
74 | + */ |
|
75 | + public $hide_covid19_warning; |
|
76 | + |
|
77 | + /** |
|
78 | + * Driver phone number |
|
79 | + * @var type string |
|
80 | + */ |
|
81 | + public $driver_phone; |
|
82 | + |
|
83 | + /** |
|
84 | + * If true, the route started |
|
85 | + * @var type Boolean |
|
86 | + */ |
|
87 | + public $route_started; |
|
88 | + |
|
89 | + /** |
|
90 | + * Driver name |
|
91 | + * @var type string |
|
92 | + */ |
|
93 | + public $driver_name; |
|
94 | + |
|
95 | + /** |
|
96 | + * A link to a driver picture file |
|
97 | + * @var type string |
|
98 | + */ |
|
99 | + public $driver_picture; |
|
100 | + |
|
101 | + /** |
|
102 | + * A sub-headline of a tracking page |
|
103 | + * @var type string |
|
104 | + */ |
|
105 | + public $tracking_page_subheadline; |
|
106 | + |
|
107 | + /** |
|
108 | + * A first destination address |
|
109 | + * @var type string |
|
110 | + */ |
|
111 | + public $destination_address_1; |
|
112 | + |
|
113 | + /** |
|
114 | + * A second destination address |
|
115 | + * @var type string |
|
116 | + */ |
|
117 | + public $destination_address_2; |
|
118 | + |
|
119 | + /** |
|
120 | + * True if the asset was delivered |
|
121 | + * @var type Boolean |
|
122 | + */ |
|
123 | + public $delivered; |
|
124 | + |
|
125 | + /** |
|
126 | + * Asset status history |
|
127 | + * @var type array |
|
128 | + */ |
|
129 | + public $status_history = []; |
|
130 | + |
|
131 | + /** |
|
132 | + * An array of the asset locations |
|
133 | + * @var type array |
|
134 | + */ |
|
135 | + public $locations = []; |
|
136 | + |
|
137 | + /** |
|
138 | + * Custom data |
|
139 | + * @var type array |
|
140 | + */ |
|
141 | + public $custom_data; |
|
142 | + |
|
143 | + /** |
|
144 | + * An array of the asset arrival times |
|
145 | + * @var type array |
|
146 | + */ |
|
147 | + public $arrival = []; |
|
148 | 148 | |
149 | - public static function fromArray(array $params) |
|
150 | - { |
|
151 | - $findAssetResponse = new self(); |
|
149 | + public static function fromArray(array $params) |
|
150 | + { |
|
151 | + $findAssetResponse = new self(); |
|
152 | 152 | |
153 | - foreach ($params as $key => $value) { |
|
154 | - if (property_exists($findAssetResponse, $key)) { |
|
155 | - $findAssetResponse->{$key} = $value; |
|
156 | - } |
|
157 | - } |
|
153 | + foreach ($params as $key => $value) { |
|
154 | + if (property_exists($findAssetResponse, $key)) { |
|
155 | + $findAssetResponse->{$key} = $value; |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - return $findAssetResponse; |
|
160 | - } |
|
159 | + return $findAssetResponse; |
|
160 | + } |
|
161 | 161 | } |
162 | 162 | \ No newline at end of file |
@@ -6,97 +6,97 @@ |
||
6 | 6 | |
7 | 7 | class UserTracking extends \Route4Me\Common |
8 | 8 | { |
9 | - /** @var string $route_id */ |
|
10 | - public $route_id; |
|
9 | + /** @var string $route_id */ |
|
10 | + public $route_id; |
|
11 | 11 | |
12 | - /** @var string $device_id */ |
|
13 | - public $device_id; |
|
12 | + /** @var string $device_id */ |
|
13 | + public $device_id; |
|
14 | 14 | |
15 | - /** @var long $activity_timestamp */ |
|
16 | - public $activity_timestamp; |
|
15 | + /** @var long $activity_timestamp */ |
|
16 | + public $activity_timestamp; |
|
17 | 17 | |
18 | - /** @var string $activity_timestamp */ |
|
19 | - public $device_timestamp; |
|
18 | + /** @var string $activity_timestamp */ |
|
19 | + public $device_timestamp; |
|
20 | 20 | |
21 | - /** @var int $device_type */ |
|
22 | - public $device_type; |
|
21 | + /** @var int $device_type */ |
|
22 | + public $device_type; |
|
23 | 23 | |
24 | - /** @var int $member_id */ |
|
25 | - public $member_id; |
|
24 | + /** @var int $member_id */ |
|
25 | + public $member_id; |
|
26 | 26 | |
27 | - /** @var int $root_member_id */ |
|
28 | - public $root_member_id; |
|
27 | + /** @var int $root_member_id */ |
|
28 | + public $root_member_id; |
|
29 | 29 | |
30 | - /** @var string $vehicle_id */ |
|
31 | - public $vehicle_id; |
|
30 | + /** @var string $vehicle_id */ |
|
31 | + public $vehicle_id; |
|
32 | 32 | |
33 | - /** @var int $direction */ |
|
34 | - public $direction; |
|
33 | + /** @var int $direction */ |
|
34 | + public $direction; |
|
35 | 35 | |
36 | - /** @var int $speed */ |
|
37 | - public $speed; |
|
36 | + /** @var int $speed */ |
|
37 | + public $speed; |
|
38 | 38 | |
39 | - /** @var string $calculated_speed */ |
|
40 | - public $calculated_speed; |
|
39 | + /** @var string $calculated_speed */ |
|
40 | + public $calculated_speed; |
|
41 | 41 | |
42 | - /** @var string $speed_accuracy */ |
|
43 | - public $speed_accuracy; |
|
42 | + /** @var string $speed_accuracy */ |
|
43 | + public $speed_accuracy; |
|
44 | 44 | |
45 | - /** @var string $speed_unit */ |
|
46 | - public $speed_unit; |
|
45 | + /** @var string $speed_unit */ |
|
46 | + public $speed_unit; |
|
47 | 47 | |
48 | - /** @var int $bearing */ |
|
49 | - public $bearing; |
|
48 | + /** @var int $bearing */ |
|
49 | + public $bearing; |
|
50 | 50 | |
51 | - /** @var string $bearing_accuracy */ |
|
52 | - public $bearing_accuracy; |
|
51 | + /** @var string $bearing_accuracy */ |
|
52 | + public $bearing_accuracy; |
|
53 | 53 | |
54 | - /** @var string $accuracy */ |
|
55 | - public $accuracy; |
|
54 | + /** @var string $accuracy */ |
|
55 | + public $accuracy; |
|
56 | 56 | |
57 | - /** @var int $day_id */ |
|
58 | - public $day_id; |
|
57 | + /** @var int $day_id */ |
|
58 | + public $day_id; |
|
59 | 59 | |
60 | - /** @var double $position_lat */ |
|
61 | - public $position_lat; |
|
60 | + /** @var double $position_lat */ |
|
61 | + public $position_lat; |
|
62 | 62 | |
63 | - /** @var double $position_lng */ |
|
64 | - public $position_lng; |
|
63 | + /** @var double $position_lng */ |
|
64 | + public $position_lng; |
|
65 | 65 | |
66 | - /** @var int $altitude */ |
|
67 | - public $altitude; |
|
66 | + /** @var int $altitude */ |
|
67 | + public $altitude; |
|
68 | 68 | |
69 | - /** @var int $footsteps */ |
|
70 | - public $footsteps; |
|
69 | + /** @var int $footsteps */ |
|
70 | + public $footsteps; |
|
71 | 71 | |
72 | - /** @var string $data_source_name */ |
|
73 | - public $data_source_name; |
|
72 | + /** @var string $data_source_name */ |
|
73 | + public $data_source_name; |
|
74 | 74 | |
75 | - /** @var string $custom_data */ |
|
76 | - public $custom_data; |
|
75 | + /** @var string $custom_data */ |
|
76 | + public $custom_data; |
|
77 | 77 | |
78 | - /** @var string $device_timezone */ |
|
79 | - public $device_timezone; |
|
78 | + /** @var string $device_timezone */ |
|
79 | + public $device_timezone; |
|
80 | 80 | |
81 | - /** @var int $device_timezone_offset */ |
|
82 | - public $device_timezone_offset; |
|
81 | + /** @var int $device_timezone_offset */ |
|
82 | + public $device_timezone_offset; |
|
83 | 83 | |
84 | - /** @var string $activity_timestamp_friendly */ |
|
85 | - public $activity_timestamp_friendly; |
|
84 | + /** @var string $activity_timestamp_friendly */ |
|
85 | + public $activity_timestamp_friendly; |
|
86 | 86 | |
87 | - /** @var long $LAST_KNOWN */ |
|
88 | - public $LAST_KNOWN; |
|
87 | + /** @var long $LAST_KNOWN */ |
|
88 | + public $LAST_KNOWN; |
|
89 | 89 | |
90 | - public static function fromArray(array $params) |
|
91 | - { |
|
92 | - $userTracking = new self(); |
|
90 | + public static function fromArray(array $params) |
|
91 | + { |
|
92 | + $userTracking = new self(); |
|
93 | 93 | |
94 | - foreach ($params as $key => $value) { |
|
95 | - if (property_exists($userTracking, $key)) { |
|
96 | - $userTracking->{$key} = $value; |
|
97 | - } |
|
98 | - } |
|
94 | + foreach ($params as $key => $value) { |
|
95 | + if (property_exists($userTracking, $key)) { |
|
96 | + $userTracking->{$key} = $value; |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | - return $userTracking; |
|
101 | - } |
|
100 | + return $userTracking; |
|
101 | + } |
|
102 | 102 | } |
103 | 103 | \ No newline at end of file |
@@ -7,32 +7,32 @@ |
||
7 | 7 | |
8 | 8 | class Track extends \Route4Me\Common |
9 | 9 | { |
10 | - public function __construct() |
|
11 | - { |
|
12 | - Route4Me\Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
13 | - } |
|
14 | - |
|
15 | - public static function set(TrackSetParams $params) |
|
16 | - { |
|
17 | - $allQueryFields = Route4Me\Route4Me::getObjectProperties(new TrackSetParams(), ['tx_id']); |
|
18 | - |
|
19 | - $json = Route4Me\Route4Me::makeRequst([ |
|
20 | - 'url' => Endpoint::TRACK_SET, |
|
21 | - 'method' => 'GET', |
|
22 | - 'query' => Route4Me\Route4Me::generateRequestParameters($allQueryFields, $params), |
|
23 | - ]); |
|
24 | - |
|
25 | - return $json; |
|
26 | - } |
|
27 | - |
|
28 | - public static function getUserLocations($query=null) |
|
29 | - { |
|
30 | - $json = Route4Me\Route4Me::makeRequst([ |
|
31 | - 'url' => Endpoint::USER_LOCATION, |
|
32 | - 'method' => 'GET', |
|
33 | - 'query' => isset($query) ? ['query' => $query] : null |
|
34 | - ]); |
|
35 | - |
|
36 | - return $json; |
|
37 | - } |
|
10 | + public function __construct() |
|
11 | + { |
|
12 | + Route4Me\Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
13 | + } |
|
14 | + |
|
15 | + public static function set(TrackSetParams $params) |
|
16 | + { |
|
17 | + $allQueryFields = Route4Me\Route4Me::getObjectProperties(new TrackSetParams(), ['tx_id']); |
|
18 | + |
|
19 | + $json = Route4Me\Route4Me::makeRequst([ |
|
20 | + 'url' => Endpoint::TRACK_SET, |
|
21 | + 'method' => 'GET', |
|
22 | + 'query' => Route4Me\Route4Me::generateRequestParameters($allQueryFields, $params), |
|
23 | + ]); |
|
24 | + |
|
25 | + return $json; |
|
26 | + } |
|
27 | + |
|
28 | + public static function getUserLocations($query=null) |
|
29 | + { |
|
30 | + $json = Route4Me\Route4Me::makeRequst([ |
|
31 | + 'url' => Endpoint::USER_LOCATION, |
|
32 | + 'method' => 'GET', |
|
33 | + 'query' => isset($query) ? ['query' => $query] : null |
|
34 | + ]); |
|
35 | + |
|
36 | + return $json; |
|
37 | + } |
|
38 | 38 | } |
@@ -10,32 +10,32 @@ |
||
10 | 10 | */ |
11 | 11 | class ServiceTimeRulesClass |
12 | 12 | { |
13 | - /** |
|
14 | - * Mode of a first item of the bundled addresses. |
|
15 | - * @var integer |
|
16 | - * @see Enum\AddressBundlingModes\FirstItemMode |
|
17 | - */ |
|
18 | - public $first_item_mode = AddressBundlingModes\FirstItemMode::KEEP_ORIGINAL; |
|
13 | + /** |
|
14 | + * Mode of a first item of the bundled addresses. |
|
15 | + * @var integer |
|
16 | + * @see Enum\AddressBundlingModes\FirstItemMode |
|
17 | + */ |
|
18 | + public $first_item_mode = AddressBundlingModes\FirstItemMode::KEEP_ORIGINAL; |
|
19 | 19 | |
20 | - /** |
|
21 | - * First item mode parameters.<br> |
|
22 | - * If FirstItemMode=CustomTime, contains custom service time in seconds. |
|
23 | - * @var integer[] |
|
24 | - */ |
|
25 | - public $first_item_mode_params = []; |
|
20 | + /** |
|
21 | + * First item mode parameters.<br> |
|
22 | + * If FirstItemMode=CustomTime, contains custom service time in seconds. |
|
23 | + * @var integer[] |
|
24 | + */ |
|
25 | + public $first_item_mode_params = []; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Mode of the non-first items of the bundled addresses. |
|
29 | - * @var integer |
|
30 | - * @see Enum\AddressBundlingModes\AdditionalItemsMode |
|
31 | - */ |
|
32 | - public $additional_items_mode = AddressBundlingModes\AdditionalItemsMode::KEEP_ORIGINAL; |
|
27 | + /** |
|
28 | + * Mode of the non-first items of the bundled addresses. |
|
29 | + * @var integer |
|
30 | + * @see Enum\AddressBundlingModes\AdditionalItemsMode |
|
31 | + */ |
|
32 | + public $additional_items_mode = AddressBundlingModes\AdditionalItemsMode::KEEP_ORIGINAL; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Additional items mode parameters:<br> |
|
36 | - * if AdditionalItemsMode=AddressBundlingAdditionalItemsMode.CustomTime, |
|
37 | - * contains an array of the custom service times. |
|
38 | - * @var integer[] |
|
39 | - */ |
|
40 | - public $additional_items_mode_params = []; |
|
34 | + /** |
|
35 | + * Additional items mode parameters:<br> |
|
36 | + * if AdditionalItemsMode=AddressBundlingAdditionalItemsMode.CustomTime, |
|
37 | + * contains an array of the custom service times. |
|
38 | + * @var integer[] |
|
39 | + */ |
|
40 | + public $additional_items_mode_params = []; |
|
41 | 41 | } |
@@ -11,28 +11,28 @@ |
||
11 | 11 | */ |
12 | 12 | class Direction extends Common |
13 | 13 | { |
14 | - /** |
|
15 | - * Starting location of a direction |
|
16 | - * @var DirectionLocation |
|
17 | - */ |
|
18 | - public $location = []; |
|
19 | - |
|
20 | - /** |
|
21 | - * The direction steps |
|
22 | - * @var DirectionStep[] |
|
23 | - */ |
|
24 | - public $steps = []; |
|
25 | - |
|
26 | - public static function fromArray(array $params) |
|
27 | - { |
|
28 | - $thisParams = new self(); |
|
29 | - |
|
30 | - foreach ($params as $key => $value) { |
|
31 | - if (property_exists($thisParams, $key)) { |
|
32 | - $thisParams->{$key} = $value; |
|
33 | - } |
|
34 | - } |
|
35 | - |
|
36 | - return $thisParams; |
|
37 | - } |
|
14 | + /** |
|
15 | + * Starting location of a direction |
|
16 | + * @var DirectionLocation |
|
17 | + */ |
|
18 | + public $location = []; |
|
19 | + |
|
20 | + /** |
|
21 | + * The direction steps |
|
22 | + * @var DirectionStep[] |
|
23 | + */ |
|
24 | + public $steps = []; |
|
25 | + |
|
26 | + public static function fromArray(array $params) |
|
27 | + { |
|
28 | + $thisParams = new self(); |
|
29 | + |
|
30 | + foreach ($params as $key => $value) { |
|
31 | + if (property_exists($thisParams, $key)) { |
|
32 | + $thisParams->{$key} = $value; |
|
33 | + } |
|
34 | + } |
|
35 | + |
|
36 | + return $thisParams; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -6,75 +6,75 @@ |
||
6 | 6 | |
7 | 7 | class TelematicsVendor extends Common |
8 | 8 | { |
9 | - public $id; // Telematics Vendor id |
|
10 | - public $name; // Vendor name |
|
11 | - public $slug; // Vendor slug |
|
12 | - public $description; // Vendor description |
|
13 | - public $logo_url; // Vendor's logo URL |
|
14 | - public $website_url; // Vendor's website URL |
|
15 | - public $api_docs_url; // API documentation URL |
|
16 | - public $is_integrated; // If 1, the vendor is integrated in Route4Me |
|
17 | - public $size; // Vendor size |
|
18 | - public $page; // starting page |
|
19 | - public $per_page; // Vendors per page in a response |
|
20 | - public $countries = []; // Country Alpha 2 code |
|
21 | - public $features = []; // Vendor's feature |
|
22 | - public $search; // Searched text |
|
23 | - public $vendors; // Comma-delimited list of the vendors IDs. |
|
24 | - |
|
25 | - public static function fromArray(array $params) |
|
26 | - { |
|
27 | - $vendorsParameters = new self(); |
|
28 | - |
|
29 | - foreach ($params as $key => $value) { |
|
30 | - if (property_exists($vendorsParameters, $key)) { |
|
31 | - $vendorsParameters->{$key} = $value; |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - return $vendorsParameters; |
|
36 | - } |
|
37 | - |
|
38 | - public static function GetTelematicsVendors($params) |
|
39 | - { |
|
40 | - Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); |
|
41 | - |
|
42 | - $allQueryFields = ['vendor_id', 'is_integrated', 'page', 'per_page', 'country', 'feature', 'search', 'vendors']; |
|
43 | - |
|
44 | - $vendors = Route4Me::makeRequst([ |
|
45 | - 'url' => '', |
|
46 | - 'method' => 'GET', |
|
47 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
48 | - ]); |
|
49 | - |
|
50 | - return $vendors; |
|
51 | - } |
|
52 | - |
|
53 | - public static function GetRandomVendorID($offset, $limit) |
|
54 | - { |
|
55 | - $allVendors = self::GetTelematicsVendors(null); |
|
56 | - $vendorsNumber = sizeof($allVendors['vendors']); |
|
57 | - |
|
58 | - if ($vendorsNumber < $limit) { |
|
59 | - if ($vendorsNumber > $offset) { |
|
60 | - $limit = $vendorsNumber; |
|
61 | - } else { |
|
62 | - if ($vendorsNumber == $offset) { |
|
63 | - return $allVendors['vendors'][$offset]->{'vendor_id'}; |
|
64 | - } else { |
|
65 | - echo 'The vendors numbers are less than offset'; |
|
66 | - |
|
67 | - return null; |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
71 | - |
|
72 | - $randNumber = rand($offset, $limit); |
|
73 | - |
|
74 | - return $allVendors['vendors'][$randNumber]['id']; |
|
75 | - } |
|
76 | - |
|
77 | - /* |
|
9 | + public $id; // Telematics Vendor id |
|
10 | + public $name; // Vendor name |
|
11 | + public $slug; // Vendor slug |
|
12 | + public $description; // Vendor description |
|
13 | + public $logo_url; // Vendor's logo URL |
|
14 | + public $website_url; // Vendor's website URL |
|
15 | + public $api_docs_url; // API documentation URL |
|
16 | + public $is_integrated; // If 1, the vendor is integrated in Route4Me |
|
17 | + public $size; // Vendor size |
|
18 | + public $page; // starting page |
|
19 | + public $per_page; // Vendors per page in a response |
|
20 | + public $countries = []; // Country Alpha 2 code |
|
21 | + public $features = []; // Vendor's feature |
|
22 | + public $search; // Searched text |
|
23 | + public $vendors; // Comma-delimited list of the vendors IDs. |
|
24 | + |
|
25 | + public static function fromArray(array $params) |
|
26 | + { |
|
27 | + $vendorsParameters = new self(); |
|
28 | + |
|
29 | + foreach ($params as $key => $value) { |
|
30 | + if (property_exists($vendorsParameters, $key)) { |
|
31 | + $vendorsParameters->{$key} = $value; |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + return $vendorsParameters; |
|
36 | + } |
|
37 | + |
|
38 | + public static function GetTelematicsVendors($params) |
|
39 | + { |
|
40 | + Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); |
|
41 | + |
|
42 | + $allQueryFields = ['vendor_id', 'is_integrated', 'page', 'per_page', 'country', 'feature', 'search', 'vendors']; |
|
43 | + |
|
44 | + $vendors = Route4Me::makeRequst([ |
|
45 | + 'url' => '', |
|
46 | + 'method' => 'GET', |
|
47 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
48 | + ]); |
|
49 | + |
|
50 | + return $vendors; |
|
51 | + } |
|
52 | + |
|
53 | + public static function GetRandomVendorID($offset, $limit) |
|
54 | + { |
|
55 | + $allVendors = self::GetTelematicsVendors(null); |
|
56 | + $vendorsNumber = sizeof($allVendors['vendors']); |
|
57 | + |
|
58 | + if ($vendorsNumber < $limit) { |
|
59 | + if ($vendorsNumber > $offset) { |
|
60 | + $limit = $vendorsNumber; |
|
61 | + } else { |
|
62 | + if ($vendorsNumber == $offset) { |
|
63 | + return $allVendors['vendors'][$offset]->{'vendor_id'}; |
|
64 | + } else { |
|
65 | + echo 'The vendors numbers are less than offset'; |
|
66 | + |
|
67 | + return null; |
|
68 | + } |
|
69 | + } |
|
70 | + } |
|
71 | + |
|
72 | + $randNumber = rand($offset, $limit); |
|
73 | + |
|
74 | + return $allVendors['vendors'][$randNumber]['id']; |
|
75 | + } |
|
76 | + |
|
77 | + /* |
|
78 | 78 | public static function GetTelematicsVendor($params) { |
79 | 79 | Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); |
80 | 80 |
@@ -6,20 +6,20 @@ |
||
6 | 6 | |
7 | 7 | class RapidAddressSearchResponse |
8 | 8 | { |
9 | - public $zipcode; |
|
10 | - public $street_name; |
|
11 | - public $county_no; |
|
9 | + public $zipcode; |
|
10 | + public $street_name; |
|
11 | + public $county_no; |
|
12 | 12 | |
13 | - public static function fromArray(array $params) |
|
14 | - { |
|
15 | - $rapidSearch = new self(); |
|
13 | + public static function fromArray(array $params) |
|
14 | + { |
|
15 | + $rapidSearch = new self(); |
|
16 | 16 | |
17 | - foreach ($params as $key => $value) { |
|
18 | - if (property_exists($rapidSearch, $key)) { |
|
19 | - $rapidSearch->{$key} = $value; |
|
20 | - } |
|
21 | - } |
|
17 | + foreach ($params as $key => $value) { |
|
18 | + if (property_exists($rapidSearch, $key)) { |
|
19 | + $rapidSearch->{$key} = $value; |
|
20 | + } |
|
21 | + } |
|
22 | 22 | |
23 | - return $rapidSearch; |
|
24 | - } |
|
23 | + return $rapidSearch; |
|
24 | + } |
|
25 | 25 | } |
@@ -7,291 +7,291 @@ |
||
7 | 7 | |
8 | 8 | class Route4Me |
9 | 9 | { |
10 | - public static $apiKey; |
|
11 | - public static $baseUrl = Endpoint::BASE_URL; |
|
12 | - |
|
13 | - public static function setApiKey($apiKey) |
|
14 | - { |
|
15 | - self::$apiKey = $apiKey; |
|
16 | - } |
|
17 | - |
|
18 | - public static function getApiKey() |
|
19 | - { |
|
20 | - return self::$apiKey; |
|
21 | - } |
|
22 | - |
|
23 | - public static function setBaseUrl($baseUrl) |
|
24 | - { |
|
25 | - self::$baseUrl = $baseUrl; |
|
26 | - } |
|
27 | - |
|
28 | - public static function getBaseUrl() |
|
29 | - { |
|
30 | - return self::$baseUrl; |
|
31 | - } |
|
32 | - |
|
33 | - public static function makeRequst($options) |
|
34 | - { |
|
35 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
36 | - $query = isset($options['query']) ? array_filter($options['query'], function ($x) { return !is_null($x); }) : []; |
|
37 | - |
|
38 | - $body = isset($options['body']) ? $options['body'] : null; |
|
39 | - $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
40 | - $headers = [ |
|
41 | - 'User-Agent: Route4Me php-sdk', |
|
42 | - ]; |
|
43 | - |
|
44 | - if (isset($options['HTTPHEADER'])) { |
|
45 | - $headers[] = $options['HTTPHEADER']; |
|
46 | - } |
|
47 | - |
|
48 | - if (isset($options['HTTPHEADERS'])) { |
|
49 | - foreach ($options['HTTPHEADERS'] as $header) { |
|
50 | - $headers[] = $header; |
|
51 | - } |
|
52 | - } |
|
53 | - |
|
54 | - $ch = curl_init(); |
|
55 | - |
|
56 | - $url = isset($options['url']) ? $options['url'].'?'.http_build_query(array_merge( |
|
57 | - $query, ['api_key' => self::getApiKey()] |
|
58 | - )) : ''; |
|
59 | - |
|
60 | - $baseUrl = self::getBaseUrl(); |
|
61 | - |
|
62 | - $curlOpts = [ |
|
63 | - CURLOPT_URL => $baseUrl.$url, |
|
64 | - CURLOPT_RETURNTRANSFER => true, |
|
65 | - CURLOPT_TIMEOUT => 120, |
|
66 | - CURLOPT_FOLLOWLOCATION => true, |
|
67 | - CURLOPT_SSL_VERIFYHOST => false, |
|
68 | - CURLOPT_SSL_VERIFYPEER => false, |
|
69 | - CURLOPT_HTTPHEADER => $headers, |
|
70 | - ]; |
|
71 | - |
|
72 | - curl_setopt_array($ch, $curlOpts); |
|
73 | - |
|
74 | - if (null != $file) { |
|
75 | - $cfile = new \CURLFile($file,'',''); |
|
76 | - $body['strFilename']=$cfile; |
|
77 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
78 | - curl_setopt($ch, CURLOPT_POST,true); |
|
79 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
|
80 | - } else { |
|
81 | - switch ($method) { |
|
82 | - case 'DELETE': |
|
83 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
84 | - break; |
|
85 | - case 'DELETEARRAY': |
|
86 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
87 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
88 | - break; |
|
89 | - case 'PUT': |
|
90 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
91 | - break; |
|
92 | - case 'POST': |
|
93 | - if (isset($body)) { |
|
94 | - $bodyData = json_encode($body); |
|
95 | - if (isset($options['HTTPHEADER'])) { |
|
96 | - if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
97 | - $bodyData = $body; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
102 | - } |
|
103 | - break; |
|
104 | - case 'ADD': |
|
105 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
106 | - } |
|
107 | - |
|
108 | - if (is_numeric(array_search($method, ['DELETE', 'PUT']))) { |
|
109 | - if (isset($body)) { |
|
110 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
111 | - } |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - $result = curl_exec($ch); |
|
116 | - |
|
117 | - $isxml = false; |
|
118 | - $jxml = ''; |
|
119 | - if (strpos($result, '<?xml') > -1) { |
|
120 | - $xml = simplexml_load_string($result); |
|
121 | - //$jxml = json_encode($xml); |
|
122 | - $jxml = self::object2array($xml); |
|
123 | - $isxml = true; |
|
124 | - } |
|
125 | - |
|
126 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
127 | - curl_close($ch); |
|
128 | - |
|
129 | - if (200 == $code) { |
|
130 | - if ($isxml) { |
|
131 | - $json = $jxml; |
|
132 | - } else { |
|
133 | - $json = json_decode($result, true); |
|
134 | - } |
|
135 | - |
|
136 | - if (isset($json['errors'])) { |
|
137 | - throw new ApiError(implode(', ', $json['errors'])); |
|
138 | - } else { |
|
139 | - return $json; |
|
140 | - } |
|
141 | - } elseif (409 == $code) { |
|
142 | - throw new ApiError('Wrong API key'); |
|
143 | - } else { |
|
144 | - throw new ApiError('Something wrong'); |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @param $object: JSON object |
|
150 | - */ |
|
151 | - public static function object2array($object) |
|
152 | - { |
|
153 | - return @json_decode(@json_encode($object), 1); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Prints on the screen main keys and values of the array. |
|
158 | - * |
|
159 | - * @param $results: object to be printed on the screen |
|
160 | - * @param $deepPrinting: if true, object will be printed recursively |
|
161 | - */ |
|
162 | - public static function simplePrint($results, $deepPrinting = null) |
|
163 | - { |
|
164 | - if (isset($results)) { |
|
165 | - if (is_array($results)) { |
|
166 | - foreach ($results as $key => $result) { |
|
167 | - if (is_array($result)) { |
|
168 | - foreach ($result as $key1 => $result1) { |
|
169 | - if (is_array($result1)) { |
|
170 | - if ($deepPrinting) { |
|
171 | - echo "<br>$key1 ------><br>"; |
|
172 | - self::simplePrint($result1, true); |
|
173 | - echo '------<br>'; |
|
174 | - } else { |
|
175 | - echo $key1.' --> '.'Array() <br>'; |
|
176 | - } |
|
177 | - } else { |
|
178 | - if (is_object($result1)) { |
|
179 | - if ($deepPrinting) { |
|
180 | - echo "<br>$key1 ------><br>"; |
|
181 | - $oarray = (array) $result1; |
|
182 | - self::simplePrint($oarray, true); |
|
183 | - echo '------<br>'; |
|
184 | - } else { |
|
185 | - echo $key1.' --> '.'Object <br>'; |
|
186 | - } |
|
187 | - } else { |
|
188 | - if (!is_null($result1)) { |
|
189 | - echo $key1.' --> '.$result1.'<br>'; |
|
190 | - } |
|
191 | - } |
|
192 | - } |
|
193 | - } |
|
194 | - } else { |
|
195 | - if (is_object($result)) { |
|
196 | - if ($deepPrinting) { |
|
197 | - echo "<br>$key ------><br>"; |
|
198 | - $oarray = (array) $result; |
|
199 | - self::simplePrint($oarray, true); |
|
200 | - echo '------<br>'; |
|
201 | - } else { |
|
202 | - echo $key.' --> '.'Object <br>'; |
|
203 | - } |
|
204 | - } else { |
|
205 | - if (!is_null($result)) { |
|
206 | - echo $key.' --> '.$result.'<br>'; |
|
207 | - } |
|
208 | - } |
|
209 | - } |
|
210 | - //echo "<br>"; |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Generates query or body parameters. |
|
218 | - * |
|
219 | - * @param $allFields: all known fields could be used for parameters generation |
|
220 | - * @param $params: input parameters (array or object) |
|
221 | - */ |
|
222 | - public static function generateRequestParameters($allFields, $params) |
|
223 | - { |
|
224 | - $generatedParams = []; |
|
225 | - |
|
226 | - if (is_array($params)) { |
|
227 | - foreach ($allFields as $field) { |
|
228 | - if (isset($params[$field])) { |
|
229 | - $generatedParams[$field] = $params[$field]; |
|
230 | - } |
|
231 | - } |
|
232 | - } elseif (is_object($params)) { |
|
233 | - foreach ($allFields as $field) { |
|
234 | - if (isset($params->{$field})) { |
|
235 | - $generatedParams[$field] = $params->{$field}; |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - return $generatedParams; |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Returns an array of the object properties. |
|
245 | - * |
|
246 | - * @param $object: An object |
|
247 | - * @param $exclude: array of the object parameters to be excluded from the returned array |
|
248 | - */ |
|
249 | - public static function getObjectProperties($object, $exclude) |
|
250 | - { |
|
251 | - $objectParameters = []; |
|
252 | - |
|
253 | - foreach (get_object_vars($object) as $key => $value) { |
|
254 | - if (property_exists($object, $key)) { |
|
255 | - if (!is_numeric(array_search($key, $exclude))) { |
|
256 | - array_push($objectParameters, $key); |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
260 | - |
|
261 | - return $objectParameters; |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Returns url path generated from the array of the fields and parameters. |
|
266 | - * |
|
267 | - * @param $allFields; array of the paossible fields (parameter names) |
|
268 | - * @param $params: input parameters (array or object) |
|
269 | - */ |
|
270 | - public static function generateUrlPath($allFields, $params) |
|
271 | - { |
|
272 | - $generatedPath = ''; |
|
273 | - |
|
274 | - if (is_array($params)) { |
|
275 | - foreach ($allFields as $field) { |
|
276 | - if (isset($params[$field])) { |
|
277 | - $generatedPath .= $params[$field].'/'; |
|
278 | - } |
|
279 | - } |
|
280 | - } elseif (is_object($params)) { |
|
281 | - foreach ($allFields as $field) { |
|
282 | - if (isset($params->{$field})) { |
|
283 | - $generatedPath .= $params->{$field}.'/'; |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
287 | - |
|
288 | - return $generatedPath; |
|
289 | - } |
|
290 | - |
|
291 | - public static function getFileRealPath($fileName) |
|
292 | - { |
|
293 | - $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName); |
|
294 | - |
|
295 | - return $rpath; |
|
296 | - } |
|
10 | + public static $apiKey; |
|
11 | + public static $baseUrl = Endpoint::BASE_URL; |
|
12 | + |
|
13 | + public static function setApiKey($apiKey) |
|
14 | + { |
|
15 | + self::$apiKey = $apiKey; |
|
16 | + } |
|
17 | + |
|
18 | + public static function getApiKey() |
|
19 | + { |
|
20 | + return self::$apiKey; |
|
21 | + } |
|
22 | + |
|
23 | + public static function setBaseUrl($baseUrl) |
|
24 | + { |
|
25 | + self::$baseUrl = $baseUrl; |
|
26 | + } |
|
27 | + |
|
28 | + public static function getBaseUrl() |
|
29 | + { |
|
30 | + return self::$baseUrl; |
|
31 | + } |
|
32 | + |
|
33 | + public static function makeRequst($options) |
|
34 | + { |
|
35 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
36 | + $query = isset($options['query']) ? array_filter($options['query'], function ($x) { return !is_null($x); }) : []; |
|
37 | + |
|
38 | + $body = isset($options['body']) ? $options['body'] : null; |
|
39 | + $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
40 | + $headers = [ |
|
41 | + 'User-Agent: Route4Me php-sdk', |
|
42 | + ]; |
|
43 | + |
|
44 | + if (isset($options['HTTPHEADER'])) { |
|
45 | + $headers[] = $options['HTTPHEADER']; |
|
46 | + } |
|
47 | + |
|
48 | + if (isset($options['HTTPHEADERS'])) { |
|
49 | + foreach ($options['HTTPHEADERS'] as $header) { |
|
50 | + $headers[] = $header; |
|
51 | + } |
|
52 | + } |
|
53 | + |
|
54 | + $ch = curl_init(); |
|
55 | + |
|
56 | + $url = isset($options['url']) ? $options['url'].'?'.http_build_query(array_merge( |
|
57 | + $query, ['api_key' => self::getApiKey()] |
|
58 | + )) : ''; |
|
59 | + |
|
60 | + $baseUrl = self::getBaseUrl(); |
|
61 | + |
|
62 | + $curlOpts = [ |
|
63 | + CURLOPT_URL => $baseUrl.$url, |
|
64 | + CURLOPT_RETURNTRANSFER => true, |
|
65 | + CURLOPT_TIMEOUT => 120, |
|
66 | + CURLOPT_FOLLOWLOCATION => true, |
|
67 | + CURLOPT_SSL_VERIFYHOST => false, |
|
68 | + CURLOPT_SSL_VERIFYPEER => false, |
|
69 | + CURLOPT_HTTPHEADER => $headers, |
|
70 | + ]; |
|
71 | + |
|
72 | + curl_setopt_array($ch, $curlOpts); |
|
73 | + |
|
74 | + if (null != $file) { |
|
75 | + $cfile = new \CURLFile($file,'',''); |
|
76 | + $body['strFilename']=$cfile; |
|
77 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
78 | + curl_setopt($ch, CURLOPT_POST,true); |
|
79 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); |
|
80 | + } else { |
|
81 | + switch ($method) { |
|
82 | + case 'DELETE': |
|
83 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
84 | + break; |
|
85 | + case 'DELETEARRAY': |
|
86 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
|
87 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
88 | + break; |
|
89 | + case 'PUT': |
|
90 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
91 | + break; |
|
92 | + case 'POST': |
|
93 | + if (isset($body)) { |
|
94 | + $bodyData = json_encode($body); |
|
95 | + if (isset($options['HTTPHEADER'])) { |
|
96 | + if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) { |
|
97 | + $bodyData = $body; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
102 | + } |
|
103 | + break; |
|
104 | + case 'ADD': |
|
105 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
106 | + } |
|
107 | + |
|
108 | + if (is_numeric(array_search($method, ['DELETE', 'PUT']))) { |
|
109 | + if (isset($body)) { |
|
110 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
111 | + } |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + $result = curl_exec($ch); |
|
116 | + |
|
117 | + $isxml = false; |
|
118 | + $jxml = ''; |
|
119 | + if (strpos($result, '<?xml') > -1) { |
|
120 | + $xml = simplexml_load_string($result); |
|
121 | + //$jxml = json_encode($xml); |
|
122 | + $jxml = self::object2array($xml); |
|
123 | + $isxml = true; |
|
124 | + } |
|
125 | + |
|
126 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
127 | + curl_close($ch); |
|
128 | + |
|
129 | + if (200 == $code) { |
|
130 | + if ($isxml) { |
|
131 | + $json = $jxml; |
|
132 | + } else { |
|
133 | + $json = json_decode($result, true); |
|
134 | + } |
|
135 | + |
|
136 | + if (isset($json['errors'])) { |
|
137 | + throw new ApiError(implode(', ', $json['errors'])); |
|
138 | + } else { |
|
139 | + return $json; |
|
140 | + } |
|
141 | + } elseif (409 == $code) { |
|
142 | + throw new ApiError('Wrong API key'); |
|
143 | + } else { |
|
144 | + throw new ApiError('Something wrong'); |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * @param $object: JSON object |
|
150 | + */ |
|
151 | + public static function object2array($object) |
|
152 | + { |
|
153 | + return @json_decode(@json_encode($object), 1); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Prints on the screen main keys and values of the array. |
|
158 | + * |
|
159 | + * @param $results: object to be printed on the screen |
|
160 | + * @param $deepPrinting: if true, object will be printed recursively |
|
161 | + */ |
|
162 | + public static function simplePrint($results, $deepPrinting = null) |
|
163 | + { |
|
164 | + if (isset($results)) { |
|
165 | + if (is_array($results)) { |
|
166 | + foreach ($results as $key => $result) { |
|
167 | + if (is_array($result)) { |
|
168 | + foreach ($result as $key1 => $result1) { |
|
169 | + if (is_array($result1)) { |
|
170 | + if ($deepPrinting) { |
|
171 | + echo "<br>$key1 ------><br>"; |
|
172 | + self::simplePrint($result1, true); |
|
173 | + echo '------<br>'; |
|
174 | + } else { |
|
175 | + echo $key1.' --> '.'Array() <br>'; |
|
176 | + } |
|
177 | + } else { |
|
178 | + if (is_object($result1)) { |
|
179 | + if ($deepPrinting) { |
|
180 | + echo "<br>$key1 ------><br>"; |
|
181 | + $oarray = (array) $result1; |
|
182 | + self::simplePrint($oarray, true); |
|
183 | + echo '------<br>'; |
|
184 | + } else { |
|
185 | + echo $key1.' --> '.'Object <br>'; |
|
186 | + } |
|
187 | + } else { |
|
188 | + if (!is_null($result1)) { |
|
189 | + echo $key1.' --> '.$result1.'<br>'; |
|
190 | + } |
|
191 | + } |
|
192 | + } |
|
193 | + } |
|
194 | + } else { |
|
195 | + if (is_object($result)) { |
|
196 | + if ($deepPrinting) { |
|
197 | + echo "<br>$key ------><br>"; |
|
198 | + $oarray = (array) $result; |
|
199 | + self::simplePrint($oarray, true); |
|
200 | + echo '------<br>'; |
|
201 | + } else { |
|
202 | + echo $key.' --> '.'Object <br>'; |
|
203 | + } |
|
204 | + } else { |
|
205 | + if (!is_null($result)) { |
|
206 | + echo $key.' --> '.$result.'<br>'; |
|
207 | + } |
|
208 | + } |
|
209 | + } |
|
210 | + //echo "<br>"; |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Generates query or body parameters. |
|
218 | + * |
|
219 | + * @param $allFields: all known fields could be used for parameters generation |
|
220 | + * @param $params: input parameters (array or object) |
|
221 | + */ |
|
222 | + public static function generateRequestParameters($allFields, $params) |
|
223 | + { |
|
224 | + $generatedParams = []; |
|
225 | + |
|
226 | + if (is_array($params)) { |
|
227 | + foreach ($allFields as $field) { |
|
228 | + if (isset($params[$field])) { |
|
229 | + $generatedParams[$field] = $params[$field]; |
|
230 | + } |
|
231 | + } |
|
232 | + } elseif (is_object($params)) { |
|
233 | + foreach ($allFields as $field) { |
|
234 | + if (isset($params->{$field})) { |
|
235 | + $generatedParams[$field] = $params->{$field}; |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + return $generatedParams; |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Returns an array of the object properties. |
|
245 | + * |
|
246 | + * @param $object: An object |
|
247 | + * @param $exclude: array of the object parameters to be excluded from the returned array |
|
248 | + */ |
|
249 | + public static function getObjectProperties($object, $exclude) |
|
250 | + { |
|
251 | + $objectParameters = []; |
|
252 | + |
|
253 | + foreach (get_object_vars($object) as $key => $value) { |
|
254 | + if (property_exists($object, $key)) { |
|
255 | + if (!is_numeric(array_search($key, $exclude))) { |
|
256 | + array_push($objectParameters, $key); |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | + |
|
261 | + return $objectParameters; |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Returns url path generated from the array of the fields and parameters. |
|
266 | + * |
|
267 | + * @param $allFields; array of the paossible fields (parameter names) |
|
268 | + * @param $params: input parameters (array or object) |
|
269 | + */ |
|
270 | + public static function generateUrlPath($allFields, $params) |
|
271 | + { |
|
272 | + $generatedPath = ''; |
|
273 | + |
|
274 | + if (is_array($params)) { |
|
275 | + foreach ($allFields as $field) { |
|
276 | + if (isset($params[$field])) { |
|
277 | + $generatedPath .= $params[$field].'/'; |
|
278 | + } |
|
279 | + } |
|
280 | + } elseif (is_object($params)) { |
|
281 | + foreach ($allFields as $field) { |
|
282 | + if (isset($params->{$field})) { |
|
283 | + $generatedPath .= $params->{$field}.'/'; |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | + |
|
288 | + return $generatedPath; |
|
289 | + } |
|
290 | + |
|
291 | + public static function getFileRealPath($fileName) |
|
292 | + { |
|
293 | + $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName); |
|
294 | + |
|
295 | + return $rpath; |
|
296 | + } |
|
297 | 297 | } |
@@ -6,22 +6,22 @@ |
||
6 | 6 | |
7 | 7 | class AddressBookLocationSearchResponse |
8 | 8 | { |
9 | - public $results=[]; |
|
10 | - public $total; |
|
11 | - public $fields=[]; |
|
9 | + public $results=[]; |
|
10 | + public $total; |
|
11 | + public $fields=[]; |
|
12 | 12 | |
13 | - public static function fromArray(array $params) |
|
14 | - { |
|
15 | - $ablSearchResponse = new self(); |
|
13 | + public static function fromArray(array $params) |
|
14 | + { |
|
15 | + $ablSearchResponse = new self(); |
|
16 | 16 | |
17 | - foreach ($params as $key => $value) { |
|
18 | - if (property_exists($ablSearchResponse, $key)) { |
|
19 | - $ablSearchResponse->{$key} = $value; |
|
20 | - } else { |
|
21 | - throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key"); |
|
22 | - } |
|
23 | - } |
|
17 | + foreach ($params as $key => $value) { |
|
18 | + if (property_exists($ablSearchResponse, $key)) { |
|
19 | + $ablSearchResponse->{$key} = $value; |
|
20 | + } else { |
|
21 | + throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key"); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - return $ablSearchResponse; |
|
26 | - } |
|
25 | + return $ablSearchResponse; |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |