-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from JouwWeb/international-parcel-support
international-parcel-support
- Loading branch information
Showing
10 changed files
with
370 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# SendCloud | ||
# Sendcloud | ||
|
||
[![CircleCI](https://circleci.com/gh/JouwWeb/sendcloud.svg?style=svg)](https://circleci.com/gh/JouwWeb/sendcloud) | ||
|
||
This is a PHP library that provides a simple way to communicate with the SendCloud API. It was created because there | ||
were no simple alternatives that follow good object-oriented code practices. | ||
This is a PHP library that provides a simple way to communicate with the Sendcloud API. It was created because there | ||
were no simple alternatives that follow good object-oriented code practices. | ||
|
||
> NOTE: This library does not implement all SendCloud API functionality. If you require functionality that is missing | ||
> NOTE: This library does not implement all Sendcloud API functionality. If you require functionality that is missing | ||
please request it through a GitHub issue or pull request. | ||
|
||
## Example | ||
|
@@ -14,6 +14,7 @@ please request it through a GitHub issue or pull request. | |
use JouwWeb\SendCloud\Client; | ||
use JouwWeb\SendCloud\Model\Address; | ||
use JouwWeb\SendCloud\Model\Parcel; | ||
use JouwWeb\SendCloud\Model\ParcelItem; | ||
use JouwWeb\SendCloud\Model\WebhookEvent; | ||
use JouwWeb\SendCloud\Exception\SendCloudRequestException; | ||
|
||
|
@@ -29,20 +30,27 @@ foreach ($client->getShippingMethods() as $shippingMethod) { | |
|
||
// Create a parcel and label | ||
try { | ||
// Most of these arguments are optional and will fall back to defaults configured in SendCloud | ||
// Most of these arguments are optional and will fall back to defaults configured in Sendcloud | ||
$parcel = $client->createParcel( | ||
new Address('Customer name', 'Customer company name', 'Customer street', '4A', 'City', '9999ZZ', 'NL', '[email protected]', '+31612345678'), | ||
null, // Service point ID | ||
'20190001', // Order number | ||
2500 // Weight (2.5kg) | ||
2500, // Weight (2.5kg) | ||
// Below options are only required when shipping outside the EU | ||
'customsInvoiceNumber', | ||
Parcel::CUSTOMS_SHIPMENT_TYPE_COMMERCIAL_GOODS, | ||
[ | ||
new ParcelItem('green tea', 1, 123, 15.20, '090210', 'EC'), | ||
new ParcelItem('cardboard', 3, 50, 0.20, '090210', 'NL'), | ||
] | ||
); | ||
|
||
$parcel = $client->createLabel( | ||
$parcel, | ||
8, // Shipping method ID | ||
null // Default sender address | ||
); | ||
|
||
$pdf = $client->getLabelPdf($parcel, Parcel::LABEL_FORMAT_A4_BOTTOM_RIGHT); | ||
|
||
var_dump($parcel, $pdf); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.