Skip to content

Commit

Permalink
Merge pull request #256 from sitkoru/update-api
Browse files Browse the repository at this point in the history
feat: remove not supported consts
  • Loading branch information
pogromistik authored Jan 31, 2022
2 parents 956926d + cd081a5 commit be1e130
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/services/campaigns/CampaignsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public function toUpdateEntities(array $entities): array
foreach ($converted as $campaign) {
if ($campaign->TextCampaign && $campaign->TextCampaign->Settings) {
foreach ($campaign->TextCampaign->Settings as $i => $setting) {
TextCampaignSettingsEnum::checkValue($setting->Option);
if (TextCampaignSettingsEnum::isGetOnly($setting->Option)) {
unset($campaign->TextCampaign->Settings[$i]);
}
Expand Down Expand Up @@ -240,6 +241,7 @@ public function toUpdateEntities(array $entities): array
}
if ($campaign->MobileAppCampaign && $campaign->MobileAppCampaign->Settings) {
foreach ($campaign->MobileAppCampaign->Settings as $i => $setting) {
MobileAppCampaignSettingsEnum::checkValue($setting->Option);
if (MobileAppCampaignSettingsEnum::isGetOnly($setting->Option)) {
unset($campaign->MobileAppCampaign->Settings[$i]);
}
Expand Down
11 changes: 11 additions & 0 deletions src/services/campaigns/enum/MobileAppCampaignSettingsEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace directapi\services\campaigns\enum;

use directapi\components\Enum;
use directapi\exceptions\DirectApiException;

class MobileAppCampaignSettingsEnum extends Enum
{
Expand Down Expand Up @@ -33,4 +34,14 @@ public static function isGetOnly(MobileAppCampaignSettingsEnum $value): bool
}
return false;
}

/**
* @throws \Exception
*/
public static function checkValue(MobileAppCampaignSettingsEnum $value)
{
if ($value == self::MAINTAIN_NETWORK_CPC) {
throw new DirectApiException(self::MAINTAIN_NETWORK_CPC . " is deprecated");
}
}
}
11 changes: 11 additions & 0 deletions src/services/campaigns/enum/TextCampaignSettingsEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace directapi\services\campaigns\enum;

use directapi\components\Enum;
use directapi\exceptions\DirectApiException;

class TextCampaignSettingsEnum extends Enum
{
Expand Down Expand Up @@ -40,4 +41,14 @@ public static function isGetOnly(TextCampaignSettingsEnum $value): bool
}
return false;
}

/**
* @throws \Exception
*/
public static function checkValue(TextCampaignSettingsEnum $value)
{
if ($value == self::MAINTAIN_NETWORK_CPC) {
throw new DirectApiException(self::MAINTAIN_NETWORK_CPC . " is deprecated");
}
}
}

0 comments on commit be1e130

Please sign in to comment.