-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from seatsio/nami/subaccount-filter
Nami/subaccount filter
- Loading branch information
Showing
4 changed files
with
210 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Seatsio\Subaccounts; | ||
|
||
class FilterableSubaccountLister | ||
{ | ||
|
||
protected $pageFetcher; | ||
|
||
public function __construct($pageFetcher) | ||
{ | ||
$this->pageFetcher = $pageFetcher; | ||
} | ||
|
||
/** | ||
* @param $queryParams SubaccountListParams[] | ||
* @return SubaccountPagedIterator | ||
*/ | ||
public function all($queryParams) | ||
{ | ||
return new SubaccountPagedIterator($this->pageFetcher, $queryParams); | ||
} | ||
|
||
/** | ||
* @param $pageSize int | ||
* @param $queryParams SubaccountListParams[] | ||
* @return SubaccountPage | ||
*/ | ||
public function firstPage($pageSize = null, $queryParams) | ||
{ | ||
return $this->pageFetcher->fetchAfter(null, $queryParams, $pageSize); | ||
} | ||
|
||
/** | ||
* @param $afterId int | ||
* @param $pageSize int | ||
* @param $queryParams SubaccountListParams[] | ||
* @return SubaccountPage | ||
*/ | ||
public function pageAfter($afterId, $pageSize = null, $queryParams) | ||
{ | ||
return $this->pageFetcher->fetchAfter($afterId, $queryParams, $pageSize); | ||
} | ||
|
||
/** | ||
* @param $beforeId int | ||
* @param $pageSize int | ||
* @param $queryParams SubaccountListParams[] | ||
* @return SubaccountPage | ||
*/ | ||
public function pageBefore($beforeId, $pageSize = null, $queryParams) | ||
{ | ||
return $this->pageFetcher->fetchBefore($beforeId, $queryParams, $pageSize); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Seatsio\Subaccounts; | ||
|
||
class SubaccountListParams | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $filter; | ||
|
||
/** | ||
* @param $filter string | ||
*/ | ||
public function __construct($filter = null) | ||
{ | ||
$this->filter = $filter; | ||
} | ||
|
||
/** | ||
* @param $filter string | ||
* @return $this | ||
*/ | ||
public function withFilter($filter) | ||
{ | ||
$this->filter = $filter; | ||
return $this; | ||
} | ||
|
||
public function toArray() | ||
{ | ||
$result = []; | ||
|
||
if ($this->filter !== null) { | ||
$result['filter'] = $this->filter; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters