Skip to content

Commit

Permalink
Implement article individualization retrival/saving
Browse files Browse the repository at this point in the history
Fixes #196
  • Loading branch information
usox committed Feb 8, 2023
1 parent f32a141 commit ba25256
Show file tree
Hide file tree
Showing 14 changed files with 384 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.12.0] - 2023-02-17
### ADDED
- Support methods to retrieve article individualization (#196)

## [1.11.0] - 2022-12-20
### ADDED
- Support methods to retrieve article and container details (#193)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"require": {
"php": ">=7.2",
"ext-soap": "*",
"scn/evalanche-soap-api-struct": "^1.15",
"scn/evalanche-soap-api-struct": "^1.16",
"scn/hydrator": "^2|^3",
"scn/hydrator-property-values": "^2.0|^3.0"
},
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions docs/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ update(
): HashMap
```

Retrieve article individualization configuration

```
getIndividualization(
int <article-id>
): ArticleIndividualizationInterface
```

Set article individualization configuration

```
setIndividualization(
int <article-id>,
ArticleIndividualizationInterface <individualization>
): bool;
```

Move an article to a folder


Expand Down
48 changes: 48 additions & 0 deletions src/Client/Article/ArticleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Scn\EvalancheSoapApiConnector\Client\Generic\ResourceTrait;
use Scn\EvalancheSoapApiConnector\Exception\EmptyResultException;
use Scn\EvalancheSoapStruct\Struct\Article\ArticleDetailInterface;
use Scn\EvalancheSoapStruct\Struct\Article\ArticleIndividualizationInterface;
use Scn\EvalancheSoapStruct\Struct\Generic\HashMapInterface;
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;

Expand Down Expand Up @@ -130,4 +131,51 @@ public function getByArticleTypeId(int $articleTypeId): array
$this->hydratorConfigFactory->createResourceInformationConfig()
);
}

/**
* Return the article's individualization config
*
* @param int $id The article's id
* @return ArticleIndividualizationInterface
*
* @throws EmptyResultException
*/
public function getIndividualization(int $id): ArticleIndividualizationInterface
{
return $this->responseMapper->getObject(
$this->soapClient->getIndividualization(
[
'article_id' => $id,
]
),
'getIndividualizationResult',
$this->hydratorConfigFactory->createArticleIndividualizationConfig()
);
}

/**
* Sets an article's individualization config
*
* @param int $id
* @param ArticleIndividualizationInterface $individualization
*
* @return bool
*
* @throws EmptyResultException
*/
public function setIndividualization(
int $id,
ArticleIndividualizationInterface $individualization
): bool {
return $this->responseMapper->getBoolean(
$this->soapClient->setIndividualization([
'article_id' => $id,
'configuration' => $this->extractor->extract(
$this->hydratorConfigFactory->createArticleIndividualizationConfig(),
$individualization
)
]),
'setIndividualizationResult'
);
}
}
22 changes: 22 additions & 0 deletions src/Client/Article/ArticleClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Scn\EvalancheSoapApiConnector\Client\Generic\ResourceTraitInterface;
use Scn\EvalancheSoapApiConnector\Exception\EmptyResultException;
use Scn\EvalancheSoapStruct\Struct\Article\ArticleDetailInterface;
use Scn\EvalancheSoapStruct\Struct\Article\ArticleIndividualizationInterface;
use Scn\EvalancheSoapStruct\Struct\Generic\HashMapInterface;
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;

Expand Down Expand Up @@ -64,4 +65,25 @@ public function getDetailsById(int $id): ArticleDetailInterface;
* @throws EmptyResultException
*/
public function getByArticleTypeId(int $articleTypeId): array;

/**
* Return the article's individualization config
*
* @param int $id The article's id
* @return ArticleIndividualizationInterface
*/
public function getIndividualization(int $id): ArticleIndividualizationInterface;

/**
* Sets an article's individualization config
*
* @param int $id The article's id
* @param ArticleIndividualizationInterface $individualization
*
* @return bool
*/
public function setIndividualization(
int $id,
ArticleIndividualizationInterface $individualization
): bool;
}
44 changes: 44 additions & 0 deletions src/Hydrator/Config/Article/ArticleIndividualizationConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Scn\EvalancheSoapApiConnector\Hydrator\Config\Article;

use Scn\EvalancheSoapApiConnector\Hydrator\Config\HydratorConfigInterface;
use Scn\EvalancheSoapApiConnector\Hydrator\Property\ArrayOfObjectValue;
use Scn\EvalancheSoapStruct\Struct\Article\ArticleIndividualization;
use Scn\EvalancheSoapStruct\Struct\StructInterface;
use Scn\HydratorPropertyValues\Property\BooleanValue;

class ArticleIndividualizationConfig implements HydratorConfigInterface
{
/**
* @return StructInterface
*/
public function getObject(): StructInterface
{
return new ArticleIndividualization();
}

/**
* @return array
*/
public function getHydratorProperties(): array
{
return [
'has_fallback' => BooleanValue::set('hasFallback'),
'individualization_items' => ArrayOfObjectValue::set('individualizationItems', new ArticleIndividualizationItemConfig()),
];
}

/**
* @return array
*/
public function getExtractorProperties(): array
{
return [
'has_fallback' => BooleanValue::get('hasFallback'),
'individualization_items' => ArrayOfObjectValue::get('individualizationItems', new ArticleIndividualizationItemConfig()),
];
}
}
43 changes: 43 additions & 0 deletions src/Hydrator/Config/Article/ArticleIndividualizationItemConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Scn\EvalancheSoapApiConnector\Hydrator\Config\Article;

use Scn\EvalancheSoapApiConnector\Hydrator\Config\HydratorConfigInterface;
use Scn\EvalancheSoapStruct\Struct\Article\ArticleIndividualizationItem;
use Scn\EvalancheSoapStruct\Struct\StructInterface;
use Scn\HydratorPropertyValues\Property\IntegerValue;

class ArticleIndividualizationItemConfig implements HydratorConfigInterface
{
/**
* @return StructInterface
*/
public function getObject(): StructInterface
{
return new ArticleIndividualizationItem();
}

/**
* @return array
*/
public function getHydratorProperties(): array
{
return [
'targetgroup_id' => IntegerValue::set('targetgroupId'),
'article_id' => IntegerValue::set('articleId'),
];
}

/**
* @return array
*/
public function getExtractorProperties(): array
{
return [
'targetgroup_id' => IntegerValue::get('targetgroupId'),
'article_id' => IntegerValue::get('articleId'),
];
}
}
6 changes: 6 additions & 0 deletions src/Hydrator/Config/HydratorConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Account\AccountConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Account\DiscountConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Article\ArticleDetailConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Article\ArticleIndividualizationConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Blacklist\BlackListConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Container\ContainerAttributeConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Container\ContainerAttributeGroupConfig;
Expand Down Expand Up @@ -346,4 +347,9 @@ public function createContainerDetailConfig(): HydratorConfigInterface
{
return new ContainerDetailConfig();
}

public function createArticleIndividualizationConfig(): HydratorConfigInterface
{
return new ArticleIndividualizationConfig();
}
}
2 changes: 2 additions & 0 deletions src/Hydrator/Config/HydratorConfigFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,6 @@ public function createWorkflowStateChangeResultConfig(): HydratorConfigInterface
public function createArticleDetailConfig(): HydratorConfigInterface;

public function createContainerDetailConfig(): HydratorConfigInterface;

public function createArticleIndividualizationConfig(): HydratorConfigInterface;
}
Loading

0 comments on commit ba25256

Please sign in to comment.