forked from Smile-SA/elasticsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
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 Smile-SA#68 from Elastic-Suite/feat-ESP-19-ab-test…
…ing-rest-graphql [Campaign][Headless] Retrieve/Apply current scenario #ESP-94 #ESP-103
- Loading branch information
Showing
5 changed files
with
93 additions
and
2 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
58 changes: 58 additions & 0 deletions
58
src/module-elasticsuite-ab-campaign/Model/Resolver/Campaigns.php
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,58 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade Smile Elastic Suite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteAbCampaign | ||
* @author Botis <botis@smile.fr> | ||
* @copyright 2021 Smile | ||
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided. | ||
* Unauthorized copying of this file, via any medium, is strictly prohibited. | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteAbCampaign\Model\Resolver; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Smile\ElasticsuiteAbCampaign\Api\CampaignServiceInterface; | ||
|
||
/** | ||
* ElasticSuite campaigns resolver. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteAbCampaign | ||
* @author Botis <botis@smile.fr> | ||
*/ | ||
class Campaigns implements ResolverInterface | ||
{ | ||
/** | ||
* @var CampaignServiceInterface | ||
*/ | ||
private $campaignService; | ||
|
||
/** | ||
* Recommendations constructor. | ||
* | ||
* @param CampaignServiceInterface $campaignService Campaign service. | ||
*/ | ||
public function __construct(CampaignServiceInterface $campaignService) | ||
{ | ||
$this->campaignService = $campaignService; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
return $this->campaignService->getCampaignScenarios(); | ||
} | ||
} |
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,25 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Smile\ElasticsuiteAbCampaign frontend dependency injection configuration. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteAbCampaign | ||
* @author Richard BAYET <richard.bayet@smile.fr> | ||
* @copyright 2021 Smile | ||
* @license Licensed to Smile-SA. All rights reserved. No warranty, explicit or implicit, provided. | ||
* Unauthorized copying of this file, via any medium, is strictly prohibited. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<!-- Plugins --> | ||
<type name="Magento\Framework\App\FrontControllerInterface"> | ||
<plugin name="elasticsuite-ab-campaign-front-controller-context-dispatch" | ||
type="Smile\ElasticsuiteAbCampaign\Plugin\Framework\App\FrontControllerInterfacePlugin" /> | ||
</type> | ||
</config> |
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,8 @@ | ||
type Query { | ||
elasticsuiteAbCampaigns: [AbCampaign] @resolver(class: "Smile\\ElasticsuiteAbCampaign\\Model\\Resolver\\Campaigns") @doc(description: "AB campaigns applied for the current customer.") @cache(cacheable: false) | ||
} | ||
|
||
type AbCampaign { | ||
campaign_id: String @doc(description: "Campaign id.") | ||
scenario_id: String @doc(description: "Scenario id.") | ||
} |