Skip to content

Commit

Permalink
Fix and simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
hedii committed Jun 8, 2018
1 parent e27fe0c commit e205e0e
Show file tree
Hide file tree
Showing 12 changed files with 336 additions and 1,978 deletions.
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# IntelliJ project files
/vendor/
.idea
*.iml
out
gen

.DS_Store
/vendor
/index.php
composer.lock
17 changes: 4 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
language: php

php:
- 5.6
- 7.0
- hhvm

- 7.1
- 7.2
before_script:
- composer self-update
- composer install

- composer install --no-interaction
script:
- vendor/bin/phpunit tests

matrix:
allow_failures:
- hhvm
fast_finish: true
- ./vendor/bin/phpunit
81 changes: 63 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[![Build Status](https://travis-ci.org/hedii/colissimo-api.svg?branch=master)](https://travis-ci.org/hedii/colissimo-api)

# colissimo-api
A php API to track Colissimo (La Poste) parcels
A php package to track Colissimo (La Poste) parcels

### Requirements
- PHP >= 7.1
- XML PHP Extension
- Curl PHP Extension

### Installation
````bash
Expand All @@ -10,31 +15,71 @@ composer require hedii/colissimo-api

### Usage
````php
<?php

require 'vendor/autoload.php';

// create a new instance
$colissimoApi = new \Hedii\ColissimoApi\ColissimoApi();

// get data
$all = $colissimoApi->get('9V01144114240')->all();
$status = $colissimoApi->get('9V01144114240')->status();
$id = $colissimoApi->get('9V01144114240')->id();
$destination = $colissimoApi->get('9V01144114240')->destination();
var_dump($all, $status, $id, $destination);
$colissimo = new \Hedii\ColissimoApi\ColissimoApi();

// show json
$colissimoApi->show('9V01144114240')->all();
$colissimoApi->show('9V01144114240')->status();
$colissimoApi->show('9V01144114240')->id();
$colissimoApi->show('9V01144114240')->destination();
try {
$result = $colissimo->get('your_colissimo_id_here');
} catch (\Hedii\ColissimoApi\ColissimoApiException $e) {
// ...
}
````

The result is an array of chronological status:
````
array(5) {
[0] =>
array(3) {
'date' =>
string(10) "30/05/2018"
'label' =>
string(23) "Votre colis est livré."
'location' =>
string(18) "Centre Courrier 75"
}
[1] =>
array(3) {
'date' =>
string(10) "30/05/2018"
'label' =>
string(50) "Votre colis est en préparation pour la livraison."
'location' =>
string(18) "Centre Courrier 75"
}
[2] =>
array(3) {
'date' =>
string(10) "30/05/2018"
'label' =>
string(52) "Votre colis est arrivé sur son site de distribution"
'location' =>
string(18) "Centre Courrier 75"
}
[3] =>
array(3) {
'date' =>
string(10) "29/05/2018"
'label' =>
string(40) "Votre colis est en cours d'acheminement."
'location' =>
string(16) "Plateforme Colis"
}
[4] =>
array(3) {
'date' =>
string(10) "28/05/2018"
'label' =>
string(110) "Votre colis a été déposé après l'heure limite de dépôt. Il sera expédié dès le prochain jour ouvré."
'location' =>
string(28) "Bureau de Poste Les estables"
}
}
````

### Run tests

````bash
vendor/bin/phpunit tests
composer test
````
You may need to update the id in */tests/ColissimoApiTest.php* because the id is only valid for 90 days.
34 changes: 24 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
{
"name": "hedii/colissimo-api",
"minimum-stability": "stable",
"description": "A php API to track Colissimo (La Poste) parcels",
"keywords": ["colissimo", "api", "colissimoapi", "hedii"],
"description": "A php package to track Colissimo (La Poste) parcels",
"keywords": ["colissimo", "api", "colissimoapi", "hedii", "la poste", "laposte"],
"license": "MIT",
"homepage": "https://github.com/hedii/colissimo-api",
"authors": [
{
"name": "Hedi Chaibi",
"email": "hedi.chaibs@gmail.com"
"email": "contact@hedichaibi.com"
}
],
"support": {
"issues": "https://github.com/hedii/colissimo-api/issues",
"source": "https://github.com/hedii/colissimo-api",
"email": "hedi.chaibs@gmail.com"
"email": "contact@hedichaibi.com"
},
"require": {
"php": ">=5.6",
"php": "^7.1.0",
"ext-curl": "*",
"ext-xml": "*",
"symfony/dom-crawler": "^3.0",
"symfony/css-selector": "^3.0"
"guzzlehttp/guzzle": "^6.3",
"symfony/css-selector": "^3.0",
"symfony/dom-crawler": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "5.0.*"
"phpunit/phpunit": "^7.0"
},
"autoload": {
"psr-4": {
"Hedii\\": "src/",
"Hedii\\ColissimoApi\\": "src/ColissimoApi"
"Hedii\\ColissimoApi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Hedii\\ColissimoApi\\Tests\\": "tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Loading

0 comments on commit e205e0e

Please sign in to comment.