Need help about notifications settings GET (SOAP API)

  • woodhouse
    Account geschlossen

    75 Beiträge

    Italien

    Hi there,
    I have a problem with the notification settings results.
    I call the notification/settings and the results are:
    ...
    [body] => SimpleXMLElement Object
    (
    [notification_settings] => Array
    (
    [0] => SimpleXMLElement Object
    (
    [id_notification] => xxxxxxx
    [id_user] => yyyyyy
    [channel] => Curl
    [type] => Curl_Default
    [destination] => Link (https) .....
    [active] => 1
    )

    [1] => SimpleXMLElement Object
    (
    [id_notification] => zzzzzz
    [id_user] => yyyyyy
    [channel] => curl
    [type] => Curl_Default
    [destination] => Link (https) ......
    [active] => SimpleXMLElement Object
    (
    )

    )

    And so on.
    The problem is that I'm not able to iterate through the notification_settings elements.
    If I call the gettype($xml->Notification_Data->body->notification_settings) it returns "object"

    I'm a bit confused. Does someone have suggestions?
    Thanks for the help.

    Daniele
  • woodhouse
    Account geschlossen

    75 Beiträge

    Italien

    OK, I'm able to iterate through the notification_settings elements usin a foreach loop.
    Now the question is: does the call always returns array? Even if there is only 1 setting?
    Otherwise I think the foreach will raise an exception.
    Thank you
    Daniele
  • woodhouse
    Account geschlossen

    75 Beiträge

    Italien

    Hi there,
    I use this topic to post another question:
    If a notification setting is active like elemt 0 above, the "active" is set to 1. That make sense.
    If a notification setting is NOT active like elemt 1 above, the "active" is set to "SimpleXMLElement Object". I wonder why not set this value to 0.

    Daniele
  • @thomas
    Administrator

    348 Beiträge

    Belgien

    Hi there,
    I use this topic to post another question:
    If a notification setting is active like elemt 0 above, the "active" is set to 1. That make sense.
    If a notification setting is NOT active like elemt 1 above, the "active" is set to "SimpleXMLElement Object". I wonder why not set this value to 0.

    Daniele
    • Erstellt am 02.10.2020 um 06:12
    • #1194540
    Hello Daniele,

    The call will not always returns an array since it depends on the library used to read the XML. With your library you use, if there are several elements it will be an array otherwise it will return a SimpleXMLElement Object. But the PHP foreach will handle this well, no worries.

    If the notification is inactive the tag 'active' will be empty. It is still your library that parse empty fields into SimpleXMLElement Object.

    Sorry for the late response, I hope I have answered your questions.

    Best Regards,
    --
    Thomas
    Delcampe Team
  • woodhouse
    Account geschlossen

    75 Beiträge

    Italien

    Hi Thomas,
    thank you for the reply.
    I added some line of code and it works fine.
    However I think that returning an empty field on a logical element is a bug, not a feature.
    Empty does not match true nor false. An [active] field should be true(1) or false (0).
    Regards
    Daniele
  • @thomas
    Administrator

    348 Beiträge

    Belgien

    Hi Thomas,
    thank you for the reply.
    I added some line of code and it works fine.
    However I think that returning an empty field on a logical element is a bug, not a feature.
    Empty does not match true nor false. An [active] field should be true(1) or false (0).
    Regards
    Daniele
    • Erstellt am 12.10.2020 um 04:51
    • #1197967
    Hello Daniele,

    I'm glad to read that you've managed to make it work.

    You are right: we should not return an empty field. Unfortunately that's the way it was done back then and now many systems have been built that way. That's why we won't change this behaviour.

    I hope you understand this decision, forgive us for the inconvenience.

    Best Regards,
    --
    Thomas
    Delcampe Team

Werden Sie Mitglied der Sammler-Community!

Anmelden Einloggen