Skip to content

Commit c905064

Browse files
Marc SerratMarc Serrat
authored andcommitted
Added RQL to listRequests method
1 parent ee3eb9c commit c905064

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/Modules/Fulfillment.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,26 @@ public function __construct(Config $config, LoggerInterface $logger, ClientInter
4545

4646
/**
4747
* List the pending requests
48-
* @param array $filters Filter for listing key->value or key->array(value1, value2)
48+
* @param array|\Connect\RQL\Query $filters Filter for listing key->value or key->array(value1, value2)
4949
* @return array|Request
5050
* @throws GuzzleException
5151
*/
52-
public function listRequests(array $filters = [])
52+
public function listRequests($filters = [])
5353
{
5454
$query = '';
5555

56-
if ($this->config->products) {
57-
$filters['asset.product.id__in'] = implode(",", $this->config->products);
56+
if($filters instanceof \Connect\RQL\Query){
57+
$query = $filters->compile();
5858
}
59-
60-
if ($filters) {
61-
$query = '?' . preg_replace('/%5B[0-9]+%5D/simU', '', http_build_query($filters));
62-
$query = urldecode($query);
59+
else {
60+
if ($this->config->products) {
61+
$filters['asset.product.id__in'] = implode(",", $this->config->products);
62+
}
63+
64+
if ($filters) {
65+
$query = '?' . preg_replace('/%5B[0-9]+%5D/simU', '', http_build_query($filters));
66+
$query = urldecode($query);
67+
}
6368
}
6469

6570
$body = $this->sendRequest('GET', '/requests' . $query);

0 commit comments

Comments
 (0)