kanekescom / laravel-siasn-api
SIASN REST API Client for Laravel
Fund package maintenance!
achmadhadikurnia
Buymeacoffee
Patreon
Saweria
Installs: 2 345
Dependents: 5
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 3
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.2
- illuminate/contracts: ^10.0||^11.0
- kanekescom/laravel-helperia: ^2.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
- dev-main / 2.x-dev
- v2.0.21
- v2.0.20
- v2.0.19
- v2.0.18
- v2.0.17
- v2.0.16
- v2.0.15
- v2.0.14
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0
- dev-dependabot/github_actions/JetBrains/qodana-action-2024.2
- dev-dependabot/github_actions/peter-evans/create-pull-request-7
- dev-dependabot/github_actions/actions/checkout-4
This package is auto-updated.
Last update: 2024-10-23 08:02:17 UTC
README
SIASN REST API Client for Laravel. This library is the abstraction of SIASN API for access from applications written with Laravel PHP Framework.
Support us
Want to provide tangible support? Use the following platform to contribute to open-source software developers. Every contribution you make is a significant boost to continue building and enhancing technology that benefits everyone.
- Buy Me a Coffee https://s.id/hadibmac
- Patreon https://s.id/hadipatreon
- Saweria https://s.id/hadisaweria
We highly appreciate you sending us a few cups of coffee to accompany us while writing code. Super, thanks.
Use pro version
We also offer a professional version. We're excited for you to try it out, as it allows us to consistently deliver high-quality software. Feel free to contact us at kanekescom@gmail.com or @achmadhadikurnia (maintainer) for further information.
- Laravel SIASN Referensi Panel
- Laravel SIASN SIMPEG Panel
- SIMPEGDA App
Installation
You can install the package via composer:
composer require kanekescom/laravel-siasn-api
You can publish the config file with:
php artisan vendor:publish --tag="siasn-api-config"
This is the contents of the published config file:
// config/siasn-api.php <?php return [ // Supported mode: "production", "training" 'mode' => env('SIASN_MODE', 'training'), 'apim' => [ 'production' => [ 'url' => 'https://apimws.bkn.go.id/oauth2/token', 'grant_type' => 'client_credentials', 'username' => env('SIASN_APIM_USERNAME'), 'password' => env('SIASN_APIM_PASSWORD'), ], 'training' => [ 'url' => 'https://training-apimws.bkn.go.id/oauth2/token', 'grant_type' => 'client_credentials', 'username' => env('TRAINING_SIASN_APIM_USERNAME'), 'password' => env('TRAINING_SIASN_APIM_PASSWORD'), ], ], 'sso' => [ 'production' => [ 'url' => 'https://sso-siasn.bkn.go.id/auth/realms/public-siasn/protocol/openid-connect/token', 'grant_type' => 'password', 'client_id' => env('SIASN_SSO_CLIENT_ID'), 'username' => env('SIASN_SSO_USERNAME'), 'password' => env('SIASN_SSO_PASSWORD'), ], 'training' => [ 'url' => 'https://iam-siasn.bkn.go.id/auth/realms/public-siasn/protocol/openid-connect/token', 'grant_type' => 'password', 'client_id' => env('TRAINING_SIASN_SSO_CLIENT_ID'), 'username' => env('TRAINING_SIASN_SSO_USERNAME'), 'password' => env('TRAINING_SIASN_SSO_PASSWORD'), ], ], 'const' => [ 'instansi_id' => env('SIASN_CONST_INSTANSI_ID'), 'satuan_kerja_id' => env('SIASN_CONST_SATUAN_KERJA_ID'), ], 'token_age' => [ 'apim' => (int) env('SIASN_APIM_TOKEN_AGE', 3600 - 60), 'sso' => (int) env('SIASN_SSO_TOKEN_AGE', 43200 - 60), ], 'debug' => (bool) env('SIASN_DEBUG', env('APP_DEBUG')), 'enable_ssl_verification' => (bool) env('SIASN_ENABLE_SSL_VERIFICATION', true), 'max_request_attempts' => (int) env('SIASN_REQUEST_ATTEMPTS', 3), 'max_request_wait_attempts' => (int) env('SIASN_REQUEST_WAIT_ATTEMPTS', 30), 'request_timeout' => (int) env('SIASN_REQUEST_TIMEOUT', 60), ];
Or, all installations can be completed with the installation command:
php artisan siasn-api:install
Usage
Token Generator
Generate an APIM Token
php artisan siasn:apim-token
Generate an SSO Token
php artisan siasn:sso-token
Generate an APIM and SSO Tokens
php artisan siasn:token
You can add the --fresh
option to always request a new token
Remove Tokens
Remove an APIM and SSO Tokens
php artisan siasn:forget-token
Available Token Methods
Generate an APIM Token
Token::getNewApimToken(); // Always request a new APIM token Token::getApimToken(); // Request a new APIM token Token::getNewSsoToken(); // Always request a new SSO token Token::getSsoToken(); // Request a new SSO token Token::forget(); // Remove APIM and SSO Tokens
Send a Request
Using Command
Send a GET request to endpoint of SIASN API
php artisan siasn:get {endpoint}
An example to get the referensi unor
php artisan siasn:get https://apimws.bkn.go.id:8243/apisiasn/1.0/referensi/ref-unor
Send a POST request to endpoint of SIASN API
php artisan siasn:post {endpoint}
Send a Request Using Class
The Siasn class uses the Http
class (Illuminate\Support\Facades\Http
) from Laravel. So you can use it just like you would use that class.
Siasn::get($endpoint, $params)
We added the withSso()
method for dual authentication purposes required by BKN. So you just need to add this method if needed, making it like the following.
Siasn::withSso()->get($endpoint, $params)
Testing
composer test
Our other cool packages
Need a package for other BKN's Web Service APIs? Consider installing our packages for seamless integration.
Referensi APIs
-
https://github.com/kanekescom/laravel-siasn-referensi-api as API client
-
https://github.com/kanekescom/laravel-siasn-referensi as backend
SIASNAPI-SIMPEG APIs
-
https://github.com/kanekescom/laravel-siasn-simpeg-api as API client
-
https://github.com/kanekescom/laravel-siasn-simpeg as backend
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.