katalam / laravel-onoffice-adapter
This is my package laravel-onoffice-adapter
Fund package maintenance!
Innobrain
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- guzzlehttp/guzzle: ^7.8
- 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
- dev-main
- v1.x-dev
- v0.13.6
- v0.13.5
- v0.13.4
- v0.13.3
- v0.13.2
- v0.13.1
- v0.13.0
- v0.12.4
- v0.12.3
- v0.12.2
- v0.12.1
- v0.12.0
- v0.11.0
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.1
- v0.9.0
- v0.8.6
- v0.8.5
- v0.8.4
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.0
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
This package is auto-updated.
Last update: 2024-09-19 08:18:23 UTC
README
An onOffice adapter for Laravel
Installation
You can install the package via composer:
composer require innobrain/laravel-onoffice-adapter
You can publish the config file with:
php artisan vendor:publish --tag="laravel-onoffice-adapter-config"
This is the contents of the published config file:
return [ /** * The base URL of the OnOffice API. * Change that if you are using a different version of the API. */ 'base_url' => 'https://api.onoffice.de/api/stable/api.php', /** * The headers to be sent with the request. * Override this if you need to send additional headers. */ 'headers' => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], /** * The token and secret to be used for authentication with the OnOffice API. */ 'token' => env('ON_OFFICE_TOKEN', ''), 'secret' => env('ON_OFFICE_SECRET', ''), ];
Usage
Repositories
- ActivityRepository
- AddressRepository
- EstateRepository
- FieldRepository
- FileRepository
- MarketplaceRepository
- RelationRepository
- SearchCriteriaRepository
- SettingRepository
Syntax for typical queries
$estates = EstateRepository::query() ->select('Id') ->where('status', 1) ->where('kaufpreis', '<', 30_000) ->orderBy('kaufpreis') ->orderByDesc('warmmiete') ->get(); $users = UserRepository::query() ->select([ 'Anrede', 'Vorname', 'Nachname', 'Mobil', ]) ->where('Nr', $this->userId) ->get();
Unusual queries
$success = MarketplaceRepository::query() ->unlockProvider($parameterCacheId, $extendedClaim);
$tmpUploadId = FileRepository::upload() ->save(base64_encode($fileContent)); $success = FileRepository::upload()->link($tmpUploadId, [ 'module' => 'estate', 'relatedRecordId' => '12345', ]); // or $success = FileRepository::upload() ->uploadInBlocks() ->saveAndLink(base64_encode($fileContent), [ 'module' => 'estate', 'relatedRecordId' => '12345', ]);
ActivityRepository::query() ->recordIds($recordIds) ->recordIdsAsAddress() ->create([ 'datetime' => $event->getDateFormatted(), 'actionkind' => 'Newsletter', 'actiontype' => 'Hard Bounce', 'note' => $message, ]);
Config::set('onoffice.token', 'token'); Config::set('onoffice.secret', 'secret'); Config::set('onoffice.api_claim', 'api_claim');
Usage in tests
use Innobrain\OnOfficeAdapter\Facades\EstateRepository; EstateRepository::fake(EstateRepository::response([ EstateRepository::page(recordFactories: [ EstateFactory::make() ->id(1), ]), ])); $response = EstateRepository::query()->get(); expect($response->count())->toBe(1) ->and($response->first()['id'])->toBe(1); EstateRepository::assertSentCount(1);
use Innobrain\OnOfficeAdapter\Facades\EstateRepository; EstateRepository::fake(EstateRepository::response([ EstateRepository::page(recordFactories: [ EstateFactory::make() ->id(1), ]), EstateRepository::page(recordFactories: [ EstateFactory::make() ->id(2), ]), ])); $response = EstateRepository::query()->get(); expect($response->count())->toBe(2) ->and($response->first()['id'])->toBe(1) ->and($response->last()['id'])->toBe(2); EstateRepository::assertSentCount(2);
use Innobrain\OnOfficeAdapter\Facades\EstateRepository; EstateRepository::preventStrayRequests(); EstateRepository::fake([ EstateRepository::response([ EstateRepository::page(recordFactories: [ EstateFactory::make() ->id(1), ]), EstateRepository::page(recordFactories: [ EstateFactory::make() ->id(2), ]), ]), EstateRepository::response([ EstateRepository::page(recordFactories: [ EstateFactory::make() ->id(3), ]), EstateRepository::page(recordFactories: [ EstateFactory::make() ->id(4), ]), ]), ]); $response = EstateRepository::query()->get(); expect($response->count())->toBe(2) ->and($response->first()['id'])->toBe(1) ->and($response->last()['id'])->toBe(2); $response = EstateRepository::query()->get(); expect($response->count())->toBe(2) ->and($response->first()['id'])->toBe(3) ->and($response->last()['id'])->toBe(4); EstateRepository::assertSentCount(4); $response = EstateRepository::query()->get(); // throws StrayRequestException
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
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.