Skip to content

Commit

Permalink
refact: fix cms
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Mar 12, 2024
1 parent 23488e9 commit dc93eba
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Leads/Lead.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function startShowRoom(Dealer $dealer, User $user): self
return new self($response);
}

public static function getCoBuyer(Dealer $dealer, User $user, int $leadsId): ?int
public static function getCoBuyer(Dealer $dealer, User $user, int $leadsId): ?string
{
$client = new Client($dealer->id, $user->id);
$data['DealerId'] = $dealer->id;
Expand All @@ -181,12 +181,16 @@ public static function getCoBuyer(Dealer $dealer, User $user, int $leadsId): ?in
'/leads/id/' . $leadsId,
[
'headers' => [
'Accept' => 'application/vnd.coxauto.v1+json',
'Accept' => 'application/vnd.coxauto.v3+json',
],
]
);

return $response['coBuyerContact'] ?? null;
if (preg_match("/\/id\/(\d+)/", $response['coBuyerContact'], $matches)) {
return $matches[1]; // $matches[1] contains the first captured group, which is the ID
}

return null;
}

/**
Expand Down

0 comments on commit dc93eba

Please sign in to comment.