messagebird / ruby-rest-api

MessageBird's REST API for Ruby
BSD 2-Clause "Simplified" License
37 stars 46 forks source link

Fix message status datetime not showing in MessageBird::Recipient object #81

Open karissekjw opened 2 years ago

karissekjw commented 2 years ago

Issue

Based on MessageBird's API documentation, MessageBird::Recipient object contains statusDatetime. But the library is currently throwing an error when attempting to retrieve status_datetime

NoMethodError: undefined method `status_datetime' for #<MessageBird::Recipient:0x00000001125047a0 @recipient=6581825086, @status="delivered">

Solution

After some digging, notice that this bug is due to incorrect method name when executing map_hash_elements_to_self method in Message::Base. This PR renames the method so elements can be mapped to the method correctly and retrieve statusDatetime successfully

After this fix, the object looks like this:

<MessageBird::Recipient:0x00000001172fd8a8 @recipient=6581825086, @status="delivered", @status_datetime=2022-09-20 06:17:51 +0000>

Also added a test case to ensure that the change works as expected