diff --git a/composer.json b/composer.json index 0699314..a398463 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,12 @@ ], "require": { "php": "^8.2", - "guzzlehttp/guzzle": "^7.5", + "guzzlehttp/guzzle": "^7.6", "illuminate/contracts": "^9.0|^10.0", "nesbot/carbon": "^2.64.0", - "saloonphp/cache-plugin": "^2.0", - "saloonphp/saloon": "^2.0", - "saloonphp/laravel-plugin": "^2.0", + "saloonphp/cache-plugin": "^3.0", + "saloonphp/saloon": "^3.0", + "saloonphp/laravel-plugin": "^3.0", "spatie/laravel-package-tools": "^1.14.0" }, "require-dev": { diff --git a/src/Events/DocuWareResponseLog.php b/src/Events/DocuWareResponseLog.php index e6f02f0..662bb76 100644 --- a/src/Events/DocuWareResponseLog.php +++ b/src/Events/DocuWareResponseLog.php @@ -6,7 +6,6 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Http\Client\Response; use Illuminate\Queue\SerializesModels; -use Saloon\Contracts\Response as SaloonContracts; use Saloon\Http\Response as SaloonResponse; class DocuWareResponseLog @@ -16,7 +15,7 @@ class DocuWareResponseLog use SerializesModels; public function __construct( - public Response|SaloonResponse|SaloonContracts $response + public Response|SaloonResponse $response ) { } } diff --git a/src/Requests/Auth/PostLoginRequest.php b/src/Requests/Auth/PostLoginRequest.php index 7331d39..e14deb6 100644 --- a/src/Requests/Auth/PostLoginRequest.php +++ b/src/Requests/Auth/PostLoginRequest.php @@ -5,8 +5,8 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; use Saloon\Contracts\Body\HasBody; -use Saloon\Contracts\Response; use Saloon\Enums\Method; +use Saloon\Http\Response; use Saloon\Http\SoloRequest; use Saloon\Traits\Body\HasFormBody; diff --git a/src/Requests/Dialogs/GetDialogRequest.php b/src/Requests/Dialogs/GetDialogRequest.php index 1a7b0c6..4dadfcd 100644 --- a/src/Requests/Dialogs/GetDialogRequest.php +++ b/src/Requests/Dialogs/GetDialogRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDialogRequest extends Request implements Cacheable { diff --git a/src/Requests/Dialogs/GetDialogsRequest.php b/src/Requests/Dialogs/GetDialogsRequest.php index 866c812..f21437d 100644 --- a/src/Requests/Dialogs/GetDialogsRequest.php +++ b/src/Requests/Dialogs/GetDialogsRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDialogsRequest extends Request implements Cacheable { diff --git a/src/Requests/Document/DeleteDocumentRequest.php b/src/Requests/Document/DeleteDocumentRequest.php index 967c0b6..f48ae9b 100644 --- a/src/Requests/Document/DeleteDocumentRequest.php +++ b/src/Requests/Document/DeleteDocumentRequest.php @@ -3,9 +3,9 @@ namespace CodebarAg\DocuWare\Requests\Document; use CodebarAg\DocuWare\Responses\Document\DeleteDocumentResponse; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class DeleteDocumentRequest extends Request { diff --git a/src/Requests/Document/GetDocumentCountRequest.php b/src/Requests/Document/GetDocumentCountRequest.php index 15d5fba..863e0f9 100644 --- a/src/Requests/Document/GetDocumentCountRequest.php +++ b/src/Requests/Document/GetDocumentCountRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDocumentCountRequest extends Request implements Cacheable { diff --git a/src/Requests/Document/GetDocumentDownloadRequest.php b/src/Requests/Document/GetDocumentDownloadRequest.php index a6dcbe0..157720d 100644 --- a/src/Requests/Document/GetDocumentDownloadRequest.php +++ b/src/Requests/Document/GetDocumentDownloadRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDocumentDownloadRequest extends Request implements Cacheable { diff --git a/src/Requests/Document/GetDocumentPreviewRequest.php b/src/Requests/Document/GetDocumentPreviewRequest.php index e42ee73..2afc2f7 100644 --- a/src/Requests/Document/GetDocumentPreviewRequest.php +++ b/src/Requests/Document/GetDocumentPreviewRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDocumentPreviewRequest extends Request implements Cacheable { diff --git a/src/Requests/Document/GetDocumentRequest.php b/src/Requests/Document/GetDocumentRequest.php index 880da53..8f07f40 100644 --- a/src/Requests/Document/GetDocumentRequest.php +++ b/src/Requests/Document/GetDocumentRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDocumentRequest extends Request implements Cacheable { diff --git a/src/Requests/Document/GetDocumentsDownloadRequest.php b/src/Requests/Document/GetDocumentsDownloadRequest.php index 5479b53..79ac015 100644 --- a/src/Requests/Document/GetDocumentsDownloadRequest.php +++ b/src/Requests/Document/GetDocumentsDownloadRequest.php @@ -9,9 +9,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDocumentsDownloadRequest extends Request implements Cacheable { diff --git a/src/Requests/Document/GetDocumentsRequest.php b/src/Requests/Document/GetDocumentsRequest.php index d5684e6..6f6745c 100644 --- a/src/Requests/Document/GetDocumentsRequest.php +++ b/src/Requests/Document/GetDocumentsRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDocumentsRequest extends Request implements Cacheable { diff --git a/src/Requests/Document/PostDocumentRequest.php b/src/Requests/Document/PostDocumentRequest.php index 9b73cdf..9c4a126 100644 --- a/src/Requests/Document/PostDocumentRequest.php +++ b/src/Requests/Document/PostDocumentRequest.php @@ -6,10 +6,10 @@ use CodebarAg\DocuWare\Responses\Document\PostDocumentResponse; use Illuminate\Support\Collection; use Saloon\Contracts\Body\HasBody; -use Saloon\Contracts\Response; use Saloon\Data\MultipartValue; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; use Saloon\Traits\Body\HasMultipartBody; class PostDocumentRequest extends Request implements HasBody diff --git a/src/Requests/Document/PostTransferDocumentRequest.php b/src/Requests/Document/PostTransferDocumentRequest.php index 02dc47c..171791a 100644 --- a/src/Requests/Document/PostTransferDocumentRequest.php +++ b/src/Requests/Document/PostTransferDocumentRequest.php @@ -4,9 +4,9 @@ use CodebarAg\DocuWare\Responses\Document\PostTransferDocumentResponse; use Saloon\Contracts\Body\HasBody; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; class PostTransferDocumentRequest extends Request implements HasBody diff --git a/src/Requests/Document/PutDocumentFieldsRequest.php b/src/Requests/Document/PutDocumentFieldsRequest.php index 1ad7960..3ff1712 100644 --- a/src/Requests/Document/PutDocumentFieldsRequest.php +++ b/src/Requests/Document/PutDocumentFieldsRequest.php @@ -5,9 +5,9 @@ use CodebarAg\DocuWare\Exceptions\UnableToUpdateFields; use CodebarAg\DocuWare\Responses\Document\PutDocumentFieldsResponse; use Saloon\Contracts\Body\HasBody; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; class PutDocumentFieldsRequest extends Request implements HasBody diff --git a/src/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequest.php b/src/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequest.php index 5d33397..a3910e1 100644 --- a/src/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequest.php +++ b/src/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetDocumentDownloadThumbnailRequest extends Request implements Cacheable { diff --git a/src/Requests/Fields/GetFieldsRequest.php b/src/Requests/Fields/GetFieldsRequest.php index 0a6f779..c62fabc 100644 --- a/src/Requests/Fields/GetFieldsRequest.php +++ b/src/Requests/Fields/GetFieldsRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetFieldsRequest extends Request implements Cacheable { diff --git a/src/Requests/FileCabinets/GetFileCabinetsRequest.php b/src/Requests/FileCabinets/GetFileCabinetsRequest.php index cf758e3..e3021f1 100644 --- a/src/Requests/FileCabinets/GetFileCabinetsRequest.php +++ b/src/Requests/FileCabinets/GetFileCabinetsRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetFileCabinetsRequest extends Request implements Cacheable { diff --git a/src/Requests/Organization/GetOrganizationRequest.php b/src/Requests/Organization/GetOrganizationRequest.php index 4c1001c..9b30864 100644 --- a/src/Requests/Organization/GetOrganizationRequest.php +++ b/src/Requests/Organization/GetOrganizationRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetOrganizationRequest extends Request implements Cacheable { diff --git a/src/Requests/Organization/GetOrganizationsRequest.php b/src/Requests/Organization/GetOrganizationsRequest.php index f9d11ac..31b072b 100644 --- a/src/Requests/Organization/GetOrganizationsRequest.php +++ b/src/Requests/Organization/GetOrganizationsRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetOrganizationsRequest extends Request implements Cacheable { diff --git a/src/Requests/Search/GetSearchRequest.php b/src/Requests/Search/GetSearchRequest.php index e047257..84ac157 100644 --- a/src/Requests/Search/GetSearchRequest.php +++ b/src/Requests/Search/GetSearchRequest.php @@ -8,9 +8,9 @@ use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; use Saloon\Contracts\Body\HasBody; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; class GetSearchRequest extends Request implements Cacheable, HasBody diff --git a/src/Requests/Sections/GetSectionsRequest.php b/src/Requests/Sections/GetSectionsRequest.php index fea39ab..280bc87 100644 --- a/src/Requests/Sections/GetSectionsRequest.php +++ b/src/Requests/Sections/GetSectionsRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetSectionsRequest extends Request implements Cacheable { diff --git a/src/Requests/SelectList/GetSelectListRequest.php b/src/Requests/SelectList/GetSelectListRequest.php index 68b1c04..beb9631 100644 --- a/src/Requests/SelectList/GetSelectListRequest.php +++ b/src/Requests/SelectList/GetSelectListRequest.php @@ -7,9 +7,9 @@ use Saloon\CachePlugin\Contracts\Cacheable; use Saloon\CachePlugin\Drivers\LaravelCacheDriver; use Saloon\CachePlugin\Traits\HasCaching; -use Saloon\Contracts\Response; use Saloon\Enums\Method; use Saloon\Http\Request; +use Saloon\Http\Response; class GetSelectListRequest extends Request implements Cacheable { diff --git a/src/Responses/Dialogs/GetDialogResponse.php b/src/Responses/Dialogs/GetDialogResponse.php index 23cf257..ad09963 100644 --- a/src/Responses/Dialogs/GetDialogResponse.php +++ b/src/Responses/Dialogs/GetDialogResponse.php @@ -5,7 +5,7 @@ use CodebarAg\DocuWare\DTO\Dialog; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDialogResponse { diff --git a/src/Responses/Dialogs/GetDialogsResponse.php b/src/Responses/Dialogs/GetDialogsResponse.php index 819f207..2f2c0d3 100644 --- a/src/Responses/Dialogs/GetDialogsResponse.php +++ b/src/Responses/Dialogs/GetDialogsResponse.php @@ -7,7 +7,7 @@ use CodebarAg\DocuWare\Support\EnsureValidResponse; use Illuminate\Support\Collection; use Illuminate\Support\Enumerable; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDialogsResponse { diff --git a/src/Responses/Document/DeleteDocumentResponse.php b/src/Responses/Document/DeleteDocumentResponse.php index b6cd064..8d408a1 100644 --- a/src/Responses/Document/DeleteDocumentResponse.php +++ b/src/Responses/Document/DeleteDocumentResponse.php @@ -4,7 +4,7 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class DeleteDocumentResponse { diff --git a/src/Responses/Document/GetDocumentCountResponse.php b/src/Responses/Document/GetDocumentCountResponse.php index 92a3f34..6c97d7a 100644 --- a/src/Responses/Document/GetDocumentCountResponse.php +++ b/src/Responses/Document/GetDocumentCountResponse.php @@ -6,7 +6,7 @@ use CodebarAg\DocuWare\Exceptions\UnableToGetDocumentCount; use CodebarAg\DocuWare\Support\EnsureValidResponse; use Illuminate\Support\Arr; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDocumentCountResponse { diff --git a/src/Responses/Document/GetDocumentDownloadResponse.php b/src/Responses/Document/GetDocumentDownloadResponse.php index b50242a..0741be1 100644 --- a/src/Responses/Document/GetDocumentDownloadResponse.php +++ b/src/Responses/Document/GetDocumentDownloadResponse.php @@ -4,7 +4,7 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDocumentDownloadResponse { diff --git a/src/Responses/Document/GetDocumentPreviewResponse.php b/src/Responses/Document/GetDocumentPreviewResponse.php index 716b450..8800cd7 100644 --- a/src/Responses/Document/GetDocumentPreviewResponse.php +++ b/src/Responses/Document/GetDocumentPreviewResponse.php @@ -4,7 +4,7 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDocumentPreviewResponse { diff --git a/src/Responses/Document/GetDocumentResponse.php b/src/Responses/Document/GetDocumentResponse.php index c928c56..4abc76d 100644 --- a/src/Responses/Document/GetDocumentResponse.php +++ b/src/Responses/Document/GetDocumentResponse.php @@ -5,7 +5,7 @@ use CodebarAg\DocuWare\DTO\Document; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDocumentResponse { diff --git a/src/Responses/Document/GetDocumentsDownloadResponse.php b/src/Responses/Document/GetDocumentsDownloadResponse.php index 4a4859a..d7891c7 100644 --- a/src/Responses/Document/GetDocumentsDownloadResponse.php +++ b/src/Responses/Document/GetDocumentsDownloadResponse.php @@ -4,7 +4,7 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDocumentsDownloadResponse { diff --git a/src/Responses/Document/GetDocumentsResponse.php b/src/Responses/Document/GetDocumentsResponse.php index ac5fe7c..bb8f1a5 100644 --- a/src/Responses/Document/GetDocumentsResponse.php +++ b/src/Responses/Document/GetDocumentsResponse.php @@ -6,7 +6,7 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; use Illuminate\Support\Collection; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDocumentsResponse { diff --git a/src/Responses/Document/PostDocumentResponse.php b/src/Responses/Document/PostDocumentResponse.php index cb45ed1..8e2c1b2 100644 --- a/src/Responses/Document/PostDocumentResponse.php +++ b/src/Responses/Document/PostDocumentResponse.php @@ -5,7 +5,7 @@ use CodebarAg\DocuWare\DTO\Document; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class PostDocumentResponse { diff --git a/src/Responses/Document/PostTransferDocumentResponse.php b/src/Responses/Document/PostTransferDocumentResponse.php index bc32714..b497829 100644 --- a/src/Responses/Document/PostTransferDocumentResponse.php +++ b/src/Responses/Document/PostTransferDocumentResponse.php @@ -4,7 +4,7 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class PostTransferDocumentResponse { diff --git a/src/Responses/Document/PutDocumentFieldsResponse.php b/src/Responses/Document/PutDocumentFieldsResponse.php index 9abb91f..b1e7937 100644 --- a/src/Responses/Document/PutDocumentFieldsResponse.php +++ b/src/Responses/Document/PutDocumentFieldsResponse.php @@ -6,7 +6,7 @@ use CodebarAg\DocuWare\Support\EnsureValidResponse; use CodebarAg\DocuWare\Support\ParseValue; use Illuminate\Support\Collection; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class PutDocumentFieldsResponse { diff --git a/src/Responses/Document/Thumbnail/GetDocumentDownloadThumbnailResponse.php b/src/Responses/Document/Thumbnail/GetDocumentDownloadThumbnailResponse.php index 7b0a635..40dda9f 100644 --- a/src/Responses/Document/Thumbnail/GetDocumentDownloadThumbnailResponse.php +++ b/src/Responses/Document/Thumbnail/GetDocumentDownloadThumbnailResponse.php @@ -5,7 +5,7 @@ use CodebarAg\DocuWare\DTO\DocumentThumbnail; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetDocumentDownloadThumbnailResponse { diff --git a/src/Responses/Fields/GetFieldsResponse.php b/src/Responses/Fields/GetFieldsResponse.php index 667eccb..20ed8e3 100644 --- a/src/Responses/Fields/GetFieldsResponse.php +++ b/src/Responses/Fields/GetFieldsResponse.php @@ -7,7 +7,7 @@ use CodebarAg\DocuWare\Support\EnsureValidResponse; use Illuminate\Support\Collection; use Illuminate\Support\Enumerable; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetFieldsResponse { diff --git a/src/Responses/FileCabinets/GetFileCabinetsResponse.php b/src/Responses/FileCabinets/GetFileCabinetsResponse.php index 7096d1b..9eb4e8d 100644 --- a/src/Responses/FileCabinets/GetFileCabinetsResponse.php +++ b/src/Responses/FileCabinets/GetFileCabinetsResponse.php @@ -7,7 +7,7 @@ use CodebarAg\DocuWare\Support\EnsureValidResponse; use Illuminate\Support\Collection; use Illuminate\Support\Enumerable; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetFileCabinetsResponse { diff --git a/src/Responses/Organization/GetOrganizationResponse.php b/src/Responses/Organization/GetOrganizationResponse.php index 7d786be..3693e79 100644 --- a/src/Responses/Organization/GetOrganizationResponse.php +++ b/src/Responses/Organization/GetOrganizationResponse.php @@ -5,7 +5,7 @@ use CodebarAg\DocuWare\DTO\Organization; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetOrganizationResponse { diff --git a/src/Responses/Organization/GetOrganizationsResponse.php b/src/Responses/Organization/GetOrganizationsResponse.php index 80690c0..bf013c7 100644 --- a/src/Responses/Organization/GetOrganizationsResponse.php +++ b/src/Responses/Organization/GetOrganizationsResponse.php @@ -7,7 +7,7 @@ use CodebarAg\DocuWare\Support\EnsureValidResponse; use Illuminate\Support\Collection; use Illuminate\Support\Enumerable; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetOrganizationsResponse { diff --git a/src/Responses/Search/GetSearchResponse.php b/src/Responses/Search/GetSearchResponse.php index f3c7001..42e4535 100644 --- a/src/Responses/Search/GetSearchResponse.php +++ b/src/Responses/Search/GetSearchResponse.php @@ -6,7 +6,7 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; use Exception; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetSearchResponse { diff --git a/src/Responses/Sections/GetSectionsResponse.php b/src/Responses/Sections/GetSectionsResponse.php index 05af065..603b2c8 100644 --- a/src/Responses/Sections/GetSectionsResponse.php +++ b/src/Responses/Sections/GetSectionsResponse.php @@ -6,7 +6,7 @@ use CodebarAg\DocuWare\Support\EnsureValidResponse; use Illuminate\Support\Collection; use Illuminate\Support\Enumerable; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetSectionsResponse { diff --git a/src/Responses/SelectList/GetSelectListResponse.php b/src/Responses/SelectList/GetSelectListResponse.php index e69ed30..14b7078 100644 --- a/src/Responses/SelectList/GetSelectListResponse.php +++ b/src/Responses/SelectList/GetSelectListResponse.php @@ -4,7 +4,7 @@ use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Support\EnsureValidResponse; -use Saloon\Contracts\Response; +use Saloon\Http\Response; final class GetSelectListResponse { diff --git a/src/Support/EnsureValidResponse.php b/src/Support/EnsureValidResponse.php index f7c40f0..26ed841 100644 --- a/src/Support/EnsureValidResponse.php +++ b/src/Support/EnsureValidResponse.php @@ -5,13 +5,12 @@ use CodebarAg\DocuWare\Exceptions\UnableToMakeRequest; use CodebarAg\DocuWare\Exceptions\UnableToProcessRequest; use Illuminate\Http\Client\Response; -use Saloon\Contracts\Response as SaloonContracts; use Saloon\Http\Response as SaloonResponse; use Symfony\Component\HttpFoundation\Response as Status; class EnsureValidResponse { - public static function from(Response|SaloonResponse|SaloonContracts $response): void + public static function from(Response|SaloonResponse $response): void { if ($response->successful()) { return; diff --git a/tests/Feature/DocumentTest.php b/tests/Feature/DocumentTest.php deleted file mode 100644 index 1d25be9..0000000 --- a/tests/Feature/DocumentTest.php +++ /dev/null @@ -1,288 +0,0 @@ -group('docuware'); - -beforeEach(function () { - EnsureValidCookie::check(); - - $config = Config::make([ - 'url' => config('docuware.credentials.url'), - 'cookie' => config('docuware.cookies'), - 'cache_driver' => config('docuware.configurations.cache.driver'), - 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), - 'request_timeout_in_seconds' => config('docuware.timeout'), - ]); - - $this->connector = new DocuWareStaticConnector($config); -}); - -it('can preview a document image', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - - $document = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $image = $this->connector->send(new GetDocumentPreviewRequest($fileCabinetId, $document->id))->dto(); - - $this->assertSame(9221, strlen($image)); - Event::assertDispatched(DocuWareResponseLog::class); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document->id - ))->dto(); -}); - -it('can show a document', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - - $document = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $getdocument = $this->connector->send(new GetDocumentRequest($fileCabinetId, $document->id))->dto(); - - $this->assertInstanceOf(Document::class, $getdocument); - $this->assertSame($document->id, $getdocument->id); - $this->assertSame($fileCabinetId, $getdocument->file_cabinet_id); - Event::assertDispatched(DocuWareResponseLog::class); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document->id - ))->dto(); -}); - -it('can update a document value', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - $newValue = 'laravel-docuware'; - - $document = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $response = $this->connector->send(new PutDocumentFieldsRequest( - $fileCabinetId, - $document->id, - ['UUID' => $newValue] - ))->dto(); - - $this->assertSame('laravel-docuware', $response['UUID']); - Event::assertDispatched(DocuWareResponseLog::class); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document->id - ))->dto(); -}); - -it('can update multiple document values', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - $values = [ - 'UUID' => 'laravel-docuware', - 'DOCUMENT_LABEL' => 'laravel-docuware-2', - ]; - - $document = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $response = $this->connector->send(new PutDocumentFieldsRequest( - $fileCabinetId, - $document->id, - $values, - true - ))->dto(); - - $this->assertSame('laravel-docuware', $response['UUID']); - $this->assertSame('laravel-docuware-2', $response['DOCUMENT_LABEL']); - - Event::assertDispatched(DocuWareResponseLog::class); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document->id - ))->dto(); -}); - -it('can download multiple documents', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - - $document1 = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $document2 = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $contents = $this->connector->send(new GetDocumentsDownloadRequest( - $fileCabinetId, - [$document1->id, $document2->id] - ))->dto(); - - $this->assertSame(478, strlen($contents)); - Event::assertDispatched(DocuWareResponseLog::class); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document1->id - ))->dto(); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document2->id - ))->dto(); -}); - -it('can download a document', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - - $document = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $contents = $this->connector->send(new GetDocumentDownloadRequest( - $fileCabinetId, - $document->id - ))->dto(); - - $this->assertSame(strlen('::fake-file-content::'), strlen($contents)); - Event::assertDispatched(DocuWareResponseLog::class); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document->id - ))->dto(); -}); - -it('can get a total count of documents', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - $dialogId = config('docuware.tests.dialog_id'); - - $document = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $count = $this->connector->send(new GetDocumentCountRequest( - $fileCabinetId, - $dialogId - ))->dto(); - - $this->assertSame(1, $count); - Event::assertDispatched(DocuWareResponseLog::class); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document->id - ))->dto(); -}); - -it('can upload document with index values and delete it', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - $fileContent = '::fake-file-content::'; - $fileName = 'example.txt'; - - $document = $this->connector->send(new PostDocumentRequest( - $fileCabinetId, - $fileContent, - $fileName, - collect([ - DocumentIndex::make('DOCUMENT_LABEL', '::text::'), - ]), - ))->dto(); - - $this->connector->send(new DeleteDocumentRequest( - $fileCabinetId, - $document->id, - ))->dto(); - - $this->assertInstanceOf(Document::class, $document); - $this->assertSame('example', $document->title); - tap($document->fields['DOCUMENT_LABEL'], function (DocumentField $field) { - $this->assertSame($field->name, 'DOCUMENT_LABEL'); - $this->assertSame($field->type, 'String'); - $this->assertSame($field->value, '::text::'); - }); - Event::assertDispatched(DocuWareResponseLog::class); -}); - -it('can get all documents', function () { - Event::fake(); - - $this->connector->send(new PostDocumentRequest( - config('docuware.tests.file_cabinet_id'), - '::fake-file-content::', - 'example.txt' - ))->dto(); - $this->connector->send(new PostDocumentRequest( - config('docuware.tests.file_cabinet_id'), - '::fake-file-content::', - 'example.txt' - ))->dto(); - - $documents = $this->connector->send(new GetDocumentsRequest( - config('docuware.tests.file_cabinet_id') - ))->dto(); - - foreach ($documents as $document) { - $this->assertInstanceOf(Document::class, $document); - $this->connector->send(new DeleteDocumentRequest( - config('docuware.tests.file_cabinet_id'), - $document->id, - ))->dto(); - } - - Event::assertDispatched(DocuWareResponseLog::class); -}); diff --git a/tests/Feature/Requests/Dialogs/GetDialogRequestTest.php b/tests/Feature/Requests/Dialogs/GetDialogRequestTest.php new file mode 100644 index 0000000..a0c81c8 --- /dev/null +++ b/tests/Feature/Requests/Dialogs/GetDialogRequestTest.php @@ -0,0 +1,38 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can get a dialog', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + $dialogId = config('docuware.tests.dialog_id'); + + $dialog = $this->connector->send(new GetDialogRequest($fileCabinetId, $dialogId))->dto(); + + $this->assertInstanceOf(Dialog::class, $dialog); + + Event::assertDispatched(DocuWareResponseLog::class); +}); diff --git a/tests/Feature/DialogsTest.php b/tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php similarity index 74% rename from tests/Feature/DialogsTest.php rename to tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php index aa8dde2..f070a6b 100644 --- a/tests/Feature/DialogsTest.php +++ b/tests/Feature/Requests/Dialogs/GetDialogsRequestTest.php @@ -4,7 +4,6 @@ use CodebarAg\DocuWare\DTO\Config; use CodebarAg\DocuWare\DTO\Dialog; use CodebarAg\DocuWare\Events\DocuWareResponseLog; -use CodebarAg\DocuWare\Requests\Dialogs\GetDialogRequest; use CodebarAg\DocuWare\Requests\Dialogs\GetDialogsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; use Illuminate\Support\Collection; @@ -26,19 +25,6 @@ $this->connector = new DocuWareStaticConnector($config); }); -it('can get a dialog', function () { - Event::fake(); - - $fileCabinetId = config('docuware.tests.file_cabinet_id'); - $dialogId = config('docuware.tests.dialog_id'); - - $dialog = $this->connector->send(new GetDialogRequest($fileCabinetId, $dialogId))->dto(); - - $this->assertInstanceOf(Dialog::class, $dialog); - - Event::assertDispatched(DocuWareResponseLog::class); -}); - it('can list dialogs for a file cabinet', function () { Event::fake(); @@ -47,6 +33,12 @@ $dialogs = $this->connector->send(new GetDialogsRequest($fileCabinetId))->dto(); $this->assertInstanceOf(Collection::class, $dialogs); + $this->assertNotCount(0, $dialogs); + + foreach ($dialogs as $dialog) { + $this->assertInstanceOf(Dialog::class, $dialog); + } + Event::assertDispatched(DocuWareResponseLog::class); }); diff --git a/tests/Feature/Requests/Document/GetDocumentCountRequestTest.php b/tests/Feature/Requests/Document/GetDocumentCountRequestTest.php new file mode 100644 index 0000000..0b01843 --- /dev/null +++ b/tests/Feature/Requests/Document/GetDocumentCountRequestTest.php @@ -0,0 +1,55 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can get a total count of documents', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + $dialogId = config('docuware.tests.dialog_id'); + + $document = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $count = $this->connector->send(new GetDocumentCountRequest( + $fileCabinetId, + $dialogId + ))->dto(); + + $this->assertIsInt($count); + + $this->assertSame(1, $count); + + Event::assertDispatched(DocuWareResponseLog::class); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document->id + ))->dto(); +}); diff --git a/tests/Feature/Requests/Document/GetDocumentDownloadRequestTest.php b/tests/Feature/Requests/Document/GetDocumentDownloadRequestTest.php new file mode 100644 index 0000000..25eab82 --- /dev/null +++ b/tests/Feature/Requests/Document/GetDocumentDownloadRequestTest.php @@ -0,0 +1,51 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can download a document', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + + $document = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $contents = $this->connector->send(new GetDocumentDownloadRequest( + $fileCabinetId, + $document->id + ))->dto(); + + $this->assertSame(strlen('::fake-file-content::'), strlen($contents)); + Event::assertDispatched(DocuWareResponseLog::class); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document->id + ))->dto(); +}); diff --git a/tests/Feature/Requests/Document/GetDocumentPreviewRequestTest.php b/tests/Feature/Requests/Document/GetDocumentPreviewRequestTest.php new file mode 100644 index 0000000..7a9bb68 --- /dev/null +++ b/tests/Feature/Requests/Document/GetDocumentPreviewRequestTest.php @@ -0,0 +1,48 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can preview a document image', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + + $document = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $image = $this->connector->send(new GetDocumentPreviewRequest($fileCabinetId, $document->id))->dto(); + + $this->assertSame(9221, strlen($image)); + Event::assertDispatched(DocuWareResponseLog::class); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document->id + ))->dto(); +}); diff --git a/tests/Feature/Requests/Document/GetDocumentRequestTest.php b/tests/Feature/Requests/Document/GetDocumentRequestTest.php new file mode 100644 index 0000000..bfb56c5 --- /dev/null +++ b/tests/Feature/Requests/Document/GetDocumentRequestTest.php @@ -0,0 +1,52 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can show a document', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + + $document = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $getdocument = $this->connector->send(new GetDocumentRequest($fileCabinetId, $document->id))->dto(); + + $this->assertInstanceOf(Document::class, $getdocument); + + $this->assertSame($document->id, $getdocument->id); + $this->assertSame($fileCabinetId, $getdocument->file_cabinet_id); + Event::assertDispatched(DocuWareResponseLog::class); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document->id + ))->dto(); +}); diff --git a/tests/Feature/Requests/Document/GetDocumentsDownloadRequestTest.php b/tests/Feature/Requests/Document/GetDocumentsDownloadRequestTest.php new file mode 100644 index 0000000..c86cb15 --- /dev/null +++ b/tests/Feature/Requests/Document/GetDocumentsDownloadRequestTest.php @@ -0,0 +1,62 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can download multiple documents', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + + $document1 = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $document2 = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $contents = $this->connector->send(new GetDocumentsDownloadRequest( + $fileCabinetId, + [$document1->id, $document2->id] + ))->dto(); + + $this->assertSame(478, strlen($contents)); + Event::assertDispatched(DocuWareResponseLog::class); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document1->id + ))->dto(); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document2->id + ))->dto(); +}); diff --git a/tests/Feature/Requests/Document/GetDocumentsRequestTest.php b/tests/Feature/Requests/Document/GetDocumentsRequestTest.php new file mode 100644 index 0000000..6f66af4 --- /dev/null +++ b/tests/Feature/Requests/Document/GetDocumentsRequestTest.php @@ -0,0 +1,57 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can get all documents', function () { + Event::fake(); + + $this->connector->send(new PostDocumentRequest( + config('docuware.tests.file_cabinet_id'), + '::fake-file-content::', + 'example.txt' + ))->dto(); + $this->connector->send(new PostDocumentRequest( + config('docuware.tests.file_cabinet_id'), + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $documents = $this->connector->send(new GetDocumentsRequest( + config('docuware.tests.file_cabinet_id') + ))->dto(); + + foreach ($documents as $document) { + $this->assertInstanceOf(Document::class, $document); + + $this->connector->send(new DeleteDocumentRequest( + config('docuware.tests.file_cabinet_id'), + $document->id, + ))->dto(); + } + + Event::assertDispatched(DocuWareResponseLog::class); +}); diff --git a/tests/Feature/Requests/Document/PostDocumentRequestTest.php b/tests/Feature/Requests/Document/PostDocumentRequestTest.php new file mode 100644 index 0000000..dfc5d18 --- /dev/null +++ b/tests/Feature/Requests/Document/PostDocumentRequestTest.php @@ -0,0 +1,60 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can upload document with index values and delete it', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + $fileContent = '::fake-file-content::'; + $fileName = 'example.txt'; + + $document = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + $fileContent, + $fileName, + collect([ + DocumentIndex::make('DOCUMENT_LABEL', '::text::'), + ]), + ))->dto(); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document->id, + ))->dto(); + + $this->assertInstanceOf(Document::class, $document); + + $this->assertSame('example', $document->title); + tap($document->fields['DOCUMENT_LABEL'], function (DocumentField $field) { + $this->assertSame($field->name, 'DOCUMENT_LABEL'); + $this->assertSame($field->type, 'String'); + $this->assertSame($field->value, '::text::'); + }); + Event::assertDispatched(DocuWareResponseLog::class); +}); diff --git a/tests/Feature/Requests/Document/PutDocumentFieldsRequestTest.php b/tests/Feature/Requests/Document/PutDocumentFieldsRequestTest.php new file mode 100644 index 0000000..784d658 --- /dev/null +++ b/tests/Feature/Requests/Document/PutDocumentFieldsRequestTest.php @@ -0,0 +1,89 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can update a document value', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + $newValue = 'laravel-docuware'; + + $document = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $response = $this->connector->send(new PutDocumentFieldsRequest( + $fileCabinetId, + $document->id, + ['UUID' => $newValue] + ))->dto(); + + $this->assertSame('laravel-docuware', $response['UUID']); + Event::assertDispatched(DocuWareResponseLog::class); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document->id + ))->dto(); +}); + +it('can update multiple document values', function () { + Event::fake(); + + $fileCabinetId = config('docuware.tests.file_cabinet_id'); + $values = [ + 'UUID' => 'laravel-docuware', + 'DOCUMENT_LABEL' => 'laravel-docuware-2', + ]; + + $document = $this->connector->send(new PostDocumentRequest( + $fileCabinetId, + '::fake-file-content::', + 'example.txt' + ))->dto(); + + $response = $this->connector->send(new PutDocumentFieldsRequest( + $fileCabinetId, + $document->id, + $values, + true + ))->dto(); + + $this->assertInstanceOf(Collection::class, $response); + + $this->assertSame('laravel-docuware', $response['UUID']); + $this->assertSame('laravel-docuware-2', $response['DOCUMENT_LABEL']); + + Event::assertDispatched(DocuWareResponseLog::class); + + $this->connector->send(new DeleteDocumentRequest( + $fileCabinetId, + $document->id + ))->dto(); +}); diff --git a/tests/Feature/ThumbnailTest.php b/tests/Feature/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequestTest.php similarity index 93% rename from tests/Feature/ThumbnailTest.php rename to tests/Feature/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequestTest.php index 8cb0d14..f267abd 100644 --- a/tests/Feature/ThumbnailTest.php +++ b/tests/Feature/Requests/Document/Thumbnail/GetDocumentDownloadThumbnailRequestTest.php @@ -2,6 +2,7 @@ use CodebarAg\DocuWare\Connectors\DocuWareStaticConnector; use CodebarAg\DocuWare\DTO\Config; +use CodebarAg\DocuWare\DTO\DocumentThumbnail; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\Document\DeleteDocumentRequest; use CodebarAg\DocuWare\Requests\Document\PostDocumentRequest; @@ -44,6 +45,9 @@ $this->assertSame('image/png', $contents->mime); $this->assertSame(282, strlen($contents->data)); + + $this->assertInstanceOf(DocumentThumbnail::class, $contents); + Event::assertDispatched(DocuWareResponseLog::class); $this->connector->send(new DeleteDocumentRequest( diff --git a/tests/Feature/FieldsTest.php b/tests/Feature/Requests/Fields/GetFieldsRequestTest.php similarity index 90% rename from tests/Feature/FieldsTest.php rename to tests/Feature/Requests/Fields/GetFieldsRequestTest.php index 81dc463..1c82e91 100644 --- a/tests/Feature/FieldsTest.php +++ b/tests/Feature/Requests/Fields/GetFieldsRequestTest.php @@ -2,6 +2,7 @@ use CodebarAg\DocuWare\Connectors\DocuWareStaticConnector; use CodebarAg\DocuWare\DTO\Config; +use CodebarAg\DocuWare\DTO\Field; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\Fields\GetFieldsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; @@ -32,6 +33,12 @@ $fields = $this->connector->send(new GetFieldsRequest($fileCabinetId))->dto(); $this->assertInstanceOf(Collection::class, $fields); + + foreach ($fields as $field) { + $this->assertInstanceOf(Field::class, $field); + } + $this->assertNotCount(0, $fields); + Event::assertDispatched(DocuWareResponseLog::class); }); diff --git a/tests/Feature/FileCabinetsTests.php b/tests/Feature/Requests/FileCabinets/GetFileCabinetsRequestTest.php similarity index 87% rename from tests/Feature/FileCabinetsTests.php rename to tests/Feature/Requests/FileCabinets/GetFileCabinetsRequestTest.php index da6703c..23354dd 100644 --- a/tests/Feature/FileCabinetsTests.php +++ b/tests/Feature/Requests/FileCabinets/GetFileCabinetsRequestTest.php @@ -2,6 +2,7 @@ use CodebarAg\DocuWare\Connectors\DocuWareStaticConnector; use CodebarAg\DocuWare\DTO\Config; +use CodebarAg\DocuWare\DTO\FileCabinet; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\FileCabinets\GetFileCabinetsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; @@ -31,7 +32,12 @@ $fileCabinets = $this->connector->send(new GetFileCabinetsRequest())->dto(); $this->assertInstanceOf(Collection::class, $fileCabinets); + + foreach ($fileCabinets as $fileCabinet) { + $this->assertInstanceOf(FileCabinet::class, $fileCabinet); + } + $this->assertNotCount(0, $fileCabinets); Event::assertDispatched(DocuWareResponseLog::class); -})->only(); +}); diff --git a/tests/Feature/OrganizationTest.php b/tests/Feature/Requests/Organization/GetOrganizationRequestTest.php similarity index 74% rename from tests/Feature/OrganizationTest.php rename to tests/Feature/Requests/Organization/GetOrganizationRequestTest.php index 6dafc68..6bf6201 100644 --- a/tests/Feature/OrganizationTest.php +++ b/tests/Feature/Requests/Organization/GetOrganizationRequestTest.php @@ -5,9 +5,7 @@ use CodebarAg\DocuWare\DTO\Organization; use CodebarAg\DocuWare\Events\DocuWareResponseLog; use CodebarAg\DocuWare\Requests\Organization\GetOrganizationRequest; -use CodebarAg\DocuWare\Requests\Organization\GetOrganizationsRequest; use CodebarAg\DocuWare\Support\EnsureValidCookie; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\Event; uses()->group('docuware'); @@ -26,16 +24,6 @@ $this->connector = new DocuWareStaticConnector($config); }); -it('can list organizations', function () { - Event::fake(); - - $organizations = $this->connector->send(new GetOrganizationsRequest())->dto(); - - $this->assertInstanceOf(Collection::class, $organizations); - $this->assertNotCount(0, $organizations); - Event::assertDispatched(DocuWareResponseLog::class); -}); - it('can get an organization', function () { Event::fake(); diff --git a/tests/Feature/Requests/Organization/GetOrganizationsRequestTest.php b/tests/Feature/Requests/Organization/GetOrganizationsRequestTest.php new file mode 100644 index 0000000..974fd54 --- /dev/null +++ b/tests/Feature/Requests/Organization/GetOrganizationsRequestTest.php @@ -0,0 +1,41 @@ +group('docuware'); + +beforeEach(function () { + EnsureValidCookie::check(); + + $config = Config::make([ + 'url' => config('docuware.credentials.url'), + 'cookie' => config('docuware.cookies'), + 'cache_driver' => config('docuware.configurations.cache.driver'), + 'cache_lifetime_in_seconds' => config('docuware.configurations.cache.lifetime_in_seconds'), + 'request_timeout_in_seconds' => config('docuware.timeout'), + ]); + + $this->connector = new DocuWareStaticConnector($config); +}); + +it('can list organizations', function () { + Event::fake(); + + $organizations = $this->connector->send(new GetOrganizationsRequest())->dto(); + + $this->assertInstanceOf(Collection::class, $organizations); + + foreach ($organizations as $organization) { + $this->assertInstanceOf(OrganizationIndex::class, $organization); + } + + $this->assertNotCount(0, $organizations); + Event::assertDispatched(DocuWareResponseLog::class); +}); diff --git a/tests/Feature/SearchTest.php b/tests/Feature/Requests/Search/GetSearchRequestTest.php similarity index 100% rename from tests/Feature/SearchTest.php rename to tests/Feature/Requests/Search/GetSearchRequestTest.php diff --git a/tests/Feature/SelectListTest.php b/tests/Feature/Requests/SelectList/GetSelectListRequest.php similarity index 100% rename from tests/Feature/SelectListTest.php rename to tests/Feature/Requests/SelectList/GetSelectListRequest.php