| | |
| | | namespace SIPL\UCRM\wFirma; |
| | | |
| | | class UcrmAttributes { |
| | | protected $attributesFile; |
| | | protected $api; |
| | | protected string $attributesFile; |
| | | protected \Ubnt\UcrmPluginSdk\Service\UcrmApi $api; |
| | | |
| | | protected static $definition = [ |
| | | protected static array $definition = [ |
| | | 'wFirma Customer ID' => [ |
| | | 'code' => 'client', |
| | | 'type' => 'client', |
| | |
| | | 'code' => 'invoice', |
| | | 'type' => 'invoice', |
| | | ], |
| | | 'KSeF Number' => [ |
| | | 'code' => 'ksef-number', |
| | | 'type' => 'invoice', |
| | | ], |
| | | 'KSeF URL' => [ |
| | | 'code' => 'ksef-url', |
| | | 'type' => 'invoice', |
| | | ], |
| | | 'KSeF QR Code' => [ |
| | | 'code' => 'ksef-qr-code', |
| | | 'type' => 'invoice', |
| | | ], |
| | | 'wFirma Payment ID' => [ |
| | | 'code' => 'payment', |
| | | 'type' => 'payment', |
| | | ], |
| | | ]; |
| | | protected $ids = []; |
| | | protected array $ids = []; |
| | | |
| | | function __construct(UcrmHelper $ucrmHelper) { |
| | | $this->attributesFile = $ucrmHelper->getRootDirectory() . '/data/attributes.json'; |
| | |
| | | return $this->ids[$attributeCode]; |
| | | } |
| | | |
| | | function updateMapping() { |
| | | function updateMapping(): bool { |
| | | $attributes = $this->api->get('/custom-attributes'); |
| | | foreach ($attributes as $attribute) { |
| | | $data = self::$definition[$attribute['name']] ?? NULL; |
| | |
| | | return $changed; |
| | | } |
| | | |
| | | function saveMapping() { |
| | | function saveMapping(): void { |
| | | if (!is_dir(dirname($this->attributesFile))) { |
| | | mkdir(dirname($this->attributesFile)); |
| | | } |