Skip to content
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

[BUG] additionalData property in NotificationRequestItem seems to be typed incorrectly #1303

Open
PiotrOwsiak opened this issue Dec 27, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@PiotrOwsiak
Copy link

In v 15.1.0 the 'additionalData' property in NotificationRequestItem is typed as:

export declare class NotificationRequestItem {
    'additionalData'?: {
        [key: string]: string;
    };

but in the docs here https://docs.adyen.com/api-explorer/Webhooks/1/post/NOTIFICATION_OF_FRAUD#request-notificationItems-NotificationRequestItem-additionalData-metadata
the metadata property on 'additionalData' is described as object which would make it incompatible with type string.

@PiotrOwsiak PiotrOwsiak added the bug Something isn't working label Dec 27, 2023
@wboereboom
Copy link
Contributor

Hi @PiotrOwsiak,

Thanks for raising this issue.
Unfortunately, we are not able to generate more accurate AdditionalData models due to dynamic key names in this object. i.e; index numbers, fraudCheck ID's and names, etc.
Therefore you'd need to separately parse the metadata value to a JSON object as a workaround.
I apologise for any inconvenience this might cause.

Kind Regards,
Wouter
Adyen

@PiotrOwsiak
Copy link
Author

PiotrOwsiak commented Jan 4, 2024

hey @wboereboom
thank you for reply but what I mean is that additionalData propery is just not typed correctly because it should be allowed to contain either string or again an object that is key-value probably again typed as string to string.
Here you can see what the problem is: https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBAE2AYwDYEMrDm9BnPOAOQhgEsAzM5dciAOwCVgBHAV2DxgEkZgBbOAG8AUHHFwA5OgQIydeulQARWukkB+AFzCxE-QG0A1sACeOrlDL0A5gF0LMK7YDce8QF83+6bPlkGJVUYdAA1ACZNHVF9QxNzOEtre0dnGzgAH2FjM1Tkh0SnZK93OBKPERFkBi44elJKaloA+h0ScioaBWZ2Th4+QQBeXX0ZOQUgtWjS-XkBAEYdSTn+eckAGhmJFfClnY2t8X5gEIQpkdjLlYBmPYHJQ7LSj03RvwmVNQjpy-EVxak-wOvzgOzuAkir1+x1O5xiIO2A1ugPujwq+gqFREQA
The original typing makes TS complain about metadata not being a string but the additionalDataV2 allows for nested objects like metadata and it allows this nested object to be again just a key value map of string to string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants