Skip to content

Commit

Permalink
Add some more fields
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasGraml11 committed Nov 21, 2023
1 parent bf749a4 commit 3b9a6b9
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions src/Operation/Search/SearchOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class SearchOperation extends AbstractSearchOperation

private ?string $categoryId = null;

private ?string $categoryPath = null;

private ?string $variationId = null;

private int $size = 20;

private int $from = 0;
Expand All @@ -57,6 +61,20 @@ class SearchOperation extends AbstractSearchOperation

private ?array $sessionParams = null;

private bool $explain = false;

private ?string $redirect = null;

private ?float $time = null;

private array $rules = [];

private array $customRules = [];

private array $segments = [];

private ?array $keywords = null;

public function setAccountId(string $accountId): void
{
$this->accountId = $accountId;
Expand All @@ -72,6 +90,16 @@ public function setCategoryId(string $categoryId): void
$this->categoryId = $categoryId;
}

public function setCategoryPath(string $categoryPath): void
{
$this->categoryPath = $categoryPath;
}

public function setVariationId(string $variationId): void
{
$this->variationId = $variationId;
}

public function setSort(string $field, string $order): void
{
$this->sort = [
Expand Down Expand Up @@ -131,30 +159,83 @@ public function setSessionParams(array $sessionParams): void
$this->sessionParams = $sessionParams;
}

public function setExplain(bool $explain): void
{
$this->explain = $explain;
}

public function setRedirect(string $redirect): void
{
$this->redirect = $redirect;
}

public function setTime(float $time): void
{
$this->time = $time;
}

public function setRules(array $rules): void
{
$this->rules = $rules;
}

public function setCustomRules(array $customRules): void
{
$this->customRules = $customRules;
}

public function setSegments(array $segments): void
{
$this->segments = $segments;
}

public function setKeywords(array $keywords): void
{
$this->keywords = $keywords;
}

public function getQuery()
{
return <<<GRAPHQL
query(
\$accountId: String,
\$query: String,
\$categoryId: String,
\$categoryPath: String,
\$variationId: String,
\$sort: [InputSearchSort!],
\$filter: [InputSearchTopLevelFilter!],
\$sessionParams: InputSearchQuery,
\$size: Int,
\$from: Int,
\$redirect: String,
\$explain: Boolean,
\$time: Float,
\$rules: [String!],
\$customRules: [InputSearchRule!],
\$segments: [String!],
\$keywords: InputSearchKeywords,
) {
search(
accountId: \$accountId,
query: \$query,
products: {
categoryId: \$categoryId,
categoryPath: \$categoryPath,
variationId: \$variationId,
sort: \$sort,
filter: \$filter,
size: \$size,
from: \$from,
},
sessionParams: \$sessionParams,
redirect: \$redirect,
explain: \$explain,
time: \$time,
rules: \$rules,
customRules: \$customRules,
segments: \$segments,
keywords: \$keywords,
) {
redirect,
products {
Expand Down Expand Up @@ -200,11 +281,20 @@ public function getVariables(): array
'accountId' => $this->accountId,
'query' => $this->query,
'categoryId' => $this->categoryId,
'categoryPath' => $this->categoryPath,
'variationId' => $this->variationId,
'sort' => $this->sort,
'size' => $this->size,
'from' => $this->from,
'filter' => array_values($this->filters),
'sessionParams' => $this->sessionParams,
'explain' => $this->explain,
'redirect' => $this->redirect,
'time' => $this->time,
'rules' => $this->rules,
'customRules' => $this->customRules,
'segments' => $this->segments,
'keywords' => $this->keywords,
];
}
}

0 comments on commit 3b9a6b9

Please sign in to comment.