Skip to content

Commit

Permalink
Update TradeIn.php
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken authored Apr 4, 2022
1 parent 734d5f8 commit 71d359a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/Vehicles/TradeIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,51 @@ public static function getByLeadId(Dealer $dealer, User $user, int $leadsId) : T

return new TradeIn($response);
}

/**
* Update vehicle interest.
*
* @param Dealer $dealer
* @param User $user
* @param string $id
* @param array $data
*
* @return bool
*/
public static function update(Dealer $dealer, User $user, string $id, array $data) : bool
{
$client = new Client($dealer->id, $user->id);

$response = $client->put(
'/vehicles/trade/id/' . $id,
json_encode(
$data
),
[
'headers' => [
'Content-Type' => 'application/vnd.coxauto.v1+json'
]
]
);

return true;
}

/**
* Get specific interest.
*
* @param int $index
*
* @return array
*/
public function getVehicleByIndex(int $index) : array
{
$id = str_replace('https://api.vinsolutions.com/vehicles/trade/id/', '', $this->items[$index]['href']);
unset($this->items[$index]['href'], $this->items[$index]['lead'], $this->items[$index]['downPaymentRequested'], $this->items[$index]['monthlyPaymentRequested'], $this->items[$index]['reservationPaymentRequested'], $this->items[$index]['paymentMethod']);

return [
'id' => $id,
'vehicle' => $this->items[$index]
];
}
}

0 comments on commit 71d359a

Please sign in to comment.