Skip to content

Commit

Permalink
Merge pull request #1 from innobraingmbh/v1
Browse files Browse the repository at this point in the history
V1
  • Loading branch information
Katalam authored Sep 19, 2024
2 parents ec19b18 + 219814e commit f952bbe
Show file tree
Hide file tree
Showing 173 changed files with 2,905 additions and 2,475 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: Katalam
github: Innobrain
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/Katalam/laravel-onoffice-adapter/discussions/new?category=q-a
url: https://github.com/Innobrain/laravel-onoffice-adapter/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/Katalam/laravel-onoffice-adapter/discussions/new?category=ideas
url: https://github.com/Innobrain/laravel-onoffice-adapter/discussions/new?category=ideas
about: Share ideas for new features
- name: Report a security issue
url: https://github.com/Katalam/laravel-onoffice-adapter/security/policy
url: https://github.com/Innobrain/laravel-onoffice-adapter/security/policy
about: Learn how to notify us for sensitive bugs
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
build
composer.lock
coverage
docs
phpunit.xml
phpstan.neon
testbench.yaml
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
## main

## v1.0.0
- Overhaul of the package to use a new fake implementation
- Overhaul of the package to remove the fake builder classes
- Added the ability to call a custom request

## v0.13.6
- Fixed typo on relation create

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Katalam <[email protected]>
Copyright (c) Innobrain <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
141 changes: 108 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# onOffice Adapter for Laravel

[![Latest Version on Packagist](https://img.shields.io/packagist/v/katalam/laravel-onoffice-adapter.svg?style=flat-square)](https://packagist.org/packages/katalam/laravel-onoffice-adapter)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/katalam/laravel-onoffice-adapter/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/katalam/laravel-onoffice-adapter/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/katalam/laravel-onoffice-adapter/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/katalam/laravel-onoffice-adapter/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/katalam/laravel-onoffice-adapter.svg?style=flat-square)](https://packagist.org/packages/katalam/laravel-onoffice-adapter)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/innobrain/laravel-onoffice-adapter.svg?style=flat-square)](https://packagist.org/packages/innobrain/laravel-onoffice-adapter)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/innobrain/laravel-onoffice-adapter/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/innobrain/laravel-onoffice-adapter/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/innobrain/laravel-onoffice-adapter/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/innobrain/laravel-onoffice-adapter/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/innobrain/laravel-onoffice-adapter.svg?style=flat-square)](https://packagist.org/packages/innobrain/laravel-onoffice-adapter)

An onOffice adapter for Laravel

Expand All @@ -12,7 +12,7 @@ An onOffice adapter for Laravel
You can install the package via composer:

```bash
composer require katalam/laravel-onoffice-adapter
composer require innobrain/laravel-onoffice-adapter
```

You can publish the config file with:
Expand Down Expand Up @@ -50,6 +50,18 @@ return [

## Usage

### Repositories
* ActivityRepository
* AddressRepository
* EstateRepository
* FieldRepository
* FileRepository
* MarketplaceRepository
* RelationRepository
* SearchCriteriaRepository
* SettingRepository

### Syntax for typical queries
```php
$estates = EstateRepository::query()
->select('Id')
Expand All @@ -59,9 +71,6 @@ $estates = EstateRepository::query()
->orderByDesc('warmmiete')
->get();

$success = MarketplaceRepository::query()
->unlockProvider($parameterCacheId, $extendedClaim);

$users = UserRepository::query()
->select([
'Anrede',
Expand All @@ -72,16 +81,29 @@ $users = UserRepository::query()
->where('Nr', $this->userId)
->get();
```

### Unusual queries
```php
$success = MarketplaceRepository::query()
->unlockProvider($parameterCacheId, $extendedClaim);
```
```php
$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',
]);
```
```php
ActivityRepository::query()
->recordIds($recordIds)
Expand All @@ -102,33 +124,86 @@ Config::set('onoffice.api_claim', 'api_claim');

### Usage in tests
```php
EstateRepository::fake([ // First request
[ // First page of first request
EstateFactory::make() // First record of first page of first request
->id(1)
->set('foo', 'bar'),
],
], [ // Second request
[ // First page of second request
EstateFactory::make() // First record of first page of second request
->id(2)
->set('foo', 'baz'),
EstateFactory::make() // Second record of first page of second request
->id(3),
],
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);
```
```php
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);
```
```php
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),
]),
]),
]);

// request as normal
$estates = EstateRepository::query()->get();
$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($estates)->toHaveCount(1)
->and($estates->first()['id'])->toBe(1);
expect($response->count())->toBe(2)
->and($response->first()['id'])->toBe(3)
->and($response->last()['id'])->toBe(4);

$estates = EstateRepository::query()->get();
EstateRepository::assertSentCount(4);

expect($estates)->toHaveCount(2)
->and($estates->first()['id'])->toBe(2)
->and($estates->last()['id'])->toBe(3);
$response = EstateRepository::query()->get(); // throws StrayRequestException
```

## Testing
Expand All @@ -147,7 +222,7 @@ Please review [our security policy](../../security/policy) on how to report secu

## Credits

- [Bruno Görß](https://github.com/Katalam)
- [Bruno Görß](https://github.com/Innobrain)
- [All Contributors](../../contributors)

## License
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "katalam/laravel-onoffice-adapter",
"name": "innobrain/laravel-onoffice-adapter",
"description": "This is my package laravel-onoffice-adapter",
"keywords": [
"Katalam",
"laravel",
"laravel-onoffice-adapter"
],
"homepage": "https://github.com/katalam/laravel-onoffice-adapter",
"homepage": "https://github.com/innobraingmbh/laravel-onoffice-adapter",
"license": "MIT",
"authors": [
{
Expand Down Expand Up @@ -35,13 +35,13 @@
},
"autoload": {
"psr-4": {
"Katalam\\OnOfficeAdapter\\": "src/",
"Katalam\\OnOfficeAdapter\\Database\\Factories\\": "database/factories/"
"Innobrain\\OnOfficeAdapter\\": "src/",
"Innobrain\\OnOfficeAdapter\\Database\\Factories\\": "database/factories/"
}
},
"autoload-dev": {
"psr-4": {
"Katalam\\OnOfficeAdapter\\Tests\\": "tests/"
"Innobrain\\OnOfficeAdapter\\Tests\\": "tests/"
}
},
"scripts": {
Expand Down Expand Up @@ -72,7 +72,7 @@
"extra": {
"laravel": {
"providers": [
"Katalam\\OnOfficeAdapter\\OnOfficeAdapterServiceProvider"
"Innobrain\\OnOfficeAdapter\\OnOfficeAdapterServiceProvider"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion config/onoffice.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

// config for Katalam/OnOfficeAdapter
// config for Innobrain/OnOfficeAdapter
return [
/**
* The base URL of the OnOffice API.
Expand Down
45 changes: 45 additions & 0 deletions docs/ActivityRepository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Activity Repository

## Estates
```php
use Innobrain\OnOfficeAdapter\Facades\ActivityRepository;

$activities = ActivityRepository::query()
->recordIdsAsAddress()
->recordIdsAsEstate()
->estate()
->address()
->recordIds([1, 2, 3])
->get();

$activity = ActivityRepository::query()
->recordIdsAsAddress()
->recordIdsAsEstate()
->estate()
->address()
->recordIds([1, 2, 3])
->first();

$activity = ActivityRepository::query()
->find(1);

ActivityRepository::query()
->recordIdsAsAddress()
->recordIdsAsEstate()
->estate()
->address()
->recordIds([1, 2, 3])
->each(function (array $estates) {
// First page
});

$activity = ActivityRepository::query()
->recordIdsAsAddress()
->recordIdsAsEstate()
->estate()
->address()
->recordIds([1, 2, 3])
->create([
'activity_id' => 1,
]);
```
44 changes: 44 additions & 0 deletions docs/AddressRepository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Address Repository

## Estates
```php
use Innobrain\OnOfficeAdapter\Facades\AddressRepository;

$addresses = AddressRepository::query()
->addCountryIsoCodeType('DE')
->recordIds([1, 2, 3])
->get();

$address = AddressRepository::query()
->addCountryIsoCodeType('DE')
->recordIds([1, 2, 3])
->first();

$address = AddressRepository::query()
->addCountryIsoCodeType('DE')
->find(1);

AddressRepository::query()
->addCountryIsoCodeType('DE')
->recordIds([1, 2, 3])
->each(function (array $estates) {
// First page
});

AddressRepository::query()
->addModify('address_id', 1)
->modify(1);

$addressCounted = AddressRepository::query()
->recordIds([1, 2, 3])
->count();

$estate = AddressRepository::query()
->create([
'estate_id' => 1,
]);

$addresses = AddressRepository::query()
->setInput('foo')
->search();
```
Loading

0 comments on commit f952bbe

Please sign in to comment.