@@ -20,654 +20,654 @@ |
||
| 20 | 20 | |
| 21 | 21 | final class TeamManagementUnitTests extends \PHPUnit\Framework\TestCase |
| 22 | 22 | { |
| 23 | - public static $createdAdddressIds = []; |
|
| 24 | - |
|
| 25 | - public static function setUpBeforeClass() : void |
|
| 26 | - { |
|
| 27 | - Route4Me::setApiKey(Constants::API_KEY); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public function testAddressCanBeCreateFromArray() : void |
|
| 31 | - { |
|
| 32 | - $this->assertInstanceOf(Address::class, new Address([ |
|
| 33 | - 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 34 | - 'cached_lat' => 38.024654, |
|
| 35 | - 'cached_lng' => 77.338814, |
|
| 36 | - 'address_stop_type' => 'DELIVERY' |
|
| 37 | - ])); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - public function testAddressCanBeCreateFromParams() : void |
|
| 41 | - { |
|
| 42 | - $this->assertInstanceOf(Address::class, new Address( |
|
| 43 | - '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 44 | - 38.024654, |
|
| 45 | - 77.338814, |
|
| 46 | - 'DELIVERY' |
|
| 47 | - )); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - public function testAssignedToCanBeCreateEmpty() : void |
|
| 51 | - { |
|
| 52 | - $this->assertInstanceOf(AssignedTo::class, new AssignedTo()); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - public function testAssignedToCanBeCreateFromArray() : void |
|
| 56 | - { |
|
| 57 | - $this->assertInstanceOf(AssignedTo::class, new AssignedTo([ |
|
| 58 | - 'member_id' => '1', |
|
| 59 | - 'member_first_name' => 'John Doe' |
|
| 60 | - ])); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public function testClusterCanBeCreateEmpty() : void |
|
| 64 | - { |
|
| 65 | - $this->assertInstanceOf(Cluster::class, new Cluster()); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - public function testClusterCanBeCreateFromArray() : void |
|
| 69 | - { |
|
| 70 | - $this->assertInstanceOf(Cluster::class, new Cluster([ |
|
| 71 | - 'geohash' => '1gmlagrpoarepker', |
|
| 72 | - 'lat' => 34.3456 |
|
| 73 | - ])); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - public function testResponseAddressCanBeCreateEmpty() : void |
|
| 77 | - { |
|
| 78 | - $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress()); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - public function testResponseAddressCanBeCreateFromArray() : void |
|
| 82 | - { |
|
| 83 | - $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress([ |
|
| 84 | - 'created_timestamp' => 15, |
|
| 85 | - 'address_id' => 1234567, |
|
| 86 | - 'schedule' => [ |
|
| 87 | - 'enable' => true, |
|
| 88 | - 'mode' => 'monthly' |
|
| 89 | - ], |
|
| 90 | - 'assigned_to' => [ |
|
| 91 | - 'member_id' => 123453, |
|
| 92 | - 'member_first_name' => 'Jane Doe' |
|
| 93 | - ] |
|
| 94 | - ])); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public function testResponseAddressCanBeCreateFromArrayAndObjects() : void |
|
| 98 | - { |
|
| 99 | - $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress([ |
|
| 100 | - 'created_timestamp' => 15, |
|
| 101 | - 'address_id' => 1234567, |
|
| 102 | - 'schedule' => new ScheduleItem(), |
|
| 103 | - 'assigned_to' => new AssignedTo() |
|
| 104 | - ])); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function testResponseAllCanBeCreateEmpty() : void |
|
| 108 | - { |
|
| 109 | - $this->assertInstanceOf(ResponseAll::class, new ResponseAll()); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - public function testResponseAllCanBeCreateFromArray() : void |
|
| 113 | - { |
|
| 114 | - $this->assertInstanceOf(ResponseAll::class, new ResponseAll([ |
|
| 115 | - 'results' => [[ |
|
| 116 | - 'created_timestamp' => 1, |
|
| 117 | - 'address_id' => 11 |
|
| 118 | - ], [ |
|
| 119 | - 'created_timestamp' => 2, |
|
| 120 | - 'address_id' => 22 |
|
| 121 | - ]], |
|
| 122 | - 'total' => 0 |
|
| 123 | - ])); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - public function testResponseAllCanBeCreateFromArrayAndResponseAddresses() : void |
|
| 127 | - { |
|
| 128 | - $this->assertInstanceOf(ResponseAll::class, new ResponseAll([ |
|
| 129 | - 'results' => [ |
|
| 130 | - new ResponseAddress(), |
|
| 131 | - new ResponseAddress(), |
|
| 132 | - ], |
|
| 133 | - 'total' => 0 |
|
| 134 | - ])); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - public function testResponseClusterCanBeCreateEmpty() : void |
|
| 138 | - { |
|
| 139 | - $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster()); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - public function testResponseClusterCanBeCreateFromArrays() : void |
|
| 143 | - { |
|
| 144 | - $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster([ |
|
| 145 | - 'cluster' => [ |
|
| 146 | - 'geohash' => 'tipageohash', |
|
| 147 | - 'lat' => 123.5657 |
|
| 148 | - ], |
|
| 149 | - 'address_count' => 1 |
|
| 150 | - ])); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - public function testResponseClusterCanBeCreateFromArrayAndCluster() : void |
|
| 154 | - { |
|
| 155 | - $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster([ |
|
| 156 | - 'cluster' => new Cluster(), |
|
| 157 | - 'address_count' => 1 |
|
| 158 | - ])); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - public function testResponseClusteringCanBeCreateEmpty() : void |
|
| 162 | - { |
|
| 163 | - $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering()); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - public function testResponseClusteringCanBeCreateFromArrays() : void |
|
| 167 | - { |
|
| 168 | - $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering([ |
|
| 169 | - 'clusters' => [[ |
|
| 170 | - 'geohash' => 'tipageohash', |
|
| 171 | - 'lat' => 123.5657 |
|
| 172 | - ], [ |
|
| 173 | - 'geohash' => 'tipageohashtoo', |
|
| 174 | - 'lat' => 23.56578 |
|
| 175 | - ]], |
|
| 176 | - 'total' => 2 |
|
| 177 | - ])); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - public function testResponseClusteringCanBeCreateFromArrayAndClusters() : void |
|
| 181 | - { |
|
| 182 | - $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering([ |
|
| 183 | - 'clusters' => [ |
|
| 184 | - new Cluster(), |
|
| 185 | - new Cluster() |
|
| 186 | - ], |
|
| 187 | - 'total' => 2 |
|
| 188 | - ])); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - public function testResponsePaginationCanBeCreateEmpty() : void |
|
| 192 | - { |
|
| 193 | - $this->assertInstanceOf(ResponsePagination::class, new ResponsePagination()); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - public function testResponsePaginationCanBeCreateFromArray() : void |
|
| 197 | - { |
|
| 198 | - $this->assertInstanceOf(ResponsePagination::class, new ResponsePagination([ |
|
| 199 | - 'current_page' => 1, |
|
| 200 | - 'last_page' => 2 |
|
| 201 | - ])); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - public function testScheduleItemCanBeCreateEmpty() : void |
|
| 205 | - { |
|
| 206 | - $this->assertInstanceOf(ScheduleItem::class, new ScheduleItem()); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - public function testScheduleItemCanBeCreateFromArray() : void |
|
| 210 | - { |
|
| 211 | - $this->assertInstanceOf(ScheduleItem::class, new ScheduleItem([ |
|
| 212 | - 'enable' => true, |
|
| 213 | - 'mode' => 'monthly' |
|
| 214 | - ])); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - public function testStatusCheckerCanBeCreateEmpty() : void |
|
| 218 | - { |
|
| 219 | - $this->assertInstanceOf(StatusChecker::class, new StatusChecker()); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - public function testStatusCheckerCanBeCreateFromArray() : void |
|
| 223 | - { |
|
| 224 | - $this->assertInstanceOf(StatusChecker::class, new StatusChecker([ |
|
| 225 | - 'code' => 200, |
|
| 226 | - 'data' => [] |
|
| 227 | - ])); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - public function testUpdateAddressCanBeCreateFromParam() : void |
|
| 231 | - { |
|
| 232 | - $this->assertInstanceOf(UpdateAddress::class, new UpdateAddress(15)); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - public function testAddressBookCanBeCreateEmpty() : void |
|
| 236 | - { |
|
| 237 | - $this->assertInstanceOf(AddressBook::class, new AddressBook()); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - public function testAddAddressGetArrayMustReturnResponseAddress() : void |
|
| 241 | - { |
|
| 242 | - $addr_book = new AddressBook(); |
|
| 243 | - $res_addr = $addr_book->addAddress([ |
|
| 244 | - 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 245 | - 'cached_lat' => 38.024654, |
|
| 246 | - 'cached_lng' => 77.338814, |
|
| 247 | - 'address_stop_type' => 'DELIVERY', |
|
| 248 | - 'address_city' => 'Tbilisi Vah', |
|
| 249 | - 'first_name' => 'Tusha I', |
|
| 250 | - 'last_name' => 'Grigoriani' |
|
| 251 | - ]); |
|
| 252 | - |
|
| 253 | - $this->assertInstanceOf(ResponseAddress::class, $res_addr); |
|
| 254 | - $this->assertNotNull($res_addr->address_id); |
|
| 255 | - $this->assertEquals($res_addr->first_name, 'Tusha I'); |
|
| 256 | - |
|
| 257 | - self::$createdAdddressIds[] = $res_addr->address_id; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - public function testAddAddressGetAddressMustReturnResponseAddress() : void |
|
| 261 | - { |
|
| 262 | - $addr_book = new AddressBook(); |
|
| 263 | - $addr = new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY'); |
|
| 264 | - $addr->first_name = 'Tusha I'; |
|
| 265 | - $res_addr = $addr_book->addAddress($addr); |
|
| 266 | - |
|
| 267 | - $this->assertInstanceOf(Address::class, $addr); |
|
| 268 | - $this->assertEquals($addr->first_name, 'Tusha I'); |
|
| 269 | - $this->assertInstanceOf(ResponseAddress::class, $res_addr); |
|
| 270 | - $this->assertNotNull($res_addr->address_id); |
|
| 271 | - $this->assertEquals($res_addr->first_name, 'Tusha I'); |
|
| 272 | - |
|
| 273 | - self::$createdAdddressIds[] = $res_addr->address_id; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - public function testAddMultipleAddressGetArrayMustReturnBool() : void |
|
| 277 | - { |
|
| 278 | - $addr_book = new AddressBook(); |
|
| 279 | - $res = $addr_book->addMultipleAddresses([[ |
|
| 280 | - 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 281 | - 'cached_lat' => 38.024654, |
|
| 282 | - 'cached_lng' => 77.338814, |
|
| 283 | - 'address_stop_type' => 'DELIVERY', |
|
| 284 | - 'address_city' => 'Tbilisi Vah', |
|
| 285 | - 'first_name' => 'Tusha I', |
|
| 286 | - 'last_name' => 'Grigoriani' |
|
| 287 | - ], [ |
|
| 288 | - 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 289 | - 'cached_lat' => 38.024654, |
|
| 290 | - 'cached_lng' => 77.338814, |
|
| 291 | - 'address_stop_type' => 'DELIVERY', |
|
| 292 | - 'address_city' => 'Tbilisi Vah', |
|
| 293 | - 'first_name' => 'Tusha II', |
|
| 294 | - 'last_name' => 'Grigoriani' |
|
| 295 | - ]]); |
|
| 296 | - |
|
| 297 | - $this->assertIsBool($res); |
|
| 298 | - $this->assertTrue($res); |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - public function testAddMultipleAddressGetAddressesMustReturnBool() : void |
|
| 302 | - { |
|
| 303 | - $addr_book = new AddressBook(); |
|
| 304 | - $addresses = [ |
|
| 305 | - new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY'), |
|
| 306 | - new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY') |
|
| 307 | - ]; |
|
| 308 | - $addresses[0]->first_name = 'Tusha I'; |
|
| 309 | - $addresses[1]->first_name = 'Tusha II'; |
|
| 310 | - $res = $addr_book->addMultipleAddresses($addresses); |
|
| 311 | - |
|
| 312 | - $this->assertIsBool($res); |
|
| 313 | - $this->assertTrue($res); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - public function testGetAddressesMustReturnResponseAll() : void |
|
| 317 | - { |
|
| 318 | - $options = [ |
|
| 319 | - 'fields' => "address_id, address_1, first_name, last_name, address_city", |
|
| 320 | - 'query' => 'Tusha', |
|
| 321 | - 'limit' => 5, |
|
| 322 | - 'offset' => 0 |
|
| 323 | - ]; |
|
| 324 | - $addr_book = new AddressBook(); |
|
| 325 | - $result = $addr_book->getAddresses($options); |
|
| 326 | - |
|
| 327 | - $this->assertInstanceOf(ResponseAll::class, $result); |
|
| 328 | - $this->assertNotNull($result->fields); |
|
| 329 | - $this->assertIsArray($result->results); |
|
| 330 | - $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - public function testGetAddressesByBodyPayloadMustReturnResponseAll() : void |
|
| 334 | - { |
|
| 335 | - $options = [ |
|
| 336 | - 'filter' => [ |
|
| 337 | - 'query' => 'Tusha', |
|
| 338 | - 'selected_areas' => [[ |
|
| 339 | - 'type' => 'circle', |
|
| 340 | - 'value' => [ |
|
| 341 | - 'center' => [ |
|
| 342 | - 'lat' => 38.024654, |
|
| 343 | - 'lng' => 77.338814 |
|
| 344 | - ], |
|
| 345 | - 'distance' => 10000 |
|
| 346 | - ] |
|
| 347 | - ]] |
|
| 348 | - ], |
|
| 349 | - 'limit' => 5, |
|
| 350 | - 'offset' => 0 |
|
| 351 | - ]; |
|
| 352 | - $addr_book = new AddressBook(); |
|
| 353 | - $result = $addr_book->getAddressesByBodyPayload($options); |
|
| 354 | - |
|
| 355 | - $this->assertInstanceOf(ResponseAll::class, $result); |
|
| 356 | - $this->assertIsArray($result->results); |
|
| 357 | - $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - public function testGetAddressesPaginatedMustReturnResponsePaginated() : void |
|
| 361 | - { |
|
| 362 | - $options = [ |
|
| 363 | - 'fields' => "address_id, address_1, first_name, last_name, address_city", |
|
| 364 | - 'query' => 'Tusha', |
|
| 365 | - 'per_page' => 5, |
|
| 366 | - 'page' => 0 |
|
| 367 | - ]; |
|
| 368 | - $addr_book = new AddressBook(); |
|
| 369 | - $result = $addr_book->getAddressesPaginated($options); |
|
| 370 | - |
|
| 371 | - $this->assertInstanceOf(ResponsePagination::class, $result); |
|
| 372 | - $this->assertNotNull($result->fields); |
|
| 373 | - $this->assertNotNull($result->current_page); |
|
| 374 | - $this->assertIsArray($result->results); |
|
| 375 | - $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - public function testGetAddressesPaginatedByBodyPayloadMustReturnResponsePaginated() : void |
|
| 379 | - { |
|
| 380 | - $options = [ |
|
| 381 | - 'filter' => [ |
|
| 382 | - 'query' => 'Tusha', |
|
| 383 | - 'selected_areas' => [[ |
|
| 384 | - 'type' => 'circle', |
|
| 385 | - 'value' => [ |
|
| 386 | - 'center' => [ |
|
| 387 | - 'lat' => 52.4025, |
|
| 388 | - 'lng' => 4.5601 |
|
| 389 | - ], |
|
| 390 | - 'distance' => 10000 |
|
| 391 | - ] |
|
| 392 | - ]] |
|
| 393 | - ], |
|
| 394 | - 'page' => 2, |
|
| 395 | - 'per_page' => 10 |
|
| 396 | - ]; |
|
| 397 | - $addr_book = new AddressBook(); |
|
| 398 | - $result = $addr_book->getAddressesPaginated($options); |
|
| 399 | - |
|
| 400 | - $this->assertInstanceOf(ResponsePagination::class, $result); |
|
| 401 | - $this->assertNotNull($result->current_page); |
|
| 402 | - $this->assertIsArray($result->results); |
|
| 403 | - $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - public function testGetAddressClustersMustReturnResponseClustering() : void |
|
| 407 | - { |
|
| 408 | - $options = [ |
|
| 409 | - 'display' => 'unrouted', |
|
| 410 | - 'query' => 'Tusha' |
|
| 411 | - ]; |
|
| 412 | - $addr_book = new AddressBook(); |
|
| 413 | - $result = $addr_book->getAddressClusters($options); |
|
| 414 | - |
|
| 415 | - $this->assertInstanceOf(ResponseClustering::class, $result); |
|
| 416 | - $this->assertIsArray($result->clusters); |
|
| 417 | - $this->assertInstanceOf(Cluster::class, $result->clusters[0]); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - public function testGetAddressClustersByBodyPayloadMustReturnResponseClustering() : void |
|
| 421 | - { |
|
| 422 | - $options = [ |
|
| 423 | - 'clustering' => [ |
|
| 424 | - 'precision' => 2 |
|
| 425 | - ], |
|
| 426 | - 'filter' => [ |
|
| 427 | - 'query' => 'Tusha', |
|
| 428 | - 'selected_areas' => [[ |
|
| 429 | - 'type' => 'circle', |
|
| 430 | - 'value' => [ |
|
| 431 | - 'center' => [ |
|
| 432 | - 'lat' => 52.4025, |
|
| 433 | - 'lng' => 4.5601 |
|
| 434 | - ], |
|
| 435 | - 'distance' => 10000 |
|
| 436 | - ] |
|
| 437 | - ]] |
|
| 438 | - ] |
|
| 439 | - ]; |
|
| 440 | - $addr_book = new AddressBook(); |
|
| 441 | - $result = $addr_book->getAddressClustersByBodyPayload($options); |
|
| 442 | - |
|
| 443 | - $this->assertInstanceOf(ResponseClustering::class, $result); |
|
| 444 | - $this->assertIsArray($result->clusters); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - public function testGetAddressByIdMustReturnResponseAddress() : void |
|
| 448 | - { |
|
| 449 | - $addr_book = new AddressBook(); |
|
| 450 | - $result = $addr_book->getAddressById(self::$createdAdddressIds[0]); |
|
| 451 | - |
|
| 452 | - $this->assertInstanceOf(ResponseAddress::class, $result); |
|
| 453 | - $this->assertIsInt($result->address_id); |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - public function testGetAddressesByIdsMustReturnResponseAddress() : void |
|
| 457 | - { |
|
| 458 | - $addr_book = new AddressBook(); |
|
| 459 | - $result = $addr_book->getAddressesByIds(self::$createdAdddressIds); |
|
| 460 | - |
|
| 461 | - $this->assertInstanceOf(ResponseAll::class, $result); |
|
| 462 | - $this->assertIsArray($result->results); |
|
| 463 | - $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 464 | - $this->assertIsInt($result->results[0]->address_id); |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - public function testUpdateAddressByIdMustReturnResponseAddress() : void |
|
| 468 | - { |
|
| 469 | - $addr_book = new AddressBook(); |
|
| 470 | - $result = $addr_book->updateAddressById(self::$createdAdddressIds[0], ['last_name' => 'Grigoriani III']); |
|
| 471 | - |
|
| 472 | - $this->assertInstanceOf(ResponseAddress::class, $result); |
|
| 473 | - $this->assertEqualsCanonicalizing($result->last_name, 'Grigoriani III'); |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - public function testUpdateAddressesByIdsMustReturnArray() : void |
|
| 477 | - { |
|
| 478 | - $addr_book = new AddressBook(); |
|
| 479 | - $result = $addr_book->updateAddressesByIds(self::$createdAdddressIds, ['last_name' => 'Grigoriani IV']); |
|
| 480 | - |
|
| 481 | - $this->assertIsArray($result); |
|
| 482 | - $this->assertInstanceOf(ResponseAddress::class, $result[0]); |
|
| 483 | - $this->assertEqualsCanonicalizing($result[0]->last_name, 'Grigoriani IV'); |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - // TODO: request has uncheckable result - 403 forbidden |
|
| 487 | - public function testUpdateAddressesByAreasMustReturnStatusChecker() : void |
|
| 488 | - { |
|
| 489 | - $addr_book = new AddressBook(); |
|
| 490 | - $filter = [ |
|
| 491 | - 'query' => "Tusha", |
|
| 492 | - 'bounding_box' => null, |
|
| 493 | - 'selected_areas' => [[ |
|
| 494 | - 'type' => 'circle', |
|
| 495 | - 'value' => [ |
|
| 496 | - 'center' => [ |
|
| 497 | - 'lat' => 38.024654, |
|
| 498 | - 'lng' => 77.338814 |
|
| 499 | - ], |
|
| 500 | - 'distance' => 10000 |
|
| 501 | - ] |
|
| 502 | - ]] |
|
| 503 | - ]; |
|
| 23 | + public static $createdAdddressIds = []; |
|
| 24 | + |
|
| 25 | + public static function setUpBeforeClass() : void |
|
| 26 | + { |
|
| 27 | + Route4Me::setApiKey(Constants::API_KEY); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public function testAddressCanBeCreateFromArray() : void |
|
| 31 | + { |
|
| 32 | + $this->assertInstanceOf(Address::class, new Address([ |
|
| 33 | + 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 34 | + 'cached_lat' => 38.024654, |
|
| 35 | + 'cached_lng' => 77.338814, |
|
| 36 | + 'address_stop_type' => 'DELIVERY' |
|
| 37 | + ])); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + public function testAddressCanBeCreateFromParams() : void |
|
| 41 | + { |
|
| 42 | + $this->assertInstanceOf(Address::class, new Address( |
|
| 43 | + '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 44 | + 38.024654, |
|
| 45 | + 77.338814, |
|
| 46 | + 'DELIVERY' |
|
| 47 | + )); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + public function testAssignedToCanBeCreateEmpty() : void |
|
| 51 | + { |
|
| 52 | + $this->assertInstanceOf(AssignedTo::class, new AssignedTo()); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + public function testAssignedToCanBeCreateFromArray() : void |
|
| 56 | + { |
|
| 57 | + $this->assertInstanceOf(AssignedTo::class, new AssignedTo([ |
|
| 58 | + 'member_id' => '1', |
|
| 59 | + 'member_first_name' => 'John Doe' |
|
| 60 | + ])); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public function testClusterCanBeCreateEmpty() : void |
|
| 64 | + { |
|
| 65 | + $this->assertInstanceOf(Cluster::class, new Cluster()); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + public function testClusterCanBeCreateFromArray() : void |
|
| 69 | + { |
|
| 70 | + $this->assertInstanceOf(Cluster::class, new Cluster([ |
|
| 71 | + 'geohash' => '1gmlagrpoarepker', |
|
| 72 | + 'lat' => 34.3456 |
|
| 73 | + ])); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + public function testResponseAddressCanBeCreateEmpty() : void |
|
| 77 | + { |
|
| 78 | + $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress()); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + public function testResponseAddressCanBeCreateFromArray() : void |
|
| 82 | + { |
|
| 83 | + $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress([ |
|
| 84 | + 'created_timestamp' => 15, |
|
| 85 | + 'address_id' => 1234567, |
|
| 86 | + 'schedule' => [ |
|
| 87 | + 'enable' => true, |
|
| 88 | + 'mode' => 'monthly' |
|
| 89 | + ], |
|
| 90 | + 'assigned_to' => [ |
|
| 91 | + 'member_id' => 123453, |
|
| 92 | + 'member_first_name' => 'Jane Doe' |
|
| 93 | + ] |
|
| 94 | + ])); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public function testResponseAddressCanBeCreateFromArrayAndObjects() : void |
|
| 98 | + { |
|
| 99 | + $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress([ |
|
| 100 | + 'created_timestamp' => 15, |
|
| 101 | + 'address_id' => 1234567, |
|
| 102 | + 'schedule' => new ScheduleItem(), |
|
| 103 | + 'assigned_to' => new AssignedTo() |
|
| 104 | + ])); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function testResponseAllCanBeCreateEmpty() : void |
|
| 108 | + { |
|
| 109 | + $this->assertInstanceOf(ResponseAll::class, new ResponseAll()); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + public function testResponseAllCanBeCreateFromArray() : void |
|
| 113 | + { |
|
| 114 | + $this->assertInstanceOf(ResponseAll::class, new ResponseAll([ |
|
| 115 | + 'results' => [[ |
|
| 116 | + 'created_timestamp' => 1, |
|
| 117 | + 'address_id' => 11 |
|
| 118 | + ], [ |
|
| 119 | + 'created_timestamp' => 2, |
|
| 120 | + 'address_id' => 22 |
|
| 121 | + ]], |
|
| 122 | + 'total' => 0 |
|
| 123 | + ])); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + public function testResponseAllCanBeCreateFromArrayAndResponseAddresses() : void |
|
| 127 | + { |
|
| 128 | + $this->assertInstanceOf(ResponseAll::class, new ResponseAll([ |
|
| 129 | + 'results' => [ |
|
| 130 | + new ResponseAddress(), |
|
| 131 | + new ResponseAddress(), |
|
| 132 | + ], |
|
| 133 | + 'total' => 0 |
|
| 134 | + ])); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + public function testResponseClusterCanBeCreateEmpty() : void |
|
| 138 | + { |
|
| 139 | + $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster()); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + public function testResponseClusterCanBeCreateFromArrays() : void |
|
| 143 | + { |
|
| 144 | + $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster([ |
|
| 145 | + 'cluster' => [ |
|
| 146 | + 'geohash' => 'tipageohash', |
|
| 147 | + 'lat' => 123.5657 |
|
| 148 | + ], |
|
| 149 | + 'address_count' => 1 |
|
| 150 | + ])); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + public function testResponseClusterCanBeCreateFromArrayAndCluster() : void |
|
| 154 | + { |
|
| 155 | + $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster([ |
|
| 156 | + 'cluster' => new Cluster(), |
|
| 157 | + 'address_count' => 1 |
|
| 158 | + ])); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + public function testResponseClusteringCanBeCreateEmpty() : void |
|
| 162 | + { |
|
| 163 | + $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering()); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + public function testResponseClusteringCanBeCreateFromArrays() : void |
|
| 167 | + { |
|
| 168 | + $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering([ |
|
| 169 | + 'clusters' => [[ |
|
| 170 | + 'geohash' => 'tipageohash', |
|
| 171 | + 'lat' => 123.5657 |
|
| 172 | + ], [ |
|
| 173 | + 'geohash' => 'tipageohashtoo', |
|
| 174 | + 'lat' => 23.56578 |
|
| 175 | + ]], |
|
| 176 | + 'total' => 2 |
|
| 177 | + ])); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + public function testResponseClusteringCanBeCreateFromArrayAndClusters() : void |
|
| 181 | + { |
|
| 182 | + $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering([ |
|
| 183 | + 'clusters' => [ |
|
| 184 | + new Cluster(), |
|
| 185 | + new Cluster() |
|
| 186 | + ], |
|
| 187 | + 'total' => 2 |
|
| 188 | + ])); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + public function testResponsePaginationCanBeCreateEmpty() : void |
|
| 192 | + { |
|
| 193 | + $this->assertInstanceOf(ResponsePagination::class, new ResponsePagination()); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + public function testResponsePaginationCanBeCreateFromArray() : void |
|
| 197 | + { |
|
| 198 | + $this->assertInstanceOf(ResponsePagination::class, new ResponsePagination([ |
|
| 199 | + 'current_page' => 1, |
|
| 200 | + 'last_page' => 2 |
|
| 201 | + ])); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + public function testScheduleItemCanBeCreateEmpty() : void |
|
| 205 | + { |
|
| 206 | + $this->assertInstanceOf(ScheduleItem::class, new ScheduleItem()); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + public function testScheduleItemCanBeCreateFromArray() : void |
|
| 210 | + { |
|
| 211 | + $this->assertInstanceOf(ScheduleItem::class, new ScheduleItem([ |
|
| 212 | + 'enable' => true, |
|
| 213 | + 'mode' => 'monthly' |
|
| 214 | + ])); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + public function testStatusCheckerCanBeCreateEmpty() : void |
|
| 218 | + { |
|
| 219 | + $this->assertInstanceOf(StatusChecker::class, new StatusChecker()); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + public function testStatusCheckerCanBeCreateFromArray() : void |
|
| 223 | + { |
|
| 224 | + $this->assertInstanceOf(StatusChecker::class, new StatusChecker([ |
|
| 225 | + 'code' => 200, |
|
| 226 | + 'data' => [] |
|
| 227 | + ])); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + public function testUpdateAddressCanBeCreateFromParam() : void |
|
| 231 | + { |
|
| 232 | + $this->assertInstanceOf(UpdateAddress::class, new UpdateAddress(15)); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + public function testAddressBookCanBeCreateEmpty() : void |
|
| 236 | + { |
|
| 237 | + $this->assertInstanceOf(AddressBook::class, new AddressBook()); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + public function testAddAddressGetArrayMustReturnResponseAddress() : void |
|
| 241 | + { |
|
| 242 | + $addr_book = new AddressBook(); |
|
| 243 | + $res_addr = $addr_book->addAddress([ |
|
| 244 | + 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 245 | + 'cached_lat' => 38.024654, |
|
| 246 | + 'cached_lng' => 77.338814, |
|
| 247 | + 'address_stop_type' => 'DELIVERY', |
|
| 248 | + 'address_city' => 'Tbilisi Vah', |
|
| 249 | + 'first_name' => 'Tusha I', |
|
| 250 | + 'last_name' => 'Grigoriani' |
|
| 251 | + ]); |
|
| 252 | + |
|
| 253 | + $this->assertInstanceOf(ResponseAddress::class, $res_addr); |
|
| 254 | + $this->assertNotNull($res_addr->address_id); |
|
| 255 | + $this->assertEquals($res_addr->first_name, 'Tusha I'); |
|
| 256 | + |
|
| 257 | + self::$createdAdddressIds[] = $res_addr->address_id; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + public function testAddAddressGetAddressMustReturnResponseAddress() : void |
|
| 261 | + { |
|
| 262 | + $addr_book = new AddressBook(); |
|
| 263 | + $addr = new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY'); |
|
| 264 | + $addr->first_name = 'Tusha I'; |
|
| 265 | + $res_addr = $addr_book->addAddress($addr); |
|
| 266 | + |
|
| 267 | + $this->assertInstanceOf(Address::class, $addr); |
|
| 268 | + $this->assertEquals($addr->first_name, 'Tusha I'); |
|
| 269 | + $this->assertInstanceOf(ResponseAddress::class, $res_addr); |
|
| 270 | + $this->assertNotNull($res_addr->address_id); |
|
| 271 | + $this->assertEquals($res_addr->first_name, 'Tusha I'); |
|
| 272 | + |
|
| 273 | + self::$createdAdddressIds[] = $res_addr->address_id; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + public function testAddMultipleAddressGetArrayMustReturnBool() : void |
|
| 277 | + { |
|
| 278 | + $addr_book = new AddressBook(); |
|
| 279 | + $res = $addr_book->addMultipleAddresses([[ |
|
| 280 | + 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 281 | + 'cached_lat' => 38.024654, |
|
| 282 | + 'cached_lng' => 77.338814, |
|
| 283 | + 'address_stop_type' => 'DELIVERY', |
|
| 284 | + 'address_city' => 'Tbilisi Vah', |
|
| 285 | + 'first_name' => 'Tusha I', |
|
| 286 | + 'last_name' => 'Grigoriani' |
|
| 287 | + ], [ |
|
| 288 | + 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 289 | + 'cached_lat' => 38.024654, |
|
| 290 | + 'cached_lng' => 77.338814, |
|
| 291 | + 'address_stop_type' => 'DELIVERY', |
|
| 292 | + 'address_city' => 'Tbilisi Vah', |
|
| 293 | + 'first_name' => 'Tusha II', |
|
| 294 | + 'last_name' => 'Grigoriani' |
|
| 295 | + ]]); |
|
| 296 | + |
|
| 297 | + $this->assertIsBool($res); |
|
| 298 | + $this->assertTrue($res); |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + public function testAddMultipleAddressGetAddressesMustReturnBool() : void |
|
| 302 | + { |
|
| 303 | + $addr_book = new AddressBook(); |
|
| 304 | + $addresses = [ |
|
| 305 | + new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY'), |
|
| 306 | + new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY') |
|
| 307 | + ]; |
|
| 308 | + $addresses[0]->first_name = 'Tusha I'; |
|
| 309 | + $addresses[1]->first_name = 'Tusha II'; |
|
| 310 | + $res = $addr_book->addMultipleAddresses($addresses); |
|
| 311 | + |
|
| 312 | + $this->assertIsBool($res); |
|
| 313 | + $this->assertTrue($res); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + public function testGetAddressesMustReturnResponseAll() : void |
|
| 317 | + { |
|
| 318 | + $options = [ |
|
| 319 | + 'fields' => "address_id, address_1, first_name, last_name, address_city", |
|
| 320 | + 'query' => 'Tusha', |
|
| 321 | + 'limit' => 5, |
|
| 322 | + 'offset' => 0 |
|
| 323 | + ]; |
|
| 324 | + $addr_book = new AddressBook(); |
|
| 325 | + $result = $addr_book->getAddresses($options); |
|
| 326 | + |
|
| 327 | + $this->assertInstanceOf(ResponseAll::class, $result); |
|
| 328 | + $this->assertNotNull($result->fields); |
|
| 329 | + $this->assertIsArray($result->results); |
|
| 330 | + $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + public function testGetAddressesByBodyPayloadMustReturnResponseAll() : void |
|
| 334 | + { |
|
| 335 | + $options = [ |
|
| 336 | + 'filter' => [ |
|
| 337 | + 'query' => 'Tusha', |
|
| 338 | + 'selected_areas' => [[ |
|
| 339 | + 'type' => 'circle', |
|
| 340 | + 'value' => [ |
|
| 341 | + 'center' => [ |
|
| 342 | + 'lat' => 38.024654, |
|
| 343 | + 'lng' => 77.338814 |
|
| 344 | + ], |
|
| 345 | + 'distance' => 10000 |
|
| 346 | + ] |
|
| 347 | + ]] |
|
| 348 | + ], |
|
| 349 | + 'limit' => 5, |
|
| 350 | + 'offset' => 0 |
|
| 351 | + ]; |
|
| 352 | + $addr_book = new AddressBook(); |
|
| 353 | + $result = $addr_book->getAddressesByBodyPayload($options); |
|
| 354 | + |
|
| 355 | + $this->assertInstanceOf(ResponseAll::class, $result); |
|
| 356 | + $this->assertIsArray($result->results); |
|
| 357 | + $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + public function testGetAddressesPaginatedMustReturnResponsePaginated() : void |
|
| 361 | + { |
|
| 362 | + $options = [ |
|
| 363 | + 'fields' => "address_id, address_1, first_name, last_name, address_city", |
|
| 364 | + 'query' => 'Tusha', |
|
| 365 | + 'per_page' => 5, |
|
| 366 | + 'page' => 0 |
|
| 367 | + ]; |
|
| 368 | + $addr_book = new AddressBook(); |
|
| 369 | + $result = $addr_book->getAddressesPaginated($options); |
|
| 370 | + |
|
| 371 | + $this->assertInstanceOf(ResponsePagination::class, $result); |
|
| 372 | + $this->assertNotNull($result->fields); |
|
| 373 | + $this->assertNotNull($result->current_page); |
|
| 374 | + $this->assertIsArray($result->results); |
|
| 375 | + $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + public function testGetAddressesPaginatedByBodyPayloadMustReturnResponsePaginated() : void |
|
| 379 | + { |
|
| 380 | + $options = [ |
|
| 381 | + 'filter' => [ |
|
| 382 | + 'query' => 'Tusha', |
|
| 383 | + 'selected_areas' => [[ |
|
| 384 | + 'type' => 'circle', |
|
| 385 | + 'value' => [ |
|
| 386 | + 'center' => [ |
|
| 387 | + 'lat' => 52.4025, |
|
| 388 | + 'lng' => 4.5601 |
|
| 389 | + ], |
|
| 390 | + 'distance' => 10000 |
|
| 391 | + ] |
|
| 392 | + ]] |
|
| 393 | + ], |
|
| 394 | + 'page' => 2, |
|
| 395 | + 'per_page' => 10 |
|
| 396 | + ]; |
|
| 397 | + $addr_book = new AddressBook(); |
|
| 398 | + $result = $addr_book->getAddressesPaginated($options); |
|
| 399 | + |
|
| 400 | + $this->assertInstanceOf(ResponsePagination::class, $result); |
|
| 401 | + $this->assertNotNull($result->current_page); |
|
| 402 | + $this->assertIsArray($result->results); |
|
| 403 | + $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + public function testGetAddressClustersMustReturnResponseClustering() : void |
|
| 407 | + { |
|
| 408 | + $options = [ |
|
| 409 | + 'display' => 'unrouted', |
|
| 410 | + 'query' => 'Tusha' |
|
| 411 | + ]; |
|
| 412 | + $addr_book = new AddressBook(); |
|
| 413 | + $result = $addr_book->getAddressClusters($options); |
|
| 414 | + |
|
| 415 | + $this->assertInstanceOf(ResponseClustering::class, $result); |
|
| 416 | + $this->assertIsArray($result->clusters); |
|
| 417 | + $this->assertInstanceOf(Cluster::class, $result->clusters[0]); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + public function testGetAddressClustersByBodyPayloadMustReturnResponseClustering() : void |
|
| 421 | + { |
|
| 422 | + $options = [ |
|
| 423 | + 'clustering' => [ |
|
| 424 | + 'precision' => 2 |
|
| 425 | + ], |
|
| 426 | + 'filter' => [ |
|
| 427 | + 'query' => 'Tusha', |
|
| 428 | + 'selected_areas' => [[ |
|
| 429 | + 'type' => 'circle', |
|
| 430 | + 'value' => [ |
|
| 431 | + 'center' => [ |
|
| 432 | + 'lat' => 52.4025, |
|
| 433 | + 'lng' => 4.5601 |
|
| 434 | + ], |
|
| 435 | + 'distance' => 10000 |
|
| 436 | + ] |
|
| 437 | + ]] |
|
| 438 | + ] |
|
| 439 | + ]; |
|
| 440 | + $addr_book = new AddressBook(); |
|
| 441 | + $result = $addr_book->getAddressClustersByBodyPayload($options); |
|
| 442 | + |
|
| 443 | + $this->assertInstanceOf(ResponseClustering::class, $result); |
|
| 444 | + $this->assertIsArray($result->clusters); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + public function testGetAddressByIdMustReturnResponseAddress() : void |
|
| 448 | + { |
|
| 449 | + $addr_book = new AddressBook(); |
|
| 450 | + $result = $addr_book->getAddressById(self::$createdAdddressIds[0]); |
|
| 451 | + |
|
| 452 | + $this->assertInstanceOf(ResponseAddress::class, $result); |
|
| 453 | + $this->assertIsInt($result->address_id); |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + public function testGetAddressesByIdsMustReturnResponseAddress() : void |
|
| 457 | + { |
|
| 458 | + $addr_book = new AddressBook(); |
|
| 459 | + $result = $addr_book->getAddressesByIds(self::$createdAdddressIds); |
|
| 460 | + |
|
| 461 | + $this->assertInstanceOf(ResponseAll::class, $result); |
|
| 462 | + $this->assertIsArray($result->results); |
|
| 463 | + $this->assertInstanceOf(ResponseAddress::class, $result->results[0]); |
|
| 464 | + $this->assertIsInt($result->results[0]->address_id); |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + public function testUpdateAddressByIdMustReturnResponseAddress() : void |
|
| 468 | + { |
|
| 469 | + $addr_book = new AddressBook(); |
|
| 470 | + $result = $addr_book->updateAddressById(self::$createdAdddressIds[0], ['last_name' => 'Grigoriani III']); |
|
| 471 | + |
|
| 472 | + $this->assertInstanceOf(ResponseAddress::class, $result); |
|
| 473 | + $this->assertEqualsCanonicalizing($result->last_name, 'Grigoriani III'); |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + public function testUpdateAddressesByIdsMustReturnArray() : void |
|
| 477 | + { |
|
| 478 | + $addr_book = new AddressBook(); |
|
| 479 | + $result = $addr_book->updateAddressesByIds(self::$createdAdddressIds, ['last_name' => 'Grigoriani IV']); |
|
| 480 | + |
|
| 481 | + $this->assertIsArray($result); |
|
| 482 | + $this->assertInstanceOf(ResponseAddress::class, $result[0]); |
|
| 483 | + $this->assertEqualsCanonicalizing($result[0]->last_name, 'Grigoriani IV'); |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + // TODO: request has uncheckable result - 403 forbidden |
|
| 487 | + public function testUpdateAddressesByAreasMustReturnStatusChecker() : void |
|
| 488 | + { |
|
| 489 | + $addr_book = new AddressBook(); |
|
| 490 | + $filter = [ |
|
| 491 | + 'query' => "Tusha", |
|
| 492 | + 'bounding_box' => null, |
|
| 493 | + 'selected_areas' => [[ |
|
| 494 | + 'type' => 'circle', |
|
| 495 | + 'value' => [ |
|
| 496 | + 'center' => [ |
|
| 497 | + 'lat' => 38.024654, |
|
| 498 | + 'lng' => 77.338814 |
|
| 499 | + ], |
|
| 500 | + 'distance' => 10000 |
|
| 501 | + ] |
|
| 502 | + ]] |
|
| 503 | + ]; |
|
| 504 | 504 | |
| 505 | - $params = [ |
|
| 506 | - 'last_name' => 'Grigoriani V' |
|
| 507 | - ]; |
|
| 508 | - try { |
|
| 509 | - $result = $addr_book->updateAddressesByAreas($filter, $params); |
|
| 510 | - |
|
| 511 | - $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 512 | - } catch (ApiError $err) { |
|
| 513 | - $this->assertEquals($err->getCode(), 403); |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - public function testDeleteAddressesByIdsMustReturnStatusChecker() : void |
|
| 518 | - { |
|
| 519 | - $addr_book = new AddressBook(); |
|
| 520 | - $result = $addr_book->deleteAddressesByIds(self::$createdAdddressIds); |
|
| 521 | - |
|
| 522 | - $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 523 | - $this->assertIsInt($result->code); |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - // TODO: request has uncheckable result - 403 forbidden |
|
| 527 | - public function testDeleteAddressesByAreasMustReturnStatusChecker() : void |
|
| 528 | - { |
|
| 529 | - $addr_book = new AddressBook(); |
|
| 530 | - $filter = [ |
|
| 531 | - 'query' => 'Tusha', |
|
| 532 | - 'selected_areas' => [[ |
|
| 533 | - 'type' => 'circle', |
|
| 534 | - 'value' => [ |
|
| 535 | - 'center' => [ |
|
| 536 | - 'lat' => 38.024654, |
|
| 537 | - 'lng' => 77.338814 |
|
| 538 | - ], |
|
| 539 | - 'distance' => 10000 |
|
| 540 | - ] |
|
| 541 | - ]] |
|
| 542 | - ]; |
|
| 543 | - try { |
|
| 544 | - $result = $addr_book->deleteAddressesByAreas($filter); |
|
| 545 | - |
|
| 546 | - $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 547 | - $this->assertIsInt($result->code); |
|
| 548 | - } catch (ApiError $err) { |
|
| 549 | - $this->assertEquals($err->getCode(), 403); |
|
| 550 | - } |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - public function testGetAddressCustomFieldsMustReturnArray() : void |
|
| 554 | - { |
|
| 555 | - $addr_book = new AddressBook(); |
|
| 556 | - $result = $addr_book->getAddressCustomFields(); |
|
| 557 | - |
|
| 558 | - $this->assertIsArray($result); |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - public function testGetAddressDepotsFieldsMustReturnArray() : void |
|
| 562 | - { |
|
| 563 | - $addr_book = new AddressBook(); |
|
| 564 | - $result = $addr_book->getAddressesDepots(); |
|
| 565 | - |
|
| 566 | - $this->assertIsArray($result); |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - public function testExportAddressesByIdsMustReturnStatusChecker() : void |
|
| 570 | - { |
|
| 571 | - $addr_book = new AddressBook(); |
|
| 572 | - $filename = 'test_export.csv'; |
|
| 573 | - $result = $addr_book->exportAddressesByIds(self::$createdAdddressIds, $filename); |
|
| 574 | - |
|
| 575 | - $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 576 | - $this->assertIsInt($result->code); |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - // TODO: request has uncheckable result - 403 forbidden |
|
| 580 | - public function testExportAddressesByAreasMustReturnStatusChecker() : void |
|
| 581 | - { |
|
| 582 | - $addr_book = new AddressBook(); |
|
| 583 | - $filter = [ |
|
| 584 | - 'query' => "Tusha", |
|
| 585 | - 'bounding_box' => null, |
|
| 586 | - 'selected_areas' => [[ |
|
| 587 | - 'type' => 'circle', |
|
| 588 | - 'value' => [ |
|
| 589 | - 'center' => [ |
|
| 590 | - 'lat' => 38.024654, |
|
| 591 | - 'lng' => 77.338814 |
|
| 592 | - ], |
|
| 593 | - 'distance' => 10000 |
|
| 594 | - ] |
|
| 595 | - ]], |
|
| 596 | - 'filename' => 'test_export.csv' |
|
| 597 | - ]; |
|
| 598 | - try { |
|
| 599 | - $result = $addr_book->exportAddressesByAreas($filter); |
|
| 600 | - |
|
| 601 | - $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 602 | - $this->assertIsInt($result->code); |
|
| 603 | - } catch (ApiError $err) { |
|
| 604 | - $this->assertEquals($err->getCode(), 403); |
|
| 605 | - } |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - // TODO: request has uncheckable result - 403 forbidden |
|
| 609 | - public function testExportAddressesByAreaIdsMustReturnStatusChecker() : void |
|
| 610 | - { |
|
| 611 | - $addr_book = new AddressBook(); |
|
| 612 | - $territoryIds = [96100573, 96100961]; |
|
| 613 | - $filename = 'test_export.csv'; |
|
| 614 | - try { |
|
| 615 | - $result = $addr_book->exportAddressesByAreaIds($territoryIds, $filename); |
|
| 616 | - |
|
| 617 | - $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 618 | - $this->assertIsInt($result->code); |
|
| 619 | - } catch (ApiError $err) { |
|
| 620 | - $this->assertEquals($err->getCode(), 403); |
|
| 621 | - } |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - public function testGetAddressesAsynchronousJobStatusMustReturnStatusChecker() : void |
|
| 625 | - { |
|
| 626 | - $addr_book = new AddressBook(); |
|
| 627 | - $jobId = 96100961; |
|
| 628 | - try { |
|
| 629 | - $result = $addr_book->getAddressesAsynchronousJobStatus($jobId); |
|
| 630 | - |
|
| 631 | - $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 632 | - $this->assertIsInt($result->code); |
|
| 633 | - } catch (ApiError $err) { |
|
| 634 | - $this->assertEquals($err->getCode(), 404); |
|
| 635 | - } |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - public function testGetAddressesAsynchronousJobResultMustReturnBool() : void |
|
| 639 | - { |
|
| 640 | - $addr_book = new AddressBook(); |
|
| 641 | - $jobId = 96100961; |
|
| 642 | - try { |
|
| 643 | - $result = $addr_book->getAddressesAsynchronousJobResult($jobId); |
|
| 644 | - |
|
| 645 | - $this->assertIsBool($result); |
|
| 646 | - } catch (ApiError $err) { |
|
| 647 | - $this->assertEquals($err->getCode(), 404); |
|
| 648 | - } |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - public static function tearDownAfterClass() : void |
|
| 652 | - { |
|
| 653 | - sleep(5); |
|
| 654 | - |
|
| 655 | - $addr_book = new AddressBook(); |
|
| 656 | - |
|
| 657 | - if (count(self::$createdAdddressIds)) { |
|
| 658 | - $addr_book->deleteAddressesByIds(self::$createdAdddressIds); |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - $res = $addr_book->getAddresses(['query' => 'Tusha']); |
|
| 662 | - if ($res) { |
|
| 663 | - $ids = []; |
|
| 664 | - foreach ($res->results as $key => $value) { |
|
| 665 | - $ids[] = $value->address_id; |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - if (count($ids)) { |
|
| 669 | - $addr_book->deleteAddressesByIds($ids); |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - } |
|
| 505 | + $params = [ |
|
| 506 | + 'last_name' => 'Grigoriani V' |
|
| 507 | + ]; |
|
| 508 | + try { |
|
| 509 | + $result = $addr_book->updateAddressesByAreas($filter, $params); |
|
| 510 | + |
|
| 511 | + $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 512 | + } catch (ApiError $err) { |
|
| 513 | + $this->assertEquals($err->getCode(), 403); |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + public function testDeleteAddressesByIdsMustReturnStatusChecker() : void |
|
| 518 | + { |
|
| 519 | + $addr_book = new AddressBook(); |
|
| 520 | + $result = $addr_book->deleteAddressesByIds(self::$createdAdddressIds); |
|
| 521 | + |
|
| 522 | + $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 523 | + $this->assertIsInt($result->code); |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + // TODO: request has uncheckable result - 403 forbidden |
|
| 527 | + public function testDeleteAddressesByAreasMustReturnStatusChecker() : void |
|
| 528 | + { |
|
| 529 | + $addr_book = new AddressBook(); |
|
| 530 | + $filter = [ |
|
| 531 | + 'query' => 'Tusha', |
|
| 532 | + 'selected_areas' => [[ |
|
| 533 | + 'type' => 'circle', |
|
| 534 | + 'value' => [ |
|
| 535 | + 'center' => [ |
|
| 536 | + 'lat' => 38.024654, |
|
| 537 | + 'lng' => 77.338814 |
|
| 538 | + ], |
|
| 539 | + 'distance' => 10000 |
|
| 540 | + ] |
|
| 541 | + ]] |
|
| 542 | + ]; |
|
| 543 | + try { |
|
| 544 | + $result = $addr_book->deleteAddressesByAreas($filter); |
|
| 545 | + |
|
| 546 | + $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 547 | + $this->assertIsInt($result->code); |
|
| 548 | + } catch (ApiError $err) { |
|
| 549 | + $this->assertEquals($err->getCode(), 403); |
|
| 550 | + } |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + public function testGetAddressCustomFieldsMustReturnArray() : void |
|
| 554 | + { |
|
| 555 | + $addr_book = new AddressBook(); |
|
| 556 | + $result = $addr_book->getAddressCustomFields(); |
|
| 557 | + |
|
| 558 | + $this->assertIsArray($result); |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + public function testGetAddressDepotsFieldsMustReturnArray() : void |
|
| 562 | + { |
|
| 563 | + $addr_book = new AddressBook(); |
|
| 564 | + $result = $addr_book->getAddressesDepots(); |
|
| 565 | + |
|
| 566 | + $this->assertIsArray($result); |
|
| 567 | + } |
|
| 568 | + |
|
| 569 | + public function testExportAddressesByIdsMustReturnStatusChecker() : void |
|
| 570 | + { |
|
| 571 | + $addr_book = new AddressBook(); |
|
| 572 | + $filename = 'test_export.csv'; |
|
| 573 | + $result = $addr_book->exportAddressesByIds(self::$createdAdddressIds, $filename); |
|
| 574 | + |
|
| 575 | + $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 576 | + $this->assertIsInt($result->code); |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + // TODO: request has uncheckable result - 403 forbidden |
|
| 580 | + public function testExportAddressesByAreasMustReturnStatusChecker() : void |
|
| 581 | + { |
|
| 582 | + $addr_book = new AddressBook(); |
|
| 583 | + $filter = [ |
|
| 584 | + 'query' => "Tusha", |
|
| 585 | + 'bounding_box' => null, |
|
| 586 | + 'selected_areas' => [[ |
|
| 587 | + 'type' => 'circle', |
|
| 588 | + 'value' => [ |
|
| 589 | + 'center' => [ |
|
| 590 | + 'lat' => 38.024654, |
|
| 591 | + 'lng' => 77.338814 |
|
| 592 | + ], |
|
| 593 | + 'distance' => 10000 |
|
| 594 | + ] |
|
| 595 | + ]], |
|
| 596 | + 'filename' => 'test_export.csv' |
|
| 597 | + ]; |
|
| 598 | + try { |
|
| 599 | + $result = $addr_book->exportAddressesByAreas($filter); |
|
| 600 | + |
|
| 601 | + $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 602 | + $this->assertIsInt($result->code); |
|
| 603 | + } catch (ApiError $err) { |
|
| 604 | + $this->assertEquals($err->getCode(), 403); |
|
| 605 | + } |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + // TODO: request has uncheckable result - 403 forbidden |
|
| 609 | + public function testExportAddressesByAreaIdsMustReturnStatusChecker() : void |
|
| 610 | + { |
|
| 611 | + $addr_book = new AddressBook(); |
|
| 612 | + $territoryIds = [96100573, 96100961]; |
|
| 613 | + $filename = 'test_export.csv'; |
|
| 614 | + try { |
|
| 615 | + $result = $addr_book->exportAddressesByAreaIds($territoryIds, $filename); |
|
| 616 | + |
|
| 617 | + $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 618 | + $this->assertIsInt($result->code); |
|
| 619 | + } catch (ApiError $err) { |
|
| 620 | + $this->assertEquals($err->getCode(), 403); |
|
| 621 | + } |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + public function testGetAddressesAsynchronousJobStatusMustReturnStatusChecker() : void |
|
| 625 | + { |
|
| 626 | + $addr_book = new AddressBook(); |
|
| 627 | + $jobId = 96100961; |
|
| 628 | + try { |
|
| 629 | + $result = $addr_book->getAddressesAsynchronousJobStatus($jobId); |
|
| 630 | + |
|
| 631 | + $this->assertInstanceOf(StatusChecker::class, $result); |
|
| 632 | + $this->assertIsInt($result->code); |
|
| 633 | + } catch (ApiError $err) { |
|
| 634 | + $this->assertEquals($err->getCode(), 404); |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + public function testGetAddressesAsynchronousJobResultMustReturnBool() : void |
|
| 639 | + { |
|
| 640 | + $addr_book = new AddressBook(); |
|
| 641 | + $jobId = 96100961; |
|
| 642 | + try { |
|
| 643 | + $result = $addr_book->getAddressesAsynchronousJobResult($jobId); |
|
| 644 | + |
|
| 645 | + $this->assertIsBool($result); |
|
| 646 | + } catch (ApiError $err) { |
|
| 647 | + $this->assertEquals($err->getCode(), 404); |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + public static function tearDownAfterClass() : void |
|
| 652 | + { |
|
| 653 | + sleep(5); |
|
| 654 | + |
|
| 655 | + $addr_book = new AddressBook(); |
|
| 656 | + |
|
| 657 | + if (count(self::$createdAdddressIds)) { |
|
| 658 | + $addr_book->deleteAddressesByIds(self::$createdAdddressIds); |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + $res = $addr_book->getAddresses(['query' => 'Tusha']); |
|
| 662 | + if ($res) { |
|
| 663 | + $ids = []; |
|
| 664 | + foreach ($res->results as $key => $value) { |
|
| 665 | + $ids[] = $value->address_id; |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + if (count($ids)) { |
|
| 669 | + $addr_book->deleteAddressesByIds($ids); |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | 673 | } |
@@ -17,31 +17,31 @@ |
||
| 17 | 17 | Route4Me::setApiKey(Constants::API_KEY); |
| 18 | 18 | |
| 19 | 19 | try { |
| 20 | - $ab = new AddressBook(); |
|
| 21 | - |
|
| 22 | - ///////////////////////////////////////////// |
|
| 23 | - // update adresses in circle aria |
|
| 24 | - $filter = [ |
|
| 25 | - 'query' => "Tusha", |
|
| 26 | - 'bounding_box' => null, |
|
| 27 | - 'selected_areas' => [[ |
|
| 28 | - 'type' => 'circle', |
|
| 29 | - 'value' => [ |
|
| 30 | - 'center' => [ |
|
| 31 | - 'lat' => 38.024654, |
|
| 32 | - 'lng' => 77.338814 |
|
| 33 | - ], |
|
| 34 | - 'distance' => 10000 |
|
| 35 | - ] |
|
| 36 | - ]] |
|
| 37 | - ]; |
|
| 38 | - |
|
| 39 | - $params = [ |
|
| 40 | - 'last_name' => 'Grigoriani VII' |
|
| 41 | - ]; |
|
| 42 | - $res = $ab->updateAddressesByAreas($filter, $params); |
|
| 43 | - print_r($res); |
|
| 20 | + $ab = new AddressBook(); |
|
| 21 | + |
|
| 22 | + ///////////////////////////////////////////// |
|
| 23 | + // update adresses in circle aria |
|
| 24 | + $filter = [ |
|
| 25 | + 'query' => "Tusha", |
|
| 26 | + 'bounding_box' => null, |
|
| 27 | + 'selected_areas' => [[ |
|
| 28 | + 'type' => 'circle', |
|
| 29 | + 'value' => [ |
|
| 30 | + 'center' => [ |
|
| 31 | + 'lat' => 38.024654, |
|
| 32 | + 'lng' => 77.338814 |
|
| 33 | + ], |
|
| 34 | + 'distance' => 10000 |
|
| 35 | + ] |
|
| 36 | + ]] |
|
| 37 | + ]; |
|
| 38 | + |
|
| 39 | + $params = [ |
|
| 40 | + 'last_name' => 'Grigoriani VII' |
|
| 41 | + ]; |
|
| 42 | + $res = $ab->updateAddressesByAreas($filter, $params); |
|
| 43 | + print_r($res); |
|
| 44 | 44 | } catch (ApiError $e) { |
| 45 | - echo $e->getCode() . PHP_EOL; |
|
| 46 | - echo $e->getMessage() . PHP_EOL; |
|
| 45 | + echo $e->getCode() . PHP_EOL; |
|
| 46 | + echo $e->getMessage() . PHP_EOL; |
|
| 47 | 47 | } |
@@ -42,6 +42,6 @@ |
||
| 42 | 42 | $res = $ab->updateAddressesByAreas($filter, $params); |
| 43 | 43 | print_r($res); |
| 44 | 44 | } catch (ApiError $e) { |
| 45 | - echo $e->getCode() . PHP_EOL; |
|
| 46 | - echo $e->getMessage() . PHP_EOL; |
|
| 45 | + echo $e->getCode().PHP_EOL; |
|
| 46 | + echo $e->getMessage().PHP_EOL; |
|
| 47 | 47 | } |
@@ -18,39 +18,39 @@ |
||
| 18 | 18 | Route4Me::setApiKey(Constants::API_KEY); |
| 19 | 19 | |
| 20 | 20 | try { |
| 21 | - $ab = new AddressBook(); |
|
| 22 | - |
|
| 23 | - ///////////////////////////////////////////// |
|
| 24 | - // add 2 adresses from array |
|
| 25 | - $arr = [[ |
|
| 26 | - 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 27 | - 'cached_lat' => 38.024654, |
|
| 28 | - 'cached_lng' => 77.338814, |
|
| 29 | - 'address_stop_type' => 'DELIVERY', |
|
| 30 | - 'address_city' => 'Tbilisi Vah', |
|
| 31 | - 'first_name' => 'Tusha', |
|
| 32 | - 'last_name' => 'Grigoriani I' |
|
| 33 | - ], [ |
|
| 34 | - 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 35 | - 'cached_lat' => 38.024654, |
|
| 36 | - 'cached_lng' => 77.338814, |
|
| 37 | - 'address_stop_type' => 'DELIVERY', |
|
| 38 | - 'address_city' => 'Tbilisi Vah', |
|
| 39 | - 'first_name' => 'Tusha', |
|
| 40 | - 'last_name' => 'Grigoriani II' |
|
| 41 | - ]]; |
|
| 42 | - $res = $ab->addMultipleAddresses($arr); |
|
| 43 | - print_r($res); |
|
| 44 | - |
|
| 45 | - ///////////////////////////////////////////// |
|
| 46 | - // add 2 adresses from Address |
|
| 47 | - $arr = [ |
|
| 48 | - new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY'), |
|
| 49 | - new Address('17206 Tbilisi Vah, GEORGIAN, GE, 22515', 38.024654, 77.338814, 'VISIT') |
|
| 50 | - ]; |
|
| 51 | - $res = $ab->addMultipleAddresses($arr); |
|
| 52 | - print_r($res); |
|
| 21 | + $ab = new AddressBook(); |
|
| 22 | + |
|
| 23 | + ///////////////////////////////////////////// |
|
| 24 | + // add 2 adresses from array |
|
| 25 | + $arr = [[ |
|
| 26 | + 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 27 | + 'cached_lat' => 38.024654, |
|
| 28 | + 'cached_lng' => 77.338814, |
|
| 29 | + 'address_stop_type' => 'DELIVERY', |
|
| 30 | + 'address_city' => 'Tbilisi Vah', |
|
| 31 | + 'first_name' => 'Tusha', |
|
| 32 | + 'last_name' => 'Grigoriani I' |
|
| 33 | + ], [ |
|
| 34 | + 'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514', |
|
| 35 | + 'cached_lat' => 38.024654, |
|
| 36 | + 'cached_lng' => 77.338814, |
|
| 37 | + 'address_stop_type' => 'DELIVERY', |
|
| 38 | + 'address_city' => 'Tbilisi Vah', |
|
| 39 | + 'first_name' => 'Tusha', |
|
| 40 | + 'last_name' => 'Grigoriani II' |
|
| 41 | + ]]; |
|
| 42 | + $res = $ab->addMultipleAddresses($arr); |
|
| 43 | + print_r($res); |
|
| 44 | + |
|
| 45 | + ///////////////////////////////////////////// |
|
| 46 | + // add 2 adresses from Address |
|
| 47 | + $arr = [ |
|
| 48 | + new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY'), |
|
| 49 | + new Address('17206 Tbilisi Vah, GEORGIAN, GE, 22515', 38.024654, 77.338814, 'VISIT') |
|
| 50 | + ]; |
|
| 51 | + $res = $ab->addMultipleAddresses($arr); |
|
| 52 | + print_r($res); |
|
| 53 | 53 | } catch (ApiError $e) { |
| 54 | - echo $e->getCode() . PHP_EOL; |
|
| 55 | - echo $e->getMessage() . PHP_EOL; |
|
| 54 | + echo $e->getCode() . PHP_EOL; |
|
| 55 | + echo $e->getMessage() . PHP_EOL; |
|
| 56 | 56 | } |
@@ -51,6 +51,6 @@ |
||
| 51 | 51 | $res = $ab->addMultipleAddresses($arr); |
| 52 | 52 | print_r($res); |
| 53 | 53 | } catch (ApiError $e) { |
| 54 | - echo $e->getCode() . PHP_EOL; |
|
| 55 | - echo $e->getMessage() . PHP_EOL; |
|
| 54 | + echo $e->getCode().PHP_EOL; |
|
| 55 | + echo $e->getMessage().PHP_EOL; |
|
| 56 | 56 | } |
@@ -17,39 +17,39 @@ |
||
| 17 | 17 | Route4Me::setApiKey(Constants::API_KEY); |
| 18 | 18 | |
| 19 | 19 | try { |
| 20 | - $ab = new AddressBook(); |
|
| 21 | - |
|
| 22 | - ///////////////////////////////////////////// |
|
| 23 | - // get the first 5 addresses |
|
| 24 | - $options = [ |
|
| 25 | - 'limit' => 5, |
|
| 26 | - 'offset' => 0 |
|
| 27 | - ]; |
|
| 28 | - $res = $ab->getAddressesByBodyPayload($options); |
|
| 29 | - print_r($res); |
|
| 30 | - |
|
| 31 | - ///////////////////////////////////////////// |
|
| 32 | - // get the first 5 addresses in the selected area from the server |
|
| 33 | - $options = [ |
|
| 34 | - 'filter' => [ |
|
| 35 | - 'query' => 'Tusha', |
|
| 36 | - 'selected_areas' => [[ |
|
| 37 | - 'type' => 'circle', |
|
| 38 | - 'value' => [ |
|
| 39 | - 'center' => [ |
|
| 40 | - 'lat' => 38.024654, |
|
| 41 | - 'lng' => 77.338814 |
|
| 42 | - ], |
|
| 43 | - 'distance' => 10000 |
|
| 44 | - ] |
|
| 45 | - ]] |
|
| 46 | - ], |
|
| 47 | - 'limit' => 5, |
|
| 48 | - 'offset' => 0 |
|
| 49 | - ]; |
|
| 50 | - $res = $ab->getAddressesByBodyPayload($options); |
|
| 51 | - print_r($res); |
|
| 20 | + $ab = new AddressBook(); |
|
| 21 | + |
|
| 22 | + ///////////////////////////////////////////// |
|
| 23 | + // get the first 5 addresses |
|
| 24 | + $options = [ |
|
| 25 | + 'limit' => 5, |
|
| 26 | + 'offset' => 0 |
|
| 27 | + ]; |
|
| 28 | + $res = $ab->getAddressesByBodyPayload($options); |
|
| 29 | + print_r($res); |
|
| 30 | + |
|
| 31 | + ///////////////////////////////////////////// |
|
| 32 | + // get the first 5 addresses in the selected area from the server |
|
| 33 | + $options = [ |
|
| 34 | + 'filter' => [ |
|
| 35 | + 'query' => 'Tusha', |
|
| 36 | + 'selected_areas' => [[ |
|
| 37 | + 'type' => 'circle', |
|
| 38 | + 'value' => [ |
|
| 39 | + 'center' => [ |
|
| 40 | + 'lat' => 38.024654, |
|
| 41 | + 'lng' => 77.338814 |
|
| 42 | + ], |
|
| 43 | + 'distance' => 10000 |
|
| 44 | + ] |
|
| 45 | + ]] |
|
| 46 | + ], |
|
| 47 | + 'limit' => 5, |
|
| 48 | + 'offset' => 0 |
|
| 49 | + ]; |
|
| 50 | + $res = $ab->getAddressesByBodyPayload($options); |
|
| 51 | + print_r($res); |
|
| 52 | 52 | } catch (ApiError $e) { |
| 53 | - echo $e->getCode() . PHP_EOL; |
|
| 54 | - echo $e->getMessage() . PHP_EOL; |
|
| 53 | + echo $e->getCode() . PHP_EOL; |
|
| 54 | + echo $e->getMessage() . PHP_EOL; |
|
| 55 | 55 | } |
@@ -50,6 +50,6 @@ |
||
| 50 | 50 | $res = $ab->getAddressesByBodyPayload($options); |
| 51 | 51 | print_r($res); |
| 52 | 52 | } catch (ApiError $e) { |
| 53 | - echo $e->getCode() . PHP_EOL; |
|
| 54 | - echo $e->getMessage() . PHP_EOL; |
|
| 53 | + echo $e->getCode().PHP_EOL; |
|
| 54 | + echo $e->getMessage().PHP_EOL; |
|
| 55 | 55 | } |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | Route4Me::setApiKey(Constants::API_KEY); |
| 17 | 17 | |
| 18 | 18 | try { |
| 19 | - $ab = new AddressBook(); |
|
| 19 | + $ab = new AddressBook(); |
|
| 20 | 20 | |
| 21 | - $res = $ab->getAddressesDepots(); |
|
| 22 | - print_r($res); |
|
| 21 | + $res = $ab->getAddressesDepots(); |
|
| 22 | + print_r($res); |
|
| 23 | 23 | } catch (ApiError $e) { |
| 24 | - echo $e->getCode() . PHP_EOL; |
|
| 25 | - echo $e->getMessage() . PHP_EOL; |
|
| 24 | + echo $e->getCode() . PHP_EOL; |
|
| 25 | + echo $e->getMessage() . PHP_EOL; |
|
| 26 | 26 | } |
@@ -21,6 +21,6 @@ |
||
| 21 | 21 | $res = $ab->getAddressesDepots(); |
| 22 | 22 | print_r($res); |
| 23 | 23 | } catch (ApiError $e) { |
| 24 | - echo $e->getCode() . PHP_EOL; |
|
| 25 | - echo $e->getMessage() . PHP_EOL; |
|
| 24 | + echo $e->getCode().PHP_EOL; |
|
| 25 | + echo $e->getMessage().PHP_EOL; |
|
| 26 | 26 | } |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | Route4Me::setApiKey(Constants::API_KEY); |
| 17 | 17 | |
| 18 | 18 | try { |
| 19 | - $ab = new AddressBook(); |
|
| 19 | + $ab = new AddressBook(); |
|
| 20 | 20 | |
| 21 | - $jobId = '434A746FF41D5572FB3D76FACB55161E'; |
|
| 21 | + $jobId = '434A746FF41D5572FB3D76FACB55161E'; |
|
| 22 | 22 | |
| 23 | - $res = $ab->getAddressesAsynchronousJobResult($jobId); |
|
| 24 | - print_r($res); |
|
| 23 | + $res = $ab->getAddressesAsynchronousJobResult($jobId); |
|
| 24 | + print_r($res); |
|
| 25 | 25 | } catch (ApiError $e) { |
| 26 | - echo $e->getCode() . PHP_EOL; |
|
| 27 | - echo $e->getMessage() . PHP_EOL; |
|
| 26 | + echo $e->getCode() . PHP_EOL; |
|
| 27 | + echo $e->getMessage() . PHP_EOL; |
|
| 28 | 28 | } |
@@ -23,6 +23,6 @@ |
||
| 23 | 23 | $res = $ab->getAddressesAsynchronousJobResult($jobId); |
| 24 | 24 | print_r($res); |
| 25 | 25 | } catch (ApiError $e) { |
| 26 | - echo $e->getCode() . PHP_EOL; |
|
| 27 | - echo $e->getMessage() . PHP_EOL; |
|
| 26 | + echo $e->getCode().PHP_EOL; |
|
| 27 | + echo $e->getMessage().PHP_EOL; |
|
| 28 | 28 | } |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | Route4Me::setApiKey(Constants::API_KEY); |
| 17 | 17 | |
| 18 | 18 | try { |
| 19 | - $ab = new AddressBook(); |
|
| 19 | + $ab = new AddressBook(); |
|
| 20 | 20 | |
| 21 | - $res = $ab->getAddressCustomFields(); |
|
| 22 | - print_r($res); |
|
| 21 | + $res = $ab->getAddressCustomFields(); |
|
| 22 | + print_r($res); |
|
| 23 | 23 | } catch (ApiError $e) { |
| 24 | - echo $e->getCode() . PHP_EOL; |
|
| 25 | - echo $e->getMessage() . PHP_EOL; |
|
| 24 | + echo $e->getCode() . PHP_EOL; |
|
| 25 | + echo $e->getMessage() . PHP_EOL; |
|
| 26 | 26 | } |
@@ -21,6 +21,6 @@ |
||
| 21 | 21 | $res = $ab->getAddressCustomFields(); |
| 22 | 22 | print_r($res); |
| 23 | 23 | } catch (ApiError $e) { |
| 24 | - echo $e->getCode() . PHP_EOL; |
|
| 25 | - echo $e->getMessage() . PHP_EOL; |
|
| 24 | + echo $e->getCode().PHP_EOL; |
|
| 25 | + echo $e->getMessage().PHP_EOL; |
|
| 26 | 26 | } |
@@ -18,17 +18,17 @@ |
||
| 18 | 18 | Route4Me::setApiKey(Constants::API_KEY); |
| 19 | 19 | |
| 20 | 20 | try { |
| 21 | - $ab = new AddressBook(); |
|
| 21 | + $ab = new AddressBook(); |
|
| 22 | 22 | |
| 23 | - ///////////////////////////////////////////// |
|
| 24 | - // update adress's last_name |
|
| 25 | - $addressId = 96100576; |
|
| 26 | - $params = [ |
|
| 27 | - 'last_name' => 'Grigoriani III' |
|
| 28 | - ]; |
|
| 29 | - $res = $ab->updateAddressById($addressId, $params); |
|
| 30 | - print_r($res); |
|
| 23 | + ///////////////////////////////////////////// |
|
| 24 | + // update adress's last_name |
|
| 25 | + $addressId = 96100576; |
|
| 26 | + $params = [ |
|
| 27 | + 'last_name' => 'Grigoriani III' |
|
| 28 | + ]; |
|
| 29 | + $res = $ab->updateAddressById($addressId, $params); |
|
| 30 | + print_r($res); |
|
| 31 | 31 | } catch (ApiError $e) { |
| 32 | - echo $e->getCode() . PHP_EOL; |
|
| 33 | - echo $e->getMessage() . PHP_EOL; |
|
| 32 | + echo $e->getCode() . PHP_EOL; |
|
| 33 | + echo $e->getMessage() . PHP_EOL; |
|
| 34 | 34 | } |
@@ -29,6 +29,6 @@ |
||
| 29 | 29 | $res = $ab->updateAddressById($addressId, $params); |
| 30 | 30 | print_r($res); |
| 31 | 31 | } catch (ApiError $e) { |
| 32 | - echo $e->getCode() . PHP_EOL; |
|
| 33 | - echo $e->getMessage() . PHP_EOL; |
|
| 32 | + echo $e->getCode().PHP_EOL; |
|
| 33 | + echo $e->getMessage().PHP_EOL; |
|
| 34 | 34 | } |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | Route4Me::setApiKey(Constants::API_KEY); |
| 17 | 17 | |
| 18 | 18 | try { |
| 19 | - $ab = new AddressBook(); |
|
| 19 | + $ab = new AddressBook(); |
|
| 20 | 20 | |
| 21 | - $jobId = '866BCFF5C3722432BAE58E6731753BC2'; |
|
| 21 | + $jobId = '866BCFF5C3722432BAE58E6731753BC2'; |
|
| 22 | 22 | |
| 23 | - $res = $ab->getAddressesAsynchronousJobStatus($jobId); |
|
| 24 | - print_r($res); |
|
| 23 | + $res = $ab->getAddressesAsynchronousJobStatus($jobId); |
|
| 24 | + print_r($res); |
|
| 25 | 25 | } catch (ApiError $e) { |
| 26 | - echo $e->getCode() . PHP_EOL; |
|
| 27 | - echo $e->getMessage() . PHP_EOL; |
|
| 26 | + echo $e->getCode() . PHP_EOL; |
|
| 27 | + echo $e->getMessage() . PHP_EOL; |
|
| 28 | 28 | } |
@@ -23,6 +23,6 @@ |
||
| 23 | 23 | $res = $ab->getAddressesAsynchronousJobStatus($jobId); |
| 24 | 24 | print_r($res); |
| 25 | 25 | } catch (ApiError $e) { |
| 26 | - echo $e->getCode() . PHP_EOL; |
|
| 27 | - echo $e->getMessage() . PHP_EOL; |
|
| 26 | + echo $e->getCode().PHP_EOL; |
|
| 27 | + echo $e->getMessage().PHP_EOL; |
|
| 28 | 28 | } |