bibrokhim / http-clients
Http clients for microservices
Requires
- php: ^8.2
- guzzlehttp/psr7: ^2.0
- illuminate/http: ^10|^11|^12|^13
- illuminate/support: ^10|^11|^12|^13
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 2.4.3
- 2.4.2
- 2.4.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.0
- 1.15.0
- 1.14.1
- 1.14.0
- 1.13.1
- 1.13.0
- 1.12.0
- 1.11.0
- 1.10.2
- 1.10.1
- v1.10.0
- 1.9.0
- 1.8.9
- 1.8.8
- 1.8.7
- 1.8.6
- 1.8.5
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.7
- 1.7.6
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.36
- 1.6.35
- 1.6.34
- 1.6.33
- 1.6.32
- 1.6.31
- 1.6.30
- 1.6.29
- 1.6.28
- 1.6.27
- 1.6.26
- 1.6.25
- 1.6.24
- 1.6.23
- 1.6.22
- 1.6.21
- 1.6.20
- 1.6.19
- 1.6.18
- 1.6.17
- 1.6.16
- 1.6.15
- 1.6.14
- 1.6.13
- 1.6.12
- 1.6.11
- 1.6.10
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feature/product-by-id-post-request
- dev-feature/site-map-endpoint
This package is auto-updated.
Last update: 2026-09-28 05:21:47 UTC
README
Typed HTTP clients for the internal microservices (CRM, Products, SMS, Firebase, Media, Helpdesk, OneC, ApiGateway, Rating, ServiceCRM, PsSap, Epamarket, Pos, PollwonProducts, PollwonSite). Installed as a dependency of the consuming Laravel applications; it is not run standalone.
composer require bibrokhim/http-clients
Every client is bound in HttpClientsServiceProvider, reading config/config.php
under the http_clients key. Setting HTTP_CLIENT_CACHE=true swaps the clients
that have a cache decorator (Products, PollwonProducts, CRM) for their
*CacheClient variant.
Pollwon Product Service — site categories
GET {POLLWON_PRODUCTS_BASE_URL}/v1/site/categories backs the public storefront
category tree.
use Bibrokhim\HttpClients\Clients\PollwonProducts\PollwonProductsClientInterface; public function index(PollwonProductsClientInterface $client, Request $request) { $categories = $client->siteCategories( $request->query('parent_id'), // null for the root level $request->header('Accept-Language'), $request->query('slug'), ); return response()->json($categories); }
The contract
public function siteCategories( ?string $parentId, ?string $language = null, ?string $slug = null, ): array;
$parentId—nullis sent withoutparent_id; any other value is sent unchanged asparent_id.$language— when supplied, it is sent unchanged asAccept-Language. The client does not validate, normalise, or replace it. When omitted, the package's existing defaultAccept-Languageheader is used.$slug— when supplied, it is sent unchanged asslug. It can be used together with$parentId; the client does not validate either lookup value.- The decoded JSON body is returned as an
array, in line with the otherPollwonProductsClientmethods. ExistingBaseClienterror behaviour is unchanged.
Caching
With HTTP_CLIENT_CACHE=true the container binds PollwonProductsCacheClient,
which caches under:
pollwon-products.site-categories.v1.{language}.{root|lookup}
One key per lookup and locale, so root, each parent lookup, and each slug lookup
stay independent; a combined parent-and-slug lookup gets its own key as well.
root is used only when both lookups are null, and empty strings remain distinct
values. Only a successful 2xx response is stored.
| Env var | Default | Purpose |
|---|---|---|
POLLWON_PRODUCTS_BASE_URL |
— | Service base URL, ending /api. |
POLLWON_SITE_CATEGORIES_CACHE_TTL |
300 |
Cache lifetime, seconds. |
POLLWON_PRODUCTS_SITE_CATEGORIES_CACHE_TTL is the pre-release name for the TTL
and is still read as a fallback; new deployments should set
POLLWON_SITE_CATEGORIES_CACHE_TTL.
Cached entries expire on the TTL alone — the package has no knowledge of product
service category events, so a change to a category's active, title,
position or parent becomes visible only once the entry lapses. Shorten the
TTL if that window is too wide.
Pollwon Product Service — storefront products
The four public catalog endpoints the storefront reads. Each one forwards its query string verbatim and returns the decoded upstream body unchanged, so the consuming application decides what to validate and what to expose.
use Bibrokhim\HttpClients\Clients\PollwonProducts\PollwonProductsClientInterface; $client = app(PollwonProductsClientInterface::class); $list = $client->siteProducts(['category_slug' => 'nasoslar', 'page' => 2], 'uz'); $byIds = $client->siteProductsByPost(['product_ids' => $ids, 'page' => 2], 'uz'); $search = $client->siteProductSearch(['search' => 'nasos'], 'ru'); $product = $client->siteProduct('0f8fad5b-d9cb-469f-a165-70867728950e', 'uz'); $similar = $client->siteSimilarProducts('0f8fad5b-d9cb-469f-a165-70867728950e', 'uz');
The contract
public function siteProducts(array $query = [], ?string $language = null): array; public function siteProductsByPost(array $payload = [], ?string $language = null): array; public function siteProductSearch(array $query = [], ?string $language = null): array; public function siteProduct(string $productId, ?string $language = null): array; public function siteSimilarProducts(string $productId, ?string $language = null): array;
| Method | Upstream path |
|---|---|
siteProducts |
GET /v1/site |
siteProductsByPost |
POST /v1/site |
siteProductSearch |
GET /v1/site/search |
siteProduct |
GET /v1/site/{productId} |
siteSimilarProducts |
GET /v1/site/{productId}/similar-products |
$query— sent verbatim, including nested parameters such asspecifications[<uuid>][]andranges[<uuid>][from]. The client neither validates nor renames anything.$payload(siteProductsByPost) — the same parameters assiteProducts, sent verbatim as a JSON body. Use it whenproduct_idsis long: 500 UUIDs are ~29 KB as a query string, well past a typical proxy URL limit. Upstream validation and the response shape match the GET list; only thelinksURLs lose the body filters (the paginator keeps the query string only), so page bymetaand resend the body with a newpage.$language— when supplied it is sent unchanged asAccept-Language; otherwiseBaseClient's default (the host app's locale) applies.- The decoded JSON body is returned as an
array, in line with the otherPollwonProductsClientmethods. ExistingBaseClienterror behaviour is unchanged: 5xx always throwsServerErrorException, and 4xx throwsClientErrorExceptiononly when the caller enabledfailOnClientErrors().
Caching
With HTTP_CLIENT_CACHE=true the container binds PollwonProductsCacheClient,
which caches under:
pollwon-products.site-products.v1.{language}.{all|query.<sha256>}
pollwon-products.site-products-post.v1.{language}.{all|query.<sha256>}
pollwon-products.site-product-search.v1.{language}.{all|query.<sha256>}
pollwon-products.site-product.v1.{language}.{productId}
pollwon-products.site-similar-products.v1.{language}.{productId}
Only a successful 2xx response is stored. The list and search keys hash the
whole parameter set, so every distinct filter, page, sort and locale
combination gets its own entry; key order is normalised, value order is not —
except product_ids in the POST list, which is sorted before hashing because
upstream treats it as a set.
| Env var | Default | Purpose |
|---|---|---|
POLLWON_PRODUCTS_BASE_URL |
— | Service base URL, ending /api/pollwon-site. |
POLLWON_SITE_PRODUCTS_CACHE_TTL |
300 |
Cache lifetime for the site product reads, in seconds. |
Pollwon Product Service — sitemap
GET {POLLWON_PRODUCTS_BASE_URL}/v1/site/sitemap returns active products' slug
maps for every available language. It has no parameters or request body.
$sitemap = $client->siteSitemap();
With HTTP_CLIENT_CACHE=true, successful responses are cached under
pollwon-products.site-sitemap.v1 for 30 minutes by default. Set
POLLWON_SITE_SITEMAP_CACHE_TTL to change the lifetime in seconds.
Pollwon Product Service — counterparty map points
GET {POLLWON_PRODUCTS_BASE_URL}/pollwon-site/v1/site/counterparties/map-points
returns map points within the supplied bounds.
$points = $client->counterpartiesMapPoints([ 'north' => 41.36, 'south' => 41.20, 'east' => 69.38, 'west' => 69.15, ]);
With HTTP_CLIENT_CACHE=true, successful responses are cached per bounds for
300 seconds by default. Set POLLWON_COUNTERPARTIES_MAP_POINTS_CACHE_TTL to
change the lifetime in seconds. Bound key order does not affect the cache key.
Development
composer install composer test # PHPUnit vendor/bin/pint --dirty composer audit --locked
The suite runs on a minimal Illuminate container (tests/TestApplication.php)
rather than a full framework install, so the package's production dependency
footprint stays small. tests/helpers.php supplies the app(), config() and
now() helpers a host Laravel application would otherwise provide.