-
Notifications
You must be signed in to change notification settings - Fork 55
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
Decoding error when trying to create a CVC2 code #167
Comments
@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 sdk_php/src/Model/Generated/Endpoint/CardGeneratedCvc2.php Lines 111 to 118 in e9511e1
? if so then this method must return https://github.com/bunq/sdk_php/blob/cc52274dc6400a38573f3bab17da3e5920c202fb/src/Model/Generated/Endpoint/BunqResponseNull.php as shown here sdk_php/src/Model/Generated/Endpoint/Session.php Lines 39 to 41 in cc52274
|
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 :) |
Steps to reproduce:
What should happen:
What happens:
an arraya response with a single CardGeneratedCvc2 object in it, tries to process it as an ID and fails.Traceback
SDK version and environment
The text was updated successfully, but these errors were encountered: