hyperext/hyperaccounts-v2-sdk

HyperAccounts V2 SDK

2.22 2024-09-06 14:23 UTC

This package is not auto-updated.

Last update: 2024-09-20 14:35:19 UTC


README

HyperAccounts API SDK 提供了一个易于使用的接口,用于处理 Sage 50 Accounts HyperAccounts 网络API,版本2及其以上。如果您想获取API访问权限,请直接联系 Hyperext联系我们。此工具旨在简化对网络API进行 HTTP 请求的过程,抽象出底层技术的复杂性。此外,SDK还提供了请求体和API响应的模型,从而简化了开发过程。

用法

$request = ClientConstructor::construct($url,$username,$password);

$query = SalesInvoicesRequestBuilderGetRequestConfiguration::addQueryParameters(null,null,'items',null,'3');
$requestConfiguration = new SalesInvoicesRequestBuilderGetRequestConfiguration(null,null,$query);

$request->api()->v2()->salesInvoices()->get($requestConfiguration)->then(

        function (SalesInvoiceCollection $response) {
            foreach ($response->getData() as $data){
                echo $data->getInvoiceNumber();
                echo $data->getAttributes()->getAddress1();
                echo $data->getIncluded()->getItems()->getData()[0]->getRelationships()->getStock()->getData()->getStockCode();              
            }
        },
        function ($exception) {
            // Gets full API error but will throw a php error if it gets a CURL error
            echo $exception->getResponse()->getBody()->getContents();   
            
            // gets CURL errors but will truncate API errors
            echo $exception->getMessage();

        }

);