2022-10-21 10:46:09 +02:00
|
|
|
<?php
|
2023-02-28 13:36:25 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-10-21 10:46:09 +02:00
|
|
|
namespace Xentral\Carrier\SendCloud\Data;
|
|
|
|
|
|
|
|
class ShippingProduct {
|
|
|
|
public string $Name;
|
|
|
|
public string $Carrier;
|
|
|
|
public string $ServicePointsCarrier;
|
|
|
|
public string $Code;
|
|
|
|
public int $MinWeight;
|
|
|
|
public int $MaxWeight;
|
|
|
|
public array $ShippingMethods;
|
|
|
|
|
|
|
|
public static function fromApiResponse(object $data): ShippingProduct {
|
|
|
|
$obj = new ShippingProduct();
|
|
|
|
$obj->Name = $data->name;
|
|
|
|
$obj->Carrier = $data->carrier;
|
|
|
|
$obj->ServicePointsCarrier = $data->service_points_carrier;
|
|
|
|
$obj->Code = $data->code;
|
|
|
|
$obj->MinWeight = $data->weight_range->min_weight;
|
|
|
|
$obj->MaxWeight = $data->weight_range->max_weight;
|
|
|
|
foreach ($data->methods as $method) {
|
|
|
|
$child = ShippingMethod::fromApiResponse($method);
|
|
|
|
$child->Carrier = $obj->Carrier;
|
|
|
|
$obj->ShippingMethods[] = $child;
|
|
|
|
}
|
|
|
|
return $obj;
|
|
|
|
}
|
|
|
|
}
|