File tree Expand file tree Collapse file tree 4 files changed +13
-11
lines changed Expand file tree Collapse file tree 4 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ This package was developed to give you a quick start to receive public listings
9
9
10
10
## 💡 What is Flatfox?
11
11
12
- Flatfox is a web based portal where you can Search & advertise apartments for free.
12
+ Flatfox is a web- based portal where you can Search & advertise apartments for free.
13
13
14
14
## 🛠 Requirements
15
15
@@ -28,7 +28,7 @@ composer require codebar-ag/laravel-flatfox
28
28
## Usage
29
29
30
30
``` php
31
- $request = new GetPublicListing(142, '&expand=documents&expand=images' );
31
+ $request = new GetPublicListing(identifier: 142 );
32
32
$response = $request->send();
33
33
34
34
$status = $request->status();
Original file line number Diff line number Diff line change @@ -159,22 +159,19 @@ protected static function attributes(array $attributes): Collection
159
159
return collect ($ attributes )->map (function ($ result ) {
160
160
return Attribute::fromJson ($ result );
161
161
});
162
-
163
162
}
164
163
165
164
protected static function images (array $ images ): Collection
166
165
{
167
166
return collect ($ images )->map (function ($ result ) {
168
167
return Image::fromJson ($ result );
169
168
});
170
-
171
169
}
172
170
173
171
protected static function documents (array $ documents ): Collection
174
172
{
175
173
return collect ($ documents )->map (function ($ result ) {
176
174
return Document::fromJson ($ result );
177
175
});
178
-
179
176
}
180
177
}
Original file line number Diff line number Diff line change 8
8
use Saloon \CachePlugin \Contracts \Driver ;
9
9
use Saloon \CachePlugin \Drivers \LaravelCacheDriver ;
10
10
use Saloon \CachePlugin \Traits \HasCaching ;
11
- use Saloon \Http \Response ;
12
11
use Saloon \Enums \Method ;
12
+ use Saloon \Http \Response ;
13
13
use Saloon \Http \SoloRequest ;
14
14
15
15
class GetPublicListing extends SoloRequest implements Cacheable
@@ -22,12 +22,18 @@ public function resolveEndpoint(): string
22
22
{
23
23
$ endpoint = trim (config ('flatfox.endpoint ' , 'https://flatfox.ch ' ), '/ ' );
24
24
25
- return "$ endpoint/api/v1/public-listing/?organization= {$ this ->identifier }{$ this ->expand }" ;
25
+ $ this ->expand = array_merge ($ this ->expand , ['documents ' , 'images ' ]);
26
+
27
+ return sprintf ('%s/api/v1/public-listing/?organization=%s&expand=%s ' ,
28
+ $ endpoint ,
29
+ urlencode ($ this ->identifier ),
30
+ urlencode (implode (', ' , $ this ->expand ))
31
+ );
26
32
}
27
33
28
34
public function __construct (
29
35
protected string $ identifier ,
30
- protected ? string $ expand = null ,
36
+ protected array $ expand = [] ,
31
37
) {
32
38
}
33
39
Original file line number Diff line number Diff line change 12
12
GetPublicListing::class => MockResponse::fixture ('get-public-listing-request ' ),
13
13
]);
14
14
15
- $ request = new GetPublicListing (142 , ' &expand=documents&expand=images ' );
15
+ $ request = new GetPublicListing (identifier: 142 );
16
16
$ request ->withMockClient ($ mockClient );
17
17
18
18
$ response = $ request ->send ();
21
21
22
22
expect ($ response ->status ())->toBe (200 )
23
23
->and ($ response ->dto ())->not ()->toBeEmpty ();
24
- })
25
- ->group ('get ' , 'public-listing ' );
24
+ })->group ('get ' , 'public-listing ' );
You can’t perform that action at this time.
0 commit comments