dasun4u/laravel-ideabiz-handler

Laravel package for IDEABIZ REST API handling

Downloads

30

Stars

4

Version

2.0.1

Latest Stable Version Total Downloads License StyleCI

Laravel IDEABIZ Handler (Laravel 8.0+)

Laravel IDEABIZ Handler is a laravel plugin to handle REST API request for IDEABIZ APIs

Requirements

  • PHP 7.0+
  • Laravel 8.0+

Installation

  1. Install the package by running this command in your terminal/cmd:
composer require dasun4u/laravel-ideabiz-handler
  1. You can import config file and sample token file by running this command in your terminal/cmd:
php artisan vendor:publish --provider="Dasun4u\LaravelIDEABIZHandler\RestAPIProvider"
  1. Then set the configurations in ideabiz.php file.

  2. For the first time, token generate using 'grant_type' => 'password' or manualy. Verify that token.json file has the valid access token and refresh token

It has following functions:

  • Generate access token
IDEABIZ::generateAccessToken();
  • Get access token
IDEABIZ::getAccessToken();
  • Make the request
$access_token = IDEABIZ::getAccessToken();
$url = "https://ideabiz.lk/apicall/xyz"
$method = "POST";
$headers = [
                "Content-Type" => "application/json",
                "Authorization" => "Bearer ".$access_token,
                "Accept" => "application/json",
           ];
$request_body = [
                    "a" => 123,
                    "b" => "xyz",
                ];
 
// Rest API request and response get to a variable                
$response = IDEABIZ::apiCall($url, $method, $headers, $request_body);

// Get response body
$response->getBody();

// Get status code
$response->getStatusCode();

// Get response headers
$response->getHeaders();

Author

License

This project is licensed under the MIT License - see the LICENSE file for details

Special Thanks to

dasun4u

Author

dasun4u