Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3d34db3
Fixed #197
StanBarrows Oct 17, 2025
6087c04
Resolved #189, updated Docs and Tests for Enums
StanBarrows Oct 17, 2025
b96f386
Removed phpunit cache
StanBarrows Oct 17, 2025
30b8d82
Resolved #188
StanBarrows Oct 17, 2025
fd4e1cf
wip
StanBarrows Oct 17, 2025
ee22c40
Merge branch 'main' into feature-a-few-fixes
StanBarrows Oct 17, 2025
d8c2a1a
Minor code improvements
StanBarrows Oct 17, 2025
56b872e
Improved TransferDocument Request
StanBarrows Oct 17, 2025
083a264
Merge branch 'main' of github.com:codebar-ag/laravel-docuware into fe…
StanBarrows Nov 14, 2025
9de480b
Security updates
StanBarrows Mar 20, 2026
ddae347
Optimized Repository Skeleton
StanBarrows Mar 20, 2026
72a9de0
chore: sync Laravel Pint workflow from template
StanBarrows Mar 20, 2026
81ff180
chore: sync CONTRIBUTING.md from template
StanBarrows Mar 20, 2026
928c56c
chore: sync security policy from template
StanBarrows Mar 20, 2026
61ccea0
chore: sync PHPStan workflow from template
StanBarrows Mar 21, 2026
6661fd2
chore: sync Laravel Pint workflow from template
StanBarrows Mar 21, 2026
8720eaf
chore: sync Dependabot config and workflows from template
StanBarrows Mar 21, 2026
6ca012b
chore: sync Laravel Pint workflow from template
StanBarrows Mar 21, 2026
8a79d8b
chore: sync PHPStan workflow from template
StanBarrows Mar 21, 2026
b527192
chore: sync release workflow from template
StanBarrows Mar 21, 2026
da18fe8
Optimized Repository Skeleton
StanBarrows Mar 21, 2026
aff5617
chore: sync CONTRIBUTING.md from template
StanBarrows Mar 21, 2026
4fe6613
chore: sync security policy from template
StanBarrows Mar 21, 2026
43984b5
Optimized Repository Skeleton
StanBarrows Mar 26, 2026
abd68bc
Merge remote-tracking branch 'origin/main'
StanBarrows Mar 26, 2026
a9fbe31
Optimized Repository Skeleton
StanBarrows Mar 26, 2026
74c8e09
chore: sync dependency audit workflows from template
StanBarrows Mar 26, 2026
1ab8848
Merge remote-tracking branch 'origin/main'
StanBarrows Mar 26, 2026
62b59c3
chore: sync GitHub issue templates
StanBarrows Apr 3, 2026
7209cf8
chore: sync Laravel Pint workflow from template
StanBarrows Apr 3, 2026
e7a27df
chore: sync PHPStan workflow from template
StanBarrows Apr 3, 2026
9a02f11
chore: sync dependency audit workflows from template
StanBarrows Apr 3, 2026
d843cfc
chore: sync Dependabot config and workflows from template
StanBarrows Apr 3, 2026
fec181b
Laravel 13
StanBarrows Apr 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ We're sorry to hear you have a problem. Can you help us solve it by providing th
attributes:
label: PHP Version
description: What version of PHP are you running? Please be as specific as possible
placeholder: "8.4.0"
value: "8.4.0"
placeholder: "8.5.0"
value: "8.5.0"
validations:
required: true
- type: input
id: laravel-version
attributes:
label: Laravel Version
description: What version of Laravel are you running? Please be as specific as possible
placeholder: "12.0.0"
value: "12.0.0"
placeholder: "13.0.0"
value: "13.0.0"
validations:
required: true
- type: dropdown
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/composer-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Composer audit

on:
push:
paths:
- 'composer.json'
- 'composer.lock'
pull_request:
paths:
- 'composer.json'
- 'composer.lock'
schedule:
- cron: '0 6 * * 1'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
composer-audit:
name: composer audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6.0.2

- name: Setup PHP
uses: shivammathur/setup-php@2.37.0
with:
php-version: '8.5'
coverage: none

- name: Resolve dependencies and audit
run: |
composer update --no-interaction --no-ansi
composer audit
4 changes: 3 additions & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2.5.0
uses: dependabot/fetch-metadata@v3.0.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6.0.2

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@2.6
- name: Setup PHP
uses: shivammathur/setup-php@2.37.0
with:
php-version: '8.5'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@4.0.0

- name: Run Laravel Pint
run: vendor/bin/pint

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v7.1.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@2.37.0
with:
php-version: '8.4'
php-version: '8.5'
coverage: none

- name: Install composer dependencies
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ jobs:
max-parallel: 1
matrix:
os: [ ubuntu-latest ]
php: [ 8.2, 8.3, 8.4 ]
laravel: [ 12.* ]
php: [ 8.3, 8.4, 8.5 ]
laravel: [ 13.* ]
stability: [ prefer-lowest, prefer-stable ]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
coverage: pcov

- name: Setup problem matchers
run: |
Expand All @@ -41,10 +41,10 @@ jobs:
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
- name: Copy PHPUnit configuration
run: cp phpunit.xml.dist phpunit.xml

- name: Execute tests
- name: Run Pest tests
run: vendor/bin/pest
env:
DOCUWARE_URL: ${{ secrets.DOCUWARE_URL }}
Expand All @@ -54,7 +54,7 @@ jobs:

- name: Store Log Artifacts
if: failure()
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v6
with:
name: Store report artifacts
path: ./vendor/orchestra/testbench-core/laravel/storage/logs
41 changes: 22 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,27 @@
}
],
"require": {
"php": "8.2.*|8.3.*|8.4.*",
"guzzlehttp/guzzle": "^7.8",
"illuminate/contracts": "^12.0",
"nesbot/carbon": "^3.8",
"php": "8.3.*|8.4.*|8.5.*",
"guzzlehttp/guzzle": "^7.9.2",
"illuminate/contracts": "^13.0",
"illuminate/support": "^13.0",
"nesbot/carbon": "^3.8.4",
"saloonphp/cache-plugin": "^3.1",
"saloonphp/laravel-plugin": "^3.0|^4.0",
"saloonphp/saloon": "^3.0|^4.0",
"spatie/laravel-package-tools": "^1.19"
"saloonphp/laravel-plugin": "^4.0",
"saloonphp/saloon": "^4.0",
"spatie/laravel-package-tools": "^1.19.0"
},
"require-dev": {
"laravel/pint": "^1.21",
"larastan/larastan": "^v3.1",
"orchestra/testbench": "^10.0",
"pestphp/pest": "^3.7",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"spatie/laravel-ray": "^1.39"
"laravel/pint": "^1.21.1",
"larastan/larastan": "^3.9.3",
"nunomaduro/collision": "^8.9",
"orchestra/testbench": "^11.0",
"pestphp/pest": "^4.4",
"phpdocumentor/reflection-docblock": "^5.6.1",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan-deprecation-rules": "^2.0.1",
"phpstan/phpstan-phpunit": "^2.0.4",
"spatie/laravel-ray": "^1.40.0"
},
"autoload": {
"psr-4": {
Expand All @@ -53,16 +56,16 @@
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test": "vendor/bin/pest --no-coverage",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"phpstan/extension-installer": true,
"pestphp/pest-plugin": true
"composer/package-versions-deprecated": false,
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 5
level: 6
paths:
- src
- config
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" backupGlobals="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" backupGlobals="false"
bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false"
executionOrder="defects" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
Expand Down
45 changes: 21 additions & 24 deletions src/Connectors/DocuWareConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Psr\SimpleCache\InvalidArgumentException;
use Saloon\Http\Auth\TokenAuthenticator;
use Saloon\Http\Connector;
use Saloon\Http\Response;

class DocuWareConnector extends Connector
{
Expand Down Expand Up @@ -48,42 +49,40 @@ protected function defaultAuth(): TokenAuthenticator
return new TokenAuthenticator($this->getOrCreateNewOAuthToken());
}

protected function oauthTokenCacheTtlSeconds(RequestTokenDto $token): int
{
return max(1, $token->expiresIn - 60);
}

/**
* @throws InvalidArgumentException
* @throws \Exception
*/
protected function getOrCreateNewOAuthToken(): string
{
$cache = Cache::store($this->configuration->cacheDriver);

$cacheKey = 'docuware.oauth.'.$this->configuration->identifier;

// Check if the token exists in cache and return it if found
if ($cache->has($cacheKey)) {
$token = Crypt::decrypt($cache->get($cacheKey));
DocuWareOAuthLog::dispatch($this->configuration->url, $this->configuration->username, 'Token retrieved from cache');

return $token->accessToken;
}

// Handle token retrieval for ConfigWithCredentials
if ($this->configuration instanceof ConfigWithCredentials) {
$token = $this->getNewOAuthTokenWithCredentials();
DocuWareOAuthLog::dispatch($this->configuration->url, $this->configuration->username, 'Token retrieved from API');
$cache->put($cacheKey, Crypt::encrypt($token), $token->expiresIn - 60);
$cache->put($cacheKey, Crypt::encrypt($token), $this->oauthTokenCacheTtlSeconds($token));

return $token->accessToken;
}

// Handle token retrieval for ConfigWithCredentialsTrustedUser
// @phpstan-ignore-next-line
if ($this->configuration instanceof ConfigWithCredentialsTrustedUser) {
$token = $this->getNewOAuthTokenWithCredentialsTrustedUser();
DocuWareOAuthLog::dispatch($this->configuration->url, $this->configuration->username, 'Token retrieved from API');
$cache->put($cacheKey, Crypt::encrypt($token), $token->expiresIn - 60);
$token = $this->getNewOAuthTokenWithCredentialsTrustedUser();
DocuWareOAuthLog::dispatch($this->configuration->url, $this->configuration->username, 'Token retrieved from API');
$cache->put($cacheKey, Crypt::encrypt($token), $this->oauthTokenCacheTtlSeconds($token));

return $token->accessToken;
}
return $token->accessToken;
}

protected function getAuthenticationTokenEndpoint(): IdentityServiceConfiguration
Expand Down Expand Up @@ -111,18 +110,7 @@ protected function getNewOAuthTokenWithCredentials(): RequestTokenDto
password: $this->configuration->password,
))->send();

throw_if(
$requestTokenResponse->failed(),
trim(preg_replace('/\s\s+/', ' ', Arr::get(
array: $requestTokenResponse->json(),
key: 'error_description',
default: $requestTokenResponse->body()
)))
);

throw_if($requestTokenResponse->dto() == null, 'Token response is null');

return $requestTokenResponse->dto();
return $this->ensureRequestTokenSuccess($requestTokenResponse);
}

/**
Expand All @@ -140,6 +128,15 @@ protected function getNewOAuthTokenWithCredentialsTrustedUser(): RequestTokenDto
impersonateName: $this->configuration->impersonatedUsername,
))->send();

return $this->ensureRequestTokenSuccess($requestTokenResponse);
}

/**
* @throws \Throwable
* @throws \JsonException
*/
protected function ensureRequestTokenSuccess(Response $requestTokenResponse): RequestTokenDto
{
throw_if(
$requestTokenResponse->failed(),
trim(preg_replace('/\s\s+/', ' ', Arr::get(
Expand Down
Loading
Loading