mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Improve rate limiting
This commit is contained in:
parent
3569cef5dd
commit
656a115eba
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Import\Transformer\Quickbooks;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
trait CommonTrait
|
||||
{
|
||||
protected $model;
|
||||
|
||||
public function getString($data, $field)
|
||||
{
|
||||
return Arr::get($data, $field);
|
||||
}
|
||||
|
||||
public function getCreateTime($data, $field = null)
|
||||
{
|
||||
return $this->parseDateOrNull($data, 'MetaData.CreateTime');
|
||||
}
|
||||
|
||||
public function getLastUpdatedTime($data, $field = null)
|
||||
{
|
||||
return $this->parseDateOrNull($data, 'MetaData.LastUpdatedTime');
|
||||
}
|
||||
|
||||
public function transform($data)
|
||||
{
|
||||
$transformed = [];
|
||||
|
||||
foreach ($this->fillable as $key => $field) {
|
||||
$transformed[$key] = is_null((($v = $this->getString($data, $field)))) ? null : (method_exists($this, ($method = "get{$field}")) ? call_user_func([$this, $method], $data, $field) : $this->getString($data, $field));
|
||||
}
|
||||
|
||||
return $this->model->fillable(array_keys($this->fillable))->fill($transformed)->toArray() + ['company_id' => $this->company->id ] ;
|
||||
}
|
||||
|
||||
}
|
@ -81,7 +81,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
if (Ninja::isSelfHost()) {
|
||||
return Limit::none();
|
||||
} else {
|
||||
return Limit::perMinute(25)->by($request->ip());
|
||||
return Limit::perMinute(10)->by($request->ip());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -55,9 +55,6 @@ class SdkWrapper
|
||||
|
||||
public function company()
|
||||
{
|
||||
nlog("getting company info");
|
||||
// nlog($this->sdk->getAccessToken());
|
||||
|
||||
return $this->sdk->getCompanyInfo();
|
||||
}
|
||||
/*
|
||||
@ -124,8 +121,6 @@ class SdkWrapper
|
||||
*/
|
||||
public function setAccessToken(OAuth2AccessToken $token): self
|
||||
{
|
||||
// $this->sdk = $this->sdk->updateOAuth2Token($token);
|
||||
|
||||
$this->token = $token;
|
||||
|
||||
return $this;
|
||||
|
@ -10,24 +10,14 @@
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Import\Transformer\Quickbooks;
|
||||
|
||||
use App\Import\Transformer\Quickbooks\CommonTrait;
|
||||
use App\Import\Transformer\BaseTransformer;
|
||||
use App\Models\Client as Model;
|
||||
use App\Models\ClientContact;
|
||||
use App\Import\ImportException;
|
||||
use Illuminate\Support\Str;
|
||||
namespace App\Services\Import\Quickbooks\Transformers;
|
||||
|
||||
/**
|
||||
* Class ClientTransformer.
|
||||
*/
|
||||
class ClientTransformer extends BaseTransformer
|
||||
class ClientTransformer
|
||||
{
|
||||
use CommonTrait {
|
||||
transform as preTransform;
|
||||
}
|
||||
|
||||
|
||||
private $fillable = [
|
||||
'name' => 'CompanyName',
|
||||
'phone' => 'PrimaryPhone.FreeFormNumber',
|
||||
@ -44,20 +34,12 @@ class ClientTransformer extends BaseTransformer
|
||||
'public_notes' => 'Notes'
|
||||
];
|
||||
|
||||
public function __construct($company)
|
||||
public function __invoke($qb_data)
|
||||
{
|
||||
parent::__construct($company);
|
||||
|
||||
$this->model = new Model();
|
||||
return $this->transform($qb_data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transforms a Customer array into a ClientContact model.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array|bool
|
||||
*/
|
||||
public function transform($data)
|
||||
{
|
||||
$transformed_data = [];
|
109
public/build/assets/app-e0713224.js
vendored
109
public/build/assets/app-e0713224.js
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@
|
||||
]
|
||||
},
|
||||
"resources/js/app.js": {
|
||||
"file": "assets/app-e0713224.js",
|
||||
"file": "assets/app-234e3402.js",
|
||||
"imports": [
|
||||
"_index-08e160a7.js",
|
||||
"__commonjsHelpers-725317a4.js"
|
||||
|
Loading…
Reference in New Issue
Block a user