Skip to content

Commit

Permalink
Add LeadpageTemplate Client (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
WorksDev authored Jul 17, 2024
1 parent b3bfc79 commit e30f92e
Show file tree
Hide file tree
Showing 13 changed files with 477 additions and 8 deletions.
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": "^8.1",
"ext-soap": "*",
"scn/evalanche-soap-api-struct": "^2.2",
"scn/evalanche-soap-api-struct": "^2.3",
"scn/hydrator": "^2|^3",
"scn/hydrator-property-values": "^2.0|^3.0"
},
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

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

89 changes: 89 additions & 0 deletions src/Client/LeadPageTemplate/LeadpageTemplateClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

declare(strict_types=1);

namespace Scn\EvalancheSoapApiConnector\Client\LeadPageTemplate;

use Scn\EvalancheSoapApiConnector\Client\AbstractClient;
use Scn\EvalancheSoapApiConnector\Client\ClientInterface;
use Scn\EvalancheSoapApiConnector\Client\Generic\ResourceTrait;
use Scn\EvalancheSoapApiConnector\Exception\EmptyResultException;
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\TemplatesSourcesInterface;

class LeadpageTemplateClient extends AbstractClient implements LeadpageTemplateClientInterface
{
use ResourceTrait;
const PORTNAME = 'leadpagetemplate';
const VERSION = ClientInterface::VERSION_V0;

/**
* @param string $title
* @param int $folderId
*
* @return ResourceInformationInterface
* @throws EmptyResultException
*/
public function create(
string $title,
int $folderId
): ResourceInformationInterface {
return $this->responseMapper->getObject(
$this->soapClient->create(
[
'name' => $title,
'category_id' => $folderId,
]
),
'createResult',
$this->hydratorConfigFactory->createResourceInformationConfig()
);
}

/**
* @param int $id
*
* @return TemplatesSourcesInterface
* @throws EmptyResultException
*/
public function getSources(int $id): TemplatesSourcesInterface
{
return $this->responseMapper->getObject(
$this->soapClient->getSources(
[
'leadpage_template_id' => $id,
]
),
'getSourcesResult',
$this->hydratorConfigFactory->createLeadpageTemplateSourcesConfig()
);
}

/**
* @param int $id
* @param TemplatesSourcesInterface $configuration
*
* @return TemplatesSourcesInterface
* @throws EmptyResultException
*/
public function setSources(
int $id,
TemplatesSourcesInterface $configuration,
bool $overwrite = false
): TemplatesSourcesInterface {
return $this->responseMapper->getObject(
$this->soapClient->setSources(
[
'leadpage_template_id' => $id,
'sources' => $this->extractor->extract(
$this->hydratorConfigFactory->createLeadpageTemplateSourcesConfig(),
$configuration
),
'overwrite' => $overwrite
]
),
'setSourcesResult',
$this->hydratorConfigFactory->createLeadpageTemplateSourcesConfig()
);
}
}
45 changes: 45 additions & 0 deletions src/Client/LeadPageTemplate/LeadpageTemplateClientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Scn\EvalancheSoapApiConnector\Client\LeadPageTemplate;

use Scn\EvalancheSoapApiConnector\Client\ClientInterface;
use Scn\EvalancheSoapApiConnector\Client\Generic\ResourceTraitInterface;
use Scn\EvalancheSoapApiConnector\Exception\EmptyResultException;
use Scn\EvalancheSoapStruct\Struct\Generic\ResourceInformationInterface;
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\TemplatesSourcesInterface;

interface LeadpageTemplateClientInterface extends ResourceTraitInterface, ClientInterface
{
/**
* @param string $title
* @param int $folderId
*
* @return ResourceInformationInterface
* @throws EmptyResultException
*/
public function create(
string $title,
int $folderId
): ResourceInformationInterface;

/**
* @param int $id
*
* @return TemplatesSourcesInterface
* @throws EmptyResultException
*/
public function getSources(int $id): TemplatesSourcesInterface;

/**
* @param int $id
* @param TemplatesSourcesInterface $configuration
*
* @return TemplatesSourcesInterface
* @throws EmptyResultException
*/
public function setSources(
int $id,
TemplatesSourcesInterface $configuration,
bool $overwrite = false
): TemplatesSourcesInterface;
}
5 changes: 5 additions & 0 deletions src/EvalancheConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,9 @@ public function createCouponListClient(): Client\CouponList\CouponListClientInte
{
return $this->createClient(Client\CouponList\CouponListClient::class);
}

public function createLeadpageTemplateClient(): Client\LeadPageTemplate\LeadpageTemplateClientInterface
{
return $this->createClient(Client\LeadPageTemplate\LeadpageTemplateClient::class);
}
}
2 changes: 2 additions & 0 deletions src/EvalancheConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ public function createMilestoneClient(): Client\Milestone\MilestoneClientInterfa
public function createMarketplaceClient(): Client\Marketplace\MarketplaceClientInterface;

public function createCouponListClient(): Client\CouponList\CouponListClientInterface;

public function createLeadpageTemplateClient(): Client\LeadPageTemplate\LeadpageTemplateClientInterface;
}
6 changes: 6 additions & 0 deletions src/Hydrator/Config/HydratorConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Generic\ResourceTypeInformationConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Generic\ServiceStatusConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPage\LeadpageConfigurationConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPageTemplate\LeadpageTemplateSourcesConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Mailing\MailingArticleConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Mailing\MailingClickConfig;
use Scn\EvalancheSoapApiConnector\Hydrator\Config\Mailing\MailingConfigurationConfig;
Expand Down Expand Up @@ -309,6 +310,11 @@ public function createMailingTemplateSourcesConfig(): HydratorConfigInterface
{
return new MailingTemplateSourcesConfig();
}

public function createLeadpageTemplateSourcesConfig(): HydratorConfigInterface
{
return new LeadpageTemplateSourcesConfig();
}

public function createMailingSlotConfigurationConfig(): HydratorConfigInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/Hydrator/Config/HydratorConfigFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public function createMailingTemplateConfigurationConfig(): HydratorConfigInterf

public function createMailingTemplateSourcesConfig(): HydratorConfigInterface;

public function createLeadpageTemplateSourcesConfig(): HydratorConfigInterface;

public function createMailingSlotConfigurationConfig(): HydratorConfigInterface;

public function createMailingSlotConfig(): HydratorConfigInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Scn\EvalancheSoapApiConnector\Hydrator\Config\LeadPageTemplate;

use Scn\EvalancheSoapApiConnector\Hydrator\Config\HydratorConfigInterface;
use Scn\EvalancheSoapStruct\Struct\LeadPageTemplate\TemplatesSources;
use Scn\EvalancheSoapStruct\Struct\StructInterface;
use Scn\HydratorPropertyValues\Property\StringValue;

class LeadpageTemplateSourcesConfig implements HydratorConfigInterface
{
public function getObject(): StructInterface
{
return new TemplatesSources();
}

public function getHydratorProperties(): array
{
return [
'web' => StringValue::set('templateWeb'),
'landingpage' => StringValue::set('templateLandingpage'),
];
}

public function getExtractorProperties(): array
{
return [
'web' => StringValue::get('templateWeb'),
'landingpage' => StringValue::get('templateLandingpage'),
];
}
}
Loading

0 comments on commit e30f92e

Please sign in to comment.