Skip to content

Commit

Permalink
Merge pull request #171 from myparcelnl/resolved-conflicts
Browse files Browse the repository at this point in the history
resolve conflicts
  • Loading branch information
RichardPerdaan authored Oct 22, 2019
2 parents 59144ed + 92a8f37 commit 86ecfe2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# MyParcel SDK
This SDK connects to the MyParcel API using PHP.

Do you want to be kept informed of new functionalities or do you just need help? You can contact us via our [Slack channel](https://join.slack.com/t/myparcel-dev/shared_invite/enQtNDkyNTg3NzA1MjM4LTM0Y2IzNmZlY2NkOWFlNTIyODY5YjFmNGQyYzZjYmQzMzliNDBjYzBkOGMwYzA0ZDYzNmM1NzAzNDY1ZjEzOTM).

## Contents

- [Contents](#contents)
Expand All @@ -14,7 +16,7 @@ This SDK connects to the MyParcel API using PHP.
- [Label format and position](#label-format-and-position)
- [Package type and options](#package-type-and-options)
- [Retrieve data from a consignment](#retrieve-data-from-a-consignment)
- [Create and download label(s)](#create-and-download-label-s-)
- [Create and download label(s)](#create-and-download-labels)
- [List of classes and their methods](#list-of-classes-and-their-methods)
- [Models](#models)
- [Helpers](#helpers)
Expand Down Expand Up @@ -72,8 +74,11 @@ $consignment = (ConsignmentFactory::createByCarrierId(PostNLConsignment::CARRIER

$myParcelCollection = (new MyParcelCollection())
->addConsignment($consignment)
->setPdfOfLabels()
->downloadPdfOfLabels();
->setPdfOfLabels();

$consignmentId = $myParcelCollection->first()->getMyParcelConsignmentId();

$myParcelCollection->downloadPdfOfLabels();
```

### Create multiple consignments
Expand Down Expand Up @@ -227,6 +232,15 @@ echo $myParcelCollection
->getLinkOfLabels();
```

If you want to download a label at a later time, you can also use the following to fill the collection:
```
$collection = MyParcelCollection::findByReferenceId('999999', 'xxxxxx');
$collection
->setPdfOfLabels()
->downloadPdfOfLabels();
```
Instead of `findByReferenceId()` you can also use `findManyByReferenceId()`, `find()` or `findMany()`.

More information: https://myparcelnl.github.io/api/#6_F

## List of classes and their methods
Expand Down Expand Up @@ -366,7 +380,7 @@ This object is embedded in the PostNLConsignment object for global shipments and
->setClassification(0111) // Example: 0111 = "Growing of cereals (except rice), leguminous crops and oil seeds"
->setCountry('NL') // Country of origin
->setDescription('Cereal grains')
->setItemValue(["amount" => 200, "currency" => "EUR"]) // Must be array with amount and currency like in the example
->setItemValue(40000) // Price of item in cents
->setWeight() // The total weight for these items in whole grams. Between 0 and 20000 grams.

->getAmount()
Expand Down Expand Up @@ -488,9 +502,9 @@ If you use arrays a lot, Collections are usually better to work with. ([document
\MyParcelNL\Sdk\src\Support\Collection()

### Helpers
\MyParcelNL\Sdk\src\Support\Arr ([documentation](https://laravel.com/docs/5.7/helpers#arrays))
\MyParcelNL\Sdk\src\Support\Str ([documentation](https://laravel.com/docs/5.7/helpers#method-camel-case))
`\MyParcelNL\Sdk\src\Helper\SplitStreet::splitStreet('Plein 1940-45 3b'))`
* \MyParcelNL\Sdk\src\Support\Arr ([documentation](https://laravel.com/docs/5.7/helpers#arrays))
* \MyParcelNL\Sdk\src\Support\Str ([documentation](https://laravel.com/docs/5.7/helpers#method-camel-case))
* `\MyParcelNL\Sdk\src\Helper\SplitStreet::splitStreet('Plein 1940-45 3b'))`

## Contribute

Expand Down
7 changes: 7 additions & 0 deletions src/Exception/NoConsignmentFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace MyParcelNL\Sdk\src\Exception;

class NoConsignmentFoundException extends \Exception
{
}
1 change: 1 addition & 0 deletions src/Helper/MyParcelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ public function setLinkOfLabels($positions = self::DEFAULT_A4_POSITION)
->setLabelFormat($positions);

$conceptIds = $this->getConsignmentIds($key);

if ($key) {
$request = (new MyParcelRequest())
->setUserAgent($this->getUserAgent())
Expand Down
11 changes: 8 additions & 3 deletions src/Model/MyParcelCustomsItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace MyParcelNL\Sdk\src\Model;

use MyParcelNL\Sdk\src\Exception\MissingFieldException;
use MyParcelNL\Sdk\src\Support\Str;

/**
* This object is embedded in the MyParcelConsignment object for global shipments and is
Expand All @@ -24,6 +25,8 @@
*/
class MyParcelCustomsItem
{
const DESCRIPTION_MAX_LENGTH = 47;

private $description;
private $amount;
private $weight;
Expand All @@ -49,7 +52,10 @@ public function getDescription()
*/
public function setDescription($description)
{
$this->description = $description;
/**
* Description cut after 47 chars
*/
$this->description = Str::limit($description, self::DESCRIPTION_MAX_LENGTH);

return $this;
}
Expand Down Expand Up @@ -121,11 +127,10 @@ public function getItemValue()
*
* Composite type containing integer and currency. The amount is without decimal
* separators (in cents).
* Pattern: {"amount": integer, "currency": currency }
* Example {"amount": 5000, "currency": "EUR"}
* Required: Yes
*
* @param int $item_value
*
* @return $this
*/
public function setItemValue($item_value)
Expand Down

0 comments on commit 86ecfe2

Please sign in to comment.