Skip to content

Commit

Permalink
updated office request and response
Browse files Browse the repository at this point in the history
  • Loading branch information
vasildakov committed Dec 27, 2023
1 parent 5ab65be commit b58a76a
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 10 deletions.
3 changes: 0 additions & 3 deletions data/GetShipmentStatusesResponse.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 20231226233953
// https://ee.econt.com/doc_templates/srv/GetShipmentStatusesResponse.json

{
"shipmentStatuses": [
{
Expand Down
Empty file added data/ShipmentType.json
Empty file.
9 changes: 4 additions & 5 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
dump($object->findByName('София'));
*/

$json = $econt->getOffices(new GetOfficesRequest(countryCode: 'BGR', cityId: '41'));
$object = (new GetOfficesResponseFactory())($json);
foreach ($object->offices as $office) {
dump($office);
}
$json = $econt->getOffices(new GetOfficesRequest(countryCode: 'BGR', cityId: '39'));
$response = (new GetOfficesResponseFactory())($json);

dump($response);
33 changes: 33 additions & 0 deletions src/Model/Office.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@ public function __construct(

#[Serializer\Type(Address::class)]
public ?Address $address = null,

#[Serializer\Type('string')]
public ?string $info = null,

#[Serializer\Type('string')]
public ?string $currency = null,

#[Serializer\Type('string')]
public ?string $language = null,

#[Serializer\Type('int')]
public ?int $normalBusinessHoursFrom = null,

#[Serializer\Type('int')]
public ?int $normalBusinessHoursTo = null,

#[Serializer\Type('array')]
public ?array $shipmentTypes = null,

#[Serializer\Type('string')]
public ?string $partnerCode = null,

#[Serializer\Type('string')]
public ?string $hubCode = null,

#[Serializer\Type('string')]
public ?string $hubName = null,

#[Serializer\Type('string')]
public ?string $hubNameEn = null,

#[Serializer\Type('bool')]
public ?bool $isDrive = null,
){
}
}
2 changes: 2 additions & 0 deletions src/Response/GetCitiesResponseFactory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace VasilDakov\Econt\Response;

use VasilDakov\Econt\Exception\InvalidArgumentException;
Expand Down
2 changes: 2 additions & 0 deletions src/Response/GetOfficesResponse.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace VasilDakov\Econt\Response;

use Doctrine\Common\Collections\ArrayCollection;
Expand Down
7 changes: 6 additions & 1 deletion src/Response/GetOfficesResponseFactory.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?php

declare(strict_types=1);

namespace VasilDakov\Econt\Response;

use VasilDakov\Econt\Exception\InvalidArgumentException;
use VasilDakov\Econt\Serializer\SerializerFactory;

class GetOfficesResponseFactory
use function json_decode;
use function json_last_error;

final class GetOfficesResponseFactory
{
public function __invoke(string $json): GetOfficesResponse
{
Expand Down
4 changes: 3 additions & 1 deletion src/Serializer/SerializerFactory.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

declare(strict_types=1);

namespace VasilDakov\Econt\Serializer;

use JMS\Serializer;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerInterface;
use VasilDakov\Econt\Exception\ServiceNotCreatedException;

class SerializerFactory
final class SerializerFactory
{
/**
* @return SerializerInterface
Expand Down

0 comments on commit b58a76a

Please sign in to comment.