Skip to content

Commit

Permalink
Switched $sender & $recipient parameters in the Package class constru…
Browse files Browse the repository at this point in the history
…ctor + updated README.md file.
  • Loading branch information
pavolbiely committed Jan 21, 2018
1 parent a3df013 commit 2278fd7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,22 @@ As long as the token is valid you can call any API call.
The following code shows an example of how to send a simple package.

```php
// prepare sender and recipient addresses
$sender = new Address('Harry Potter', 'Webtec', 'Magnetová 1', '831 04', 'Bratislava', Address::STATE_SK);
$recipient = new Address('Albus Dumbledore', 'Neonus', 'Miestneho priemyslu 1247', '029 01', 'Námestovo', Address::STATE_SK);

// create package
$package = new Package(123, $recipient, $sender, '1201800002');

// use the following code if the package is sent by cash on delivery payment
$cashOnDelivery = new Payment(10.0, Payment::CURRENCY_EUR, Payment::TYPE_VIAMO);
$package->setCashOnDelivery($cashOnDelivery);

// use the following code if the package is insured
$insurance = new Payment(2500.0);
$package = new Package(123, $recipient, $sender, '1201800002');
$package->setInsurance($insurance);

// send a package through the Neoship API
$neoship->apiPostPackage($package);
```

Expand Down
2 changes: 1 addition & 1 deletion src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Package
* @param string
* @param string
*/
public function __construct(int $id, Address $recipient, Address $sender, string $variableNumber = NULL, $mainPackageNumber = NULL)
public function __construct(int $id, Address $sender, Address $recipient, string $variableNumber = NULL, $mainPackageNumber = NULL)
{
$this->setId($id);
$this->setSender($sender);
Expand Down
2 changes: 1 addition & 1 deletion tests/Package.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $recipient = new Address('Test Tester 2', 'Viamedia SK', 'Testovacia 2', '831 05
$cashOnDelivery = new Payment(10.0, Payment::CURRENCY_EUR, Payment::TYPE_VIAMO);
$insurance = new Payment(2500.0);

$package = new Package(123, $recipient, $sender, '1201800002', '1201800001');
$package = new Package(123, $sender, $recipient, '1201800002', '1201800001');
$package->setPrice(100.0, 20);
$package->setCashOnDelivery($cashOnDelivery);
$package->setInsurance($insurance);
Expand Down

0 comments on commit 2278fd7

Please sign in to comment.