-
Notifications
You must be signed in to change notification settings - Fork 38
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
Fix unmarshalling Webhook and Sample Events, Add SMSStatus Event type #35
Conversation
The API inconsistently returns float or string as Latitude and Longitude values. That's why we need a custom unmarshaller to parse the extra quotes as valid float32.
I think the interface needs to change. For instance message events response is more like this:
I also think that And we expose search something like this:
|
@yepher oh I see, there's another API endpoint for "Event Messages", which has - again - a different data format.. In that case, how about having new |
@VojtechVitek Until I saw the great work you had done I was punting and moving in this direction: I personally am a little torn between discrete messages (with a lot of overlap) or just one large struct that contains all possible field. |
@yepher I know what you mean.. But I think I still prefer discrete struct for each event type, since it's very easy to type-switch-case to filter out events that I really care about. And also, it's easier to understand the underlying data -- for example, I'd expect that OutOfBand event has TransmissionID - but it doesn't. I wouldn't realize that without having the OutOfBand type and it would bite me later, since I'd rely on the missing value. There's no big overlap, since we only lookup the event type and postpone parsing the actual data with json.RawMessage. This should perform well, even though it's a two-way pass. Let me have a look at MessageEvents real quick. I think it can be simple struct wrapper around |
@VojtechVitek All that sound really good and I totally agree. |
Fix unmarshalling Webhook and Sample Events, Add SMSStatus Event type
A custom Events JSON unmarshaller successfully parses both Webhook Events and Sample Events without any regexp magic.
Listening on Webhook Events is as simple as: