1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 14:12:44 +01:00
invoiceninja/app/Ninja/Import/FreshBooks/ClientTransformer.php

37 lines
1.2 KiB
PHP
Raw Normal View History

2015-11-18 15:40:50 +01:00
<?php namespace App\Ninja\Import\FreshBooks;
2015-11-17 14:53:14 +01:00
2015-12-08 11:10:20 +01:00
use App\Ninja\Import\BaseTransformer;
2015-11-18 15:40:50 +01:00
use League\Fractal\Resource\Item;
2015-11-17 14:53:14 +01:00
2015-12-08 11:10:20 +01:00
class ClientTransformer extends BaseTransformer
2015-11-17 14:53:14 +01:00
{
2015-12-08 11:10:20 +01:00
public function transform($data)
2015-11-18 15:40:50 +01:00
{
2015-12-08 11:10:20 +01:00
if ($this->hasClient($data->organization)) {
2015-11-18 15:40:50 +01:00
return false;
}
2015-11-17 14:53:14 +01:00
2015-12-08 11:10:20 +01:00
return new Item($data, function ($data) {
2015-11-17 14:53:14 +01:00
return [
2015-11-18 15:40:50 +01:00
'name' => $data->organization,
'work_phone' => $data->busphone,
'address1' => $data->street,
'address2' => $data->street2,
'city' => $data->city,
'state' => $data->province,
'postal_code' => $data->postalcode,
'private_notes' => $data->notes,
2015-11-17 14:53:14 +01:00
'contacts' => [
[
2015-11-18 15:40:50 +01:00
'first_name' => $data->firstname,
'last_name' => $data->lastname,
'email' => $data->email,
'phone' => $data->mobphone ?: $data->homephone,
],
2015-11-17 14:53:14 +01:00
],
2015-12-08 11:10:20 +01:00
'country_id' => $this->getCountryId($data->country),
2015-11-17 14:53:14 +01:00
];
});
}
2015-11-18 15:40:50 +01:00
}