Skip to content

Commit 75ae1b4

Browse files
committed
wip
1 parent f58840f commit 75ae1b4

File tree

5 files changed

+88
-16
lines changed

5 files changed

+88
-16
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,73 @@ $downloadedFile = $connector->send($request)->dto();
221221
// Returns DownloadedFile DTO with content, name, extension, size, contentType
222222
```
223223

224+
### Property Requests
225+
226+
#### GetObjectInformationRequest
227+
228+
Retrieves object information and properties from M-Files.
229+
230+
**Constructor Parameters:**
231+
- `objectType` (int) - Object type ID
232+
- `objectId` (int) - Object ID
233+
- `objectVersion` (int) - Object version
234+
235+
**Request:**
236+
```php
237+
use CodebarAg\MFiles\Requests\GetObjectInformationRequest;
238+
239+
$request = new GetObjectInformationRequest(
240+
objectType: 0,
241+
objectId: 123,
242+
objectVersion: 1
243+
);
244+
```
245+
246+
**Response:**
247+
```php
248+
use CodebarAg\MFiles\DTO\ObjectProperties;
249+
250+
$objectProperties = $connector->send($request)->dto();
251+
// Returns ObjectProperties DTO with object information and properties
252+
```
253+
254+
#### SetPropertiesRequest
255+
256+
Sets properties for an existing object in M-Files.
257+
258+
**Constructor Parameters:**
259+
- `objectType` (int) - Object type ID
260+
- `objectId` (int) - Object ID
261+
- `objectVersion` (int) - Object version (-1 for latest)
262+
- `propertyValues` (array) - Array of SetProperty objects
263+
264+
**Request:**
265+
```php
266+
use CodebarAg\MFiles\Requests\SetPropertiesRequest;
267+
use CodebarAg\MFiles\DTO\SetProperty;
268+
use CodebarAg\MFiles\Enums\MFDataTypeEnum;
269+
270+
$propertyValues = [
271+
new SetProperty(1856, MFDataTypeEnum::BOOLEAN, true),
272+
new SetProperty(0, MFDataTypeEnum::TEXT, 'Updated Title'),
273+
];
274+
275+
$request = new SetPropertiesRequest(
276+
objectType: 140,
277+
objectId: 1770,
278+
objectVersion: -1,
279+
propertyValues: $propertyValues
280+
);
281+
```
282+
283+
**Response:**
284+
```php
285+
use CodebarAg\MFiles\DTO\ObjectProperties;
286+
287+
$objectProperties = $connector->send($request)->dto();
288+
// Returns ObjectProperties DTO with updated object information
289+
```
290+
224291
## DTOs
225292

226293
### Configuration DTOs

src/Requests/SetPropertiesRequest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
use CodebarAg\MFiles\DTO\ObjectProperties;
88
use CodebarAg\MFiles\DTO\SetProperty;
99
use CodebarAg\MFiles\Responses\ObjectPropertiesResponse;
10+
use Saloon\Contracts\Body\HasBody;
1011
use Saloon\Enums\Method;
1112
use Saloon\Http\Request;
1213
use Saloon\Http\Response;
14+
use Saloon\Traits\Body\HasJsonBody;
1315
use Saloon\Traits\Plugins\AcceptsJson;
1416

15-
class SetPropertiesRequest extends Request
17+
class SetPropertiesRequest extends Request implements HasBody
1618
{
1719
use AcceptsJson;
20+
use HasJsonBody;
1821

1922
protected Method $method = Method::POST;
2023

@@ -27,12 +30,14 @@ public function __construct(
2730

2831
public function resolveEndpoint(): string
2932
{
30-
return "/objects/{$this->objectType}/{$this->objectId}/{$this->objectVersion}/properties";
33+
return "/objects/{$this->objectType}/{$this->objectId}/latest/properties";
3134
}
3235

3336
protected function defaultBody(): array
3437
{
35-
return collect($this->propertyValues)->map(fn (SetProperty $propertyValue) => $propertyValue->toArray())->toArray();
38+
$body = collect($this->propertyValues)->map(fn (SetProperty $propertyValue) => $propertyValue->toArray())->toArray();
39+
40+
return $body;
3641
}
3742

3843
public function createDtoFromResponse(Response $response): ObjectProperties

tests/Feature/Requests/SetPropertiesRequestTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
test('can set properties using object type and object id', function () {
1515

1616
Saloon::fake([
17-
LogInToVaultRequest::class => MockResponse::fixture('set-properties-login-object'),
17+
LogInToVaultRequest::class => MockResponse::fixture('set-properties-login-to-vault'),
1818
SetPropertiesRequest::class => MockResponse::fixture('set-properties'),
1919
]);
2020

@@ -35,8 +35,6 @@
3535
new SetProperty(1856, MFDataTypeEnum::BOOLEAN, true),
3636
];
3737

38-
dd(collect($propertyValues)->map(fn (SetProperty $propertyValue) => $propertyValue->toArray())->toArray());
39-
4038
$request = new SetPropertiesRequest(
4139
$objectType,
4240
$objectId,
@@ -46,6 +44,7 @@
4644

4745
$response = $connector->send($request);
4846

47+
ray($response->status(), $response->json());
4948
expect($response->status())->toBe(200);
5049

5150
})->group('set-properties');

tests/Fixtures/Saloon/set-properties-login-object.json renamed to tests/Fixtures/Saloon/set-properties-login-to-vault.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
"headers": {
44
"Cache-Control": "private, must-revalidate, max-age=0",
55
"Content-Type": "application\/json; charset=utf-8",
6-
"Expires": "Fri, 02 Aug 2024 23:18:23 GMT",
6+
"Expires": "Fri, 02 Aug 2024 23:42:47 GMT",
77
"X-Frame-Options": "SAMEORIGIN",
88
"Content-Security-Policy": "default-src 'none'; object-src 'self'; script-src 'unsafe-inline' 'unsafe-eval' 'self' blob: https:\/\/js.monitor.azure.com; style-src 'unsafe-inline' 'self'; font-src 'self' data:; connect-src 'self' https:\/\/northeurope-0.in.applicationinsights.azure.com https:\/\/js.monitor.azure.com; img-src 'self' blob: data:; manifest-src 'self'; form-action 'self' javascript:; frame-src * blob:; frame-ancestors 'self';",
9-
"Set-Cookie": "ASP.NET_SessionId=c0lzas4yvko4psyvitf22jbs; path=\/; secure; HttpOnly; SameSite=Lax",
9+
"Set-Cookie": "ASP.NET_SessionId=1d2c32d3a1gwqouphibmhe0f; path=\/; secure; HttpOnly; SameSite=Lax",
1010
"X-XSS-Protection": "1; mode=block",
1111
"X-Content-Type-Options": "nosniff",
1212
"Strict-Transport-Security": "max-age=31536000; includeSubDomains;",
13-
"Date": "Sun, 03 Aug 2025 23:18:23 GMT",
13+
"Date": "Sun, 03 Aug 2025 23:42:47 GMT",
1414
"Content-Length": "354"
1515
},
16-
"data": "{\"Value\":\"sMYWvoQES1WOqwVNu5O0xgjzy9qwc4FOXKGIMxTiVE9BaOn0l8GxDPBrFxociqacxHXMOzi6KeMMWTU1C-HZ9hqU3B0AqyvbXzmsbXnqOgYVthKeR0xRCEhKHP1zepZuR6eN01wXhUck7XdLX7RU9Zc69Q8ysi9T4FCL_HsrZSOGYWY7ED9nojLAAidGPrV8LvAjviVLxE2-rGGBwSq8H2YQ5519vC6tiwXHMvav5mJv_0ia8RMcrmOi9C1wIepFyEFTpaMqPwzPRi3D_7rkaE7tB51tnIP46nTkGaqsBduF_NqX4gI0mf3SBWHNvkNIHXzp6NSD3zpUAFAHPooZ1g\"}",
16+
"data": "{\"Value\":\"xGGAV1CZFXd--Eswlf7c1EoHXaf2qWWAXDOn9ERrZCDpK2rOuNBK74SXYXzd1Z93MKfryy_40LK4odY_li2GO7LYcB_x6X3GR4pH0Jqd1CbLuzL_bMMx2spd_bUqH3jSHSJunMgbmqNDpD2pPwa4zmjvuswGB6UhZdGU7TtIjgDXXvhHE9WxOFgp0cImiObxSvvrPjla2zg_byaUhGLsDJ7k1rK73gQND2U1q0Bx_SqLlwx-XdKLnZKkzgdIN9AYen8jf6kDdA8LnDGouGlxyVl7Kka3K9b9vOxAZvZJthiJIxLelNBHotNI_aMmR-OlQwEu5NpihrbHQjpfWkbMEA\"}",
1717
"context": []
1818
}

tests/Fixtures/Saloon/set-properties.json

Lines changed: 7 additions & 6 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)