@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | if (is_null($result) || !is_array($result)) return null; |
182 | 182 | |
183 | 183 | foreach ($result as $custNoteType) { |
184 | - if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"] == $params) { |
|
184 | + if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"]==$params) { |
|
185 | 185 | return $custNoteType; |
186 | 186 | } |
187 | 187 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $customArray = []; |
228 | 228 | |
229 | 229 | foreach ($params as $key => $value) { |
230 | - if (false !== strpos($key, 'custom_note_type')) { |
|
230 | + if (false!==strpos($key, 'custom_note_type')) { |
|
231 | 231 | $customArray[$key] = $value; |
232 | 232 | } |
233 | 233 | } |
@@ -178,7 +178,9 @@ |
||
178 | 178 | 'method' => 'GET', |
179 | 179 | ]); |
180 | 180 | |
181 | - if (is_null($result) || !is_array($result)) return null; |
|
181 | + if (is_null($result) || !is_array($result)) { |
|
182 | + return null; |
|
183 | + } |
|
182 | 184 | |
183 | 185 | foreach ($result as $custNoteType) { |
184 | 186 | if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"] == $params) { |
@@ -13,207 +13,207 @@ |
||
13 | 13 | */ |
14 | 14 | class AddressNote extends \Route4Me\Common |
15 | 15 | { |
16 | - /** An unique ID of a note |
|
17 | - * @var integer $note_id |
|
18 | - */ |
|
19 | - public $note_id; |
|
20 | - |
|
21 | - /** The route ID |
|
22 | - * @var string $route_id |
|
23 | - */ |
|
24 | - public $route_id; |
|
25 | - |
|
26 | - /** The route destination ID |
|
27 | - * @var integer $route_destination_id |
|
28 | - */ |
|
29 | - public $route_destination_id; |
|
30 | - |
|
31 | - /** An unique ID of an uploaded file |
|
32 | - * @var string $upload_id |
|
33 | - */ |
|
34 | - public $upload_id; |
|
35 | - |
|
36 | - /** When the note was added |
|
37 | - * @var integer $ts_added |
|
38 | - */ |
|
39 | - public $ts_added; |
|
40 | - |
|
41 | - /** The position latitude where the address note was added |
|
42 | - * @var double $lat |
|
43 | - */ |
|
44 | - public $lat; |
|
45 | - |
|
46 | - /** The position longitude where the address note was added |
|
47 | - * @var double $lng |
|
48 | - */ |
|
49 | - public $lng; |
|
50 | - |
|
51 | - /** The activity type |
|
52 | - * @var string $activity_type |
|
53 | - */ |
|
54 | - public $activity_type; |
|
55 | - |
|
56 | - /** The note text contents |
|
57 | - * @var string $contents |
|
58 | - */ |
|
59 | - public $contents; |
|
60 | - |
|
61 | - /** An upload type of the note |
|
62 | - * @var string $upload_type |
|
63 | - */ |
|
64 | - public $upload_type; |
|
65 | - |
|
66 | - /** An upload url - where a file-note was uploaded. |
|
67 | - * @var string $upload_url |
|
68 | - */ |
|
69 | - public $upload_url; |
|
70 | - |
|
71 | - /** An extension of the uploaded file. |
|
72 | - * @var string $upload_extension |
|
73 | - */ |
|
74 | - public $upload_extension; |
|
75 | - |
|
76 | - /** The device a note was uploaded from |
|
77 | - * @var string $device_type |
|
78 | - */ |
|
79 | - public $device_type; |
|
80 | - |
|
81 | - /** Array of the custom type notes |
|
82 | - * @var AddressCustomNote[] $custom_types |
|
83 | - */ |
|
84 | - public $custom_types = []; |
|
85 | - |
|
86 | - public function __construct() |
|
87 | - { |
|
88 | - } |
|
89 | - |
|
90 | - /*Get notes from the specified route destination |
|
16 | + /** An unique ID of a note |
|
17 | + * @var integer $note_id |
|
18 | + */ |
|
19 | + public $note_id; |
|
20 | + |
|
21 | + /** The route ID |
|
22 | + * @var string $route_id |
|
23 | + */ |
|
24 | + public $route_id; |
|
25 | + |
|
26 | + /** The route destination ID |
|
27 | + * @var integer $route_destination_id |
|
28 | + */ |
|
29 | + public $route_destination_id; |
|
30 | + |
|
31 | + /** An unique ID of an uploaded file |
|
32 | + * @var string $upload_id |
|
33 | + */ |
|
34 | + public $upload_id; |
|
35 | + |
|
36 | + /** When the note was added |
|
37 | + * @var integer $ts_added |
|
38 | + */ |
|
39 | + public $ts_added; |
|
40 | + |
|
41 | + /** The position latitude where the address note was added |
|
42 | + * @var double $lat |
|
43 | + */ |
|
44 | + public $lat; |
|
45 | + |
|
46 | + /** The position longitude where the address note was added |
|
47 | + * @var double $lng |
|
48 | + */ |
|
49 | + public $lng; |
|
50 | + |
|
51 | + /** The activity type |
|
52 | + * @var string $activity_type |
|
53 | + */ |
|
54 | + public $activity_type; |
|
55 | + |
|
56 | + /** The note text contents |
|
57 | + * @var string $contents |
|
58 | + */ |
|
59 | + public $contents; |
|
60 | + |
|
61 | + /** An upload type of the note |
|
62 | + * @var string $upload_type |
|
63 | + */ |
|
64 | + public $upload_type; |
|
65 | + |
|
66 | + /** An upload url - where a file-note was uploaded. |
|
67 | + * @var string $upload_url |
|
68 | + */ |
|
69 | + public $upload_url; |
|
70 | + |
|
71 | + /** An extension of the uploaded file. |
|
72 | + * @var string $upload_extension |
|
73 | + */ |
|
74 | + public $upload_extension; |
|
75 | + |
|
76 | + /** The device a note was uploaded from |
|
77 | + * @var string $device_type |
|
78 | + */ |
|
79 | + public $device_type; |
|
80 | + |
|
81 | + /** Array of the custom type notes |
|
82 | + * @var AddressCustomNote[] $custom_types |
|
83 | + */ |
|
84 | + public $custom_types = []; |
|
85 | + |
|
86 | + public function __construct() |
|
87 | + { |
|
88 | + } |
|
89 | + |
|
90 | + /*Get notes from the specified route destination |
|
91 | 91 | * Returns an address object with notes, if an address exists, otherwise - return null. |
92 | 92 | */ |
93 | - public static function GetAddressesNotes($noteParams) |
|
94 | - { |
|
95 | - $address = Route4Me::makeRequst([ |
|
96 | - 'url' => Endpoint::ADDRESS_V4, |
|
97 | - 'method' => 'GET', |
|
98 | - 'query' => [ |
|
99 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
100 | - 'route_destination_id' => isset($noteParams['route_destination_id']) |
|
101 | - ? $noteParams['route_destination_id'] : null, |
|
102 | - 'notes' => 1, |
|
103 | - ], |
|
104 | - ]); |
|
105 | - |
|
106 | - return $address; |
|
107 | - } |
|
108 | - |
|
109 | - public function createCustomNoteType($params) |
|
110 | - { |
|
111 | - $allBodyFields = ['type', 'values']; |
|
112 | - |
|
113 | - $result = Route4Me::makeRequst([ |
|
114 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
115 | - 'method' => 'POST', |
|
116 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
117 | - ]); |
|
118 | - |
|
119 | - return $result; |
|
120 | - } |
|
121 | - |
|
122 | - public function removeCustomNoteType($params) |
|
123 | - { |
|
124 | - $result = Route4Me::makeRequst([ |
|
125 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
126 | - 'method' => 'DELETE', |
|
127 | - 'body' => [ |
|
128 | - 'id' => isset($params['id']) ? $params['id'] : null, |
|
129 | - ], |
|
130 | - ]); |
|
131 | - |
|
132 | - return $result; |
|
133 | - } |
|
134 | - |
|
135 | - public function getAllCustomNoteTypes() |
|
136 | - { |
|
137 | - $result = Route4Me::makeRequst([ |
|
138 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
139 | - 'method' => 'GET', |
|
140 | - ]); |
|
141 | - |
|
142 | - return $result; |
|
143 | - } |
|
144 | - |
|
145 | - public function getCustomNoteTypeByKey($params) |
|
146 | - { |
|
147 | - $result = Route4Me::makeRequst([ |
|
148 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
149 | - 'method' => 'GET', |
|
150 | - ]); |
|
151 | - |
|
152 | - if (is_null($result) || !is_array($result)) return null; |
|
153 | - |
|
154 | - foreach ($result as $custNoteType) { |
|
155 | - if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"] == $params) { |
|
156 | - return $custNoteType; |
|
157 | - } |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - public function AddAddressNote($params) |
|
162 | - { |
|
163 | - $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type']; |
|
164 | - $allBodyFields = ['strNoteContents', 'strUpdateType']; |
|
165 | - |
|
166 | - $result = Route4Me::makeRequst([ |
|
167 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
168 | - 'method' => 'POST', |
|
169 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
170 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
171 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
172 | - ]); |
|
173 | - |
|
174 | - return $result; |
|
175 | - } |
|
176 | - |
|
177 | - public function AddNoteFile($params) |
|
178 | - { |
|
179 | - $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
180 | - |
|
181 | - $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type']; |
|
182 | - $allBodyFields = ['strFilename', 'strUpdateType', 'strNoteContents']; |
|
183 | - |
|
184 | - $result = Route4Me::makeRequst([ |
|
185 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
186 | - 'method' => 'POST', |
|
187 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
188 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
189 | - 'FILE' => $fname, |
|
190 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
191 | - ]); |
|
192 | - |
|
193 | - return $result; |
|
194 | - } |
|
195 | - |
|
196 | - public function addCustomNoteToRoute($params) |
|
197 | - { |
|
198 | - $customArray = []; |
|
199 | - |
|
200 | - foreach ($params as $key => $value) { |
|
201 | - if (false !== strpos($key, 'custom_note_type')) { |
|
202 | - $customArray[$key] = $value; |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - $allQueryFields = ['route_id', 'address_id', 'format', 'dev_lat', 'dev_lng']; |
|
207 | - $allBodyFields = ['strUpdateType', 'strUpdateType', 'strNoteContents']; |
|
208 | - |
|
209 | - $result = Route4Me::makeRequst([ |
|
210 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
211 | - 'method' => 'POST', |
|
212 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
213 | - 'body' => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray), |
|
214 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
215 | - ]); |
|
216 | - |
|
217 | - return $result; |
|
218 | - } |
|
93 | + public static function GetAddressesNotes($noteParams) |
|
94 | + { |
|
95 | + $address = Route4Me::makeRequst([ |
|
96 | + 'url' => Endpoint::ADDRESS_V4, |
|
97 | + 'method' => 'GET', |
|
98 | + 'query' => [ |
|
99 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
100 | + 'route_destination_id' => isset($noteParams['route_destination_id']) |
|
101 | + ? $noteParams['route_destination_id'] : null, |
|
102 | + 'notes' => 1, |
|
103 | + ], |
|
104 | + ]); |
|
105 | + |
|
106 | + return $address; |
|
107 | + } |
|
108 | + |
|
109 | + public function createCustomNoteType($params) |
|
110 | + { |
|
111 | + $allBodyFields = ['type', 'values']; |
|
112 | + |
|
113 | + $result = Route4Me::makeRequst([ |
|
114 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
115 | + 'method' => 'POST', |
|
116 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
117 | + ]); |
|
118 | + |
|
119 | + return $result; |
|
120 | + } |
|
121 | + |
|
122 | + public function removeCustomNoteType($params) |
|
123 | + { |
|
124 | + $result = Route4Me::makeRequst([ |
|
125 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
126 | + 'method' => 'DELETE', |
|
127 | + 'body' => [ |
|
128 | + 'id' => isset($params['id']) ? $params['id'] : null, |
|
129 | + ], |
|
130 | + ]); |
|
131 | + |
|
132 | + return $result; |
|
133 | + } |
|
134 | + |
|
135 | + public function getAllCustomNoteTypes() |
|
136 | + { |
|
137 | + $result = Route4Me::makeRequst([ |
|
138 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
139 | + 'method' => 'GET', |
|
140 | + ]); |
|
141 | + |
|
142 | + return $result; |
|
143 | + } |
|
144 | + |
|
145 | + public function getCustomNoteTypeByKey($params) |
|
146 | + { |
|
147 | + $result = Route4Me::makeRequst([ |
|
148 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
149 | + 'method' => 'GET', |
|
150 | + ]); |
|
151 | + |
|
152 | + if (is_null($result) || !is_array($result)) return null; |
|
153 | + |
|
154 | + foreach ($result as $custNoteType) { |
|
155 | + if (isset($custNoteType["note_custom_type"]) && $custNoteType["note_custom_type"] == $params) { |
|
156 | + return $custNoteType; |
|
157 | + } |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + public function AddAddressNote($params) |
|
162 | + { |
|
163 | + $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type']; |
|
164 | + $allBodyFields = ['strNoteContents', 'strUpdateType']; |
|
165 | + |
|
166 | + $result = Route4Me::makeRequst([ |
|
167 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
168 | + 'method' => 'POST', |
|
169 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
170 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
171 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
172 | + ]); |
|
173 | + |
|
174 | + return $result; |
|
175 | + } |
|
176 | + |
|
177 | + public function AddNoteFile($params) |
|
178 | + { |
|
179 | + $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
180 | + |
|
181 | + $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type']; |
|
182 | + $allBodyFields = ['strFilename', 'strUpdateType', 'strNoteContents']; |
|
183 | + |
|
184 | + $result = Route4Me::makeRequst([ |
|
185 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
186 | + 'method' => 'POST', |
|
187 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
188 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
189 | + 'FILE' => $fname, |
|
190 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
191 | + ]); |
|
192 | + |
|
193 | + return $result; |
|
194 | + } |
|
195 | + |
|
196 | + public function addCustomNoteToRoute($params) |
|
197 | + { |
|
198 | + $customArray = []; |
|
199 | + |
|
200 | + foreach ($params as $key => $value) { |
|
201 | + if (false !== strpos($key, 'custom_note_type')) { |
|
202 | + $customArray[$key] = $value; |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + $allQueryFields = ['route_id', 'address_id', 'format', 'dev_lat', 'dev_lng']; |
|
207 | + $allBodyFields = ['strUpdateType', 'strUpdateType', 'strNoteContents']; |
|
208 | + |
|
209 | + $result = Route4Me::makeRequst([ |
|
210 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
211 | + 'method' => 'POST', |
|
212 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
213 | + 'body' => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray), |
|
214 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
215 | + ]); |
|
216 | + |
|
217 | + return $result; |
|
218 | + } |
|
219 | 219 | } |
@@ -123,11 +123,11 @@ |
||
123 | 123 | $allVendors = self::GetTelematicsVendors(null); |
124 | 124 | $vendorsNumber = sizeof($allVendors['vendors']); |
125 | 125 | |
126 | - if ($vendorsNumber < $limit) { |
|
127 | - if ($vendorsNumber > $offset) { |
|
126 | + if ($vendorsNumber<$limit) { |
|
127 | + if ($vendorsNumber>$offset) { |
|
128 | 128 | $limit = $vendorsNumber; |
129 | 129 | } else { |
130 | - if ($vendorsNumber == $offset) { |
|
130 | + if ($vendorsNumber==$offset) { |
|
131 | 131 | return $allVendors['vendors'][$offset]->{'vendor_id'}; |
132 | 132 | } else { |
133 | 133 | echo 'The vendors numbers are less than offset'; |
@@ -6,62 +6,62 @@ |
||
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 GetTelematicsVendors($params) |
|
26 | - { |
|
27 | - Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); |
|
28 | - |
|
29 | - $allQueryFields = ['vendor_id', 'is_integrated', 'page', 'per_page', 'country', 'feature', 'search', 'vendors']; |
|
30 | - |
|
31 | - $vendors = Route4Me::makeRequst([ |
|
32 | - 'url' => '', |
|
33 | - 'method' => 'GET', |
|
34 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
35 | - ]); |
|
36 | - |
|
37 | - return $vendors; |
|
38 | - } |
|
39 | - |
|
40 | - public static function GetRandomVendorID($offset, $limit) |
|
41 | - { |
|
42 | - $allVendors = self::GetTelematicsVendors(null); |
|
43 | - $vendorsNumber = sizeof($allVendors['vendors']); |
|
44 | - |
|
45 | - if ($vendorsNumber < $limit) { |
|
46 | - if ($vendorsNumber > $offset) { |
|
47 | - $limit = $vendorsNumber; |
|
48 | - } else { |
|
49 | - if ($vendorsNumber == $offset) { |
|
50 | - return $allVendors['vendors'][$offset]->{'vendor_id'}; |
|
51 | - } else { |
|
52 | - echo 'The vendors numbers are less than offset'; |
|
53 | - |
|
54 | - return null; |
|
55 | - } |
|
56 | - } |
|
57 | - } |
|
58 | - |
|
59 | - $randNumber = rand($offset, $limit); |
|
60 | - |
|
61 | - return $allVendors['vendors'][$randNumber]['id']; |
|
62 | - } |
|
63 | - |
|
64 | - /* |
|
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 GetTelematicsVendors($params) |
|
26 | + { |
|
27 | + Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); |
|
28 | + |
|
29 | + $allQueryFields = ['vendor_id', 'is_integrated', 'page', 'per_page', 'country', 'feature', 'search', 'vendors']; |
|
30 | + |
|
31 | + $vendors = Route4Me::makeRequst([ |
|
32 | + 'url' => '', |
|
33 | + 'method' => 'GET', |
|
34 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
35 | + ]); |
|
36 | + |
|
37 | + return $vendors; |
|
38 | + } |
|
39 | + |
|
40 | + public static function GetRandomVendorID($offset, $limit) |
|
41 | + { |
|
42 | + $allVendors = self::GetTelematicsVendors(null); |
|
43 | + $vendorsNumber = sizeof($allVendors['vendors']); |
|
44 | + |
|
45 | + if ($vendorsNumber < $limit) { |
|
46 | + if ($vendorsNumber > $offset) { |
|
47 | + $limit = $vendorsNumber; |
|
48 | + } else { |
|
49 | + if ($vendorsNumber == $offset) { |
|
50 | + return $allVendors['vendors'][$offset]->{'vendor_id'}; |
|
51 | + } else { |
|
52 | + echo 'The vendors numbers are less than offset'; |
|
53 | + |
|
54 | + return null; |
|
55 | + } |
|
56 | + } |
|
57 | + } |
|
58 | + |
|
59 | + $randNumber = rand($offset, $limit); |
|
60 | + |
|
61 | + return $allVendors['vendors'][$randNumber]['id']; |
|
62 | + } |
|
63 | + |
|
64 | + /* |
|
65 | 65 | public static function GetTelematicsVendor($params) { |
66 | 66 | Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); |
67 | 67 |
@@ -18,70 +18,70 @@ |
||
18 | 18 | Route4Me::setApiKey(Constants::API_KEY); |
19 | 19 | |
20 | 20 | try { |
21 | - // get route_id and member_id |
|
22 | - $route = new Route; |
|
23 | - $routes = $route->getRoutes([ |
|
24 | - 'limit' => 1, |
|
25 | - 'offset' => 0 |
|
26 | - ]); |
|
27 | - |
|
28 | - $route_id = null; |
|
29 | - $member_id = null; |
|
30 | - if (is_array($routes) && isset($routes[0])) { |
|
31 | - $route_id = $routes[0]->route_id; |
|
32 | - $member_id = $routes[0]->member_id; |
|
33 | - } |
|
34 | - $route = null; |
|
35 | - |
|
36 | - if ($route_id === null) { |
|
37 | - throw new ApiError('There is no any route.'); |
|
38 | - } |
|
39 | - |
|
40 | - // get vehicle_id |
|
41 | - $vehicle = new Vehicle(); |
|
42 | - $vehicles = $vehicle->getVehiclesPaginatedList([ |
|
43 | - 'with_pagination' => true, |
|
44 | - 'page' => 1, |
|
45 | - 'perPage' => 1 |
|
46 | - ]); |
|
47 | - |
|
48 | - $vehicle_id = null; |
|
49 | - if (is_array($vehicles) && isset($vehicles[0]) && is_array($vehicles[0]) && isset($vehicles[0]['vehicle_id'])) { |
|
50 | - $vehicle_id = $vehicles[0]['vehicle_id']; |
|
51 | - } |
|
52 | - $vehicle = null; |
|
53 | - |
|
54 | - if ($vehicle_id === null) { |
|
55 | - throw new ApiError('There is no any vehicle.'); |
|
56 | - } |
|
57 | - |
|
58 | - // create Schedule |
|
59 | - $schedules = new Schedules; |
|
60 | - |
|
61 | - $schedule = $schedules->createSchedule([ |
|
62 | - 'name' => 'The bestest schedule', |
|
63 | - 'schedule_blacklist' => [], |
|
64 | - 'schedule' => null, |
|
65 | - 'timezone' => 'UTC' |
|
66 | - ]); |
|
67 | - |
|
68 | - // work with RouteSchedule |
|
69 | - $route_schedule = $schedules->createRouteSchedule([ |
|
70 | - 'route_id' => $route_id, |
|
71 | - 'schedule_uid' => $schedule->schedule_uid |
|
72 | - ]); |
|
73 | - |
|
74 | - $route_schedule = $schedules->updateRouteSchedule($route_id, [ |
|
75 | - 'schedule_uid' => $schedule->schedule_uid, |
|
76 | - 'member_id' => $member_id, |
|
77 | - 'vehicle_id' => $vehicle_id |
|
78 | - ]); |
|
79 | - |
|
80 | - $route_schedule = $schedules->getRouteSchedule($route_id); |
|
81 | - |
|
82 | - $schedules->deleteRouteSchedule($route_id); |
|
83 | - |
|
84 | - print_r($route_schedule); |
|
21 | + // get route_id and member_id |
|
22 | + $route = new Route; |
|
23 | + $routes = $route->getRoutes([ |
|
24 | + 'limit' => 1, |
|
25 | + 'offset' => 0 |
|
26 | + ]); |
|
27 | + |
|
28 | + $route_id = null; |
|
29 | + $member_id = null; |
|
30 | + if (is_array($routes) && isset($routes[0])) { |
|
31 | + $route_id = $routes[0]->route_id; |
|
32 | + $member_id = $routes[0]->member_id; |
|
33 | + } |
|
34 | + $route = null; |
|
35 | + |
|
36 | + if ($route_id === null) { |
|
37 | + throw new ApiError('There is no any route.'); |
|
38 | + } |
|
39 | + |
|
40 | + // get vehicle_id |
|
41 | + $vehicle = new Vehicle(); |
|
42 | + $vehicles = $vehicle->getVehiclesPaginatedList([ |
|
43 | + 'with_pagination' => true, |
|
44 | + 'page' => 1, |
|
45 | + 'perPage' => 1 |
|
46 | + ]); |
|
47 | + |
|
48 | + $vehicle_id = null; |
|
49 | + if (is_array($vehicles) && isset($vehicles[0]) && is_array($vehicles[0]) && isset($vehicles[0]['vehicle_id'])) { |
|
50 | + $vehicle_id = $vehicles[0]['vehicle_id']; |
|
51 | + } |
|
52 | + $vehicle = null; |
|
53 | + |
|
54 | + if ($vehicle_id === null) { |
|
55 | + throw new ApiError('There is no any vehicle.'); |
|
56 | + } |
|
57 | + |
|
58 | + // create Schedule |
|
59 | + $schedules = new Schedules; |
|
60 | + |
|
61 | + $schedule = $schedules->createSchedule([ |
|
62 | + 'name' => 'The bestest schedule', |
|
63 | + 'schedule_blacklist' => [], |
|
64 | + 'schedule' => null, |
|
65 | + 'timezone' => 'UTC' |
|
66 | + ]); |
|
67 | + |
|
68 | + // work with RouteSchedule |
|
69 | + $route_schedule = $schedules->createRouteSchedule([ |
|
70 | + 'route_id' => $route_id, |
|
71 | + 'schedule_uid' => $schedule->schedule_uid |
|
72 | + ]); |
|
73 | + |
|
74 | + $route_schedule = $schedules->updateRouteSchedule($route_id, [ |
|
75 | + 'schedule_uid' => $schedule->schedule_uid, |
|
76 | + 'member_id' => $member_id, |
|
77 | + 'vehicle_id' => $vehicle_id |
|
78 | + ]); |
|
79 | + |
|
80 | + $route_schedule = $schedules->getRouteSchedule($route_id); |
|
81 | + |
|
82 | + $schedules->deleteRouteSchedule($route_id); |
|
83 | + |
|
84 | + print_r($route_schedule); |
|
85 | 85 | } catch (\Exception $e) { |
86 | - echo $e->getMessage() . PHP_EOL; |
|
86 | + echo $e->getMessage() . PHP_EOL; |
|
87 | 87 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | $route = null; |
35 | 35 | |
36 | - if ($route_id === null) { |
|
36 | + if ($route_id===null) { |
|
37 | 37 | throw new ApiError('There is no any route.'); |
38 | 38 | } |
39 | 39 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | $vehicle = null; |
53 | 53 | |
54 | - if ($vehicle_id === null) { |
|
54 | + if ($vehicle_id===null) { |
|
55 | 55 | throw new ApiError('There is no any vehicle.'); |
56 | 56 | } |
57 | 57 | |
@@ -83,5 +83,5 @@ discard block |
||
83 | 83 | |
84 | 84 | print_r($route_schedule); |
85 | 85 | } catch (\Exception $e) { |
86 | - echo $e->getMessage() . PHP_EOL; |
|
86 | + echo $e->getMessage().PHP_EOL; |
|
87 | 87 | } |
@@ -15,16 +15,16 @@ |
||
15 | 15 | Route4Me::setApiKey(Constants::API_KEY); |
16 | 16 | |
17 | 17 | try { |
18 | - $route_schedules = new Schedules; |
|
18 | + $route_schedules = new Schedules; |
|
19 | 19 | |
20 | - $params = [ |
|
21 | - 'route_id' => '66C2AC4A323053FF0A40FEB6918ACF5E', |
|
22 | - 'schedule_uid' => '1515E9A65DD2DEF79CAD7A7E68D91515' |
|
23 | - ]; |
|
20 | + $params = [ |
|
21 | + 'route_id' => '66C2AC4A323053FF0A40FEB6918ACF5E', |
|
22 | + 'schedule_uid' => '1515E9A65DD2DEF79CAD7A7E68D91515' |
|
23 | + ]; |
|
24 | 24 | |
25 | - $schedule = $route_schedules->createRouteSchedule($params); |
|
25 | + $schedule = $route_schedules->createRouteSchedule($params); |
|
26 | 26 | |
27 | - print_r($schedule); |
|
27 | + print_r($schedule); |
|
28 | 28 | } catch (\Exception $e) { |
29 | - echo $e->getMessage() . PHP_EOL; |
|
29 | + echo $e->getMessage() . PHP_EOL; |
|
30 | 30 | } |
@@ -26,5 +26,5 @@ |
||
26 | 26 | |
27 | 27 | print_r($schedule); |
28 | 28 | } catch (\Exception $e) { |
29 | - echo $e->getMessage() . PHP_EOL; |
|
29 | + echo $e->getMessage().PHP_EOL; |
|
30 | 30 | } |
@@ -15,20 +15,20 @@ |
||
15 | 15 | Route4Me::setApiKey(Constants::API_KEY); |
16 | 16 | |
17 | 17 | try { |
18 | - $schedules = new Schedules; |
|
18 | + $schedules = new Schedules; |
|
19 | 19 | |
20 | - $params = [ |
|
21 | - 'schedule_uid' => '1515E9A65DD2DEF79CAD7A7E68D91515', |
|
22 | - 'root_member_id' => 15, |
|
23 | - 'name' => 'The bestest schedule 1', |
|
24 | - 'schedule_blacklist' => [], |
|
25 | - 'schedule' => null, |
|
26 | - 'timezone' => 'UTC' |
|
27 | - ]; |
|
20 | + $params = [ |
|
21 | + 'schedule_uid' => '1515E9A65DD2DEF79CAD7A7E68D91515', |
|
22 | + 'root_member_id' => 15, |
|
23 | + 'name' => 'The bestest schedule 1', |
|
24 | + 'schedule_blacklist' => [], |
|
25 | + 'schedule' => null, |
|
26 | + 'timezone' => 'UTC' |
|
27 | + ]; |
|
28 | 28 | |
29 | - $schedule = $schedules->createSchedule($params); |
|
29 | + $schedule = $schedules->createSchedule($params); |
|
30 | 30 | |
31 | - print_r($schedule); |
|
31 | + print_r($schedule); |
|
32 | 32 | } catch (\Exception $e) { |
33 | - echo $e->getMessage() . PHP_EOL; |
|
33 | + echo $e->getMessage() . PHP_EOL; |
|
34 | 34 | } |
@@ -26,5 +26,5 @@ |
||
26 | 26 | |
27 | 27 | print_r($schedule); |
28 | 28 | } catch (\Exception $e) { |
29 | - echo $e->getMessage() . PHP_EOL; |
|
29 | + echo $e->getMessage().PHP_EOL; |
|
30 | 30 | } |
@@ -15,10 +15,10 @@ |
||
15 | 15 | Route4Me::setApiKey(Constants::API_KEY); |
16 | 16 | |
17 | 17 | try { |
18 | - $schedules = new Schedules(); |
|
18 | + $schedules = new Schedules(); |
|
19 | 19 | |
20 | - $schedule = $schedules->getSchedule('1515E9A65DD2DEF79CAD7A7E68D91515'); |
|
21 | - print_r($schedule); |
|
20 | + $schedule = $schedules->getSchedule('1515E9A65DD2DEF79CAD7A7E68D91515'); |
|
21 | + print_r($schedule); |
|
22 | 22 | } catch (\Exception $e) { |
23 | - echo $e->getMessage() . PHP_EOL; |
|
23 | + echo $e->getMessage() . PHP_EOL; |
|
24 | 24 | } |
@@ -20,5 +20,5 @@ |
||
20 | 20 | $schedule = $schedules->getSchedule('1515E9A65DD2DEF79CAD7A7E68D91515'); |
21 | 21 | print_r($schedule); |
22 | 22 | } catch (\Exception $e) { |
23 | - echo $e->getMessage() . PHP_EOL; |
|
23 | + echo $e->getMessage().PHP_EOL; |
|
24 | 24 | } |
@@ -15,13 +15,13 @@ |
||
15 | 15 | Route4Me::setApiKey(Constants::API_KEY); |
16 | 16 | |
17 | 17 | try { |
18 | - $schedules = new Schedules(); |
|
19 | - $route_id = '66C2AC4A323053FF0A40FEB6918ACF5E'; |
|
20 | - $schedule_uid = '1515E9A65DD2DEF79CAD7A7E68D91515'; |
|
21 | - $route_date = '2023-01-01'; |
|
18 | + $schedules = new Schedules(); |
|
19 | + $route_id = '66C2AC4A323053FF0A40FEB6918ACF5E'; |
|
20 | + $schedule_uid = '1515E9A65DD2DEF79CAD7A7E68D91515'; |
|
21 | + $route_date = '2023-01-01'; |
|
22 | 22 | |
23 | - $schedule = $schedules->getScheduledRoutesCopies($route_id, $schedule_uid, $route_date); |
|
24 | - print_r($schedule); |
|
23 | + $schedule = $schedules->getScheduledRoutesCopies($route_id, $schedule_uid, $route_date); |
|
24 | + print_r($schedule); |
|
25 | 25 | } catch (\Exception $e) { |
26 | - echo $e->getMessage() . PHP_EOL; |
|
26 | + echo $e->getMessage() . PHP_EOL; |
|
27 | 27 | } |
@@ -23,5 +23,5 @@ |
||
23 | 23 | $schedule = $schedules->getScheduledRoutesCopies($route_id, $schedule_uid, $route_date); |
24 | 24 | print_r($schedule); |
25 | 25 | } catch (\Exception $e) { |
26 | - echo $e->getMessage() . PHP_EOL; |
|
26 | + echo $e->getMessage().PHP_EOL; |
|
27 | 27 | } |
@@ -19,17 +19,17 @@ |
||
19 | 19 | //********************************************************************** |
20 | 20 | // get list of all schedules |
21 | 21 | try { |
22 | - $list = $schedules->getAllSchedules(); |
|
23 | - print_r($list); |
|
22 | + $list = $schedules->getAllSchedules(); |
|
23 | + print_r($list); |
|
24 | 24 | } catch (\Exception $e) { |
25 | - echo $e->getMessage() . PHP_EOL; |
|
25 | + echo $e->getMessage() . PHP_EOL; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | //********************************************************************** |
29 | 29 | // get first page of paginated list of schedules |
30 | 30 | try { |
31 | - $list = $schedules->getSchedules(2, 5); |
|
32 | - print_r($list); |
|
31 | + $list = $schedules->getSchedules(2, 5); |
|
32 | + print_r($list); |
|
33 | 33 | } catch (\Exception $e) { |
34 | - echo $e->getMessage() . PHP_EOL; |
|
34 | + echo $e->getMessage() . PHP_EOL; |
|
35 | 35 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $list = $schedules->getAllSchedules(); |
23 | 23 | print_r($list); |
24 | 24 | } catch (\Exception $e) { |
25 | - echo $e->getMessage() . PHP_EOL; |
|
25 | + echo $e->getMessage().PHP_EOL; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | //********************************************************************** |
@@ -31,5 +31,5 @@ discard block |
||
31 | 31 | $list = $schedules->getSchedules(2, 5); |
32 | 32 | print_r($list); |
33 | 33 | } catch (\Exception $e) { |
34 | - echo $e->getMessage() . PHP_EOL; |
|
34 | + echo $e->getMessage().PHP_EOL; |
|
35 | 35 | } |
@@ -19,17 +19,17 @@ |
||
19 | 19 | //********************************************************************** |
20 | 20 | // get list of all Route Schedules |
21 | 21 | try { |
22 | - $list = $schedules->getAllRouteSchedules(); |
|
23 | - print_r($list); |
|
22 | + $list = $schedules->getAllRouteSchedules(); |
|
23 | + print_r($list); |
|
24 | 24 | } catch (\Exception $e) { |
25 | - echo $e->getMessage() . PHP_EOL; |
|
25 | + echo $e->getMessage() . PHP_EOL; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | //********************************************************************** |
29 | 29 | // get first page of paginated list of Route Schedules |
30 | 30 | try { |
31 | - $list = $schedules->getRouteSchedules(1, 5); |
|
32 | - print_r($list); |
|
31 | + $list = $schedules->getRouteSchedules(1, 5); |
|
32 | + print_r($list); |
|
33 | 33 | } catch (\Exception $e) { |
34 | - echo $e->getMessage() . PHP_EOL; |
|
34 | + echo $e->getMessage() . PHP_EOL; |
|
35 | 35 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $list = $schedules->getAllRouteSchedules(); |
23 | 23 | print_r($list); |
24 | 24 | } catch (\Exception $e) { |
25 | - echo $e->getMessage() . PHP_EOL; |
|
25 | + echo $e->getMessage().PHP_EOL; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | //********************************************************************** |
@@ -31,5 +31,5 @@ discard block |
||
31 | 31 | $list = $schedules->getRouteSchedules(1, 5); |
32 | 32 | print_r($list); |
33 | 33 | } catch (\Exception $e) { |
34 | - echo $e->getMessage() . PHP_EOL; |
|
34 | + echo $e->getMessage().PHP_EOL; |
|
35 | 35 | } |