/laravel-polar-api

An API wrapper for the Polar API

Primary LanguagePHPMIT LicenseMIT

Polar Branding Laravel Polar API

Larastan Static Analysis Laravel Pint Pest Testing Suite Pest Type Coverage Packagist Version Packagist Downloads

Laravel Polar API is a Laravel package that provides an API wrapper for polar.sh API. This package simplifies the process of interacting with the Polar API by providing a set of convenient methods and classes.

Installation

To install the package, you can use Composer:

composer require hdinnovations/laravel-polar-api

Configuration

After installing the package, you need to publish the configuration file:

php artisan vendor:publish --provider="HDInnovations\LaravelPolarApi\Providers\PolarApiServiceProvider"

This command will publish a polar-api.php file in your config directory. You can use this file to configure the package. The configuration file contains the following options:

  • base_url: The base URL of the POLAR API.
  • token: The token (PAT) used to authenticate requests to the POLAR API.

You can also set the POLAR_API_BASE_URL and POLAR_API_TOKEN environment variables in your .env file which is recommended.

Usage Documentation

Please refer to our documentation for detailed information on how to use this package and the endpoints + parameters it supports.

Exceptions

The package throws the following exceptions:

  • HDInnovations\LaravelPolarApi\Exceptions\PolarApiNotFoundException: Thrown when the requested resource is not found.
  • HDInnovations\LaravelPolarApi\Exceptions\PolarApiUnprocessableEntityException: Thrown when the request is invalid.
  • HDInnovations\LaravelPolarApi\Exceptions\PolarApiValidationException: Thrown when the request validation fails.
  • HDInnovations\LaravelPolarApi\Exceptions\PolarApiUnauthorizedException: Thrown when the request is unauthorized.

Testing

To run the tests, use the following command:

composer test

Test Coverage

To generate the test coverage, use the following command:

composer test-coverage

Static Analysis

To run static analysis, use the following command:

composer analyze

Type Coverage

To check the type coverage, use the following command:

composer test-type-coverage

License

The package is open-source software licensed under the MIT license.

Roadmap

  • Support all GET requests
  • Support all POST requests
  • Support all PUT requests
  • Support all DELETE requests
  • Add more exception handling
  • Add more examples
  • 100% test coverage
  • 100% type coverage