Skip to content

Commit

Permalink
Merge pull request #5 from bakaphp/master
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken authored Oct 15, 2021
2 parents fb9bd50 + 85ce438 commit 0b1500b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function __construct(int $dealerId, int $userId)
$this->client = new GuzzleClient(
[
'base_uri' => $this->baseUrl,
'timeout' => 2.0
]
);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Leads/Lead.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function getAll(Dealer $dealer, User $user, array $params = []) :
*
* @param Dealer $dealer
* @param User $user
* @param int $contactId
* @param int $leadsId
*
* @return self
*/
Expand Down Expand Up @@ -123,7 +123,6 @@ public static function create(Dealer $dealer, User $user, array $data) : self
*
* @param Dealer $dealer
* @param User $user
* @param array $data
*
* @return self
*/
Expand Down
15 changes: 12 additions & 3 deletions src/Leads/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Source
public int $id;
public string $href;
public string $name;
public int $itemsPerPage = 0;
public int $total = 0;

/**
* Initialize.
Expand All @@ -23,23 +25,28 @@ public function __construct(array $data)
$this->id = $data['leadSourceId'];
$this->href = $data['href'];
$this->name = $data['leadSourceName'];
$this->total = $data['count'] ?? 0;
$this->itemsPerPage = $data['limit'] ?? 0;
}

/**
* Get all lead source.
*
* @param Dealer $dealer
* @param User $user
* @param array $params
*
* @return array
*/
public static function getAll(Dealer $dealer, User $user) : array
public static function getAll(Dealer $dealer, User $user, array $params = []) : array
{
$client = new Client($dealer->id, $user->id);
$data = [];
$data['DealerId'] = $dealer->id;
$data['UserId'] = $user->id;
$params = http_build_query($params);

$response = $client->get('/leadSources/?dealerId=' . $dealer->id, [
$response = $client->get('/leadSources/?dealerId=' . $dealer->id . '&' . $params, [
'headers' => [
'Accept' => 'application/vnd.coxauto.v1+json'
]
Expand All @@ -48,6 +55,8 @@ public static function getAll(Dealer $dealer, User $user) : array
$source = [];
if (count($response)) {
foreach ($response['items'] as $item) {
$item['count'] = $response['count'];
$item['itemsPerPage'] = $response['limit'];
$source[$item['leadSourceId']] = new self($item);
}
}
Expand All @@ -59,7 +68,7 @@ public static function getAll(Dealer $dealer, User $user) : array
*
* @param Dealer $dealer
* @param User $user
* @param int $contactId
* @param int $sourceId
*
* @return Source
*/
Expand Down

0 comments on commit 0b1500b

Please sign in to comment.