将购买力平价API集成到您的在线产品和服务中,让您能够提供全球性的实惠价格。

v0.1 2023-08-22 19:50 UTC

This package is auto-updated.

Last update: 2024-09-25 19:29:19 UTC


README

Latest Version on Packagist

使用PHP实现https://purchasing-power-parity.com

安装

您可以通过composer安装此包。

composer require thearyanahmed/ppp

用法

use Thearyanahmed\Ppp\Request;
$response = (new Request)->fetchPPP('DE');

响应可以是SuccessfulResponseErrorResponse。成功的响应包含带有getter方法的字段。例如:可以通过getPppConversionFactor()访问pppConversionFactor

可用方法

# SuccessResponse
    public function getCountryCodeAlpha2() : string
    public function getCountryCodeAlpha3() : string
    public function getMainCurrencyName() : string
    public function getMainCurrencySymbol() : string
    public function getPppConversionFactor() : float
    public function getPPP() : float
    public function isSuccessful() : bool # will always return true

# ErrorResponse
    public function getMessage() : string
    public function isSuccessful() : bool # will always return false

如果不是HTTP 200请求,它会抛出一个通用异常。

用法

   $response = (new Request)->fetchPPP('DE');

   if($response->isSuccessful()) {
        $discountPrice = $response->getPppConversionFactor() * $originalPrice;
   }

贡献

请参阅CONTRIBUTING以获取详细信息。

安全

如果您发现任何安全问题,请通过电子邮件thearyanahmed@gmail.com而不是使用问题跟踪器。

鸣谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件

PHP包模板

此包是使用PHP包模板Beyond Code生成的。