Download the PHP package pramod/api-consumer without Composer
On this page you can find all versions of the php package pramod/api-consumer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pramod/api-consumer
More information about pramod/api-consumer
Files in pramod/api-consumer
Package api-consumer
Short Description Api consumer
License MIT
Homepage https://github.com/pramod/api-consumer
Informations about the package api-consumer
Api Consumer
This Package developed to request various external api without creating external service or traits.
Installation
You can install the package via composer:
Usage
Copy Config
If you are using Lumen Copy Config
Autoload Config
Please Refer Test Case For Complete Reference which is located in tests/ExampleTest.php
Basic Syntax
Define your custom settings[yml]
You can create your own config to manage and get proper visualization of endpoint used in your app.
-
Create Folder inside App eg, app/Consumers/covid.yml or you can create your own folder where you have to separate yml as per your service name.
-
Sample For yaml
Where uri must be your request path and story for short descriptions or uri.
-
Final Request
Sample Code
Note: your configuration should look like this
Note: Your Dynamic uri must be covered with curly brackets {}.
-
Final Words for Via injections
Adding true or array on second parameters will observe your custom class which is defined in config file as custom_consumer array file
Monitor Your Request Log
You can monitor external call request, response and execution time which is stored as json format in your default log. To activate log monitor you should enable middleware on your application
Call Your Graphql Api
-
Add Your Service setting on <<config/api-consumer.php>>
- Add your endpoint on your request class
- In case of graphQl key inside with auto set Accept and Content-Type headers as application/json
- Method is set as POST
- Need to pass your graphql query in query key
- Default It call toJson()
List of all public graphql Api to test
Descriptions
-
consume
Request Or find Service Name mapped in config file having basic application url,version definitions.
-
via
This method is used to point service end or function name written in service Namespace
- Available Method
- first parameter: Api endpoint or uri
- Second parameter: if second param is true, first param must be method name defined inside your services Folder's class
- Available Method
-
with
Includes all parameter including headers, payload, query string and method name
-
notify[proposed]
Alert developer on error
-
on[proposed]
Action on error, return code with message else message only
-
superChargedBy
Its advance method to keep your response on cache with defined cache name and time. It pick default cache Setting from your env
- conversion method [By Default it call toJson() method]
- toArray
- toJson
- toCollection
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Pramod Katuwal
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
HAPPY CODING :)
All versions of api-consumer with dependencies
guzzlehttp/guzzle Version ^6.5 || ^7.0
illuminate/support Version 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0
symfony/yaml Version ^5.1