Skip to content

Commit 607ed64

Browse files
committed
Add new leadpage-template methods
This adds several methods for slot-manipulation in leadpage-templates
1 parent 4e8a588 commit 607ed64

12 files changed

Lines changed: 752 additions & 24 deletions

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.6",
27+
"scn/evalanche-soap-api-struct": "^2.7",
2828
"scn/hydrator": "^2|^3",
2929
"scn/hydrator-property-values": "^2.0|^3.0"
3030
},

composer.lock

Lines changed: 18 additions & 18 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: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
use Scn\EvalancheSoapApiConnector\Client\ClientInterface;
99
use Scn\EvalancheSoapApiConnector\Client\Generic\ResourceTrait;
1010
use Scn\EvalancheSoapApiConnector\Exception\EmptyResultException;
11+
use Scn\EvalancheSoapStruct\Struct\Generic\HashMapInterface;
1112
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;
13+
use Scn\EvalancheSoapStruct\Struct\LeadPage\LeadpageSlotConfigurationInterface;
14+
use Scn\EvalancheSoapStruct\Struct\LeadPage\LeadpageSlotInterface;
15+
use Scn\EvalancheSoapStruct\Struct\LeadPage\LeadpageSlotItemInterface;
1216
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateConfiguration;
1317
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateConfigurationInterface;
1418
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\TemplatesSourcesInterface;
@@ -189,4 +193,130 @@ public function addArticles(int $id, array $articles): array
189193
$this->hydratorConfigFactory->createLeadpageArticleConfig()
190194
);
191195
}
196+
197+
/** @inheritdoc */
198+
public function removeSlot(int $id, int $slotId): bool
199+
{
200+
return $this->responseMapper->getBoolean(
201+
$this->soapClient->removeSlot([
202+
'leadpage_template_id' => $id,
203+
'slot_id' => $slotId
204+
]),
205+
'removeSlotResult'
206+
);
207+
}
208+
209+
/** @inheritdoc */
210+
public function removeTemplateFromSlot(
211+
int $id,
212+
int $slotId,
213+
int $templateType,
214+
int $articleTypeId = 0
215+
): bool {
216+
return $this->responseMapper->getBoolean(
217+
$this->soapClient->removeTemplateFromSlot([
218+
'leadpage_template_id' => $id,
219+
'slot_id' => $slotId,
220+
'template_type' => $templateType,
221+
'article_type_id' => $articleTypeId
222+
]),
223+
'removeTemplateFromSlotResult'
224+
);
225+
}
226+
227+
/** @inheritdoc */
228+
public function getSlotConfiguration(int $id): LeadpageSlotConfigurationInterface
229+
{
230+
return $this->responseMapper->getObject(
231+
$this->soapClient->getSlotConfiguration(['leadpage_template_id' => $id]),
232+
'getSlotConfigurationResult',
233+
$this->hydratorConfigFactory->createLeadpageSlotConfigurationConfig()
234+
);
235+
}
236+
237+
/** @inheritdoc */
238+
public function addSlot(
239+
int $id,
240+
int $slotNumber
241+
): LeadpageSlotInterface {
242+
return $this->responseMapper->getObject(
243+
$this->soapClient->addSlot([
244+
'leadpage_template_id' => $id,
245+
'slot_number' => $slotNumber,
246+
]),
247+
'addSlotResult',
248+
$this->hydratorConfigFactory->createLeadpageSlotConfig()
249+
);
250+
}
251+
252+
/** @inheritdoc */
253+
public function updateSlot(
254+
int $id,
255+
int $slotId,
256+
int $slotNumber,
257+
string $name,
258+
int $sortTypeId,
259+
int $sortValue
260+
): LeadpageSlotInterface {
261+
return $this->responseMapper->getObject(
262+
$this->soapClient->updateSlot([
263+
'leadpage_template_id' => $id,
264+
'slot_id' => $slotId,
265+
'slot_number' => $slotNumber,
266+
'name' => $name,
267+
'sort_type_id' => $sortTypeId,
268+
'sort_value' => $sortValue
269+
]),
270+
'updateSlotResult',
271+
$this->hydratorConfigFactory->createLeadpageSlotConfig()
272+
);
273+
}
274+
275+
/** @inheritdoc */
276+
public function addTemplatesToSlot(
277+
int $id,
278+
int $slotId,
279+
HashMapInterface $config,
280+
int $articleTypeId = 0,
281+
array $allowed_templates = []
282+
): LeadpageSlotItemInterface {
283+
return $this->responseMapper->getObject(
284+
$this->soapClient->addTemplatesToSlot([
285+
'leadpage_template_id' => $id,
286+
'slot_id' => $slotId,
287+
'data' => $config,
288+
'article_type_id' => $articleTypeId,
289+
'allowed_templates' => $this->extractor->extractArray(
290+
$this->hydratorConfigFactory->createLeadpageTemplateAllowedTemplatesConfig(),
291+
$allowed_templates
292+
)
293+
]),
294+
'addTemplatesToSlotResult',
295+
$this->hydratorConfigFactory->createLeadpageSlotItemConfig()
296+
);
297+
}
298+
299+
/** @inheritdoc */
300+
public function updateSlotTemplates(
301+
int $id,
302+
int $slotId,
303+
HashMapInterface $config,
304+
int $articleTypeId = 0,
305+
array $allowed_templates = []
306+
): LeadpageSlotItemInterface {
307+
return $this->responseMapper->getObject(
308+
$this->soapClient->updateSlotTemplates([
309+
'leadpage_template_id' => $id,
310+
'slot_id' => $slotId,
311+
'data' => $config,
312+
'article_type_id' => $articleTypeId,
313+
'allowed_templates' => $this->extractor->extractArray(
314+
$this->hydratorConfigFactory->createLeadpageTemplateAllowedTemplatesConfig(),
315+
$allowed_templates
316+
)
317+
]),
318+
'updateSlotTemplatesResult',
319+
$this->hydratorConfigFactory->createLeadpageSlotItemConfig()
320+
);
321+
}
192322
}

src/Client/LeadPageTemplate/LeadpageTemplateClientInterface.php

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
use Scn\EvalancheSoapApiConnector\Client\ClientInterface;
66
use Scn\EvalancheSoapApiConnector\Client\Generic\ResourceTraitInterface;
77
use Scn\EvalancheSoapApiConnector\Exception\EmptyResultException;
8+
use Scn\EvalancheSoapStruct\Struct\Generic\HashMapInterface;
89
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;
910
use Scn\EvalancheSoapStruct\Struct\LeadPage\LeadpageArticleInterface;
11+
use Scn\EvalancheSoapStruct\Struct\LeadPage\LeadpageSlotConfigurationInterface;
12+
use Scn\EvalancheSoapStruct\Struct\LeadPage\LeadpageSlotInterface;
13+
use Scn\EvalancheSoapStruct\Struct\LeadPage\LeadpageSlotItemInterface;
14+
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateAllowedTemplatesInterface;
1015
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\LeadpageTemplateConfigurationInterface;
1116
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\TemplatesSourcesInterface;
1217

@@ -108,4 +113,117 @@ public function getArticlesByLeadpageTemplateId(int $id): array;
108113
* @throws EmptyResultException
109114
*/
110115
public function addArticles(int $id, array $articles): array;
116+
117+
/**
118+
* Removes an existing slot from a leadpage-template
119+
*
120+
* @param int $id
121+
* @param int $slotId
122+
*
123+
* @return bool
124+
* @throws EmptyResultException
125+
*/
126+
public function removeSlot(int $id, int $slotId): bool;
127+
128+
/**
129+
* Removes an article template configuration for a certain template type from an existing slot of the leadpage-template
130+
*
131+
* @param int $id
132+
* @param int $slotId
133+
* @param int $templateType
134+
* @param int $articleTypeId
135+
*
136+
* @return bool
137+
* @throws EmptyResultException
138+
*/
139+
public function removeTemplateFromSlot(
140+
int $id,
141+
int $slotId,
142+
int $templateType,
143+
int $articleTypeId = 0
144+
): bool;
145+
146+
/**
147+
* @param int $id
148+
*
149+
* @return LeadpageSlotConfigurationInterface
150+
* @throws EmptyResultException
151+
*/
152+
public function getSlotConfiguration(int $id): LeadpageSlotConfigurationInterface;
153+
154+
/**
155+
* Adds a slot to the leadpage-template
156+
*
157+
* @param int $id
158+
* @param int $slotNumber
159+
*
160+
* @return LeadpageSlotInterface
161+
* @throws EmptyResultException
162+
*/
163+
public function addSlot(
164+
int $id,
165+
int $slotNumber
166+
): LeadpageSlotInterface;
167+
168+
/**
169+
* Update a slot of the leadpage-template
170+
*
171+
* @param int $id
172+
* @param int $slotId
173+
* @param int $slotNumber
174+
* @param string $name
175+
* @param int $sortTypeId
176+
* @param int $sortValue
177+
*
178+
* @return LeadpageSlotInterface
179+
* @throws EmptyResultException
180+
*/
181+
public function updateSlot(
182+
int $id,
183+
int $slotId,
184+
int $slotNumber,
185+
string $name,
186+
int $sortTypeId,
187+
int $sortValue
188+
): LeadpageSlotInterface;
189+
190+
/**
191+
* Adds a template config to an existing slot of the leadpage-template
192+
*
193+
* @param int $id
194+
* @param int $slotId
195+
* @param HashMapInterface $config
196+
* @param int $articleTypeId
197+
* @param list<LeadpageTemplateAllowedTemplatesInterface> $allowed_templates
198+
*
199+
* @return LeadpageSlotItemInterface
200+
* @throws EmptyResultException
201+
*/
202+
public function addTemplatesToSlot(
203+
int $id,
204+
int $slotId,
205+
HashMapInterface $config,
206+
int $articleTypeId = 0,
207+
array $allowed_templates = []
208+
): LeadpageSlotItemInterface;
209+
210+
/**
211+
* Updates an existing template config of a slot of the leadpage-template
212+
*
213+
* @param int $id
214+
* @param int $slotId
215+
* @param HashMapInterface $config
216+
* @param int $articleTypeId
217+
* @param list<LeadpageTemplateAllowedTemplatesInterface> $allowed_templates
218+
*
219+
* @return LeadpageSlotItemInterface
220+
* @throws EmptyResultException
221+
*/
222+
public function updateSlotTemplates(
223+
int $id,
224+
int $slotId,
225+
HashMapInterface $config,
226+
int $articleTypeId = 0,
227+
array $allowed_templates = []
228+
): LeadpageSlotItemInterface;
111229
}

0 commit comments

Comments
 (0)