Repository navigation
Releases: grinchenkoedu/diia-php
Release list
v2.0.1
Fixed
ScopesMapper::__construct()andItemsListResponse::__construct()declared implicitly nullable
parameters, which PHP 8.4 reports as deprecated each time the class loads (and a caller whose test
suite fails on printed output fails with it). They are now?Scopesand?int. No behaviour change.- The test suite now fails on deprecations (
convertDeprecationsToExceptions), so the next one
cannot pass CI unnoticed.
Other
- The copyright holder in
LICENSEis now Borys Grinchenko Kyiv Metropolitan University. The licence stays MIT.
v2.0.0
Changed
-
AcquirersClientis split into one client per API resource, each built byClientFactory
and each taking one typed mapper per job, so two mappers can no longer be swapped by mistake:1.x AcquirersClient2.0 createBranch(Branch)BranchClient::create(Branch)updateBranch($branchId, Branch)BranchClient::update($branchId, Branch)deleteBranch($branchId)BranchClient::delete($branchId)getBranch($branchId)BranchClient::get($branchId)getBranches(ItemsListRequest)BranchClient::list(ItemsListRequest)createOffer($branchId, Offer)OfferClient::create($branchId, Offer)deleteOffer($branchId, $offerId)OfferClient::delete($branchId, $offerId)getOffers($branchId, ItemsListRequest)OfferClient::list($branchId, ItemsListRequest)makeOfferRequest($branchId, OfferRequest)OfferRequestClient::makeDynamic($branchId, OfferRequest)offerRequestStatus($otp, $requestId)OfferRequestClient::status($otp, $requestId)documentRequest(DocumentRequest)DocumentRequestClient::request(DocumentRequest)documentRequestStatus($barcode, $requestId)DocumentRequestClient::status($barcode, $requestId) -
Build the clients with
new ClientFactory($guzzle, $credentials, $cache, $logger)and its
branchClient($defaultScopes),offerClient($defaultScopes),offerRequestClient()and
documentRequestClient(). Clients from one factory share one bearer token. -
Every failed API call throws
Exception\DiiaApiException(getStatusCode(),getErrorCode(),
getResponseBody()): HTTP errors and transport errors, which were Guzzle exceptions, and
unreadable responses or a status response without a status, which wereUnexpectedValueException.
A request that got no response has status code 0. StillUnexpectedValueException: a list
response without its items key, and a token response without a token. A DTO that cannot be
encoded as JSON (a string that is not valid UTF-8) throwsJsonExceptionbefore any request
is sent; 1.x sent an empty body. -
BearerTokenProvidercaches the token for 7200 − 300 seconds instead of its full lifetime,
and hasinvalidate(). A 401 from the API drops the token, fetches a new one and retries the
call once. -
Branch and offer IDs are URL-encoded in request paths. Diia's IDs are unchanged by it; an ID
holding/,?or../no longer sends the request to a different endpoint. -
Requires
guzzlehttp/guzzle ^7.8; acceptspsr/simple-cache1–3 andpsr/log1–3;
"php": "^7.4 || ^8.0". CI runs the tests on PHP 7.4 and 8.0–8.5.
Removed
Client\AcquirersClientDependency\DependencyResolver,Dependency\SupportedDependencyInterface,
Dependency\UnresolvedDependencyException, andisSupported()on every mapperMapper\Request\RequestJsonMapper,Mapper\Response\ResponseJsonMapper: JSON is encoded and
decoded by the newHttp\ApiTransportProvider\HttpHeadersProvider: the headers are set byHttp\ApiTransport
Unchanged
- Endpoints, HTTP methods, query strings, headers and JSON bodies: 2.0 sends what 1.x sent,
checked against the 1.x requests recorded intests/fixtures/requests/. - The DTOs and enums:
Branch,Offer,OfferRequest,DocumentRequest,ItemsListRequest,
ApiResource,ItemsListResponse,OfferResponse,Scopes,ScopesDiiaId,ScopesSharing.