From 5687e7ddcebc6b6be623d933044411dd181412c0 Mon Sep 17 00:00:00 2001 From: Nihar Ranjan Date: Tue, 19 Jan 2021 16:15:13 +0530 Subject: [PATCH] new ImportConfig method to Search Service --- .../SearchStorefrontApi/Api/Data/Config.php | 101 +++++++++++++ .../Api/Data/ConfigArrayMapper.php | 55 +++++++ .../Api/Data/ConfigInterface.php | 64 ++++++++ .../Api/Data/ConfigMapper.php | 99 +++++++++++++ .../Api/Data/ImportConfigRequest.php | 49 +++++++ .../Data/ImportConfigRequestArrayMapper.php | 63 ++++++++ .../Api/Data/ImportConfigRequestInterface.php | 34 +++++ .../Api/Data/ImportConfigRequestMapper.php | 100 +++++++++++++ .../Api/Data/ImportConfigResponse.php | 74 ++++++++++ .../Data/ImportConfigResponseArrayMapper.php | 54 +++++++ .../Data/ImportConfigResponseInterface.php | 49 +++++++ .../Api/Data/ImportConfigResponseMapper.php | 96 ++++++++++++ .../Api/InMemorySearch.php | 15 ++ .../SearchStorefrontApi/Api/Search.php | 93 ++++++++++++ .../Api/SearchInterface.php | 11 ++ .../Api/SearchProxyServer.php | 98 +++++++++++++ .../Api/SearchServerInterface.php | 11 ++ .../SearchStorefrontApi/Proto/Config.php | 138 ++++++++++++++++++ .../Proto/ImportConfigRequest.php | 67 +++++++++ .../Proto/ImportConfigResponse.php | 84 +++++++++++ .../Proto/SearchClient.php | 19 +++ .../Proto/SearchInterface.php | 9 ++ .../Magento/SearchStorefrontApi/etc/di.xml | 4 + magento.proto | 16 ++ 24 files changed, 1403 insertions(+) create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/Config.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ConfigArrayMapper.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ConfigInterface.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ConfigMapper.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequest.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestArrayMapper.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestInterface.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestMapper.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponse.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseArrayMapper.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseInterface.php create mode 100755 app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseMapper.php mode change 100644 => 100755 app/code/Magento/SearchStorefrontApi/Api/InMemorySearch.php mode change 100644 => 100755 app/code/Magento/SearchStorefrontApi/Api/Search.php mode change 100644 => 100755 app/code/Magento/SearchStorefrontApi/Api/SearchInterface.php mode change 100644 => 100755 app/code/Magento/SearchStorefrontApi/Api/SearchProxyServer.php mode change 100644 => 100755 app/code/Magento/SearchStorefrontApi/Api/SearchServerInterface.php create mode 100755 app/code/Magento/SearchStorefrontApi/Proto/Config.php create mode 100755 app/code/Magento/SearchStorefrontApi/Proto/ImportConfigRequest.php create mode 100755 app/code/Magento/SearchStorefrontApi/Proto/ImportConfigResponse.php mode change 100644 => 100755 app/code/Magento/SearchStorefrontApi/Proto/SearchClient.php mode change 100644 => 100755 app/code/Magento/SearchStorefrontApi/Proto/SearchInterface.php mode change 100644 => 100755 app/code/Magento/SearchStorefrontApi/etc/di.xml mode change 100644 => 100755 magento.proto diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/Config.php b/app/code/Magento/SearchStorefrontApi/Api/Data/Config.php new file mode 100755 index 0000000..5c6cf52 --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/Config.php @@ -0,0 +1,101 @@ +name; + } + + /** + * @inheritdoc + * + * @param string $value + * @return void + */ + public function setName(string $value): void + { + $this->name = $value; + } + + /** + * @inheritdoc + * + * @return string + */ + public function getValue(): string + { + return (string) $this->value; + } + + /** + * @inheritdoc + * + * @param string $value + * @return void + */ + public function setValue(string $value): void + { + $this->value = $value; + } + + /** + * @inheritdoc + * + * @return string + */ + public function getStore(): string + { + return (string) $this->store; + } + + /** + * @inheritdoc + * + * @param string $value + * @return void + */ + public function setStore(string $value): void + { + $this->store = $value; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/ConfigArrayMapper.php b/app/code/Magento/SearchStorefrontApi/Api/Data/ConfigArrayMapper.php new file mode 100755 index 0000000..53bed5a --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/ConfigArrayMapper.php @@ -0,0 +1,55 @@ +objectManager = $objectManager; + } + + /** + * Convert the DTO to the array with the data + * + * @param Config $dto + * @return array + */ + public function convertToArray(Config $dto) + { + $result = []; + $result["name"] = $dto->getName(); + $result["value"] = $dto->getValue(); + $result["store"] = $dto->getStore(); + return $result; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/ConfigInterface.php b/app/code/Magento/SearchStorefrontApi/Api/Data/ConfigInterface.php new file mode 100755 index 0000000..cb98007 --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/ConfigInterface.php @@ -0,0 +1,64 @@ +objectManager = $objectManager; + } + + /** + * Set the data to populate the DTO + * + * @param mixed $data + * @return $this + */ + public function setData($data) + { + $this->data = $data; + return $this; + } + + /** + * Build new DTO populated with the data + * + * @return Config + */ + public function build() + { + $dto = $this->objectManager->create(self::$dtoClassName); + foreach ($this->data as $key => $valueData) { + if ($valueData === null) { + continue; + } + $this->setByKey($dto, $key, $valueData); + } + return $dto; + } + + /** + * Set the value of the key using setters. + * + * In case if the field is object, the corresponding Mapper would be create and DTO representing the field data + * would be built + * + * @param Config $dto + * @param string $key + * @param mixed $value + */ + private function setByKey(Config $dto, string $key, $value): void + { + switch ($key) { + case "name": + $dto->setName((string) $value); + break; + case "value": + $dto->setValue((string) $value); + break; + case "store": + $dto->setStore((string) $value); + break; + } + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequest.php b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequest.php new file mode 100755 index 0000000..258ef38 --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequest.php @@ -0,0 +1,49 @@ +config; + } + + /** + * @inheritdoc + * + * @param \Magento\SearchStorefrontApi\Api\Data\ConfigInterface[] $value + * @return void + */ + public function setConfig(array $value): void + { + $this->config = $value; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestArrayMapper.php b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestArrayMapper.php new file mode 100755 index 0000000..b14a97a --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestArrayMapper.php @@ -0,0 +1,63 @@ +objectManager = $objectManager; + } + + /** + * Convert the DTO to the array with the data + * + * @param ImportConfigRequest $dto + * @return array + */ + public function convertToArray(ImportConfigRequest $dto) + { + $result = []; + + /** + * Convert complex Array field + **/ + $fieldArray = []; + foreach ($dto->getConfig() as $fieldArrayDto) { + $fieldArray[] = $this->objectManager->get(\Magento\SearchStorefrontApi\Api\Data\ConfigArrayMapper::class) + ->convertToArray($fieldArrayDto); + } + $result["config"] = $fieldArray; + + return $result; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestInterface.php b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestInterface.php new file mode 100755 index 0000000..0257831 --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigRequestInterface.php @@ -0,0 +1,34 @@ +objectManager = $objectManager; + } + + /** + * Set the data to populate the DTO + * + * @param mixed $data + * @return $this + */ + public function setData($data) + { + $this->data = $data; + return $this; + } + + /** + * Build new DTO populated with the data + * + * @return ImportConfigRequest + */ + public function build() + { + $dto = $this->objectManager->create(self::$dtoClassName); + foreach ($this->data as $key => $valueData) { + if ($valueData === null) { + continue; + } + $this->setByKey($dto, $key, $valueData); + } + return $dto; + } + + /** + * Set the value of the key using setters. + * + * In case if the field is object, the corresponding Mapper would be create and DTO representing the field data + * would be built + * + * @param ImportConfigRequest $dto + * @param string $key + * @param mixed $value + */ + private function setByKey(ImportConfigRequest $dto, string $key, $value): void + { + switch ($key) { + case "config": + $convertedArray = []; + foreach ($value as $element) { + $convertedArray[] = $this->objectManager + ->create(\Magento\SearchStorefrontApi\Api\Data\ConfigMapper::class) + ->setData($element) + ->build(); + } + $dto->setConfig($convertedArray); + break; + } + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponse.php b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponse.php new file mode 100755 index 0000000..9a520a2 --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponse.php @@ -0,0 +1,74 @@ +status; + } + + /** + * @inheritdoc + * + * @param bool $value + * @return void + */ + public function setStatus(bool $value): void + { + $this->status = $value; + } + + /** + * @inheritdoc + * + * @return string + */ + public function getMessage(): string + { + return (string) $this->message; + } + + /** + * @inheritdoc + * + * @param string $value + * @return void + */ + public function setMessage(string $value): void + { + $this->message = $value; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseArrayMapper.php b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseArrayMapper.php new file mode 100755 index 0000000..14863a3 --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseArrayMapper.php @@ -0,0 +1,54 @@ +objectManager = $objectManager; + } + + /** + * Convert the DTO to the array with the data + * + * @param ImportConfigResponse $dto + * @return array + */ + public function convertToArray(ImportConfigResponse $dto) + { + $result = []; + $result["status"] = $dto->getStatus(); + $result["message"] = $dto->getMessage(); + return $result; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseInterface.php b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseInterface.php new file mode 100755 index 0000000..2aa154d --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Api/Data/ImportConfigResponseInterface.php @@ -0,0 +1,49 @@ +objectManager = $objectManager; + } + + /** + * Set the data to populate the DTO + * + * @param mixed $data + * @return $this + */ + public function setData($data) + { + $this->data = $data; + return $this; + } + + /** + * Build new DTO populated with the data + * + * @return ImportConfigResponse + */ + public function build() + { + $dto = $this->objectManager->create(self::$dtoClassName); + foreach ($this->data as $key => $valueData) { + if ($valueData === null) { + continue; + } + $this->setByKey($dto, $key, $valueData); + } + return $dto; + } + + /** + * Set the value of the key using setters. + * + * In case if the field is object, the corresponding Mapper would be create and DTO representing the field data + * would be built + * + * @param ImportConfigResponse $dto + * @param string $key + * @param mixed $value + */ + private function setByKey(ImportConfigResponse $dto, string $key, $value): void + { + switch ($key) { + case "status": + $dto->setStatus((bool) $value); + break; + case "message": + $dto->setMessage((string) $value); + break; + } + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Api/InMemorySearch.php b/app/code/Magento/SearchStorefrontApi/Api/InMemorySearch.php old mode 100644 new mode 100755 index c215a1c..91d9962 --- a/app/code/Magento/SearchStorefrontApi/Api/InMemorySearch.php +++ b/app/code/Magento/SearchStorefrontApi/Api/InMemorySearch.php @@ -12,6 +12,8 @@ use \Magento\SearchStorefrontApi\Api\Data\ProductSearchRequestInterface; use \Magento\SearchStorefrontApi\Api\Data\ProductsSearchResultInterface; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequestInterface; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponseInterface; /** * Autogenerated description for InMemorySearch class @@ -42,6 +44,19 @@ public function __construct( */ public function searchProducts(ProductSearchRequestInterface $request): ProductsSearchResultInterface { + return $this->service->searchProducts($request); } + + /** + * Autogenerated description for importConfig in memory client service method + * + * @param ImportConfigRequestInterface $request + * @return ImportConfigResponseInterface + */ + public function importConfig(ImportConfigRequestInterface $request): ImportConfigResponseInterface + { + + return $this->service->importConfig($request); + } } diff --git a/app/code/Magento/SearchStorefrontApi/Api/Search.php b/app/code/Magento/SearchStorefrontApi/Api/Search.php old mode 100644 new mode 100755 index 6ea5fbb..79632ef --- a/app/code/Magento/SearchStorefrontApi/Api/Search.php +++ b/app/code/Magento/SearchStorefrontApi/Api/Search.php @@ -15,6 +15,10 @@ use \Magento\SearchStorefrontApi\Proto\ProductSearchRequest; use \Magento\SearchStorefrontApi\Proto\ProductsSearchResult; use \Magento\SearchStorefrontApi\Proto\SearchClient; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequestInterface; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponseInterface; +use \Magento\SearchStorefrontApi\Proto\ImportConfigRequest; +use \Magento\SearchStorefrontApi\Proto\ImportConfigResponse; /** * Autogenerated description for Search class @@ -50,6 +54,7 @@ public function __construct( */ public function searchProducts(ProductSearchRequestInterface $request): ProductsSearchResultInterface { + $protoRequest = $this->searchProductsToProto($request); [$protoResult, $status] = $this->protoClient->searchProducts($protoRequest)->wait(); if ($status->code !== 0) { @@ -222,4 +227,92 @@ private function searchProductsFromProto(ProductsSearchResult $value): ProductsS return $out; } + + /** + * @inheritdoc + * + * @param ImportConfigRequestInterface $request + * @return ProductsSearchResultInterface + * @throws \Throwable + */ + public function importConfig(ImportConfigRequestInterface $request): ImportConfigResponseInterface + { + + $protoRequest = $this->importConfigToProto($request); + [$protoResult, $status] = $this->protoClient->importConfig($protoRequest)->wait(); + if ($status->code !== 0) { + throw new \RuntimeException($status->details, $status->code); + } + return $this->importConfigFromProto($protoResult); + } + + /** + * Autogenerated description for importConfig method + * + * @param ImportConfigRequestInterface $value + * @return ImportConfigRequest + */ + private function importConfigToProto(ImportConfigRequestInterface $value): ImportConfigRequest + { + // convert data from \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequest + // to \Magento\SearchStorefrontApi\Proto\ImportConfigRequest + /** + * @var \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequest $value + **/ + $p = function () use ($value) { + $r = new \Magento\SearchStorefrontApi\Proto\ImportConfigRequest(); + + $res = []; + foreach ($value->getFilters() as $item5) { + // convert data from \Magento\SearchStorefrontApi\Api\Data\Config + // to \Magento\SearchStorefrontApi\Proto\Config + /** + * @var \Magento\SearchStorefrontApi\Api\Data\Config $item5 + **/ + $p = function () use ($item5) { + $r = new \Magento\SearchStorefrontApi\Proto\Config(); + $r->setName($item5->getName()); + $r->setValue($item5->getValue()); + $r->setStore($item5->getStore()); + + return $r; + }; + $proto = $p(); + $res[] = $proto; + } + $r->setConfig($res); + return $r; + }; + $proto = $p(); + + return $proto; + } + + /** + * Autogenerated description for importConfig method + * + * @param ImportConfigResponse $value + * @return ImportConfigResponseInterface + * phpcs:disable Generic.Metrics.NestingLevel.TooHigh + */ + private function importConfigFromProto(ImportConfigResponse $value): ImportConfigResponseInterface + { + // convert data from \Magento\SearchStorefrontApi\Proto\ImportConfigResponse + // to \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponse + /** + * @var \Magento\SearchStorefrontApi\Proto\ImportConfigResponse $value + **/ + $p = function () use ($value) { + $r = new \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponse(); + $r->setStatus($value->getStatus()); + $r->setMessage($value->getMessage()); + return $r; + }; + $out = $p(); + + return $out; + } + } + + diff --git a/app/code/Magento/SearchStorefrontApi/Api/SearchInterface.php b/app/code/Magento/SearchStorefrontApi/Api/SearchInterface.php old mode 100644 new mode 100755 index 56578f0..319410e --- a/app/code/Magento/SearchStorefrontApi/Api/SearchInterface.php +++ b/app/code/Magento/SearchStorefrontApi/Api/SearchInterface.php @@ -12,6 +12,8 @@ use \Magento\SearchStorefrontApi\Api\Data\ProductSearchRequestInterface; use \Magento\SearchStorefrontApi\Api\Data\ProductsSearchResultInterface; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequestInterface; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponseInterface; /** * Autogenerated description for SearchInterface interface @@ -26,4 +28,13 @@ interface SearchInterface * @throws \Throwable */ public function searchProducts(ProductSearchRequestInterface $request): ProductsSearchResultInterface; + + /** + * Autogenerated description for importConfig interface method + * + * @param ImportConfigRequestInterface $request + * @return ImportConfigResponseInterface + * @throws \Throwable + */ + public function importConfig(ImportConfigRequestInterface $request): ImportConfigResponseInterface; } diff --git a/app/code/Magento/SearchStorefrontApi/Api/SearchProxyServer.php b/app/code/Magento/SearchStorefrontApi/Api/SearchProxyServer.php old mode 100644 new mode 100755 index faf35b0..27225d9 --- a/app/code/Magento/SearchStorefrontApi/Api/SearchProxyServer.php +++ b/app/code/Magento/SearchStorefrontApi/Api/SearchProxyServer.php @@ -15,6 +15,10 @@ use \Magento\SearchStorefrontApi\Proto\ProductSearchRequest; use \Magento\SearchStorefrontApi\Proto\ProductsSearchResult; use \Magento\SearchStorefrontApi\Proto\SearchClient; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequestInterface; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponseInterface; +use \Magento\SearchStorefrontApi\Proto\ImportConfigRequest; +use \Magento\SearchStorefrontApi\Proto\ImportConfigResponse; /** * Autogenerated description for SearchProxyServer class @@ -47,6 +51,7 @@ public function __construct( */ public function searchProducts(\Spiral\GRPC\ContextInterface $ctx, ProductSearchRequest $in): ProductsSearchResult { + try { $magentoDtoRequest = $this->searchProductsFromProto($in); $magentoDtoResponse = $this->service->searchProducts($magentoDtoRequest); @@ -225,4 +230,97 @@ private function searchProductsToProto(ProductsSearchResultInterface $value): Pr return $proto; } + + /** + * Autogenerated description for importConfig method + * + * @param \Spiral\GRPC\ContextInterface $ctx + * @param ImportConfigRequest $in + * @return ImportConfigResponse + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function importConfig(\Spiral\GRPC\ContextInterface $ctx, ImportConfigRequest $in): ImportConfigResponse + { + + try { + $magentoDtoRequest = $this->importConfigFromProto($in); + $magentoDtoResponse = $this->service->importConfig($magentoDtoRequest); + return $this->importConfigToProto($magentoDtoResponse); + } catch (\Exception $e) { + throw new \Spiral\GRPC\Exception\InvokeException( + $e->getMessage(), + \Spiral\GRPC\StatusCode::UNKNOWN, + [], + $e + ); + } + } + + /** + * Autogenerated description for importConfig method + * + * @param ImportConfigRequest $value + * @return ImportConfigRequestInterface + */ + private function importConfigFromProto(ImportConfigRequest $value): ImportConfigRequestInterface + { + // convert data from \Magento\SearchStorefrontApi\Proto\ImportConfigRequest + // to \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequest + /** + * @var \Magento\SearchStorefrontApi\Proto\ImportConfigRequest $value + **/ + $p = function () use ($value) { + $r = new \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequest(); + + $res = []; + foreach ($value->getConfig() as $item5) { + // convert data from \Magento\SearchStorefrontApi\Proto\Config + // to \Magento\SearchStorefrontApi\Api\Data\Config + /** + * @var \Magento\SearchStorefrontApi\Proto\Config $item5 + **/ + $p = function () use ($item5) { + $r = new \Magento\SearchStorefrontApi\Api\Data\Config(); + $r->setName($item5->getName()); + $r->setValue($item5->getValue()); + $r->setStore($item5->getStore()); + + return $r; + }; + $out = $p(); + $res[] = $out; + } + $r->setConfig($res); + + return $r; + }; + $out = $p(); + + return $out; + } + + /** + * Autogenerated description for importConfig method + * + * @param ImportConfigResponse $value + * @return ImportConfigResponseInterface + * phpcs:disable Generic.Metrics.NestingLevel.TooHigh + */ + private function importConfigFromProto(ImportConfigResponse $value): ImportConfigResponseInterface + { + // convert data from \Magento\SearchStorefrontApi\Proto\ImportConfigResponse + // to \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponse + /** + * @var \Magento\SearchStorefrontApi\Proto\ImportConfigResponse $value + **/ + $p = function () use ($value) { + $r = new \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponse(); + $r->setStatus($value->getStatus()); + $r->setMessage($value->getMessage()); + return $r; + }; + $out = $p(); + + return $out; + } } diff --git a/app/code/Magento/SearchStorefrontApi/Api/SearchServerInterface.php b/app/code/Magento/SearchStorefrontApi/Api/SearchServerInterface.php old mode 100644 new mode 100755 index aaf1816..ae9753d --- a/app/code/Magento/SearchStorefrontApi/Api/SearchServerInterface.php +++ b/app/code/Magento/SearchStorefrontApi/Api/SearchServerInterface.php @@ -12,6 +12,8 @@ use \Magento\SearchStorefrontApi\Api\Data\ProductSearchRequestInterface; use \Magento\SearchStorefrontApi\Api\Data\ProductsSearchResultInterface; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigRequestInterface; +use \Magento\SearchStorefrontApi\Api\Data\ImportConfigResponseInterface; /** * Autogenerated description for SearchServerInterface interface @@ -26,4 +28,13 @@ interface SearchServerInterface * @throws \Throwable */ public function searchProducts(ProductSearchRequestInterface $request): ProductsSearchResultInterface; + + /** + * Autogenerated description for importConfig interface method + * + * @param ImportConfigRequestInterface $request + * @return ImportConfigResponseInterface + * @throws \Throwable + */ + public function importConfig(ImportConfigRequestInterface $request): ImportConfigResponseInterface; } diff --git a/app/code/Magento/SearchStorefrontApi/Proto/Config.php b/app/code/Magento/SearchStorefrontApi/Proto/Config.php new file mode 100755 index 0000000..95a4f70 --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Proto/Config.php @@ -0,0 +1,138 @@ +magento.searchStorefrontApi.proto.Config + */ +class Config extends \Google\Protobuf\Internal\Message +{ + /** + * attribute code to filer + * + * Generated from protobuf field string attribute = 1; + */ + protected $name = ''; + /** + * an array of values to filter on + * + * Generated from protobuf field repeated string in = 2; + */ + private $value; + /** + * a string to filter on + * + * Generated from protobuf field string eq = 3; + */ + protected $store = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * name to config + * @type string $value + * value to config + * @type string $store + * store to config + * } + */ + public function __construct($data = null) + { + \Magento\SearchStorefrontApi\Metadata\Search::initOnce(); + parent::__construct($data); + } + + /** + * name to config + * + * Generated from protobuf field string name = 1; + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * name to config + * + * Generated from protobuf field string name = 1; + * + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, true); + $this->name = $var; + + return $this; + } + + /** + * value to config + * + * Generated from protobuf field string value = 2; + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * value to config + * + * Generated from protobuf field string value = 2; + * + * @param string $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkString($var, true); + $this->value = $var; + + return $this; + } + + /** + * store to config + * + * Generated from protobuf field string store = 3; + * + * @return string + */ + public function getStore() + { + return $this->store; + } + + /** + * store to config + * + * Generated from protobuf field string store = 3; + * + * @param string $var + * @return $this + */ + public function setStore($var) + { + GPBUtil::checkString($var, true); + $this->store = $var; + + return $this; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Proto/ImportConfigRequest.php b/app/code/Magento/SearchStorefrontApi/Proto/ImportConfigRequest.php new file mode 100755 index 0000000..439027a --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Proto/ImportConfigRequest.php @@ -0,0 +1,67 @@ +magento.searchStorefrontApi.proto.ImportConfigRequest + */ +class ImportConfigRequest extends \Google\Protobuf\Internal\Message +{ + + /** + * config attribute values + * + * Generated from protobuf field repeated .magento.searchStorefrontApi.proto.Config config = 1; + */ + private $config; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Magento\SearchStorefrontApi\Proto\Config[]|\Google\Protobuf\Internal\RepeatedField $config + * config to import config for configuration values + * } + */ + public function __construct($data = null) + { + \Magento\SearchStorefrontApi\Metadata\Search::initOnce(); + parent::__construct($data); + } + + /** + * config to import config for configuration values + * + * Generated from protobuf field repeated .magento.searchStorefrontApi.proto.Config config = 1; + * + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getConfig() + { + return $this->config; + } + + /** + * config to import config for configuration values + * + * Generated from protobuf field repeated .magento.searchStorefrontApi.proto.Config config = 1; + * + * @param \Magento\SearchStorefrontApi\Proto\Config[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setConfig($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Magento\SearchStorefrontApi\Proto\Config::class); + $this->config = $arr; + + return $this; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Proto/ImportConfigResponse.php b/app/code/Magento/SearchStorefrontApi/Proto/ImportConfigResponse.php new file mode 100755 index 0000000..b20d98f --- /dev/null +++ b/app/code/Magento/SearchStorefrontApi/Proto/ImportConfigResponse.php @@ -0,0 +1,84 @@ +magento.searchStorefrontApi.proto.ImportConfigResponse + */ +class ImportConfigResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field bool status = 1; + */ + protected $status = false; + /** + * Generated from protobuf field string message = 2; + */ + protected $message = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $status + * @type string $message + * } + */ + public function __construct($data = null) + { + \Magento\SearchStorefrontApi\Metadata\Search::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field bool status = 1; + * @return bool + */ + public function getStatus() + { + return $this->status; + } + + /** + * Generated from protobuf field bool status = 1; + * @param bool $var + * @return $this + */ + public function setStatus($var) + { + GPBUtil::checkBool($var); + $this->status = $var; + + return $this; + } + + /** + * Generated from protobuf field string message = 2; + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * Generated from protobuf field string message = 2; + * @param string $var + * @return $this + */ + public function setMessage($var) + { + GPBUtil::checkString($var, true); + $this->message = $var; + + return $this; + } +} diff --git a/app/code/Magento/SearchStorefrontApi/Proto/SearchClient.php b/app/code/Magento/SearchStorefrontApi/Proto/SearchClient.php old mode 100644 new mode 100755 index e9ea0ad..4aa0bb1 --- a/app/code/Magento/SearchStorefrontApi/Proto/SearchClient.php +++ b/app/code/Magento/SearchStorefrontApi/Proto/SearchClient.php @@ -40,4 +40,23 @@ public function searchProducts( $options ); } + + /** + * @param \Magento\SearchStorefrontApi\Proto\ImportConfigRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function importConfig( + \Magento\SearchStorefrontApi\Proto\ImportConfigRequest $argument, + $metadata = [], + $options = [] + ) { + return $this->_simpleRequest( + '/magento.searchStorefrontApi.proto.Search/importConfig', + $argument, + ['\Magento\SearchStorefrontApi\Proto\ImportConfigResponse', 'decode'], + $metadata, + $options + ); + } } diff --git a/app/code/Magento/SearchStorefrontApi/Proto/SearchInterface.php b/app/code/Magento/SearchStorefrontApi/Proto/SearchInterface.php old mode 100644 new mode 100755 index 1fa6549..9c17475 --- a/app/code/Magento/SearchStorefrontApi/Proto/SearchInterface.php +++ b/app/code/Magento/SearchStorefrontApi/Proto/SearchInterface.php @@ -19,4 +19,13 @@ interface SearchInterface extends GRPC\ServiceInterface * @throws GRPC\Exception\InvokeException */ public function searchProducts(GRPC\ContextInterface $ctx, ProductSearchRequest $in): ProductsSearchResult; + + /** + * @param GRPC\ContextInterface $ctx + * @param ImportConfigRequest $in + * @return ImportConfigResponse + * + * @throws GRPC\Exception\InvokeException + */ + public function importConfig(GRPC\ContextInterface $ctx, ImportConfigRequest $in): ImportConfigResponse; } diff --git a/app/code/Magento/SearchStorefrontApi/etc/di.xml b/app/code/Magento/SearchStorefrontApi/etc/di.xml old mode 100644 new mode 100755 index b605568..fdafe00 --- a/app/code/Magento/SearchStorefrontApi/etc/di.xml +++ b/app/code/Magento/SearchStorefrontApi/etc/di.xml @@ -20,4 +20,8 @@ Generated by the Magento PHP proto generator. DO NOT EDIT! + + + + diff --git a/magento.proto b/magento.proto old mode 100644 new mode 100755 index 9209e1a..17df8e3 --- a/magento.proto +++ b/magento.proto @@ -10,6 +10,7 @@ option php_metadata_namespace = "Magento\\SearchStorefrontApi\\Metadata"; service Search { rpc searchProducts (ProductSearchRequest) returns (ProductsSearchResult) {} + rpc importConfig (ImportConfigRequest) returns (ImportConfigResponse) {} } message ProductSearchRequest { @@ -109,3 +110,18 @@ message Sort { string direction = 2; } + +message ImportConfigRequest { + repeated Config config = 1; +} + +message Config { + string name = 1; + string value = 2; + string store = 3; +} + +message ImportConfigResponse { + bool status = 1; + string message = 2; +}