msgraph-sdk-php icon indicating copy to clipboard operation
msgraph-sdk-php copied to clipboard

Wrong property types in MessageRuleActions

Open fanonwue opened this issue 4 years ago • 1 comments

Hello,

I am currently trying to set an e-mail redirection using MessageRule and MessageRuleActions. I have noticed that the API expects the "redirectTo" property (the same applies to the two forwardTo properties) to be a collection, according to the official docs and the metadata.xml you are using to generate the models.

It seems that there is a bug in the generation process though, as the setter for the redirectTo property expects a single recipient, not a collection. The problem is not that important since you can still pass an array of Microsoft\Graph\Model\Recipient objects instead of a single one, but PHPStorm for example marks it as a warning.

Is it possible to change the PHPDoc? I assume this gets automatically generated as well?

I doubt that it's necessary but here's a code snippet

$recipient = new Recipient();
// fill the object with stuff


// create the rule object and create an array of recipients instead of using the object directly
$rule = (new MessageRule())
    ->setActions(
        (new MessageRuleActions())->setRedirectTo([$recipient])->setStopProcessingRules(false)
    )->setDisplayName($displayName)
    ->setSequence(1)
    ->setIsEnabled(true);

SDK Version 1.33.0 PHP 7.4 AB#9620

fanonwue avatar May 27 '21 09:05 fanonwue

Hello @fanonwue, thanks for reporting this and sorry for the inconvenience caused, we are working on fixing the issue with setters and getters for collection types which should be available in the next release. This relates to #97 and #76

SilasKenneth avatar May 27 '21 13:05 SilasKenneth

PHPDoc issues were resolved.

Ndiritu avatar Oct 06 '22 07:10 Ndiritu