16 private function getSetup():
Setup
22 $setup = Setup::load();
28 private function getBusinessId(): ?
string
30 $setup = $this->getSetup();
32 return $setup->get($setup::BUSINESS_ID);
35 private function getInstalls():
Installs
37 static $installs =
null;
39 if ($installs ===
null)
41 $installs = Installs::load();
49 return $this->getInstalls()->getCatalog();
52 private function createResponseWithError(
string $error):
Response
54 return Response::create(self::TYPE_CODE)->addError(
new Error($error));
57 private function sendRequest(
string $name, array $data = []):
Response
59 $businessId = $this->getBusinessId();
60 if ($businessId ===
null)
62 return $this->createResponseWithError(
'Empty business id.');
70 'parameters' => array_merge(
73 'fbe_external_business_id' => $businessId,
83 if (empty($productData))
85 return $this->createResponseWithError(
'Empty product data.');
88 return $this->sendRequest(
'products.batch', [
90 'allow_upsert' =>
true,
91 'requests' => $productData,
99 return $this->createResponseWithError(
'Empty queue id.');
102 return $this->sendRequest(
'products.check.batch.status', [
103 'queue_id' => $queueId,
109 if (empty($retailerIds))
111 return $this->createResponseWithError(
'Empty retailer ids.');
114 return $this->sendRequest(
'products.get.info', [
116 'filter' => Json::encode([
118 'is_any' => $retailerIds,
121 'fields' =>
'id, retailer_id, review_status, review_rejection_reasons',