Skip to content

Commit 60047ce

Browse files
mbruckmoserusox
authored andcommitted
Add LeadpageTemplate config
- fixes #220
1 parent 202fd6e commit 60047ce

File tree

9 files changed

+241
-8
lines changed

9 files changed

+241
-8
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"require": {
2525
"php": "^8.1",
2626
"ext-soap": "*",
27-
"scn/evalanche-soap-api-struct": "^2.3",
27+
"scn/evalanche-soap-api-struct": "^2.4",
2828
"scn/hydrator": "^2|^3",
2929
"scn/hydrator-property-values": "^2.0|^3.0"
3030
},

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Client/LeadPageTemplate/LeadpageTemplateClient.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Scn\EvalancheSoapApiConnector\Client\Generic\ResourceTrait;
1010
use Scn\EvalancheSoapApiConnector\Exception\EmptyResultException;
1111
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;
12+
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateConfiguration;
13+
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateConfigurationInterface;
1214
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\TemplatesSourcesInterface;
1315

1416
class LeadpageTemplateClient extends AbstractClient implements LeadpageTemplateClientInterface
@@ -86,4 +88,49 @@ public function setSources(
8688
$this->hydratorConfigFactory->createLeadpageTemplateSourcesConfig()
8789
);
8890
}
91+
92+
/**
93+
* @param int $id
94+
*
95+
* @return LeadpageTemplateConfigurationInterface
96+
* @throws EmptyResultException
97+
*/
98+
public function getConfiguration(int $id): LeadpageTemplateConfigurationInterface
99+
{
100+
return $this->responseMapper->getObject(
101+
$this->soapClient->getConfiguration(
102+
[
103+
'leadpage_template_id' => $id,
104+
],
105+
),
106+
'getConfigurationResult',
107+
$this->hydratorConfigFactory->createLeadpageTemplateConfigurationConfig(),
108+
);
109+
}
110+
111+
/**
112+
* @param int $id
113+
* @param LeadpageTemplateConfigurationInterface $configuration
114+
*
115+
* @return LeadpageTemplateConfiguration
116+
* @throws EmptyResultException
117+
*/
118+
public function setConfiguration(
119+
int $id,
120+
LeadpageTemplateConfigurationInterface $configuration
121+
): LeadpageTemplateConfigurationInterface {
122+
return $this->responseMapper->getObject(
123+
$this->soapClient->setConfiguration(
124+
[
125+
'leadpage_template_id' => $id,
126+
'configuration' => $this->extractor->extract(
127+
$this->hydratorConfigFactory->createLeadpageTemplateConfigurationConfig(),
128+
$configuration,
129+
),
130+
],
131+
),
132+
'setConfigurationResult',
133+
$this->hydratorConfigFactory->createLeadpageTemplateConfigurationConfig(),
134+
);
135+
}
89136
}

src/Client/LeadPageTemplate/LeadpageTemplateClientInterface.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Scn\EvalancheSoapApiConnector\Client\Generic\ResourceTraitInterface;
77
use Scn\EvalancheSoapApiConnector\Exception\EmptyResultException;
88
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;
9+
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateConfigurationInterface;
910
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\TemplatesSourcesInterface;
1011

1112
interface LeadpageTemplateClientInterface extends ResourceTraitInterface, ClientInterface
@@ -42,4 +43,24 @@ public function setSources(
4243
TemplatesSourcesInterface $configuration,
4344
bool $overwrite = false
4445
): TemplatesSourcesInterface;
46+
47+
/**
48+
* @param int $id
49+
*
50+
* @return LeadpageTemplateConfigurationInterface
51+
* @throws EmptyResultException
52+
*/
53+
public function getConfiguration(int $id): LeadpageTemplateConfigurationInterface;
54+
55+
/**
56+
* @param int $id
57+
* @param LeadpageTemplateConfigurationInterface $configuration
58+
*
59+
* @return LeadpageTemplateConfigurationInterface
60+
* @throws EmptyResultException
61+
*/
62+
public function setConfiguration(
63+
int $id,
64+
LeadpageTemplateConfigurationInterface $configuration
65+
): LeadpageTemplateConfigurationInterface;
4566
}

src/Hydrator/Config/HydratorConfigFactory.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Generic\ServiceStatusConfig;
2525
use Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPage\LeadpageConfigurationConfig;
2626
use Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPageTemplate\LeadpageTemplateSourcesConfig;
27+
use Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPageTemplate\LeadpageTemplateConfigurationConfig;
2728
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Mailing\MailingArticleConfig;
2829
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Mailing\MailingClickConfig;
2930
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Mailing\MailingConfigurationConfig;
@@ -250,6 +251,11 @@ public function createLeadpageConfigurationConfig(): HydratorConfigInterface
250251
{
251252
return new LeadpageConfigurationConfig();
252253
}
254+
255+
public function createLeadpageTemplateConfigurationConfig(): HydratorConfigInterface
256+
{
257+
return new LeadpageTemplateConfigurationConfig();
258+
}
253259

254260
public function createMailingConfigurationConfig(): HydratorConfigInterface
255261
{

src/Hydrator/Config/HydratorConfigFactoryInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public function createMailingDetailConfig(): HydratorConfigInterface;
7777
public function createMailingClickConfig(): HydratorConfigInterface;
7878

7979
public function createLeadpageConfigurationConfig(): HydratorConfigInterface;
80+
81+
public function createLeadpageTemplateConfigurationConfig(): HydratorConfigInterface;
8082

8183
public function createMailingConfigurationConfig(): HydratorConfigInterface;
8284

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPageTemplate;
6+
7+
use Scn\EvalancheSoapApiConnector\Hydrator\Config\HydratorConfigInterface;
8+
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateConfiguration;
9+
use Scn\EvalancheSoapStruct\Struct\StructInterface;
10+
use Scn\HydratorPropertyValues\Property\StringValue;
11+
12+
class LeadpageTemplateConfigurationConfig implements HydratorConfigInterface
13+
{
14+
public function getObject(): StructInterface
15+
{
16+
return new LeadpageTemplateConfiguration();
17+
}
18+
19+
public function getHydratorProperties(): array
20+
{
21+
return [
22+
'inputfield_0' => StringValue::set('inputfield0'),
23+
'inputfield_1' => StringValue::set('inputfield1'),
24+
'inputfield_2' => StringValue::set('inputfield2'),
25+
'inputfield_3' => StringValue::set('inputfield3'),
26+
'inputfield_4' => StringValue::set('inputfield4'),
27+
'inputfield_5' => StringValue::set('inputfield5'),
28+
'inputfield_6' => StringValue::set('inputfield6'),
29+
'inputfield_7' => StringValue::set('inputfield7'),
30+
'inputfield_8' => StringValue::set('inputfield8'),
31+
'inputfield_9' => StringValue::set('inputfield9'),
32+
'textarea_0' => StringValue::set('textarea0'),
33+
'textarea_1' => StringValue::set('textarea1'),
34+
'textarea_2' => StringValue::set('textarea2'),
35+
'textarea_3' => StringValue::set('textarea3'),
36+
'textarea_4' => StringValue::set('textarea4'),
37+
'textarea_5' => StringValue::set('textarea5'),
38+
'textarea_6' => StringValue::set('textarea6'),
39+
'textarea_7' => StringValue::set('textarea7'),
40+
'textarea_8' => StringValue::set('textarea8'),
41+
'textarea_9' => StringValue::set('textarea9'),
42+
'htmlarea_0' => StringValue::set('htmlarea0'),
43+
'htmlarea_1' => StringValue::set('htmlarea1'),
44+
'htmlarea_2' => StringValue::set('htmlarea2'),
45+
'htmlarea_3' => StringValue::set('htmlarea3'),
46+
'htmlarea_4' => StringValue::set('htmlarea4'),
47+
'htmlarea_5' => StringValue::set('htmlarea5'),
48+
'htmlarea_6' => StringValue::set('htmlarea6'),
49+
'htmlarea_7' => StringValue::set('htmlarea7'),
50+
'htmlarea_8' => StringValue::set('htmlarea8'),
51+
'htmlarea_9' => StringValue::set('htmlarea9'),
52+
'macro_library' => StringValue::set('macroLibrary'),
53+
];
54+
}
55+
56+
/**
57+
* @return array
58+
*/
59+
public function getExtractorProperties(): array
60+
{
61+
return [
62+
'inputfield_0' => StringValue::get('inputfield0'),
63+
'inputfield_1' => StringValue::get('inputfield1'),
64+
'inputfield_2' => StringValue::get('inputfield2'),
65+
'inputfield_3' => StringValue::get('inputfield3'),
66+
'inputfield_4' => StringValue::get('inputfield4'),
67+
'inputfield_5' => StringValue::get('inputfield5'),
68+
'inputfield_6' => StringValue::get('inputfield6'),
69+
'inputfield_7' => StringValue::get('inputfield7'),
70+
'inputfield_8' => StringValue::get('inputfield8'),
71+
'inputfield_9' => StringValue::get('inputfield9'),
72+
'textarea_0' => StringValue::get('textarea0'),
73+
'textarea_1' => StringValue::get('textarea1'),
74+
'textarea_2' => StringValue::get('textarea2'),
75+
'textarea_3' => StringValue::get('textarea3'),
76+
'textarea_4' => StringValue::get('textarea4'),
77+
'textarea_5' => StringValue::get('textarea5'),
78+
'textarea_6' => StringValue::get('textarea6'),
79+
'textarea_7' => StringValue::get('textarea7'),
80+
'textarea_8' => StringValue::get('textarea8'),
81+
'textarea_9' => StringValue::get('textarea9'),
82+
'htmlarea_0' => StringValue::get('htmlarea0'),
83+
'htmlarea_1' => StringValue::get('htmlarea1'),
84+
'htmlarea_2' => StringValue::get('htmlarea2'),
85+
'htmlarea_3' => StringValue::get('htmlarea3'),
86+
'htmlarea_4' => StringValue::get('htmlarea4'),
87+
'htmlarea_5' => StringValue::get('htmlarea5'),
88+
'htmlarea_6' => StringValue::get('htmlarea6'),
89+
'htmlarea_7' => StringValue::get('htmlarea7'),
90+
'htmlarea_8' => StringValue::get('htmlarea8'),
91+
'htmlarea_9' => StringValue::get('htmlarea9'),
92+
'macro_library' => StringValue::get('macroLibrary'),
93+
];
94+
}
95+
}

tests/Client/LeadPageTemplate/LeadpageTemplateClientTest.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Scn\EvalancheSoapApiConnector\Hydrator\Config\HydratorConfigInterface;
1313
use Scn\EvalancheSoapApiConnector\Mapper\ResponseMapperInterface;
1414
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;
15+
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateConfigurationInterface;
1516
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\TemplatesSourcesInterface;
1617
use \stdClass;
1718

@@ -226,4 +227,63 @@ public function testSetSourcesReturnsSources(): void
226227
$this->subject->setSources($id, $configuration, $overwrite)
227228
);
228229
}
230+
231+
public function testSetConfigurationCanReturnInstanceOfLeadpageTemplateConfiguration(): void
232+
{
233+
$id = 128;
234+
$configuration = $this->getMockBuilder(LeadpageTemplateConfigurationInterface::class)->getMock();
235+
236+
$config = $this->getMockBuilder(HydratorConfigInterface::class)->getMock();
237+
$object = $this->getMockBuilder(LeadpageTemplateConfigurationInterface::class)->getMock();
238+
239+
$extractedData = [
240+
'some ' => 'data',
241+
];
242+
243+
$response = new stdClass();
244+
$response->setConfigurationResult = $object;
245+
246+
$this->extractor->expects($this->once())->method('extract')->with($config, $configuration)->willReturn($extractedData);
247+
$this->hydratorConfigFactory->expects($this->exactly(2))->method('createLeadpageTemplateConfigurationConfig')->willReturn($config);
248+
$this->soapClient->expects($this->once())->method('setConfiguration')->with([
249+
'leadpage_template_id' => $id,
250+
'configuration' => $extractedData,
251+
])->willReturn($response);
252+
$this->responseMapper->expects($this->once())->method('getObject')->with(
253+
$response,
254+
'setConfigurationResult',
255+
$config
256+
)->willReturn($response->setConfigurationResult);
257+
258+
self::assertInstanceOf(
259+
LeadpageTemplateConfigurationInterface::class,
260+
$this->subject->setConfiguration($id, $configuration)
261+
);
262+
}
263+
264+
public function testGetConfigurationCanReturnInstanceOfLeadpageTemplateConfiguration(): void
265+
{
266+
$id = 667;
267+
268+
$config = $this->getMockBuilder(HydratorConfigInterface::class)->getMock();
269+
$object = $this->getMockBuilder(LeadpageTemplateConfigurationInterface::class)->getMock();
270+
271+
$response = new stdClass();
272+
$response->getConfigurationResult = $object;
273+
274+
$this->hydratorConfigFactory->expects($this->once())->method('createLeadpageTemplateConfigurationConfig')->willReturn($config);
275+
$this->soapClient->expects($this->once())->method('getConfiguration')->with([
276+
'leadpage_template_id' => $id,
277+
])->willReturn($response);
278+
$this->responseMapper->expects($this->once())->method('getObject')->with(
279+
$response,
280+
'getConfigurationResult',
281+
$config
282+
)->willReturn($response->getConfigurationResult);
283+
284+
self::assertInstanceOf(
285+
LeadpageTemplateConfigurationInterface::class,
286+
$this->subject->getConfiguration($id),
287+
);
288+
}
229289
}

tests/Hydrator/Config/HydratorConfigFactoryTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Generic\ResourceTypeInformationConfig;
2626
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Generic\ServiceStatusConfig;
2727
use Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPage\LeadpageConfigurationConfig;
28+
use Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadpageTemplate\LeadpageTemplateConfigurationConfig;
2829
use Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPageTemplate\LeadpageTemplateSourcesConfig;
2930
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Mailing\MailingSlotConfig;
3031
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Mailing\MailingSlotConfigurationConfig;
@@ -154,6 +155,7 @@ public static function factoryDataProvider()
154155
['createMailingTemplateAllowedTemplatesConfig', MailingTemplateAllowedTemplatesConfig::class],
155156
['createLeadpageConfigurationConfig', LeadpageConfigurationConfig::class],
156157
['createLeadpageTemplateSourcesConfig', LeadpageTemplateSourcesConfig::class],
158+
['createLeadpageTemplateConfigurationConfig', LeadpageTemplateConfigurationConfig::class],
157159
];
158160
}
159161
}

0 commit comments

Comments
 (0)