Skip to content

Commit d8c5d74

Browse files
committed
Merge branch 'master' of github.com:mvdnbrk/myparcel-php-api
2 parents dd3823e + 8805b9b commit d8c5d74

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to `myparcel-php-api` will be documented in this file.
44

55
## [Unreleased]
66

7+
## [v0.9.2] - 2019-04-26
8+
9+
### Added
10+
- Added a `setFormatA4` method to change the default label format from A6 to A4. [`#24`](https://github.com/mvdnbrk/myparcel-php-api/pull/24)
11+
712
## [v0.9.1] - 2019-04-26
813

914
### Added
@@ -110,7 +115,8 @@ All notable changes to `myparcel-php-api` will be documented in this file.
110115

111116
### Initial release
112117

113-
[Unreleased]: https://github.com/mvdnbrk/myparcel-php-api/compare/v0.9.1...HEAD
118+
[Unreleased]: https://github.com/mvdnbrk/myparcel-php-api/compare/v0.9.2...HEAD
119+
[v0.9.2]: https://github.com/mvdnbrk/myparcel-php-api/compare/v0.9.1...v0.9.2
114120
[v0.9.1]: https://github.com/mvdnbrk/myparcel-php-api/compare/v0.9.0...v0.9.1
115121
[v0.9.0]: https://github.com/mvdnbrk/myparcel-php-api/compare/v0.8.0...v0.9.0
116122
[v0.8.0]: https://github.com/mvdnbrk/myparcel-php-api/compare/v0.7.3...v0.8.0

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,10 @@ Or you may pass the `Shipment` instance directly to this method:
8181
$myparcel->labels->get($shipment);
8282
```
8383

84-
It's also possible to specify a Label configuration (for example: A4)
85-
```php
86-
$label = new \Mvdnbrk\MyParcel\Resources\Label;
87-
$label->setFormatAttribute('A4');
88-
89-
$shipmentLabel = new \Mvdnbrk\MyParcel\Resources\ShipmentLabels($myparcel);
90-
$shipmentLabel->setLabel($label);
84+
The label format is A6 by default, you may change this by calling the `setFormatA4` method:
9185

92-
$shipmentLabel->get($shipment->id);
86+
```php
87+
$myparcel->labels->setFormatA4()->get($shipment);
9388
```
9489

9590
### Setting delivery options for a parcel

src/Endpoints/ShipmentLabels.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Mvdnbrk\MyParcel\Endpoints;
44

55
use Mvdnbrk\MyParcel\Resources\Label;
6+
use Mvdnbrk\MyParcel\Types\PaperSize;
67
use Mvdnbrk\MyParcel\Resources\Shipment;
78

89
class ShipmentLabels extends BaseEndpoint
@@ -46,6 +47,18 @@ public function get($value)
4647
return $response;
4748
}
4849

50+
/**
51+
* Sets the label to A4 format.
52+
*
53+
* @return $this
54+
*/
55+
public function setFormatA4()
56+
{
57+
$this->label->setFormatAttribute(PaperSize::A4);
58+
59+
return $this;
60+
}
61+
4962
/**
5063
* Set a label.
5164
*

tests/Feature/Endpoints/ShipmentLabelsTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public function it_can_set_a_label()
5858
$this->assertInstanceOf(ShipmentLabels::class, $this->client->labels->setLabel($label));
5959
}
6060

61+
/** @test */
62+
public function it_can_set_the_format_to_A4()
63+
{
64+
$this->assertInstanceOf(ShipmentLabels::class, $this->client->labels->setFormatA4());
65+
}
66+
6167
/** @test */
6268
public function getting_a_label_with_an_invalid_shipment_id_should_throw_an_error()
6369
{

0 commit comments

Comments
 (0)