This repository was archived by the owner on Nov 1, 2025. It is now read-only.
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
99
1010## 💡 What is Flatfox?
1111
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.
1313
1414## 🛠 Requirements
1515
@@ -28,7 +28,7 @@ composer require codebar-ag/laravel-flatfox
2828## Usage
2929
3030``` php
31- $request = new GetPublicListing(142, '&expand=documents&expand=images' );
31+ $request = new GetPublicListing(identifier: 142 );
3232 $response = $request->send();
3333
3434 $status = $request->status();
Original file line number Diff line number Diff line change @@ -159,22 +159,19 @@ protected static function attributes(array $attributes): Collection
159159 return collect ($ attributes )->map (function ($ result ) {
160160 return Attribute::fromJson ($ result );
161161 });
162-
163162 }
164163
165164 protected static function images (array $ images ): Collection
166165 {
167166 return collect ($ images )->map (function ($ result ) {
168167 return Image::fromJson ($ result );
169168 });
170-
171169 }
172170
173171 protected static function documents (array $ documents ): Collection
174172 {
175173 return collect ($ documents )->map (function ($ result ) {
176174 return Document::fromJson ($ result );
177175 });
178-
179176 }
180177}
Original file line number Diff line number Diff line change 88use Saloon \CachePlugin \Contracts \Driver ;
99use Saloon \CachePlugin \Drivers \LaravelCacheDriver ;
1010use Saloon \CachePlugin \Traits \HasCaching ;
11- use Saloon \Http \Response ;
1211use Saloon \Enums \Method ;
12+ use Saloon \Http \Response ;
1313use Saloon \Http \SoloRequest ;
1414
1515class GetPublicListing extends SoloRequest implements Cacheable
@@ -22,12 +22,18 @@ public function resolveEndpoint(): string
2222 {
2323 $ endpoint = trim (config ('flatfox.endpoint ' , 'https://flatfox.ch ' ), '/ ' );
2424
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+ );
2632 }
2733
2834 public function __construct (
2935 protected string $ identifier ,
30- protected ? string $ expand = null ,
36+ protected array $ expand = [] ,
3137 ) {
3238 }
3339
Original file line number Diff line number Diff line change 1212 GetPublicListing::class => MockResponse::fixture ('get-public-listing-request ' ),
1313 ]);
1414
15- $ request = new GetPublicListing (142 , ' &expand=documents&expand=images ' );
15+ $ request = new GetPublicListing (identifier: 142 );
1616 $ request ->withMockClient ($ mockClient );
1717
1818 $ response = $ request ->send ();
2121
2222 expect ($ response ->status ())->toBe (200 )
2323 ->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