Skip to content

Commit 608e281

Browse files
committed
WIP
1 parent edfe065 commit 608e281

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/DTO/Listing.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
use Carbon\Carbon;
66
use Illuminate\Support\Arr;
77
use Illuminate\Support\Collection;
8+
use Illuminate\Support\Str;
89

910
class Listing
1011
{
1112
public function __construct(
1213
public int $pk,
1314
public string|null $slug,
14-
public string|null $url,
15+
public array|null $url,
1516
public string|null $short_url,
16-
public string|null $submit_url,
17+
public array|null $submit_url,
1718
public string|null $status,
1819
public string|null $offer_type,
1920
public string|null $object_category,
@@ -76,12 +77,25 @@ public static function fromJson(array $data): self
7677
{
7778
$endpoint = trim(config('flatfox.endpoint', 'https://flatfox.ch'), '/');
7879

80+
$url = $endpoint.Arr::get($data, 'url');
81+
$submit_url = $endpoint.Arr::get($data, 'submit_url');
82+
7983
return new self(
8084
pk: Arr::get($data, 'pk'),
8185
slug: Arr::get($data, 'slug'),
82-
url: $endpoint.Arr::get($data, 'url'),
86+
url: [
87+
'de' => Str::replace('/en/', '/de/', $url),
88+
'en' => $url,
89+
'fr' => Str::replace('/en/', '/fr/', $url),
90+
'it' => Str::replace('/en/', '/it/', $url),
91+
],
8392
short_url: $endpoint.Arr::get($data, 'short_url'),
84-
submit_url: $endpoint.Arr::get($data, 'submit_url'),
93+
submit_url: [
94+
'de' => Str::replace('/en/', '/de/', $submit_url),
95+
'en' => $submit_url,
96+
'fr' => Str::replace('/en/', '/fr/', $submit_url),
97+
'it' => Str::replace('/en/', '/it/', $submit_url),
98+
],
8599
status: Arr::get($data, 'status'),
86100
offer_type: Arr::get($data, 'offer_type'),
87101
object_category: Arr::get($data, 'object_category'),

tests/Feature/GetPublicListingTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
it('get public listing', function () {
88
$request = new GetPublicListing(142, '&expand=documents&expand=images');
99
$response = $request->send();
10-
expect($response->status())->toBe(200);
10+
expect($response->status())->toBe(200)
11+
->and($response->dto())->not()->toBeEmpty();
1112

1213
ray($response->dto()->results->first());
1314
})

0 commit comments

Comments
 (0)