diff --git a/src/Bliskapaczka/ApiClient/Bliskapaczka/Todoor.php b/src/Bliskapaczka/ApiClient/Bliskapaczka/Todoor.php index 9d867c3..041d7db 100644 --- a/src/Bliskapaczka/ApiClient/Bliskapaczka/Todoor.php +++ b/src/Bliskapaczka/ApiClient/Bliskapaczka/Todoor.php @@ -10,10 +10,10 @@ * * @author Mateusz Koszutowski (mkoszutowski@divante.pl) */ -class Todoor extends AbstractBliskapaczka implements BliskapaczkaInterface +class Todoor extends Order implements BliskapaczkaInterface { - const REQUEST_URL = 'config'; + const REQUEST_URL = 'order'; /** * Call API method configuration options @@ -27,9 +27,9 @@ public function get() return $response; } - public function validate(array $data) - { - return true; - } +// public function validate(array $data) +// { +// return true; +// } } diff --git a/src/Bliskapaczka/ApiClient/Validator/Order.php b/src/Bliskapaczka/ApiClient/Validator/Order.php index 211bb75..8474da4 100644 --- a/src/Bliskapaczka/ApiClient/Validator/Order.php +++ b/src/Bliskapaczka/ApiClient/Validator/Order.php @@ -19,14 +19,14 @@ class Order extends AbstractValidator implements ValidatorInterface 'senderPhoneNumber' => ['notblank' => true], 'receiverPhoneNumber' => ['notblank' => true], 'senderPostCode' => ['notblank' => true], - 'senderFirstName' => ['maxlength' => 30, 'notblank' => true], - 'senderLastName' => ['maxlength' => 30, 'notblank' => true], + 'senderFirstName' => ['maxlength' => 30, 'notblankor' => [true, 'senderCompanyName']], + 'senderLastName' => ['maxlength' => 30, 'notblankor' => [true, 'senderCompanyName']], 'senderStreet' => ['maxlength' => 30, 'notblank' => true], 'senderBuildingNumber' => ['maxlength' => 10, 'notblank' => true], 'senderFlatNumber' => ['maxlength' => 10], 'senderCity' => ['maxlength' => 30, 'notblank' => true], - 'receiverFirstName' => ['maxlength' => 30, 'notblank' => true], - 'receiverLastName' => ['maxlength' => 30, 'notblank' => true], + 'receiverFirstName' => ['maxlength' => 30, 'notblankor' => [true, 'senderCompanyName']], + 'receiverLastName' => ['maxlength' => 30, 'notblankor' => [true, 'senderCompanyName']], 'deliveryType' => ['notblank' => true], 'operatorName' => ['notblank' => true], 'destinationCode' => ['notblank' => true], diff --git a/src/Bliskapaczka/ApiClient/Validator/Order/Advice.php b/src/Bliskapaczka/ApiClient/Validator/Order/Advice.php index 6ffdad5..5ba364d 100644 --- a/src/Bliskapaczka/ApiClient/Validator/Order/Advice.php +++ b/src/Bliskapaczka/ApiClient/Validator/Order/Advice.php @@ -23,6 +23,8 @@ protected function validationByProperty() foreach ($this->properties as $property => $settings) { if (!isset($this->data[$property]) && isset($settings['notblank']) && $settings['notblank'] === true) { throw new Exception($property . " is required", 1); + } elseif (!isset($this->data[$property]) && isset($settings['notblankor']) && $settings['notblankor'][0] === true && !isset($this->data[$settings['notblankor'][1]])) { + throw new Exception($property . " is required", 1); } $this->notBlank($property, $settings);