2019-10-03 03:13:25 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Transformers;
|
|
|
|
|
|
|
|
use App\Models\CompanyGateway;
|
2019-10-17 13:49:09 +02:00
|
|
|
use App\Transformers\GatewayTransformer;
|
2019-10-03 03:13:25 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class CompanyGatewayTransformer.
|
|
|
|
*/
|
|
|
|
class CompanyGatewayTransformer extends EntityTransformer
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $defaultIncludes = [
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $availableIncludes = [
|
2019-10-17 13:49:09 +02:00
|
|
|
'gateway'
|
2019-10-03 03:13:25 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param CompanyGateway $company_gateway
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform(CompanyGateway $company_gateway)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => (string)$this->encodePrimaryKey($company_gateway->id),
|
|
|
|
'gateway_key' => (string)$company_gateway->gateway_key ?: '',
|
|
|
|
'accepted_credit_cards' => (int)$company_gateway->accepted_credit_cards,
|
|
|
|
'require_cvv' => (bool)$company_gateway->require_cvv,
|
2019-10-17 13:49:09 +02:00
|
|
|
'show_billing_address' => (bool)$company_gateway->show_billing_address,
|
2019-10-03 03:13:25 +02:00
|
|
|
'show_shipping_address' => (bool)$company_gateway->show_shipping_address,
|
|
|
|
'update_details' => (bool)$company_gateway->update_details,
|
2019-10-03 12:59:19 +02:00
|
|
|
'config' => (string) $company_gateway->getConfigTransformed(),
|
2019-10-03 03:13:25 +02:00
|
|
|
'priority_id' => (int)$company_gateway->priority_id,
|
2019-10-23 22:37:20 +02:00
|
|
|
'min_limit' => (float)$company_gateway->min_limit ?: null,
|
|
|
|
'max_limit' => (float)$company_gateway->max_limit ?: null,
|
|
|
|
'fee_amount' => (float) $company_gateway->fee_amount ?: null,
|
|
|
|
'fee_percent' => (float)$company_gateway->fee_percent ?: null,
|
2019-10-03 03:13:25 +02:00
|
|
|
'fee_tax_name1' => (string)$company_gateway->fee_tax_name1 ?: '',
|
|
|
|
'fee_tax_name2' => (string) $company_gateway->fee_tax_name2 ?: '',
|
2019-10-13 12:59:55 +02:00
|
|
|
'fee_tax_name3' => (string) $company_gateway->fee_tax_name3 ?: '',
|
2019-10-03 03:13:25 +02:00
|
|
|
'fee_tax_rate1' => (float) $company_gateway->fee_tax_rate1,
|
|
|
|
'fee_tax_rate2' => (float)$company_gateway->fee_tax_rate2,
|
2019-10-13 12:59:55 +02:00
|
|
|
'fee_tax_rate3' => (float)$company_gateway->fee_tax_rate3,
|
2019-10-23 22:37:20 +02:00
|
|
|
'fee_cap' => (float)$company_gateway->fee_cap ?: null,
|
2019-10-03 03:13:25 +02:00
|
|
|
'adjust_fee_percent' => (bool)$company_gateway->adjust_fee_percent,
|
|
|
|
'updated_at' => $company_gateway->updated_at,
|
|
|
|
'deleted_at' => $company_gateway->deleted_at,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2019-10-17 13:49:09 +02:00
|
|
|
public function includeGateway(CompanyGateway $company_gateway)
|
|
|
|
{
|
|
|
|
$transformer = new GatewayTransformer($this->serializer);
|
|
|
|
|
|
|
|
return $this->includeItem($company_gateway->gateway, $transformer, Gateway::class);
|
|
|
|
}
|
|
|
|
|
2019-10-03 03:13:25 +02:00
|
|
|
}
|