Skip to content
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

[SOLUTION] SDK is outdated the BunqLib causing Tinker (and examples) Errors in addCallbackUrl #46

Open
McSloverd opened this issue Apr 20, 2020 · 1 comment

Comments

@McSloverd
Copy link

McSloverd commented Apr 20, 2020

First, It is Solved. It is FOR SURE a bug with SDK and the BunqLib in Tinker and Examples.

The basic flow is:
Tinker::addCallbackUrl => BunqLib::addCallbackUrl => UserPerson::getNotificationFilters => Add new notification filters to the current filter list => UserPerson::update().

But this is wrong in several places:

  1. at BunqLib::addCallbackUrl is using "new NotificationFilter()" to generate a new NotificationFilter Object. This is incorrect because the SDK is asking for the NotificationFilterUrlUser / NotificationFilterMonataryAccount;

  2. at BunqLib::addCallbackUrl is using UserPerson::update() to set the new NotificationFiler. This is incorrect because:
    a. the parameters are mismatched;
    b. the update is no longer taking NotificationFilter as a parameter and it is not going to update the filters;

The Solution:
STEP 1. replace BunqLib::addCallbackUrl with:

public function addCallbackUrl(string $callbackUrl) {
       $allUpdatedNotificationFilter[] = new NotificationFilterUrl(
            self::NOTIFICATION_CATEGORY_MUTATION,
            $callbackUrl
        );

        $notificationFilterUrlUser = new NotificationFilterUrlUser($allUpdatedNotificationFilter);
        $notificationFilterUrlUser -> create($allUpdatedNotificationFilter);
}

STEP 2. (THE BUG):
in bunq\sdk_php\Model\Core\BunqModel.php
at line: 361
Change:
$value = static::createListFromResponseArray($response, $wrapper);
Into:
$value = static::createListFromResponseArray($response[0], $wrapper);

Because the returned response is like:

     Array(1) => 
           Array(1) => 
                Array(5)
                     "NotificationFilters" => 
                     ....

There is one more dimension of the response array.

It is tested in both SANDBOX and PRODUCTION environments.

@McSloverd
Copy link
Author

Happy Tinkering~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant