1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Ninja/Transformers/ContactTransformer.php

50 lines
2.0 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Ninja\Transformers;
2015-11-03 15:21:17 +01:00
use App\Models\Contact;
/**
2017-01-30 20:40:43 +01:00
* Class ContactTransformer.
2017-03-17 10:28:46 +01:00
*
* @SWG\Definition(definition="Contact", @SWG\Xml(name="Contact"))
*/
2015-11-08 22:12:50 +01:00
class ContactTransformer extends EntityTransformer
2015-11-03 15:21:17 +01:00
{
/**
* @param Contact $contact
2017-01-30 20:40:43 +01:00
*
* @return array
2017-03-17 10:28:46 +01:00
*
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="first_name", type="string", example="John")
* @SWG\Property(property="last_name", type="string", example="Doe")
* @SWG\Property(property="email", type="string", example="john.doe@company.com")
* @SWG\Property(property="updated_at", type="integer", example=1451160233, readOnly=true)
* @SWG\Property(property="archived_at", type="integer", example=1451160233, readOnly=true)
* @SWG\Property(property="is_primary", type="boolean", example=false)
* @SWG\Property(property="phone", type="string", example="(212) 555-1212")
* @SWG\Property(property="last_login", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="send_invoice", type="boolean", example=false)
2017-04-16 13:31:14 +02:00
* @SWG\Property(property="custom_value1", type="string", example="Value")
* @SWG\Property(property="custom_value2", type="string", example="Value")
*/
2015-11-03 15:21:17 +01:00
public function transform(Contact $contact)
{
2016-05-03 22:02:29 +02:00
return array_merge($this->getDefaults($contact), [
2015-11-15 11:43:32 +01:00
'id' => (int) $contact->public_id,
2015-11-03 15:21:17 +01:00
'first_name' => $contact->first_name,
'last_name' => $contact->last_name,
'email' => $contact->email,
2015-12-27 12:08:58 +01:00
'updated_at' => $this->getTimestamp($contact->updated_at),
'archived_at' => $this->getTimestamp($contact->deleted_at),
2015-11-07 13:15:37 +01:00
'is_primary' => (bool) $contact->is_primary,
'phone' => $contact->phone,
'last_login' => $contact->last_login,
'send_invoice' => (bool) $contact->send_invoice,
2017-04-16 13:31:14 +02:00
'custom_value1' => $contact->custom_value1,
'custom_value2' => $contact->custom_value2,
2016-05-03 22:02:29 +02:00
]);
2015-11-03 15:21:17 +01:00
}
2016-10-27 10:57:51 +02:00
}