bunq / sdk_php

PHP SDK for bunq API
MIT License
84 stars 54 forks source link

TabUsageSingle with uuid "X" not found. #106

Closed dqos closed 6 years ago

dqos commented 6 years ago

I'm using the following code to get the status of a request/tab (no bunq request), but it always returns an error that the UUID can't be found. Is this intentional due the sandbox mode?

First I create a tab, and I use that UUID to get the status, so it should work... Then I tried to get the status of a real UUID from my bunq account, same issue.

Steps to reproduce:

// Restore the API context.
$apiContext = ApiContext::restore(ApiContext::FILENAME_CONFIG_DEFAULT);
// Retrieve the active user.
$users = User::listing($apiContext)->getValue();
// If your user is UserPerson or UserLight, replace getUserCompany() with getUserPerson() or getUserLight()
$userId = $users[INDEX_FIRST]->getUserCompany()->getId();
// Retrieve the first monetary account of the active user.
$monetaryAccounts = MonetaryAccount::listing($apiContext, $userId)->getValue();
$monetaryAccountId = $monetaryAccounts[INDEX_FIRST]->getMonetaryAccountBank()->getId();

$attachmentPublicBytes = file_get_contents(__DIR__ . ATTACHMENT_FILENAME);
$requestHeadersMap = [
    ApiClient::HEADER_CONTENT_TYPE => ATTACHMENT_CONTENT_TYPE,
    ApiClient::HEADER_ATTACHMENT_DESCRIPTION => ATTACHMENT_DESCRIPTION,
];
// Create a new public attachment.
$attachmentPublicUuid = AttachmentPublic::create($apiContext, $attachmentPublicBytes, $requestHeadersMap)->getValue();
$attachmentPublicUuidMap = [
    Avatar::FIELD_ATTACHMENT_PUBLIC_UUID => $attachmentPublicUuid,
];
// Create a new avatar using the public attachment.
$avatarUuid = Avatar::create($apiContext, $attachmentPublicUuidMap)->getValue();

$cashRegisterMap = [
    CashRegister::FIELD_AVATAR_UUID => $avatarUuid,
    CashRegister::FIELD_LOCATION => $geoLocation,
    CashRegister::FIELD_NAME => uniqid(CASH_REGISTER_PREFIX_NAME),
    CashRegister::FIELD_STATUS => CASH_REGISTER_STATUS_PENDING_APPROVAL,
];

$cashRegisterId = CashRegister::create($apiContext, $cashRegisterMap, $userId, $monetaryAccountId)->getValue();

$tab = TabUsageSingle::get($apiContext, $userId, $monetaryAccountId, $cashRegisterId, "XXX")->getValue();

What should happen:

It should return the status of the UUID.

What happens:

HTTP Response Code: 404
TabUsageSingle with uuid "691b0115-b4c9-4d3a-8fcf-c72dd3c5d47d" not found.

Thanks!

OGKevin commented 6 years ago

@qarizma in this code snippet i don't see you creating the tab ?

Where are you getting "XXX" from ?

dqos commented 6 years ago

@OGKevin I already created a tab using: https://github.com/bunq/sdk_php/blob/develop/example/tab_example.php

The XXX is returned by $tabUsageSingle->getUuid(); The UUID seems to be correct formed. Also tried using an existing/real uuid.

OGKevin commented 6 years ago

@qarizma i could not reproduce with the following code:

        static::$tabUuid = TabUsageSingle::create(
            $apiContext,
            $tabUsageSingleCreateMap,
            static::$userId,
            static::$monetaryAccountId,
            static::$cashRegisterId
        )->getValue();

        $tabUsageSingle =
            TabUsageSingle::get(
                $apiContext,
                static::$userId,
                static::$monetaryAccountId,
                static::$cashRegisterId,
                static::$tabUuid
            );
  1. Are you sure you're indeed using the correct uuid ?
  2. Could you filter out the unneeded code from the issue, maybe this will help us spot the problem quicker.
  3. When you do listing, instead of get, do you see the new tab you created in that list ?
  4. Could you do a get call to CashRegister and check the status of this cash register.