Invoice_items json

Hi James,

You should be able to add an invoice_items as an array containing an array
for each invoice item and json_encode will be smart enough to convert the
invoice_items array to bracket syntax, e.g.:

json_encode(
array(‘invoice’ =>
array(
‘contact’ =>
https://api.sandbox.freeagent.com/v2/contacts/’.$contact_id,
‘dated_on’ => ‘2013-05-03T00:00:00+00:00’,
‘payment_terms_in_days’ => ‘30’,
‘currency’ => ‘GBP’,
‘status’ => ‘Sent’,
‘invoice_items’ => array(
array(
‘description’ => ‘Test InvoiceItem’,
‘item_type’ => ‘Hours’,
‘price’ => ‘0.0’,
‘quantity’ => ‘0.0’
),
array(
‘description’ => ‘Test InvoiceItem’,
‘item_type’ => ‘Hours’,
‘price’ => ‘0.0’,
‘quantity’ => ‘0.0’
)
)
)))

Best regards,
IoanOn Tuesday, 7 May 2013 11:21:22 UTC+1, james stevenson wrote:

“invoice_items”:[
{
“description”:“Test InvoiceItem”,
“item_type”:“Hours”,
“price”:“0.0”,
“quantity”:“0.0”
}
]

How do I include the array code in json

json_encode(
array(‘invoice’ =>
array(
‘contact’ => ‘https://api.sandbox.freeagent.com/v2/contacts/’.$contact_id,
‘dated_on’ => ‘2013-05-03T00:00:00+00:00’,
‘payment_terms_in_days’ => ‘30’,
‘currency’ => ‘GBP’,
‘status’ => ‘Sent’
))
)