messagebird / php-rest-api

This repository contains the open source PHP client for MessageBird's REST API.
https://developers.messagebird.com/
BSD 2-Clause "Simplified" License
158 stars 95 forks source link

Recipient Class - Extend to include additional data i.e. messagePartCount #185

Closed chris-skilltech closed 1 year ago

chris-skilltech commented 2 years ago

We're currently building an integration using this API and have become a little stuck, hoping for any advice if there is a different way forward.

After calling the create method and receiving a response the recipients are looped over an created using the loadFromArray function in base however this only populates variables that are defined on the class. The Recipient class only contains the status and statusDatetime fields however the response returned from the API contains many more e.g. messagePartCount, messageLength, mccmnc, etc...

The general issue this causes is that you lack possibly useful information that the code throws away. In our specific case the messagePartCount is useful for determining specifically how many messages were used but I'm sure that many others may have other cases.

Is there any reason why the Recipient class could not simply be extended with all of the fields available? Or allow it to be extended by a custom instance (perhaps using a config file to determine which class to use as a recipient)? As I said the method of fixing is completely up for debate but any help would be greatly appreciated.

CoolGoose commented 2 years ago

hi @chris-skilltech , can you please checkout latest master and let me know if #186 fixes your issue?

chris-skilltech commented 2 years ago

Hi @CoolGoose, that works wonderfully thank you. Apologies for the delayed response.