setono / shipmondo-php-sdk
使用此PHP SDK消费Shipmondo API
v1.0.0-beta.3
2024-04-12 06:44 UTC
Requires
- php: >=8.1
- cuyz/valinor: ^1.10
- php-http/discovery: ^1.14
- psr/http-client: ^1.0
- psr/http-client-implementation: ^1
- psr/http-factory: ^1.0
- psr/http-factory-implementation: ^1
- psr/http-message: ^1.0
- psr/log: ^1.1 || ^2.0 || ^3.0
- webmozart/assert: ^1.11
Requires (Dev)
- infection/infection: ^0.27.11
- kriswallsmith/buzz: ^1.2
- nyholm/psr7: ^1.8
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.6
- psalm/plugin-phpunit: ^0.18
- setono/code-quality-pack: ^2.7
This package is auto-updated.
Last update: 2024-08-29 08:21:07 UTC
README
在PHP中消费Shipmondo API。
安装
composer require setono/shipmondo-php-sdk
使用
<?php use Setono\Shipmondo\Client\Client; require_once __DIR__ . '/../vendor/autoload.php'; $client = new Client('api_username', 'api_key'); $paymentGateways = $client ->paymentGateways() ->get() ; foreach ($paymentGateways as $paymentGateway) { print_r($paymentGateway); }
将输出某些内容
Setono\Shipmondo\Response\PaymentGateways\PaymentGateway Object
(
[id] => 1234
[name] => quickpay
[provider] => quick_pay
[merchantNumber] => 67894321
)
生产使用
内部,此库使用CuyZ/Valinor库,该库特别适合将API响应转换为DTO。然而,此库有一些开销,并且启用缓存时表现最佳。
当你实例化Client
时,使用设置缓存的机会
<?php use CuyZ\Valinor\Cache\FileSystemCache; use Setono\Shipmondo\Client\Client; require_once '../vendor/autoload.php'; $cache = new FileSystemCache('path/to/cache-directory'); $client = new Client('API_USERNAME', 'API_KEY'); $client->getMapperBuilder()->withCache($cache);
您可以在此处了解更多信息:Valinor: 性能和缓存。