- How do I install and configure the Asanak WebCall Client package in Laravel?
- Run `composer require asanak/laravel-web-call-client`, then publish the config with `php artisan vendor:publish --tag=asanak-config`. Add your credentials to `.env` under `ASANAK_WEB_CALL_USERNAME`, `ASANAK_WEB_CALL_PASSWORD`, and `ASANAK_WEB_CALL_BASE_URL`. The package auto-registers the service provider and facade, so no manual bootstrapping is needed.
- Which Laravel versions does this package support?
- The package is built for Laravel 9 and 10, leveraging modern PHP features like named arguments and attributes. It requires PHP 8.1+. Check the package’s changelog for updates on Laravel 11 compatibility as it evolves.
- Can I use this package for OTP call functionality?
- Yes, the package provides a dedicated method `callByOtp()` to initiate automated OTP calls. Pass the OTP code and recipient phone number as arguments, and the package handles the API request internally. Error handling is built-in via try-catch blocks.
- How do I enable logging for API requests and responses?
- Set `ASANAK_WEB_CALL_LOG=true` in your `.env` file. This will log all requests and responses to Laravel’s default log system. Logs appear in `storage/logs/laravel.log` and can be monitored via tools like Laravel Telescope.
- What happens if the API returns an error or rate limits me?
- The package includes basic error handling and retries failed requests. For rate limits, it throws exceptions that you can catch and handle in your application logic. You can extend this behavior by implementing custom middleware or listeners for pre/post-request logic.
- Is this package compatible with Laravel’s HttpClient or Guzzle?
- The package defaults to Laravel’s built-in HttpClient but can be swapped for Guzzle or other HTTP clients if needed. It abstracts the underlying client, so you retain flexibility while benefiting from the package’s convenience methods.
- How do I test this package in my Laravel application?
- Use the `WebCallClientInterface` to mock the client in unit tests. For integration tests, stub the external API responses with Laravel’s `Http::fake()` or `MockHttpClient`. The facade can be easily replaced with a mock instance during testing.
- What are the alternatives to this package for REST API integrations?
- Alternatives include `spatie/laravel-http-client` or `php-http/client`, which offer more generic HTTP client functionality. However, this package is specialized for Asanak’s WebCall API, reducing boilerplate for common operations like voice uploads, OTP calls, and call status checks.
- Can I customize the API endpoint or authentication dynamically?
- Yes, the package supports dynamic configuration via the service container. You can override the base URL, headers, or authentication credentials at runtime using Laravel’s binding or method chaining, such as `$client->setEndpoint('custom-url')`.
- Does this package support WebSocket or real-time updates for call status?
- Currently, the package focuses on REST API interactions for voice calls, OTP, and status checks. It does not support WebSocket or real-time updates. For real-time needs, you’d need to integrate a separate WebSocket client or poll the API periodically.