$this->HsCode, 'weight' => number_format($this->Weight / 1000, 3, '.', null), 'quantity' => $this->Quantity, 'description' => $this->Description, 'value' => $this->Price, 'origin_country' => $this->OriginCountry, 'sku' => $this->Sku ?? '', 'product_id' => $this->ProductId ?? '', ]; } public static function fromApiResponse(object $data): ParcelItem { $obj = new ParcelItem(); $obj->HsCode = $data->hs_code; $obj->Weight = intval(floatval($data->weight)*1000); $obj->Quantity = $data->quantity; $obj->Description = $data->description; $obj->Price = $data->value; $obj->OriginCountry = $data->origin_country; $obj->Sku = $data->sku; $obj->ProductId = $data->product_id; return $obj; } }