Closed mbernson closed 4 years ago
@kojoru most likely invalid view definition.
CardGeneratedCvc2::create() creates a new CVC2-code, but i think it returns this error because the response data is not as expected?
But you can get the generated CVC2 with CardGeneratedCvc2::listing()
$responseRaw in the create function from CardGeneratedCvc2.php is an empty stream, so $apiClient->post(..) returns no response body.
@basst85 you mean https://github.com/bunq/sdk_php/blob/e9511e1c158a2c8d768d167bc05a66d7d88ea5d5/src/Model/Generated/Endpoint/CardGeneratedCvc2.php#L111-L118
? if so then this method must return https://github.com/bunq/sdk_php/blob/cc52274dc6400a38573f3bab17da3e5920c202fb/src/Model/Generated/Endpoint/BunqResponseNull.php as shown here https://github.com/bunq/sdk_php/blob/cc52274dc6400a38573f3bab17da3e5920c202fb/src/Model/Generated/Endpoint/Session.php#L39-L41
its a weird convention tho that a POST returns an empty body :(
I made an error in the issue, the POST call just returns the newly created CardGeneratedCvc2 object, not an array. I've edited my SDK to fix the problem like so:
diff --git a/src/Model/Generated/Endpoint/CardGeneratedCvc2.php b/src/Model/Generated/Endpoint/CardGeneratedCvc2.php
index 180366b..04cb91c 100644
--- a/src/Model/Generated/Endpoint/CardGeneratedCvc2.php
+++ b/src/Model/Generated/Endpoint/CardGeneratedCvc2.php
@@ -102,9 +102,9 @@ class CardGeneratedCvc2 extends BunqModel
* GENERATED.
* @param string[] $customHeaders
*
- * @return BunqResponseInt
+ * @return CardGeneratedCvc2
*/
- public static function create(int $cardId, string $type = null, array $customHeaders = []): BunqResponseInt
+ public static function create(int $cardId, string $type = null, array $customHeaders = []): BunqResponseCardGeneratedCvc2
{
$apiClient = new ApiClient(static::getApiContext());
$apiClient->enableEncryption();
@@ -117,8 +117,8 @@ class CardGeneratedCvc2 extends BunqModel
$customHeaders
);
- return BunqResponseInt::castFromBunqResponse(
- static::processForId($responseRaw)
+ return BunqResponseCardGeneratedCvc2::castFromBunqResponse(
+ static::fromJson($responseRaw, self::OBJECT_TYPE_GET)
);
}
yup, so indeed @kojoru invalid view definition. Normal behavior for POST response is to return the id of the created item. In this case, the actual response is the created object. This needs to be explicitly defined so that the generator generates this accordingly :)
So looks like #164 , maybe this can be fixed at the same time @kojoru ?
Steps to reproduce:
What should happen:
What happens:
Traceback
SDK version and environment