Skip to content

Commit be2f4f8

Browse files
authored
Change the get() method of the servicePoints endpoint. (#20)
1 parent 81d1358 commit be2f4f8

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ This package type is only available for shipments in the Netherlands that fit in
116116
$parcel->mailboxpackage();
117117
```
118118

119-
### Send a shipment to a pick up location
119+
### Send a shipment to a service point
120120

121-
You can set set the package to be delivered to a pick up location when you create a parcel:
121+
You may send a parcel to a PostNL service point where a customer can pick up the parcel:
122122

123123
``` php
124124
$parcel = new \Mvdnbrk\MyParcel\Resources\Parcel([
@@ -136,16 +136,24 @@ $parcel = new \Mvdnbrk\MyParcel\Resources\Parcel([
136136
]);
137137
```
138138

139-
Or you may set the pick up location after you have created the parcel:
139+
### Retrieving service points
140+
141+
```php
142+
$servicepoints = $myparcel->servicePoints->setPostalcode('1234AA')->setHousenumber('1')->get();
143+
```
144+
145+
This will return a collection of `ServicePoint` objects:
146+
140147
```
141-
$parcel->pickup = [
142-
'name' => 'Name of the location',
143-
'street' => 'Poststraat',
144-
'number' => '1',
145-
'postal_code' => '1234AA',
146-
'city' => 'Amsterdam',
147-
'cc' => 'NL,
148-
];
148+
$servicepoints->each(function ($item) {
149+
$item->id;
150+
$item->name;
151+
$item->latitude;
152+
$item->longitude;
153+
$item->distance;
154+
$item->distanceForHumans();
155+
$item->opening_hours;
156+
});
149157
```
150158

151159
### Get a shipment

src/Endpoints/ServicePoints.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,11 @@ protected function boot()
6262
/**
6363
* Get delivery options for an address based on postal code and house number.
6464
*
65-
* @param string $postal_code
66-
* @param int $housenumber
6765
* @param array $filters
6866
* @return \Tightenco\Collect\Support\Collection
6967
*/
70-
public function get($postal_code, $housenumber, array $filters = [])
68+
public function get(array $filters = [])
7169
{
72-
$this->setPostalCode($postal_code);
73-
$this->setHousenumber($housenumber);
74-
7570
$response = $this->performApiCall(
7671
'GET',
7772
'delivery_options' . $this->buildQueryString($this->getFilters($filters))

tests/Feature/Endpoints/ServicePointsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function setting_an_invalid_housenumber_throws_exception()
8585
*/
8686
public function it_can_retrieve_delivery_options()
8787
{
88-
$locations = $this->servicePoints->get('1012NP', '2')->take(2);
88+
$locations = $this->servicePoints->setPostalcode('1012NP')->setHousenumber('2')->get()->take(2);
8989

9090
$this->assertInstanceOf(\Tightenco\Collect\Support\Collection::class, $locations);
9191
$this->assertEquals(2, $locations->count());

0 commit comments

Comments
 (0)