bunq / sdk_php

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

Uncaught TypeError when listing NoteAttachmentMasterCardAction #164

Open basst85 opened 5 years ago

basst85 commented 5 years ago

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:

  1. Return a JSON object with attachments

What happens:

  1. Retuns an error

Traceback

SDK version and environment

Response id

None

OGKevin commented 5 years ago

hmm, @kojoru sounds like a view definition error. Same as #76

OGKevin commented 5 years ago

@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

basst85 commented 5 years ago

@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

OGKevin commented 5 years ago

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.

OGKevin commented 5 years ago

so @kojoru this can either be an view definition mistake or the actual response is wrong :)

basst85 commented 5 years ago

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!

basst85 commented 5 years ago

@kojoru Any update on this small bug?