-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: Adjustment items can be omitted when adjustment type is full #110
Conversation
922968c
to
fc69012
Compare
public readonly string $reason, | ||
public readonly string $transactionId, | ||
public readonly AdjustmentType|Undefined $type = new Undefined(), | ||
) { | ||
if ($this->type === AdjustmentType::Partial() && ($this->items instanceof Undefined || empty($this->items))) { | ||
$typeIsFull = AdjustmentType::Full()->equals($this->type); |
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.
$this->type === AdjustmentType::Partial()
strict comparison can't be used here
throw InvalidArgumentException::arrayIsEmpty('items'); | ||
} | ||
|
||
if ($typeIsFull && is_array($this->items)) { | ||
throw new InvalidArgumentException('items are not allowed when the adjustment type is full'); |
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.
API returns error "Array must have at least 1 items" when an empty array is sent in request, and "items are not allowed when the adjustment type is full" when items are provided with full
type
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
$items = []; | ||
if (is_array($this->items)) { | ||
$items = []; |
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.
Moved $items = []
inside is_array($this->items)
check so that Undefined
value is omitted from request
Fixed