Feature/xero handle data lists
The issue
The DF_Xero library used array2xml
to produce the XML for Xero objects. This chokes on data objects that contain lists of multiple sub-objects. Examples include the <Addresses>
and <Phones>
elements when creating a new Xero contact.
With this change, a flat array (no keys, or numeric keys) can be supplied as part of a data object. The parent element name will be singularized to provide the XML subelement names.
e.g.
[
'Addresses' => [
{address data array},
{address data array}
]
]
==>
<Addresses><Address>{address data}</Address><Address>{address data</Address></Addresses>
What I did
- Replaced the existing array->xml dependency with some 'borrowed' methods that allow for data elements that contain lists of subelements.
- Methods came from a recommended third-party library we have used in Art Money: https://github.com/calcinai/xero-php
Implications
None
Setup
None
How to test
- Code review.
- Can be tested with commit
62c34e40a5c06ad29c4242630c98d059072e3537
in the National Weighing Xero integration project, but might be easier to OTS it at first opportunity.