diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b85403..ac64587 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,29 +1,37 @@ -name: WeFact API Client +name: Tests on: [push] jobs: - wefact-api-tests: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - extensions: mbstring, intl - - - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress - - - name: Execute tests (Unit and Feature tests) via PHPUnit - run: | - vendor/bin/phpunit - - - name: Execute static analysis - run: | - vendor/bin/phpstan - + test: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['8.1', '8.2', '8.3'] + + name: PHP ${{ matrix.php-versions }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl + + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress + + - name: Execute tests (Unit and Feature tests) via PHPUnit + run: | + vendor/bin/phpunit + + - name: Execute static analysis + run: | + vendor/bin/phpstan + + - name: Execute lint check + run: | + vendor/bin/pint --test diff --git a/CHANGELOG.md b/CHANGELOG.md index b68e558..d0ec142 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Please note this changelog affects this package and not the WeFact API. See the changelog of the [WeFact API](https://www.wefact.nl/api/changelog/) for detailed information. +## [4.0.0] + +### Added + +- Add support for Laravel 11. +- Add pint for code style. + +### Removed + +- Drop support for PHP versions lower than 8.1 + ## [3.0.0] ### Changed diff --git a/README.md b/README.md index b79730a..9cbb208 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Easy WeFact API client ## Requirements -This package requires at least PHP 7.4. +This package requires at least PHP 8.1. ## Installation diff --git a/composer.json b/composer.json index 92d8bc1..ae4d95b 100644 --- a/composer.json +++ b/composer.json @@ -17,15 +17,16 @@ } ], "require": { - "php": "^7.4|^8.0", + "php": "^8.1", "ext-json": "*", "guzzlehttp/guzzle": "^7.0", - "illuminate/http": "^8.0|^9.0|^10.0", - "illuminate/support": "^8.0|^9.0|^10.0" + "illuminate/http": "^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0" }, "require-dev": { + "laravel/pint": "^1.14", "phpstan/phpstan": "^1.2", - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^9.0|^10.0" }, "autoload": { "psr-4": { diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..2c48304 --- /dev/null +++ b/pint.json @@ -0,0 +1,7 @@ +{ + "preset": "laravel", + "rules": { + "array_indentation": false, + "phpdoc_align": false + } +} diff --git a/src/Contracts/RequestContract.php b/src/Contracts/RequestContract.php index 395255e..289eea8 100644 --- a/src/Contracts/RequestContract.php +++ b/src/Contracts/RequestContract.php @@ -5,7 +5,10 @@ interface RequestContract { public function getController(): string; + public function getAction(): string; + public function getParams(): array; + public function getRequestData(): array; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactController.php b/src/Enums/WeFactController.php index 09fd3d8..7f21156 100644 --- a/src/Enums/WeFactController.php +++ b/src/Enums/WeFactController.php @@ -5,17 +5,30 @@ class WeFactController { public const ATTACHMENT = 'attachment'; + public const CREDITOR = 'creditor'; + public const DEBTOR = 'debtor'; + public const EXTRA_CLIENT_CONTACT = 'extraclientcontact'; + public const GROUP = 'group'; + public const INVOICE = 'invoice'; + public const INVOICE_LINE = 'invoiceline'; + public const PRICE_QUOTE = 'pricequote'; + public const PRICE_QUOTE_LINE = 'pricequoteline'; + public const PRODUCT = 'product'; + public const PURCHASE_INVOICE = 'creditinvoice'; + public const PURCHASE_INVOICE_LINE = 'creditinvoiceline'; + public const SETTINGS = 'settings'; + public const SUBSCRIPTION = 'subscription'; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactCurrency.php b/src/Enums/WeFactCurrency.php index e1a911a..dd4bb47 100644 --- a/src/Enums/WeFactCurrency.php +++ b/src/Enums/WeFactCurrency.php @@ -5,40 +5,76 @@ class WeFactCurrency { public const ANG = 'ANG'; + public const AED = 'AED'; + public const AUD = 'AUD'; + public const AWG = 'AWG'; + public const BGN = 'BGN'; + public const BRL = 'BRL'; + public const CAD = 'CAD'; + public const CHF = 'CHF'; + public const CNY = 'CNY'; + public const CZK = 'CZK'; + public const DKK = 'DKK'; + public const EUR = 'EUR'; + public const GBP = 'GBP'; + public const HKD = 'HKD'; + public const HRK = 'HRK'; + public const HUF = 'HUF'; + public const ILS = 'ILS'; + public const INR = 'INR'; + public const ISK = 'ISK'; + public const JPY = 'JPY'; + public const MAD = 'MAD'; + public const MXN = 'MXN'; + public const MYR = 'MYR'; + public const NOK = 'NOK'; + public const NZD = 'NZD'; + public const PHP = 'PHP'; + public const PLN = 'PLN'; + public const QAR = 'QAR'; + public const RON = 'RON'; + public const RUB = 'RUB'; + public const SEK = 'SEK'; + public const SGD = 'SGD'; + public const THB = 'THB'; + public const TRY = 'TRY'; + public const TWD = 'TWD'; + public const USD = 'USD'; + public const ZAR = 'ZAR'; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactInvoiceStatus.php b/src/Enums/WeFactInvoiceStatus.php index 21555c2..d4aad47 100644 --- a/src/Enums/WeFactInvoiceStatus.php +++ b/src/Enums/WeFactInvoiceStatus.php @@ -5,9 +5,14 @@ class WeFactInvoiceStatus { public const CONCEPT = 0; + public const SENT = 2; + public const PARTIALLY_PAYED = 3; + public const PAYED = 4; + public const CREDIT_INVOICE = 8; + public const EXPIRED = 9; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactPaymentMethod.php b/src/Enums/WeFactPaymentMethod.php index 4eb39ba..38bb7f7 100644 --- a/src/Enums/WeFactPaymentMethod.php +++ b/src/Enums/WeFactPaymentMethod.php @@ -5,13 +5,22 @@ class WeFactPaymentMethod { public const ACCOUNTING = 'accounting'; + public const CASH = 'cash'; + public const CARD = 'card'; + public const DIRECT_DEBIT = 'auth'; + public const IDEAL = 'ideal'; + public const OTHER = 'other'; + public const PAYPAL = 'paypal'; + public const QR_CODE = 'qrcode'; + public const VARIOUS = 'various'; + public const WIRE = 'wire'; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactPeriodic.php b/src/Enums/WeFactPeriodic.php index c1a4f2c..6933388 100644 --- a/src/Enums/WeFactPeriodic.php +++ b/src/Enums/WeFactPeriodic.php @@ -5,11 +5,18 @@ class WeFactPeriodic { public const NO_PERIOD = ''; + public const DAY = 'd'; + public const WEEK = 'w'; + public const MONTH = 'm'; + public const QUATER = 'k'; + public const HALF_YEAR = 'h'; + public const YEAR = 'j'; + public const TWO_YEARs = 't'; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactPriceQuoteStatus.php b/src/Enums/WeFactPriceQuoteStatus.php index d650534..4126bec 100644 --- a/src/Enums/WeFactPriceQuoteStatus.php +++ b/src/Enums/WeFactPriceQuoteStatus.php @@ -5,8 +5,12 @@ class WeFactPriceQuoteStatus { public const CONCEPT = 0; + public const SENT = 2; + public const ACCEPTED = 3; + public const BILLED = 4; + public const DECLINED = 8; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactPurchaseInvoiceStatus.php b/src/Enums/WeFactPurchaseInvoiceStatus.php index 64e7cc8..d1510f0 100644 --- a/src/Enums/WeFactPurchaseInvoiceStatus.php +++ b/src/Enums/WeFactPurchaseInvoiceStatus.php @@ -5,6 +5,8 @@ class WeFactPurchaseInvoiceStatus { public const NOT_PAYED = 1; + public const PAYED = 3; + public const CREDIT_INVOICE = 8; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactSendMethod.php b/src/Enums/WeFactSendMethod.php index 723fdca..b8f983a 100644 --- a/src/Enums/WeFactSendMethod.php +++ b/src/Enums/WeFactSendMethod.php @@ -5,6 +5,8 @@ class WeFactSendMethod { public const EMAIL = 0; + public const POST = 1; + public const BOTH = 3; -} \ No newline at end of file +} diff --git a/src/Enums/WeFactSubscriptionStatus.php b/src/Enums/WeFactSubscriptionStatus.php index 4675cb5..d2ae6b2 100644 --- a/src/Enums/WeFactSubscriptionStatus.php +++ b/src/Enums/WeFactSubscriptionStatus.php @@ -5,5 +5,6 @@ class WeFactSubscriptionStatus { public const ACTIVE = 'active'; + public const TERMINATED = 'terminated'; -} \ No newline at end of file +} diff --git a/src/WeFact.php b/src/WeFact.php index 20f0fdd..acde1f8 100644 --- a/src/WeFact.php +++ b/src/WeFact.php @@ -10,9 +10,12 @@ class WeFact extends Factory { private const API_URL = 'https://api.mijnwefact.nl/v2/'; + private const TIMEOUT = 180; - private const VERSION = '2.0.0'; - private const USER_AGENT = 'vdhicts-wefact-api-client/' . self::VERSION; + + private const VERSION = '4.0.0'; + + private const USER_AGENT = 'vdhicts-wefact-api-client/'.self::VERSION; private string $apiKey; @@ -40,4 +43,4 @@ protected function newPendingRequest(): PendingRequest ->timeout(self::TIMEOUT) ->withUserAgent(self::USER_AGENT); } -} \ No newline at end of file +} diff --git a/src/WeFactRequest.php b/src/WeFactRequest.php index b735a87..2518806 100644 --- a/src/WeFactRequest.php +++ b/src/WeFactRequest.php @@ -7,7 +7,9 @@ class WeFactRequest implements RequestContract { private string $controller; + private string $action; + private array $params; public function __construct(string $controller, string $action, array $params = []) @@ -42,4 +44,4 @@ public function getRequestData(): array $this->params ); } -} \ No newline at end of file +} diff --git a/tests/Unit/WeFactRequestTest.php b/tests/Unit/WeFactRequestTest.php index 312d7ba..b03bb12 100644 --- a/tests/Unit/WeFactRequestTest.php +++ b/tests/Unit/WeFactRequestTest.php @@ -21,4 +21,4 @@ public function testRequest(): void $this->assertSame($action, $request->getAction()); $this->assertCount(1, $request->getParams()); } -} \ No newline at end of file +}