Skip to content

Commit

Permalink
Added new methods to manipulate info about parcel statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
NerijusBartosevicius committed Apr 3, 2023
1 parent 5529aeb commit e7d36a6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,32 @@ $dpd->getPickupTimeFrames(['country' => 'LT','zip' => 51336]);
$dpd->getProblems(123456);
```

## Status

### Gets parcel statuses

```php
// additional parameters are possible as an array e.g ['pknr' => '05808021421108','show_all' => 1]
// Parameters list: https://esiunta.dpd.lt/api#/Status/ede44d1ca4e3e15955d44ecc42970e3c
$dpd->getTrackingStatus(['pknr' => '05808021421108']);
```

### Subscribe to parcel

```php
// additional parameters are possible as an array e.g ['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']
// Parameters list: https://esiunta.dpd.lt/api#/Status/8d78b691726ba36b76c5960067c1370c
$dpd->subscribeToParcel(['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']);
```

### Unsubscribe to parcel

```php
// additional parameters are possible as an array e.g ['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']
// Parameters list: https://esiunta.dpd.lt/api#/Status/915e1bfce8f27458cfb3f27f78326866
$dpd->unsubscribeToParcel(['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']);
```

## Tracking

#### Environments
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "DPD API library, to help to integrate with other systems",
"homepage": "https://github.com/NerijusBartosevicius/dpd-api-lib",
"type": "library",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",
"minimum-stability": "dev",
"autoload": {
Expand All @@ -19,7 +19,7 @@
}
],
"require": {
"php" : "^8.0|^8.1"
"php" : "^8.0|^8.1|^8.2"
},
"require-dev": {
"phpunit/phpunit": "10.0.x-dev"
Expand Down
39 changes: 39 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,45 @@ public function getServices(array $params = []): bool|string
return $this->call('/services?' . http_build_query($params));
}

/**
* Gets parcel statuses.
*
* @param array $params
*
* @return bool|string
* @throws DpdException
*/
public function getTrackingStatus(array $params = []): bool|string
{
return $this->call('/status/tracking?' . http_build_query($params));
}

/**
* Subscribe to parcel.
*
* @param array $params
*
* @return bool|string
* @throws DpdException
*/
public function subscribeToParcel(array $params = []): bool|string
{
return $this->call('/status/events/subscribetoparcel?' . http_build_query($params));
}

/**
* Unsubscribe to parcel.
*
* @param array $params
*
* @return bool|string
* @throws DpdException
*/
public function unsubscribeToParcel(array $params = []): bool|string
{
return $this->call('/status/events/unsubscribetoparcel?' . http_build_query($params));
}

/**
* @param string $endpoint
* @param string $method
Expand Down

0 comments on commit e7d36a6

Please sign in to comment.