sdk_php
sdk_php copied to clipboard
Uncaught TypeError when listing NoteAttachmentMasterCardAction
Steps to reproduce:
I'm using this code:
$mastercardActions = MasterCardAction::listing($monetaryAccountId)->getValue();
$mastercardActionId = $mastercardActions[0]->getId();
$mastercardActionAttachments = NoteAttachmentMasterCardAction::listing($mastercardActionId,$monetaryAccountId)->getValue();
But it's returning this error:
Fatal error: Uncaught TypeError: Argument 1 passed to bunq\Model\Core\BunqModel::createFromResponseArray() must be of the type array, integer given, called in /var/www/domain.com/vendor/bunq/sdk_php/src/Model/Core/BunqModel.php on line 242
and defined in /var/www/domain.com/vendor/bunq/sdk_php/src/Model/Core/BunqModel.php:103 Stack trace: #0 /var/www/domain.com/vendor/bunq/sdk_php/src/Model/Core/BunqModel.php(242): bunq\Model\Core\BunqModel::createFromResponseArray(3647492, NULL) #1 /var/www/domain.com/vendor/bunq/sdk_php/src/Model/Core/BunqModel.php(207): bunq\Model\Core\BunqModel::createListFromResponseArray(Array) #2 /var/www/domain.com/vendor/bunq/sdk_php/src/Model/Core/BunqModel.php(165): bunq\Model\Core\BunqModel::determineFieldContents(Object(ReflectionProperty), Array) #3 /var/www/domain.com/vendor/bunq/sdk_php/src/Model/Core/BunqModel.php(119): bunq\Model\Core\BunqModel::createInstanceFromResponseArray(Array) #4 /var/www/domain.com/ in /var/www/domain.com/vendor/bunq/sdk_php/src/Model/Core/BunqModel.php on line 103
What should happen:
- Return a JSON object with attachments
What happens:
- Retuns an error
Traceback
SDK version and environment
- Tested on 1.1.0
- Sandbox
- Production
Response id
None
hmm, @kojoru sounds like a view definition error. Same as #76
@basst85 if you enable debugger you should be able to see/find out what its trying to deserialise and fix it by doing something like https://github.com/bunq/sdk_php/issues/76#issuecomment-379367982
@OGKevin @kojoru There is something "strange" with the returnvalue of $responseArray in the function fromJsonList() (in BunqModel): https://pastebin.com/ciGZ7k6L
The attachment object in the end of the file is strange.. ?
The response JSON: https://pastebin.com/RbfsYRNW
found it :)
"attachment": {
"id": 3647492,
"description": "",
"content_type": "image\/jpeg"
}
is an object but, this is how it's defined:
https://github.com/bunq/sdk_php/blob/f369d3b931ea833e06d40bda85620506a31568a2/src/Model/Generated/Endpoint/NoteAttachmentMasterCardAction.php#L72-L77
So please remove the []
from the doc and it should be good.
so @kojoru this can either be an view definition mistake or the actual response is wrong :)
found it :)
"attachment": { "id": 3647492, "description": "", "content_type": "image\/jpeg" }
is an object but, this is how it's defined:
sdk_php/src/Model/Generated/Endpoint/NoteAttachmentMasterCardAction.php
Lines 72 to 77 in f369d3b
/** * The attachment attached to the note. * * @var AttachmentMonetaryAccountPayment[] */ protected $attachment;
So please remove the
[]
from the doc and it should be good.
Yes! That works indeed. Thanks!
@kojoru Any update on this small bug?