Skip to content

Commit

Permalink
Merge pull request #15 from bakaphp/feat-add-cobuyer
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken authored Dec 19, 2021
2 parents 9906544 + 2b81ad9 commit 7717404
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Leads/Lead.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Lead
public int $contactId = 0;
public int $isHot = 0;
public int $isOnShowroom = 0;
public int $coBuyerContact = 0;


/**
Expand All @@ -33,6 +34,7 @@ public function __construct(array $data)
$this->leadType = $data['LeadType'] ?? 0;
$this->contactId = $data['CustomerId'] ?? 0;
$this->isHot = isset($data['IsHot']) ? (int) $data['IsHot'] : 0;
$this->coBuyerContact = isset($data['coBuyerContact']) && (int) $data['coBuyerContact'] > 0 ? (int) $data['coBuyerContact'] : 0;
$this->isOnShowroom = isset($data['IsOnShowroom']) ? (int) $data['IsOnShowroom'] : 0;
}

Expand Down Expand Up @@ -77,6 +79,7 @@ public static function getById(Dealer $dealer, User $user, int $leadsId) : self
$client = new Client($dealer->id, $user->id);
$client->useDigitalShowRoomKey();

$data = [];
$data['DealerId'] = $dealer->id;
$data['UserId'] = $user->id;

Expand Down Expand Up @@ -133,6 +136,10 @@ public function update(Dealer $dealer, User $user) : self
$data = [];
$data['isHot'] = $this->isHot ? true : false;

if ($this->coBuyerContact !== 0) {
$data['coBuyerContact'] = 'https://api.vinsolutions.com/contacts/id/' . $this->coBuyerContact . '?dealerid=' . $dealer->id;
}

$response = $client->put(
'/leads/id/' . $this->id,
json_encode($data),
Expand Down

0 comments on commit 7717404

Please sign in to comment.