Skip to content

Commit

Permalink
Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
reindertvetter committed Aug 22, 2016
0 parents commit bda87af
Show file tree
Hide file tree
Showing 11 changed files with 1,654 additions and 0 deletions.
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[![Latest Stable Version](https://poser.pugx.org/myparcelnl/sdk/v/stable)](https://packagist.org/packages/myparcelnl/sdk)
[![Latest Unstable Version](https://poser.pugx.org/myparcelnl/sdk/v/unstable)](https://packagist.org/packages/myparcelnl/sdk)
[![Build Status](https://travis-ci.org/myparcel/sdk.svg?branch=master)](https://travis-ci.org/myparcelnl/sdk)
# MyParcel SDK

---

- [Installation](#installation)
- [Installation without composer](#installation-without-composer)
- [Requirements](#requirements)
- [Quick start and examples](#quick-start-and-examples)
- [Available Methods](#available-methods)
- [Contribute](#contribute)

---

### Installation

This SDK uses composer.

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

For more information on how to use/install composer, please visit: [https://github.com/composer/composer](https://github.com/composer/composer)

To install the MyParcel SDK into your project, simply

$ composer require myparcelnl/sdk

### Installation without composer

If you don't have experience with composer, it is possible to use the SDK without using composer.

You can download the zip on the projects [releases](https://github.com/myparcelnl/sdk/releases) page.

1. Download the package zip (SDKvx.x.x.zip).
2. Unzip the contents of the zip, and upload the vendor directory to your server.
3. In your project, require the file vendor/autoload.php
4. You can now use the SDK in your project

### Requirements

The MyParcel SDK works on php versions 5.3, 5.4, 5.5, 5.6 and 7.0
Also the php curl extension needs to be installed.

### Quick start and examples

```php
use DivideBV\Postnl\Postnl;
use DivideBV\Postnl\ComplexTypes;

// Create client class using credentials received from PostNL.
$client = new Postnl(
12345678, // Customer number
'ABCD', // Customer code
'Acme BV', // Customer name
'Acme', // Username
'Password', // Password
123456, // Collection location
'CD1234', // Globalpack
true // Whether to use PostNL's sandbox environment.
);

/**
* Jan Smit
* Smit & Zonen
* Hoofdstraat 1A
* 1234 AB Heikant
* The Netherlands
*/
$receiverAddress = ComplexTypes\Address::create()
->setAddressType('01')
->setFirstName('Jan')
->setName('Smit')
->setCompanyName('Smit & Zonen')
->setStreet('Hoofdstraat')
->setHouseNr('1')
->setHouseNrExt('A')
->setZipcode('1234AB')
->setCity('Heikant')
->setCountrycode('NL');


```

### Testing
Please run ```vendor/bin/phpunit --bootstrap vendor/autoload.php tests/``` to test the application


### Available Methods
```php
ConsignmentRepository::setName($name = null)
```

### Contribute
1. Check for open issues or open a new issue to start a discussion around a bug or feature.
1. Fork the repository on GitHub to start making your changes.
1. Write one or more tests for the new feature or that expose the bug.
1. Make code changes to implement the feature or fix the bug.
1. Send a pull request to get your changes merged and published.
59 changes: 59 additions & 0 deletions Tests/CreateConsignments/InternationalFullStreetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/**
* Test no split address from full street for international address
*
* LICENSE: This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*
* If you want to add improvements, please create a fork in our GitHub:
* https://github.com/myparcelnl
*
* @author Reindert Vetter <[email protected]>
* @copyright 2010-2016 MyParcel
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US CC BY-NC-ND 3.0 NL
* @link https://github.com/myparcelnl/sdk
* @since File available since Release 0.1.0
*/
namespace MyParcel\sdk\tests\CreateConsignments\InternationalFullStreetTest;
use MyParcel\sdk\Model\Repository\MyParcelConsignmentRepository;


/**
* Class InternationalFullStreetTest
* @package MyParcel\sdk\tests\InternationalFullStreetTest
*/
class InternationalFullStreetTest extends \PHPUnit_Framework_TestCase
{

/**
* Test setFullStreet()
*/
public function testSplitStreet()
{
foreach ($this->additionProvider() as $consignmentTest) {

$consignment = new MyParcelConsignmentRepository();
$consignment->setCc($consignmentTest['cc']);
$consignment->setFullStreet($consignmentTest['full_street']);

$this->assertEquals($consignmentTest['full_street'], $consignment->getFullStreet(), 'Full street: ' . $consignmentTest['full_street']);
}
}

/**
* Data for the test
*
* @return array
*/
public function additionProvider()
{
return [
[
'cc' => 'FR',
'full_street' => 'No. 7 street',
],
];
}
}
63 changes: 63 additions & 0 deletions Tests/CreateConsignments/InternationalStreetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* Test split address from street and number for international address
*
* LICENSE: This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*
* If you want to add improvements, please create a fork in our GitHub:
* https://github.com/myparcelnl
*
* @author Reindert Vetter <[email protected]>
* @copyright 2010-2016 MyParcel
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US CC BY-NC-ND 3.0 NL
* @link https://github.com/myparcelnl/sdk
* @since File available since Release 0.1.0
* @todo Allow street number for international shipment
*/
namespace MyParcel\sdk\tests\CreateConsignments\InternationalStreetTest;


/**
* Class InternationalStreetTest
* @package MyParcel\sdk\tests\InternationalStreetTest
*/
class InternationalStreetTest extends \PHPUnit_Framework_TestCase
{

/**
* Test setFullStreet()
*/
public function testSplitStreet()
{
/*foreach ($this->additionProvider() as $consignmentTest) {
$consignment = new MyParcelConsignmentRepository();
$consignment->setCc($consignmentTest['cc']);
$consignment->setStreet($consignmentTest['street']);
$consignment->setNumber($consignmentTest['number']);
$this->assertEquals($consignmentTest['number'], $consignment->getNumber(), 'Number from: ' . $consignmentTest['full_street_test']);
$this->assertEquals($consignmentTest['street'], $consignment->getStreet(), 'Street: ' . $consignmentTest['full_street_test']);
$this->assertEquals($consignmentTest['full_street'], $consignment->getFullStreet(), 'Full street: ' . $consignmentTest['full_street_test']);
}*/
}

/**
* Data for the test
*
* @return array
*/
public function additionProvider()
{
return [
[
'cc' => 'FR',
'street' => 'Street',
'number' => 12
],
];
}
}
Loading

0 comments on commit bda87af

Please sign in to comment.