maxs94/internetmarke-rest-php
最新稳定版本:v1.0.2
Composer 安装命令:
composer require maxs94/internetmarke-rest-php
包简介
Deutsche Post INTERNETMARKE REST client for PHP
README 文档
README
PHP client for the Deutsche Post DHL Internetmarke API.
Links
Documentation
This repository provides:
- HTTP client and service-layer classes to call the Internetmarke API. See documentation: AppResource, ApiVersionResource, UserResource.
- DTO models for request/response payloads.
- Token provider for OAuth-like authentication.
- PHPUnit tests.
Highlights of recent changes
- Base URI for requests is centralized in
ClientConfig ApiClientimplementsApiClientInterface.TokenProviderimplementsTokenProviderInterface.AuthenticationRequestDTO introduced and used byTokenProviderandUserResource.- Tests were updated to use
ClientConfig('')to avoid automatic base URI prefixing during unit tests. - Several classes and tests were adapted to be more testable and type-safe.
- added Makefile for common tasks (install, test, etc.)
- added Internetmarke facade for easy setup and usage.
Requirements
- PHP 8.1+ (or the project's required PHP version)
- Composer
- client (provided via composer)
- PHPUnit (dev dependency)
Installation
Use the included Make targets to install dependencies:
# install PHP dependencies
make install
(If you prefer running composer directly, composer install is equivalent.)
Usage
The simplest way to get started is to use the Internetmarke facade class, which handles configuration, token provision, and API client setup for you:
use Maxs94\Internetmarke\Internetmarke; $internetmarke = new Internetmarke( 'your-client-id', 'your-client-secret', 'your-username', 'your-password' ); // get API version information var_dump($internetmarke->getApiVersionResource()->getVersion()); // walletBalance can be retrieved from the tokenProvider, // as DHL includes it in the authentication response var_dump($internetmarke->getTokenProvider()->getAuthentication()->getWalletBalance()); // get user profile var_dump($internetmarke->getUserResource()->getUserProfile());
Creating a label
To create and checkout a label, see the AppResource documentation for details and code examples.
Testing
Run the test suite with the Make targets:
# or explicitly run phpunit make phpunit # run static analysis make phpstan # fix coding standards issues make csfix
Development notes
- Prefer
ClientConfigfor all places where a base URI must be configured — it centralizes the setting. - The
ApiClientInterfaceandTokenProviderInterfaceallow you to provide your own implementations for special cases (e.g. custom HTTP adapters, testing). - If you need to mock the token provider or API client in tests, mock the interface types (
TokenProviderInterfaceandApiClientInterface) instead of final concrete classes.
Contributing
- Fork the repo, create a branch, add tests for any new behavior and open a pull request.
- Keep backward-compatibility in mind; update the README and tests when making breaking changes.
- Run
make phpunit,make csfixandmake phpstanbefore submitting a PR - they should pass without errors.
License
- Please see the LICENSE file in the repository.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-05