Skip to content

Commit

Permalink
Support for Todoor Order (D2D), fix CompanyName validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Radeq committed Feb 18, 2020
1 parent 0ffec82 commit 71edaf6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/Bliskapaczka/ApiClient/Bliskapaczka/Todoor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*
* @author Mateusz Koszutowski ([email protected])
*/
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
Expand All @@ -27,9 +27,9 @@ public function get()
return $response;
}

public function validate(array $data)
{
return true;
}
// public function validate(array $data)
// {
// return true;
// }

}
8 changes: 4 additions & 4 deletions src/Bliskapaczka/ApiClient/Validator/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 2 additions & 0 deletions src/Bliskapaczka/ApiClient/Validator/Order/Advice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 71edaf6

Please sign in to comment.