Download the PHP package nedoto/laravel-client without Composer
On this page you can find all versions of the php package nedoto/laravel-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nedoto/laravel-client
More information about nedoto/laravel-client
Files in nedoto/laravel-client
Package laravel-client
Short Description Nedoto Laravel HTTP Client provide access to the Nedoto HTTP APIs
License MIT
Informations about the package laravel-client
Nedoto Laravel Client
A Laravel package to connect to the Nedoto API.
References:
- Nedoto website: https://nedoto.com
- Nedoto app website: https://app.nedoto.com
- Nedoto documentation website: https://docs.nedoto.com
Installation
This package requires PHP >=8.1
and is built for Laravel >=11.x
or higher.
Installation with Composer:
Publish the package configuration:
Open your .env
file and add the NEDOTO_API_KEY
env var using your api-key created
at https://app.nedoto.com/api-keys.
Note: before start retrieving your configuration, be sure to enable the Project, Environment, Configuration and Api key in https://app.nedoto.com.
Usage
You can choose between using the Facade or injecting the Nedoto client to retrieve your configuration.
Continue reading to understand how to use both.
Using the Facade
You can use the NedotoClientFacade
facade to retrieve your configuration from Nedoto API.
Inject the Nedoto client
To retrieve your configuration from Nedoto API you should add a reference to
the Nedoto\Client\NedotoClient
to you class and then use the Client to retrieve your configuration with the unique key
that is the variable slug
.
As shown in the example below, the $response
object is of type Nedoto\Client\Response
and with it, you can retrieve the Nedoto\Configuration
object.
From the Configuration object you can access your configuration value calling the getValue()
method.
The Nedoto Response
After the call to the get()
method, you'll receive a Nedoto\Client\Response
.
Understand if the Nedoto response is ok
To understand if everything went fine after retrieving your configuration, you should use the getStatus()
method.
It will return a standard HTTP status code.
Alternatively you could you use the failed()
method that will inform you if there was a failure by returning
a boolean
value if the HTTP status code is different from 200
(HTTP OK).
Understand the errors
After checking if the status of the response you may want to understand which errors happened during the API request.
For this you could use the getErrors()
method.
The getErrors()
method will return an array of reasons explaining what's wrong with the request.
Retrieve the Configuration
To retrieve your configuration value you must use the getConfiguration()
method.
Reading you configuration
After you have your Nedoto\Configuration
object you can access different information explained below.
Retrieve the value
Probably the most important thing to read in your configuration is actually the value.
To do that you should simply use the getValue()
method.
Note: the getValue()
method will return the value already casted to the type you defined in the configuration
in https://app.nedoto.com/configurations.
Understand the type
Since Nedoto gives you the possibility to define the type
of your configuration you can retrieve it using
the getType()
method.
Note: You don't need to cast the value to the type you want, since the getValue()
method will return the value
already
casted.
Access the creation date
By using the getCreatedAt()
you can access the creation date of the configuration.
Access the update date
By using the getUpdatedAt()
you can access the update date of the configuration.
Want to improve something?
Please feel free to open a PR if you want to improve something on this repository.