public function __construct(uspsShipping $plugin, array $params)
 {
     $service = uspsServices::getServiceByCode(!empty($params['service']) ? $params['service'] : '');
     if (!$service) {
         throw new waException($plugin->_w("Unknown service"));
     }
     $supported = $this->getSupportedServices();
     if (is_array($supported) && !in_array($service['code'], $supported)) {
         throw new waException($plugin->_w("Unsupported service: ") . $service['code'] . $plugin->_w(". Supported services by this API are: ") . implode(", ", $supported));
     }
     $this->service = $service;
     parent::__construct($plugin, $params);
 }
 protected function getServiceCodeByOrder(waOrder $order)
 {
     $shipping_rate_id = $order['params']['shipping_rate_id'];
     $service_code = array();
     foreach (explode('_', $shipping_rate_id) as $part) {
         if (is_numeric($part)) {
             break;
         }
         $service_code[] = $part;
     }
     $service_code = implode(' ', $service_code);
     return uspsServices::getServiceByCode($service_code);
 }