-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
ClientMessageRequest has incomplete types, why? #374
Comments
Hi! The ClientMessageRequest is the object that will be sent to the API, which expects the body to be a stringified JSON, hence all strings. I'm guessing you are probably looking for ServerMessageTypes for your use case, which are defined just a few lines below on the same file. The types are a little underdocumented unfortunately, they do get a little confusing specially for scenarios like your. I will keep a mental note to improve them for the next release. Hope this helps! |
@Secreto31126 Thats not actually the same thing. |
Sorry for taking some time. I misunderstood you, I thought you needed the received data, my bad. Unfortunately the library doesn't need those types internally, as it uses the ClientMessage abstract class to handle the typing, and are stringified with the _build method to the API compliant structure. When I wrote the code to create the messages structures (all the way back to 0.0.1!) the objects were always stringified, and I'm quite certain it was an API requirement. I just went through a few examples in the documentation, and it seems this is no longer the case, or at least they don't mention it. PS: I got into the rabbit hole that is WayBack Machine just to find out, and it turns out it was never a string in the examples! I'm actually stunned now, as I clearly remember having issues with the API because it didn't recognize the payload except when it was stringified. I will be checking this out as soon as possible, as it would be something interesting to add/fix. Sadly, right now I'm occupied with uni, gotta deploy a Spring MVC and JavaX JSP webapp due by mid October. I miss TS 🙃 Once again, sorry I will take some time until I can sit down and handle this issue. Thanks for reporting! |
I have a requirement to save the raw data sent to whatsapp to be recovered later on.
However, i just noticed that the ClientMessageRequest type has incomplete data structure, which means that text, audio, document, image, sticker, video, location, contacts, etc... are all considered a flatened strings, when should be an object.
Any specific reason for this, @Secreto31126 ?
At: https://github.com/Secreto31126/whatsapp-api-js/blob/d67fbeaeab5dc10c1b9da9dc35ba0e4a52a45cfd/src/types.ts#L382C7-L385C8
The text was updated successfully, but these errors were encountered: