Download the PHP package eleven-labs/api-service without Composer
On this page you can find all versions of the php package eleven-labs/api-service. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package api-service
API Service
This component read API service descriptions written in OpenAPi/Swagger 2.0 in order serialize requests, and parse responses into easy to use model structures.
Dependencies
This component rely on well known interfaces that discribe:
- An HTTP client, using interfaces provided by HTTPlug
- HTTP Messages, using the PSR-7: HTTP message interfaces
- Cache (used to cache schema files), using the PSR-6: Caching Interface
Installation
This library can be easily installed via composer
Usage
In order to consume an API, you will need to write an API service description.
As of now, we only support swagger files, but we plan to support RAML 1.0 and Api Blueprint in a near future.
For standalone projects usage of the provided builder is encouraged:
Important: You MUST provide an operationId for each paths described in your swagger file.
Builder Dependencies
You will need one of the HttpClient adapter provided by HttPlug and the HTTP Client Discovery Service.
Builder configuration
The builder provide additional methods to fine tune your API Service:
-
withCacheProvider(CacheItemPoolInterface $cacheProvider)
Cache the API service description using a PSR-6: Cache Interface
-
withHttpClient(HttpClient $httpClient)
Provide an HttpClient implementing the
Http\Client\HttpClient
interface.
By default, it will use theHttp\Discovery\HttpClientDiscovery::find()
method -
withMessageFactory(MessageFactory $messageFactory)
Provide a MessageFactory implementing the
Http\Message\MessageFactory
interface.
By default, it will use theHttp\Discovery\MessageFactoryDiscovery::find()
method -
withUriFactory(UriFactory $uriFactory)
Provide an UriFactory implementing the
Http\Message\UriFactory
interface.
By default, it will use theHttp\Discovery\UriFactory::find()
method -
withSerializer(SerializerInterface $serializer)
Provide a Serializer. By default, it will use the Symfony Serializer.
-
withEncoder(EncoderInterface $encoder)
Add an encoder to encode Request body and decode Response body.
By default, it register Symfony'sJsonEncoder
andXmlEncoder
. -
withPaginationProvider(PaginationProvider $paginatorProvide)
When using the default
ResourceDenormalizer
, you can provide a pagination provider to add pagination informations intoCollection
objects. Available implementations can be found in thesrc/Pagination/Provider
folder. You can create your own by implementing theElevenLabs\Api\Service\Pagination\PaginationProvider
interface. -
withDenormalizer(NormalizerInterface $normalizer)
Add a denormalizer used to denormalize
Response
decoded body.
By default, it use theElevenLabs\Api\Service\Denormalizer\ResourceDenormalizer
that denormalize aResponse
into aResource
object. AResource
object can be anItem
or aCollection
. -
withBaseUri($baseUri)
Provide a base URI from which your API is exposed.
By default, it will use your theschemes
key andhost
key defined in your API service description. -
disableRequestValidation()
Disable
Request
validation against your API service description. Enabled by default -
enableResponseValidation()
Enable
Response
validation against your API service description. Disabled by default. -
returnResponse()
Return a PSR-7 Response when using
ApiService
call()
andcallAsync()
methods instead of a denormalized object. -
setDebug($bool)
Enable debug mode. When enabled, it will expire the schema cache immediatly if a cache implementation is provided using the
withCacheProvider(CacheItemPoolInterface $cacheProvider)
method.
All versions of api-service with dependencies
ext-json Version *
php-http/httplug Version ^1.0
php-http/message Version ^1.3
eleven-labs/api-validator Version ^0.5
beberlei/assert Version ^2.6