src/Beaudierman/Ups/Ups.php
private function parseResult()
	{
		if($this->xml_result->Response->ResponseStatusCode != '1')
		{
			return array(
				'Error' => array(
					'ErrorSeverity' => "{$this->xml_result->Response->Error->ErrorSeverity}",
					'ErrorCode' => "{$this->xml_result->Response->Error->ErrorCode}",
					'ErrorDescription' => "{$this->xml_result->Response->Error->ErrorDescription}"
				)
			);
			return $this->xml_result;
		}

		$simplified = array();
		$shipping_choices = array();

		foreach($this->xml_result->RatedShipment as $service)
		{
			$simplified[] = '{' . $service->TotalCharges->MonetaryValue . '}';
		}

		foreach($simplified as $key => $value)
		{
			$service = $this->xml_result->RatedShipment[$key]->children();

			if($this->negotiated_rates && $service->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue)
			{
				$rate = number_format((double)($service->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue), 2);
			}
			else
			{
				$rate = number_format((double)($service->TransportationCharges->MonetaryValue), 2);
			}

			$shipping_choices["{$service->Service->Code}"] = array(
				'service' => $this->shipperCodes("{$service->Service->Code}"),
				'rate' => "{$rate}"
			);
		}

		return $shipping_choices;
	}
private function parseResult()
	{
		if($this->xml_result->Response->ResponseStatusCode != '1')
		{
			return array(
				'Error' => array(
					'ErrorSeverity' => "{$this->xml_result->Response->Error->ErrorSeverity}",
					'ErrorCode' => "{$this->xml_result->Response->Error->ErrorCode}",
					'ErrorDescription' => "{$this->xml_result->Response->Error->ErrorDescription}"
				)
			);
			return $this->xml_result;
		}

		$simplified = array();
		$shipping_choices = array();

		foreach($this->xml_result->RatedShipment as $service)
		{
			$simplified[] = '{' . $service->TotalCharges->MonetaryValue . '}';
		}

		foreach($simplified as $key => $value)
		{
			$service = $this->xml_result->RatedShipment[$key]->children();

			if($this->negotiated_rates && $service->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue)
			{
				$rate = number_format((double)($service->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue), 2);
			}
			else
			{
				$rate = number_format((double)($service->TransportationCharges->MonetaryValue), 2);
			}

			$shipping_choices["{$service->Service->Code}"] = array(
				'service' => $this->shipperCodes("{$service->Service->Code}"),
				'rate' => "{$rate}"
			);
		}

		return $shipping_choices;
	}
private function parseResult ( ) { if ( $ this -> xml_result -> Response -> ResponseStatusCode != '1' ) { return array ( 'Error' => array ( 'ErrorSeverity' => "{$this->xml_result->Response->Error->ErrorSeverity}" , 'ErrorCode' => "{$this->xml_result->Response->Error->ErrorCode}" , 'ErrorDescription' => "{$this->xml_result->Response->Error->ErrorDescription}" ) ) ; return $ this -> xml_result ; } $ simplified = array ( ) ; $ shipping_choices = array ( ) ; foreach ( $ this -> xml_result -> RatedShipment as $ service ) { $ simplified [ ] = '{' . $ service -> TotalCharges -> MonetaryValue . '}' ; } foreach ( $ simplified as $ key => $ value ) { $ service = $ this -> xml_result -> RatedShipment [ $ key ] -> children ( ) ; if ( $ this -> negotiated_rates && $ service -> NegotiatedRates -> NetSummaryCharges -> GrandTotal -> MonetaryValue ) { $ rate = number_format ( ( double ) ( $ service -> NegotiatedRates -> NetSummaryCharges -> GrandTotal -> MonetaryValue ) , 2 ) ; } else { $ rate = number_format ( ( double ) ( $ service -> TransportationCharges -> MonetaryValue ) , 2 ) ; } $ shipping_choices [ "{$service->Service->Code}" ] = array ( 'service' => $ this -> shipperCodes ( "{$service->Service->Code}" ) , 'rate' => "{$rate}" ) ; } return $ shipping_choices ; }
Parse the returned XML object from
the UPS webservice.

@param void

@return array
Parse the returned XML object from the UPS webservice .