Skip to content

Commit

Permalink
WIP #10: рефакторинг; отказ от публичных свойств в пользу геттеров; р…
Browse files Browse the repository at this point in the history
…асчёт отправки
  • Loading branch information
jhaoda committed Jul 10, 2019
1 parent fa573f2 commit 87c0680
Show file tree
Hide file tree
Showing 16 changed files with 662 additions and 132 deletions.
33 changes: 0 additions & 33 deletions src/Dispatching/Endpoints/Services/Requests/CalculateRequest.php

This file was deleted.

106 changes: 106 additions & 0 deletions src/Dispatching/Endpoints/Services/Requests/CalculationRequest.php
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;
}
}
Loading

0 comments on commit 87c0680

Please sign in to comment.