-
Notifications
You must be signed in to change notification settings - Fork 119
[management] Code generation: update services and models #850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ class AffirmInfo implements ModelInterface, ArrayAccess, \JsonSerializable | |
| * @var string[] | ||
| */ | ||
| protected static $openAPITypes = [ | ||
| 'pricePlan' => 'string', | ||
| 'supportEmail' => 'string' | ||
| ]; | ||
|
|
||
|
|
@@ -52,6 +53,7 @@ class AffirmInfo implements ModelInterface, ArrayAccess, \JsonSerializable | |
| * @psalm-var array<string, string|null> | ||
| */ | ||
| protected static $openAPIFormats = [ | ||
| 'pricePlan' => null, | ||
| 'supportEmail' => null | ||
| ]; | ||
|
|
||
|
|
@@ -61,6 +63,7 @@ class AffirmInfo implements ModelInterface, ArrayAccess, \JsonSerializable | |
| * @var boolean[] | ||
| */ | ||
| protected static $openAPINullables = [ | ||
| 'pricePlan' => false, | ||
| 'supportEmail' => false | ||
| ]; | ||
|
|
||
|
|
@@ -150,6 +153,7 @@ public function isNullableSetToNull(string $property): bool | |
| * @var string[] | ||
| */ | ||
| protected static $attributeMap = [ | ||
| 'pricePlan' => 'pricePlan', | ||
| 'supportEmail' => 'supportEmail' | ||
| ]; | ||
|
|
||
|
|
@@ -159,6 +163,7 @@ public function isNullableSetToNull(string $property): bool | |
| * @var string[] | ||
| */ | ||
| protected static $setters = [ | ||
| 'pricePlan' => 'setPricePlan', | ||
| 'supportEmail' => 'setSupportEmail' | ||
| ]; | ||
|
|
||
|
|
@@ -168,6 +173,7 @@ public function isNullableSetToNull(string $property): bool | |
| * @var string[] | ||
| */ | ||
| protected static $getters = [ | ||
| 'pricePlan' => 'getPricePlan', | ||
| 'supportEmail' => 'getSupportEmail' | ||
| ]; | ||
|
|
||
|
|
@@ -212,7 +218,23 @@ public function getModelName() | |
| return self::$openAPIModelName; | ||
| } | ||
|
|
||
| public const PRICE_PLAN_BRONZE = 'BRONZE'; | ||
| public const PRICE_PLAN_SILVER = 'SILVER'; | ||
| public const PRICE_PLAN_GOLD = 'GOLD'; | ||
|
|
||
| /** | ||
| * Gets allowable values of the enum | ||
| * | ||
| * @return string[] | ||
| */ | ||
| public function getPricePlanAllowableValues() | ||
| { | ||
| return [ | ||
| self::PRICE_PLAN_BRONZE, | ||
| self::PRICE_PLAN_SILVER, | ||
| self::PRICE_PLAN_GOLD, | ||
| ]; | ||
| } | ||
| /** | ||
| * Associative array for storing property values | ||
| * | ||
|
|
@@ -228,6 +250,7 @@ public function getModelName() | |
| */ | ||
| public function __construct(?array $data = null) | ||
| { | ||
| $this->setIfExists('pricePlan', $data ?? [], null); | ||
| $this->setIfExists('supportEmail', $data ?? [], null); | ||
| } | ||
|
|
||
|
|
@@ -258,6 +281,15 @@ public function listInvalidProperties() | |
| { | ||
| $invalidProperties = []; | ||
|
|
||
| $allowedValues = $this->getPricePlanAllowableValues(); | ||
| if (!is_null($this->container['pricePlan']) && !in_array($this->container['pricePlan'], $allowedValues, true)) { | ||
| $invalidProperties[] = sprintf( | ||
| "invalid value '%s' for 'pricePlan', must be one of '%s'", | ||
| $this->container['pricePlan'], | ||
| implode("', '", $allowedValues) | ||
| ); | ||
| } | ||
|
|
||
| if ($this->container['supportEmail'] === null) { | ||
| $invalidProperties[] = "'supportEmail' can't be null"; | ||
| } | ||
|
|
@@ -276,6 +308,40 @@ public function valid() | |
| } | ||
|
|
||
|
|
||
| /** | ||
| * Gets pricePlan | ||
| * | ||
| * @return string|null | ||
| */ | ||
| public function getPricePlan() | ||
| { | ||
| return $this->container['pricePlan']; | ||
| } | ||
|
|
||
| /** | ||
| * Sets pricePlan | ||
| * | ||
| * @param string|null $pricePlan Merchant price plan | ||
| * | ||
| * @return self | ||
| */ | ||
| public function setPricePlan($pricePlan) | ||
| { | ||
| $allowedValues = $this->getPricePlanAllowableValues(); | ||
| if (!in_array($pricePlan, $allowedValues, true)) { | ||
| error_log( | ||
| sprintf( | ||
| "pricePlan: unexpected enum value '%s' - Supported values are [%s]", | ||
| $pricePlan, | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
|
Comment on lines
+332
to
+338
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using throw new \InvalidArgumentException(
sprintf(
"pricePlan: unexpected enum value '%s' - Supported values are [%s]",
$pricePlan,
implode(', ', $allowedValues)
)
); |
||
| } | ||
| $this->container['pricePlan'] = $pricePlan; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Gets supportEmail | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -384,11 +384,11 @@ public function setServiceLevel($serviceLevel) | |
| { | ||
| $allowedValues = $this->getServiceLevelAllowableValues(); | ||
| if (!in_array($serviceLevel, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'serviceLevel', must be one of '%s'", | ||
| "serviceLevel: unexpected enum value '%s' - Supported values are [%s]", | ||
| $serviceLevel, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
|
Comment on lines
+387
to
393
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using throw new \InvalidArgumentException(
sprintf(
"serviceLevel: unexpected enum value '%s' - Supported values are [%s]",
$serviceLevel,
implode(', ', $allowedValues)
)
); |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -531,11 +531,11 @@ public function setStatus($status) | |
| { | ||
| $allowedValues = $this->getStatusAllowableValues(); | ||
| if (!in_array($status, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'status', must be one of '%s'", | ||
| "status: unexpected enum value '%s' - Supported values are [%s]", | ||
| $status, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
|
Comment on lines
+534
to
540
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using throw new \InvalidArgumentException(
sprintf(
"status: unexpected enum value '%s' - Supported values are [%s]",
$status,
implode(', ', $allowedValues)
)
); |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,11 +324,11 @@ public function setSimcardStatus($simcardStatus) | |
| { | ||
| $allowedValues = $this->getSimcardStatusAllowableValues(); | ||
| if (!in_array($simcardStatus, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'simcardStatus', must be one of '%s'", | ||
| "simcardStatus: unexpected enum value '%s' - Supported values are [%s]", | ||
| $simcardStatus, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
|
Comment on lines
+327
to
333
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using throw new \InvalidArgumentException(
sprintf(
"simcardStatus: unexpected enum value '%s' - Supported values are [%s]",
$simcardStatus,
implode(', ', $allowedValues)
)
); |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -635,11 +635,11 @@ public function setCommunicationFormat($communicationFormat) | |
| { | ||
| $allowedValues = $this->getCommunicationFormatAllowableValues(); | ||
| if (!in_array($communicationFormat, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'communicationFormat', must be one of '%s'", | ||
| "communicationFormat: unexpected enum value '%s' - Supported values are [%s]", | ||
| $communicationFormat, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
|
Comment on lines
+638
to
644
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using throw new \InvalidArgumentException(
sprintf(
"communicationFormat: unexpected enum value '%s' - Supported values are [%s]",
$communicationFormat,
implode(', ', $allowedValues)
)
); |
||
| } | ||
|
|
@@ -693,11 +693,11 @@ public function setEncryptionProtocol($encryptionProtocol) | |
| { | ||
| $allowedValues = $this->getEncryptionProtocolAllowableValues(); | ||
| if (!in_array($encryptionProtocol, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'encryptionProtocol', must be one of '%s'", | ||
| "encryptionProtocol: unexpected enum value '%s' - Supported values are [%s]", | ||
| $encryptionProtocol, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
| } | ||
|
|
@@ -727,11 +727,11 @@ public function setFilterMerchantAccountType($filterMerchantAccountType) | |
| { | ||
| $allowedValues = $this->getFilterMerchantAccountTypeAllowableValues(); | ||
| if (!in_array($filterMerchantAccountType, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'filterMerchantAccountType', must be one of '%s'", | ||
| "filterMerchantAccountType: unexpected enum value '%s' - Supported values are [%s]", | ||
| $filterMerchantAccountType, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
| } | ||
|
|
@@ -785,11 +785,11 @@ public function setNetworkType($networkType) | |
| { | ||
| $allowedValues = $this->getNetworkTypeAllowableValues(); | ||
| if (!in_array($networkType, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'networkType', must be one of '%s'", | ||
| "networkType: unexpected enum value '%s' - Supported values are [%s]", | ||
| $networkType, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -590,11 +590,11 @@ public function setCommunicationFormat($communicationFormat) | |
| { | ||
| $allowedValues = $this->getCommunicationFormatAllowableValues(); | ||
| if (!in_array($communicationFormat, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'communicationFormat', must be one of '%s'", | ||
| "communicationFormat: unexpected enum value '%s' - Supported values are [%s]", | ||
| $communicationFormat, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
|
Comment on lines
+593
to
599
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using throw new \InvalidArgumentException(
sprintf(
"communicationFormat: unexpected enum value '%s' - Supported values are [%s]",
$communicationFormat,
implode(', ', $allowedValues)
)
); |
||
| } | ||
|
|
@@ -648,11 +648,11 @@ public function setEncryptionProtocol($encryptionProtocol) | |
| { | ||
| $allowedValues = $this->getEncryptionProtocolAllowableValues(); | ||
| if (!in_array($encryptionProtocol, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'encryptionProtocol', must be one of '%s'", | ||
| "encryptionProtocol: unexpected enum value '%s' - Supported values are [%s]", | ||
| $encryptionProtocol, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
| } | ||
|
|
@@ -682,11 +682,11 @@ public function setNetworkType($networkType) | |
| { | ||
| $allowedValues = $this->getNetworkTypeAllowableValues(); | ||
| if (!in_array($networkType, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'networkType', must be one of '%s'", | ||
| "networkType: unexpected enum value '%s' - Supported values are [%s]", | ||
| $networkType, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -389,11 +389,11 @@ public function setServiceLevel($serviceLevel) | |
| { | ||
| $allowedValues = $this->getServiceLevelAllowableValues(); | ||
| if (!in_array($serviceLevel, $allowedValues, true)) { | ||
| throw new \InvalidArgumentException( | ||
| error_log( | ||
| sprintf( | ||
| "Invalid value '%s' for 'serviceLevel', must be one of '%s'", | ||
| "serviceLevel: unexpected enum value '%s' - Supported values are [%s]", | ||
| $serviceLevel, | ||
| implode("', '", $allowedValues) | ||
| implode(', ', $allowedValues) | ||
| ) | ||
| ); | ||
|
Comment on lines
+392
to
398
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using throw new \InvalidArgumentException(
sprintf(
"serviceLevel: unexpected enum value '%s' - Supported values are [%s]",
$serviceLevel,
implode(', ', $allowedValues)
)
); |
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
error_loginstead of throwing an exception for invalid enum values can lead to silent failures. The previous implementation withthrow new \InvalidArgumentExceptionwas safer as it immediately stopped execution and notified the caller of the invalid data. Witherror_log, the invalid value is assigned to the property, and the program continues, potentially leading to unexpected behavior and making bugs harder to trace. It is highly recommended to revert to throwing an exception to enforce the model's contract and maintain data integrity.