-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP #10: рефакторинг; отказ от публичных свойств в пользу геттеров; р…
…асчёт отправки
- Loading branch information
Showing
16 changed files
with
662 additions
and
132 deletions.
There are no files selected for viewing
33 changes: 0 additions & 33 deletions
33
src/Dispatching/Endpoints/Services/Requests/CalculateRequest.php
This file was deleted.
Oops, something went wrong.
106 changes: 106 additions & 0 deletions
106
src/Dispatching/Endpoints/Services/Requests/CalculationRequest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests; | ||
|
||
use Appwilio\RussianPostSDK\Dispatching\Http\ApiRequest; | ||
|
||
final class CalculationRequest extends ApiRequest | ||
{ | ||
/** @var array */ | ||
private $data; | ||
|
||
public static function create(string $to, int $mass): self | ||
{ | ||
return new self(...\func_get_args()); | ||
} | ||
|
||
public function __construct(string $to, int $mass) | ||
{ | ||
$this->data = [ | ||
'index-to' => $to, | ||
'mass' => $mass, | ||
]; | ||
} | ||
|
||
public function ofEntriesType(string $entriesType) | ||
{ | ||
$this->data['entries-type'] = $entriesType; | ||
|
||
return $this; | ||
} | ||
|
||
public function ofMailCategory(string $mailCategory) | ||
{ | ||
$this->data['mail-category'] = $mailCategory; | ||
|
||
return $this; | ||
} | ||
|
||
public function ofMailType(string $mailType) | ||
{ | ||
$this->data['mail-type'] = $mailType; | ||
|
||
return $this; | ||
} | ||
|
||
public function dimensions(int $height, int $width, int $length) | ||
{ | ||
$this->data['dimension'] = \compact('height', 'width', 'length'); | ||
|
||
return $this; | ||
} | ||
|
||
public function fragile(bool $value = true) | ||
{ | ||
$this->data['fragile'] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
public function viaCourier(bool $value = true) | ||
{ | ||
$this->data['courier'] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
public function withDeclaredValue(int $value) | ||
{ | ||
$this->data['declared-value'] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
public function withCompletenessChecking(bool $value = true) | ||
{ | ||
$this->data['completeness-checking'] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
public function withSimpleNotice(bool $value = true) | ||
{ | ||
$this->data['with-simple-notice'] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
public function withRegisteredNotice(bool $value = true) | ||
{ | ||
$this->data['with-order-of-notice'] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
public function withSmsNotice(bool $value = true) | ||
{ | ||
$this->data['sms-notice-recipient'] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return $this->data; | ||
} | ||
} |
Oops, something went wrong.