Skip to content

Commit

Permalink
Complete rewrite for new API
Browse files Browse the repository at this point in the history
  • Loading branch information
shusaura85 committed Dec 13, 2023
1 parent ecf2a80 commit eb9c6da
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ composer.lock
.bak
.phpunit.result.cache
build/

3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: php

php:
- 7.2
- 7.3
- 8.1

env:
matrix:
Expand Down
152 changes: 76 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ Response
```php
if ($response->isOk()) {
var_dump($response->getData()); // raw data
// or just the information you want
echo "extraKmCost: ". $response->getKmCost().'<br />';
echo "weightCost: ". $response->getWeightCost().'<br />';
echo "insuranceCost: ". $response->getInsuranceCost().'<br />';
echo "optionsCost: ". $response->getOptionsCost().'<br />';
echo "fuelCost: ". $response->getFuelCost().'<br />';
echo "costNoVAT: ". $response->getCost().'<br />';
echo "vat: ". $response->getCostVat().'<br />';
echo "total: ".$response->getCostTotal().'<br />';
// or just the information you want
echo "extraKmCost: ". $response->getKmCost().'<br />';
echo "weightCost: ". $response->getWeightCost().'<br />';
echo "insuranceCost: ". $response->getInsuranceCost().'<br />';
echo "optionsCost: ". $response->getOptionsCost().'<br />';
echo "fuelCost: ". $response->getFuelCost().'<br />';
echo "costNoVAT: ". $response->getCost().'<br />';
echo "vat: ". $response->getCostVat().'<br />';
echo "total: ".$response->getCostTotal().'<br />';
} else {
var_dump($response->getErrorMessage());
print_r($response->getAllErrors());
print_r($response->getAllErrors());
}
```

Expand All @@ -110,23 +110,23 @@ Request
```php
$awb = new Fancourier\Objects\AwbIntern();
$awb
->setService('Cont Colector')
->setPaymentType(Fancourier\Request\CreateAwb::TYPE_SENDER)
->setParcels(1)
->setWeight(1) // in kg
->setCoD(199.99) // suma de incasat
->setDeclaredValue(1000)
->setSizes(10,5,1) // in cm
->setNotes('testing notes')
->setContents('SKU-1, SKU-2')
->setRecipientName("John Ivy")
->setPhone('0723000000')
->setCounty('Arad')
->setCity('Aciuta')
->setStreet('Str Lunga')
->setNumber(1)
->addOption('S')
->addOption('X');
->setService('Cont Colector')
->setPaymentType(Fancourier\Request\CreateAwb::TYPE_SENDER)
->setParcels(1)
->setWeight(1) // in kg
->setCoD(199.99) // suma de incasat
->setDeclaredValue(1000)
->setSizes(10,5,1) // in cm
->setNotes('testing notes')
->setContents('SKU-1, SKU-2')
->setRecipientName("John Ivy")
->setPhone('0723000000')
->setCounty('Arad')
->setCity('Aciuta')
->setStreet('Str Lunga')
->setNumber(1)
->addOption('S')
->addOption('X');

$request = new Fancourier\Request\CreateAwb();
$request->addAwb($awb);
Expand All @@ -137,24 +137,24 @@ Response
$response = $fan->createAwb($request);

if ($response->isOk()) {
var_dump($response->getData()); // raw data
// or the AWBIntern objects updated with the response information
$al = $response->getAll();
echo "Count: ".count($al)."<br />";
foreach ($al as $awbr)
{
if ($awbr->hasErrors())
{
print_r($awbr->getErrors());
}
else
{
echo "AWB: ".$awbr->getAwb()."<br />";
}
}
var_dump($response->getData()); // raw data
// or the AWBIntern objects updated with the response information
$al = $response->getAll();
echo "Count: ".count($al)."<br />";
foreach ($al as $awbr)
{
if ($awbr->hasErrors())
{
print_r($awbr->getErrors());
}
else
{
echo "AWB: ".$awbr->getAwb()."<br />";
}
}
} else {
var_dump($response->getErrorMessage());
var_dump($response->getErrorMessage());
}
```

Expand All @@ -168,29 +168,29 @@ $request = new Fancourier\Request\CreateAwb();
// create the first awb
$awb = new Fancourier\Objects\AwbIntern();
$awb
->setService('Cont Colector')
....
->addOption('X');
->setService('Cont Colector')
....
->addOption('X');

// add it to the request
$request->addAwb($awb);

// create another awb
$awb = new Fancourier\Objects\AwbIntern();
$awb
->setService('Cont Colector')
....
->addOption('X');
->setService('Cont Colector')
....
->addOption('X');

// add it to the request
$request->addAwb($awb);

// create another awb
$awb = new Fancourier\Objects\AwbIntern();
$awb
->setService('Cont Colector')
....
->addOption('X');
->setService('Cont Colector')
....
->addOption('X');

// add it to the request
$request->addAwb($awb);
Expand All @@ -201,24 +201,24 @@ Response
$response = $fan->createAwb($request);

if ($response->isOk()) {
var_dump($response->getData()); // raw data
// or the AWBIntern objects updated with the response information
$al = $response->getAll();
echo "Count: ".count($al)."<br />";
foreach ($al as $awbr)
{
if ($awbr->hasErrors())
{
print_r($awbr->getErrors());
}
else
{
echo "AWB: ".$awbr->getAwb()."<br />";
}
}
var_dump($response->getData()); // raw data
// or the AWBIntern objects updated with the response information
$al = $response->getAll();
echo "Count: ".count($al)."<br />";
foreach ($al as $awbr)
{
if ($awbr->hasErrors())
{
print_r($awbr->getErrors());
}
else
{
echo "AWB: ".$awbr->getAwb()."<br />";
}
}
} else {
var_dump($response->getErrorMessage());
var_dump($response->getErrorMessage());
}
```

Expand Down Expand Up @@ -297,8 +297,8 @@ Request
```php
$request = new Fancourier\Request\PrintAwb();
$request
->setPdf(true)
->setAwb('2150900120086');
->setPdf(true)
->setAwb('2150900120086');
```
Response
```php
Expand All @@ -307,7 +307,7 @@ if ($response->isOk()) {
echo $response->getData();
} else {
var_dump($response->getErrorMessage());
print_r($response->getAllErrors());
print_r($response->getAllErrors());
}
```

Expand All @@ -319,8 +319,8 @@ Request
```php
$request = new Fancourier\Request\PrintAwb();
$request
->setPdf(false)
->setAwb('2150900120086');
->setPdf(false)
->setAwb('2150900120086');
```
Response
```php
Expand All @@ -329,7 +329,7 @@ if ($response->isOk()) {
echo $response->getData();
} else {
var_dump($response->getErrorMessage());
print_r($response->getAllErrors());
print_r($response->getAllErrors());
}
```

Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Fancourier Api TestSuite">
<testsuite name="Fancourier Api 2 TestSuite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down

0 comments on commit eb9c6da

Please sign in to comment.