OpenXE/classes/Carrier/SendCloud/Data/ShippingMethod.php
2022-10-26 23:46:38 +02:00

28 lines
938 B
PHP

<?php
namespace Xentral\Carrier\SendCloud\Data;
class ShippingMethod {
public int $Id;
public string $Name;
public ?string $Carrier;
public int $MinWeight;
public int $MaxWeight;
public int $MaxLength;
public int $MaxWidth;
public int $MaxHeight;
public string $Unit;
public static function fromApiResponse(object $data):ShippingMethod {
$obj = new ShippingMethod();
$obj->Id = $data->id;
$obj->Name = $data->name;
$obj->Carrier = $data->carrier ?? null;
$obj->MinWeight = $data->properties->min_weight;
$obj->MaxWeight = $data->properties->max_weight;
$obj->MaxLength = $data->properties->max_dimensions->length;
$obj->MaxWidth = $data->properties->max_dimensions->width;
$obj->MaxHeight = $data->properties->max_dimensions->height;
$obj->Unit = $data->properties->max_dimensions->unit;
return $obj;
}
}