-
Notifications
You must be signed in to change notification settings - Fork 3
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 #1 from ThomasDaSilva/api
Add api connection for site_review product_review and export order
- Loading branch information
Showing
49 changed files
with
1,116 additions
and
1,702 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,7 @@ | ||
name: "Auto Release" | ||
on: | ||
push: | ||
branches: [ master, main ] | ||
jobs: | ||
release: | ||
uses: thelia-modules/ReusableWorkflow/.github/workflows/auto_release.yml@main |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace GuaranteedOpinion\Command; | ||
|
||
use Exception; | ||
use GuaranteedOpinion\Api\GuaranteedOpinionClient; | ||
use GuaranteedOpinion\Service\ProductReviewService; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Thelia\Command\ContainerAwareCommand; | ||
use Thelia\Model\ProductQuery; | ||
|
||
class GetProductReviewCommand extends ContainerAwareCommand | ||
{ | ||
public function __construct( | ||
protected GuaranteedOpinionClient $client, | ||
protected ProductReviewService $productReviewService | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
public function configure(): void | ||
{ | ||
$this | ||
->setName('module:GuaranteedOpinion:GetProductReview') | ||
->setDescription('Get product review from API Avis-Garantis'); | ||
} | ||
|
||
public function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
try { | ||
$products = ProductQuery::create()->findByVisible(1); | ||
|
||
foreach ($products as $product) | ||
{ | ||
$productReviews = $this->client->getReviewsFromApi($product->getId()); | ||
|
||
if ($productReviews !== []) | ||
{ | ||
$this->productReviewService->addGuaranteedOpinionProductReviews($productReviews, $product->getId()); | ||
} | ||
} | ||
|
||
} catch (Exception $exception) { | ||
$output->write($exception->getMessage()); | ||
} | ||
|
||
return 1; | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
|
||
namespace GuaranteedOpinion\Command; | ||
|
||
use Exception; | ||
use GuaranteedOpinion\Api\GuaranteedOpinionClient; | ||
use GuaranteedOpinion\Service\OrderService; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Thelia\Command\ContainerAwareCommand; | ||
|
||
class SendOrderCommand extends ContainerAwareCommand | ||
{ | ||
public function __construct( | ||
protected GuaranteedOpinionClient $client, | ||
protected OrderService $orderService | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
public function configure(): void | ||
{ | ||
$this | ||
->setName('module:GuaranteedOpinion:SendOrder') | ||
->setDescription('Send orders to API Avis-Garantis'); | ||
} | ||
|
||
public function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
try { | ||
$order = $this->orderService->prepareOrderRequest(); | ||
|
||
$response = $this->client->sendOrder($order); | ||
|
||
if ($response->success === 1) | ||
{ | ||
$output->write("Orders sent with success\n"); | ||
} | ||
|
||
if ($response->success === 0) | ||
{ | ||
$output->write("Error\n"); | ||
} | ||
|
||
$output->write("Orders imported : " . $response->orders_count ."\n"); | ||
$output->write("Products imported : " . $response->products_imported ."\n"); | ||
$output->write("Message : " . $response->message ."\n"); | ||
|
||
if ($response->success === 1) | ||
{ | ||
$this->orderService->clearOrderQueueTable(); | ||
$output->write("Order Queue is now empty\n"); | ||
} | ||
} catch (Exception $exception) { | ||
$output->write($exception->getMessage()); | ||
} | ||
|
||
return 1; | ||
} | ||
} |
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,45 @@ | ||
|
||
# This is a fix for InnoDB in MySQL >= 4.1.x | ||
# It "suspends judgement" for fkey relationships until are tables are set. | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- --------------------------------------------------------------------- | ||
-- guaranteed_opinion_product_review | ||
-- --------------------------------------------------------------------- | ||
|
||
DROP TABLE IF EXISTS `guaranteed_opinion_product_review`; | ||
|
||
CREATE TABLE `guaranteed_opinion_product_review` | ||
( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`product_review_id` VARCHAR(55) NOT NULL, | ||
`name` VARCHAR(255), | ||
`rate` DECIMAL(2,1) DEFAULT 0, | ||
`review` VARBINARY(10000), | ||
`review_date` DATETIME, | ||
`product_id` INTEGER, | ||
`order_id` VARCHAR(255), | ||
`order_date` DATETIME, | ||
`reply` VARCHAR(255), | ||
`reply_date` DATETIME, | ||
PRIMARY KEY (`id`), | ||
UNIQUE INDEX `guaranteed_opinion_product_review_id_unique` (`product_review_id`) | ||
) ENGINE=InnoDB; | ||
|
||
-- --------------------------------------------------------------------- | ||
-- guaranteed_opinion_order_queue | ||
-- --------------------------------------------------------------------- | ||
|
||
DROP TABLE IF EXISTS `guaranteed_opinion_order_queue`; | ||
|
||
CREATE TABLE `guaranteed_opinion_order_queue` | ||
( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`order_id` INTEGER NOT NULL, | ||
`treated_at` DATETIME, | ||
`status` INTEGER, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB; | ||
|
||
# This restores the fkey checks, after having unset them earlier | ||
SET FOREIGN_KEY_CHECKS = 1; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module xmlns="http://thelia.net/schema/dic/module" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_1.xsd"> | ||
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd"> | ||
<fullnamespace>GuaranteedOpinion\GuaranteedOpinion</fullnamespace> | ||
<descriptive locale="en_US"> | ||
<title>GuaranteedOpinion</title> | ||
</descriptive> | ||
<descriptive locale="fr_FR"> | ||
<title>GuaranteedOpinion</title> | ||
<title>Avis Garantis</title> | ||
</descriptive> | ||
<languages> | ||
<language>en_US</language> | ||
<language>fr_FR</language> | ||
</languages> | ||
<version>1.0.0</version> | ||
<author> | ||
<name>Chabreuil Antoine</name> | ||
<email>achabreuil@openstudio.fr, thelia@cqfdev.fr</email> | ||
</author> | ||
<authors> | ||
<author> | ||
<name>Chabreuil Antoine</name> | ||
<email>achabreuil@openstudio.fr, thelia@cqfdev.fr</email> | ||
</author> | ||
<author> | ||
<name>DA SILVA MENDONCA Thomas</name> | ||
<email>tdasilva@openstudio.fr</email> | ||
</author> | ||
</authors> | ||
<type>classic</type> | ||
<thelia>2.5.2</thelia> | ||
<thelia>2.5.0</thelia> | ||
<stability>other</stability> | ||
<mandatory>0</mandatory> | ||
<hidden>0</hidden> | ||
</module> |
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
Oops, something went wrong.