Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Added some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rskrzypczak committed Nov 1, 2023
1 parent ba16ed0 commit a5d3e25
Show file tree
Hide file tree
Showing 19 changed files with 586 additions and 540 deletions.
5 changes: 4 additions & 1 deletion app/RecordCollectors/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class Base
/** @var bool Requires subscription. */
protected bool $paid = true;

/** @var string The name of Add-on. */
protected string $addOnName = '';

/**
* Constructor.
*/
Expand Down Expand Up @@ -168,7 +171,7 @@ public function isActive(): bool
*/
public function isAvailable(): bool
{
return !$this->paid || \App\YetiForce\Shop::check($this->getName());
return !$this->paid || \App\YetiForce\Shop::check($this->addOnName);
}

/**
Expand Down
59 changes: 31 additions & 28 deletions app/RecordCollectors/BrReceitaWsCnpj.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,11 @@ class BrReceitaWsCnpj extends Base
/** {@inheritdoc} */
public $docUrl = 'https://developers.receitaws.com.br/#/operations/queryCNPJFree';

/** @var string CNJP sever address */
private $url = 'https://receitaws.com.br/v1/cnpj/';

/** @var string Api key */
private $apiKey;

/** {@inheritdoc} */
public $settingsFields = [
'api_key' => ['required' => 0, 'purifyType' => 'Text', 'label' => 'LBL_API_KEY_OPTIONAL'],
];

/** {@inheritdoc} */
protected $fields = [
'cnpj' => [
'labelModule' => 'Other.RecordCollector',
'label' => 'LBL_BR_RECITA_WS_CNPJ_NUMBER',
'typeofdata' => 'V~O',
]
];

/** {@inheritdoc} */
protected $modulesFieldsMap = [
'Accounts' => [
'cnpj' => 'registration_number_1',
],
'Leads' => [
'cnpj' => 'registration_number_1',
],
'Vendors' => [
'cnpj' => 'registration_number_1',
]
];

/** {@inheritdoc} */
public $formFieldsToRecordMap = [
'Accounts' => [
Expand Down Expand Up @@ -132,6 +104,37 @@ class BrReceitaWsCnpj extends Base
],
];

/** {@inheritdoc} */
protected $fields = [
'cnpj' => [
'labelModule' => 'Other.RecordCollector',
'label' => 'LBL_BR_RECITA_WS_CNPJ_NUMBER',
'typeofdata' => 'V~O',
]
];

/** {@inheritdoc} */
protected $modulesFieldsMap = [
'Accounts' => [
'cnpj' => 'registration_number_1',
],
'Leads' => [
'cnpj' => 'registration_number_1',
],
'Vendors' => [
'cnpj' => 'registration_number_1',
]
];

/** {@inheritdoc} */
protected string $addOnName = 'YetiForceRcBrReceitaWsCnpj';

/** @var string CNJP sever address */
private $url = 'https://receitaws.com.br/v1/cnpj/';

/** @var string Api key */
private $apiKey;

/** {@inheritdoc} */
public function search(): array
{
Expand Down
85 changes: 44 additions & 41 deletions app/RecordCollectors/ChZefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,53 +38,12 @@ class ChZefix extends Base
/** {@inheritdoc} */
public $docUrl = 'https://www.zefix.admin.ch/';

/** {@inheritdoc} */
private $url = 'https://www.zefix.admin.ch/ZefixPublicREST/api/v1/company/';

/** {@inheritdoc} */
public $settingsFields = [
'username' => ['required' => 1, 'purifyType' => 'Text', 'label' => 'Username'],
'password' => ['required' => 1, 'purifyType' => 'Text', 'label' => 'Password'],
];

/** @var string Username. */
private $username;

/** @var string Password. */
private $password;

/** {@inheritdoc} */
protected $fields = [
'companyName' => [
'labelModule' => '_Base',
'label' => 'Account name',
],
'companyId' => [
'labelModule' => '_Base',
'label' => 'Registration number 1',
],
];

/** {@inheritdoc} */
protected $modulesFieldsMap = [
'Accounts' => [
'companyId' => 'registration_number_1',
'companyName' => 'accountname'
],
'Leads' => [
'companyId' => 'registration_number_1',
'companyName' => 'company'
],
'Vendors' => [
'companyId' => 'registration_number_1',
'companyName' => 'vendorname'
],
'Competition' => [
'companyId' => 'registration_number_1',
'companyName' => 'subject'
]
];

/** {@inheritdoc} */
public $formFieldsToRecordMap = [
'Accounts' => [
Expand Down Expand Up @@ -158,6 +117,50 @@ class ChZefix extends Base
],
];

/** {@inheritdoc} */
protected string $addOnName = 'YetiForceRcChZefix';

/** {@inheritdoc} */
protected $fields = [
'companyName' => [
'labelModule' => '_Base',
'label' => 'Account name',
],
'companyId' => [
'labelModule' => '_Base',
'label' => 'Registration number 1',
],
];

/** {@inheritdoc} */
protected $modulesFieldsMap = [
'Accounts' => [
'companyId' => 'registration_number_1',
'companyName' => 'accountname'
],
'Leads' => [
'companyId' => 'registration_number_1',
'companyName' => 'company'
],
'Vendors' => [
'companyId' => 'registration_number_1',
'companyName' => 'vendorname'
],
'Competition' => [
'companyId' => 'registration_number_1',
'companyName' => 'subject'
]
];

/** {@inheritdoc} */
private $url = 'https://www.zefix.admin.ch/ZefixPublicREST/api/v1/company/';

/** @var string Username. */
private $username;

/** @var string Password. */
private $password;

/** {@inheritdoc} */
public function isActive(): bool
{
Expand Down
106 changes: 54 additions & 52 deletions app/RecordCollectors/DkCvr.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
class DkCvr extends Base
{
/** @var string CH sever address */
const EXTERNAL_URL = 'https://cvrapi.dk/virksomhed/';

/** {@inheritdoc} */
public $allowedModules = ['Accounts', 'Leads', 'Vendors', 'Partners', 'Competition'];

Expand All @@ -38,63 +41,11 @@ class DkCvr extends Base
/** {@inheritdoc} */
public $docUrl = 'https://cvrapi.dk/documentation';

/** @var string CH sever address */
const EXTERNAL_URL = 'https://cvrapi.dk/virksomhed/';

/** @var string CH sever address */
private $url = 'http://cvrapi.dk/api?';

/** @var string Token key */
private $token;

/** {@inheritdoc} */
public $settingsFields = [
'token' => ['required' => 0, 'purifyType' => 'Text', 'label' => 'LBL_API_KEY_OPTIONAL'],
];

/** {@inheritdoc} */
protected $fields = [
'country' => [
'labelModule' => '_Base',
'label' => 'Country',
'picklistModule' => 'Other.Country',
'typeofdata' => 'V~M',
'uitype' => 16,
'picklistValues' => [
'no' => 'Norway',
'dk' => 'Denmark'
]
],
'vatNumber' => [
'labelModule' => '_Base',
'label' => 'Vat ID',
],
'name' => [
'labelModule' => '_Base',
'label' => 'FL_COMPANY_NAME',
],
'phone' => [
'labelModule' => '_Base',
'label' => 'FL_PHONE',
],
];

/** {@inheritdoc} */
protected $modulesFieldsMap = [
'Accounts' => [
'vatNumber' => 'vat_id',
],
'Leads' => [
'vatNumber' => 'vat_id',
],
'Vendors' => [
'vatNumber' => 'vat_id',
],
'Competition' => [
'vatNumber' => 'vat_id',
]
];

/** {@inheritdoc} */
public $formFieldsToRecordMap = [
'Accounts' => [
Expand Down Expand Up @@ -179,6 +130,57 @@ class DkCvr extends Base
'country' => 'addresslevel1a',
]
];
/** {@inheritdoc} */
protected string $addOnName = 'YetiForceRcDkCvr';

/** {@inheritdoc} */
protected $fields = [
'country' => [
'labelModule' => '_Base',
'label' => 'Country',
'picklistModule' => 'Other.Country',
'typeofdata' => 'V~M',
'uitype' => 16,
'picklistValues' => [
'no' => 'Norway',
'dk' => 'Denmark'
]
],
'vatNumber' => [
'labelModule' => '_Base',
'label' => 'Vat ID',
],
'name' => [
'labelModule' => '_Base',
'label' => 'FL_COMPANY_NAME',
],
'phone' => [
'labelModule' => '_Base',
'label' => 'FL_PHONE',
],
];

/** {@inheritdoc} */
protected $modulesFieldsMap = [
'Accounts' => [
'vatNumber' => 'vat_id',
],
'Leads' => [
'vatNumber' => 'vat_id',
],
'Vendors' => [
'vatNumber' => 'vat_id',
],
'Competition' => [
'vatNumber' => 'vat_id',
]
];

/** @var string CH sever address */
private $url = 'http://cvrapi.dk/api?';

/** @var string Token key */
private $token;

/** {@inheritdoc} */
public function search(): array
Expand Down
Loading

0 comments on commit a5d3e25

Please sign in to comment.