You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to add filters to a notification but not only with Filter instances but also with Operator instances, the serialization process first turns all values of the Operator into undefined and the resulting payload will then carry an emtpy object {}.
The issues seems to be that internally the filter property of a Notification is set to be of type Array<Filter>. The ObjectSerializer therefore ignores the operator: "OR" as it's not a field of Filter. As a result, the request fails because of a BadRequest error with Body: {"errors":["Segment is not a valid filter field."]}.
) but instead Array<Filter|Operator> and that would properly be parsed. Or you just allow objects to be passed without serializing them through the ObjectSerializer.
Also the NodeJS SDK docs state that it should be possible to pass { operator: "OR"}.
Steps to reproduce?
1. create a new notification
2. set `filter` to an array of [Filter, Operator, Filter] instances
3. send the notification
What did you expect to happen?
The notification should be sent and the filter fields in the OneSignal dashboard should show that the notification was sent with three filters, the second being the "OR" operator.
Relevant log output
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
What happened?
When trying to add filters to a notification but not only with
Filter
instances but also withOperator
instances, the serialization process first turns all values of theOperator
intoundefined
and the resulting payload will then carry an emtpy object{}
.The issues seems to be that internally the filter property of a
Notification
is set to be of typeArray<Filter>
. The ObjectSerializer therefore ignores theoperator: "OR"
as it's not a field ofFilter
. As a result, the request fails because of aBadRequest
error withBody: {"errors":["Segment is not a valid filter field."]}
.The serialization happens here
onesignal-node-api/models/ObjectSerializer.ts
Lines 298 to 306 in f40b4bd
filter
property would not only beArray<Filter>
(seeonesignal-node-api/models/Notification.ts
Line 400 in f40b4bd
Array<Filter|Operator>
and that would properly be parsed. Or you just allow objects to be passed without serializing them through the ObjectSerializer.In the Go SDK, this case seems to be handled as expected: https://github.com/OneSignal/onesignal-go-api/blob/a573325af1d37a1c7dc8bad8d78fdd33fbfcaf38/model_filter_expressions.go#L27-L54
Also the NodeJS SDK docs state that it should be possible to pass
{ operator: "OR"}
.Steps to reproduce?
What did you expect to happen?
The notification should be sent and the filter fields in the OneSignal dashboard should show that the notification was sent with three filters, the second being the "OR" operator.
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: