1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-23 18:01:35 +02:00
invoiceninja/app/Ninja/Import/FreshBooks/ClientTransformer.php

37 lines
1.4 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 [
2016-01-06 08:52:26 +01:00
'name' => $this->getString($data, 'organization'),
'work_phone' => $this->getString($data, 'busphone'),
'address1' => $this->getString($data, 'street'),
'address2' => $this->getString($data, 'street2'),
'city' => $this->getString($data, 'city'),
'state' => $this->getString($data, 'province'),
'postal_code' => $this->getString($data, 'postalcode'),
'private_notes' => $this->getString($data, 'notes'),
2015-11-17 14:53:14 +01:00
'contacts' => [
[
2016-01-06 08:52:26 +01:00
'first_name' => $this->getString($data, 'firstname'),
'last_name' => $this->getString($data, 'lastname'),
'email' => $this->getString($data, 'email'),
'phone' => $this->getString($data, 'mobphone') ?: $this->getString($data, 'homephone'),
2015-11-18 15:40:50 +01:00
],
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
}