eNumber = new combinedObject ( 'PhoneLineNumber', $shipmnt['shipper']['phoneNumber']['phoneLineNumber'] );
$structuredPhoneNumber = new xmlObject ( 'StructuredPhoneNumber', Null, array ( $phoneDialPlanNumber, $phoneLinenumber ) );
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
if ( $shipmnt['shipper']['phoneNumber']['phoneCountryCode'] ) {
$phoneCountryCode = new combinedObject ( 'PhoneCountryCode', $shipmnt['shipper']['phoneNumber']['phoneCountryCode'] );
$structuredPhoneNumber->appendChild ( $phoneCountryCode );
}
if ( $shipmnt['shipper']['phoneNumber']['phoneExtension'] ) {
$phoneExtension = new combinedObject ( 'PhoneExtension', $shipmnt['shipper']['phoneNumber']['phoneExtension'] );
$structuredPhoneNumber->appendChild ( $phoneExtension );
}
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
} else {
$phoneNumber = new combinedObject ( 'PhoneNumber', $shipmnt['shipper']['phoneNumber'] );
}
$shipper->appendChild ( $phoneNumber );
}
if ( $shipmnt['shipper']['faxNumber'] ) {
$faxNumber = new combinedObject ( 'FaxNumber', $shipmnt['shipper']['faxNumber'] );
$shipper->appendChild ( $faxNumber );
}
if ( $shipmnt['shipper']['shipperNumber'] ) {
$shipperNumber = new combinedObject ( 'ShipperNumber', $shipmnt['shipper']['shipperNumber'] );
$shipper->appendChild ( $shipperNumber );
}
if ( $shipmnt['shipper']['address'] ) {
$countryCode = new combinedObject ( 'CountryCode', $shipmnt['shipper']['address']['countryCode'] );
$address = new xmlObject ( 'Address', Null, array ( $countryCode ) );
if ( $shipmnt['shipper']['address']['addressLine1'] ) {
$addressLine1 = new combinedObject ( 'AddressLine1', $shipmnt['shipper']['address']['addressLine1'] );
$address->appendChild ( $addressLine1 );
}
if ( $shipmnt['shipper']['address']['addressLine2'] ) {
$addressLine2 = new combinedObject ( 'AddressLine2', $shipmnt['shipper']['address']['addressLine2'] );
$address->appendChild ( $addressLine2 );
}
if ( $shipmnt['shipper']['address']['addressLine3'] ) {
$addressLine3 = new combinedObject ( 'AddressLine3', $shipmnt['shipper']['address']['addressLine3'] );
$address->appendChild ( $addressLine3 );
}
if ( $shipmnt['shipper']['address']['city'] ) {
$city = new combinedObject ( 'City', $shipmnt['shipper']['address']['city'] );
$address->appendChild ( $city );
}
if ( $shipmnt['shipper']['address']['stateProvinceCode'] ) {
$stateProvinceCode = new combinedObject ( 'StateProvinceCode', $shipmnt['shipper']['address']['stateProvinceCode'] );
$address->appendChild ( $stateProvinceCode );
}
if ( $shipmnt['shipper']['address']['postalCode'] ) {
$postalCode = new combinedObject ( 'PostalCode', $shipmnt['shipper']['address']['postalCode'] );
$address->appendChild ( $postalCode );
}
if ( $shipmnt['shipper']['address']['residentialAddress'] ) {
$residentialAddress = new combinedObject ( 'ResidentialAddress', $shipmnt['shipper']['address']['residentialAddress'] );
$address->appendChild ( $residentialAddress );
}
if ( $shipmnt['shipper']['address']['residentialAddressIndicator'] ) {
$residentialAddressIndicator = new combinedObject ( 'ResidentialAddressIndicator', $shipmnt['shipper']['address']['residentialAddressIndicator'] );
$address->appendChild ( $residentialAddressIndicator );
}
$shipper->appendChild ( $address );
}
// ShipTo
$countryCode = new combinedObject ( 'CountryCode', $shipmnt['shipTo']['address']['countryCode'] );
$address = new xmlObject ( 'Address', Null, array ( $countryCode ) );
if ( $shipmnt['shipTo']['address']['addressLine1'] ) {
$addressLine1 = new combinedObject ( 'AddressLine1', $shipmnt['shipTo']['address']['addressLine1'] );
$address->appendChild ( $addressLine1 );
}
if ( $shipmnt['shipTo']['address']['addressLine2'] ) {
$addressLine2 = new combinedObject ( 'AddressLine2', $shipmnt['shipTo']['address']['addressLine2'] );
$address->appendChild ( $addressLine2 );
}
if ( $shipmnt['shipTo']['address']['addressLine3'] ) {
$addressLine3 = new combinedObject ( 'AddressLine3', $shipmnt['shipTo']['address']['addressLine3'] );
$address->appendChild ( $addressLine3 );
}
if ( $shipmnt['shipTo']['address']['city'] ) {
$city = new combinedObject ( 'City', $shipmnt['shipTo']['address']['city'] );
$address->appendChild ( $city );
}
if ( $shipmnt['shipTo']['address']['stateProvinceCode'] ) {
$stateProvinceCode = new combinedObject ( 'StateProvinceCode', $shipmnt['shipTo']['address']['stateProvinceCode'] );
$address->appendChild ( $stateProvinceCode );
}
if ( $shipmnt['shipTo']['address']['postalCode'] ) {
$postalCode = new combinedObject ( 'PostalCode', $shipmnt['shipTo']['address']['postalCode'] );
$address->appendChild ( $postalCode );
}
if ( $shipmnt['shipTo']['address']['residentialAddress'] ) {
$residentialAddress = new combinedObject ( 'ResidentialAddress', $shipmnt['shipTo']['address']['residentialAddress'] );
$address->appendChild ( $residentialAddress );
}
if ( $shipmnt['shipTo']['address']['residentialAddressIndicator'] ) {
$residentialAddressIndicator = new combinedObject ( 'ResidentialAddressIndicator', $shipmnt['shipTo']['address']['residentialAddressIndicator'] );
$address->appendChild ( $residentialAddressIndicator );
}
$shipTo = new xmlObject ( 'ShipTo', Null, array ( $address ) );
if ( $shipmnt['shipTo']['shipperAssignedIdentificationNumber'] ) {
$shipperAssignedIdentificationNumber = new combinedObject ( 'ShipperAssignedIdentificationNumber', $shipmnt['shipTo']['shipperAssignedIdentificationNumber'] );
$shipTo->appendChild ( $shipperAssignedIdentificationNumber );
}
if ( $shipmnt['shipTo']['companyName'] ) {
$companyName = new combinedObject ( 'CompanyName', $shipmnt['shipTo']['companyName'] );
$shipTo->appendChild ( $companyName );
}
if ( $shipmnt['shipTo']['attentionName'] ) {
$attentionName = new combinedObject ( 'AttentionName', $shipmnt['shipTo']['attentionName'] );
$shipTo->appendChild ( $attentionName );
}
if ( $shipmnt['shipTo']['phoneNumber'] ) {
if ( is_array ( $shipmnt['shipTo']['phoneNumber'] ) ) {
$phoneDialPlanNumber = new combinedObject ( 'PhoneDialPlanNumber', $shipmnt['shipTo']['phoneNumber']['phoneDialPlanNumber'] );
$phoneLineNumber = new combinedObject ( 'PhoneLineNumber', $shipmnt['shipTo']['phoneNumber']['phoneLineNumber'] );
$structuredPhoneNumber = new xmlObject ( 'StructuredPhoneNumber', Null, array ( $phoneDialPlanNumber, $phoneLinenumber ) );
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
if ( $shipmnt['shipTo']['phoneNumber']['phoneCountryCode'] ) {
$phoneCountryCode = new combinedObject ( 'PhoneCountryCode', $shipmnt['shipTo']['phoneNumber']['phoneCountryCode'] );
$structuredPhoneNumber->appendChild ( $phoneCountryCode );
}
if ( $shipmnt['shipTo']['phoneNumber']['phoneExtension'] ) {
$phoneExtension = new combinedObject ( 'PhoneExtension', $shipmnt['shipTo']['phoneNumber']['phoneExtension'] );
$structuredPhoneNumber->appendChild ( $phoneExtension );
}
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
} else {
$phoneNumber = new combinedObject ( 'PhoneNumber', $shipmnt['shipTo']['phoneNumber'] );
}
$shipper->appendChild ( $phoneNumber );
}
if ( $shipmnt['shipTo']['taxIdentificationNumber'] ) {
$taxIdentificationNumber = new combinedObject ( 'TaxIdentificationNumber', $shipmnt['shipTo']['taxIdentificationNumber'] );
$shipTo->appendChild ( $taxIdentificationNumber );
}
if ( $shipmnt['shipTo']['faxNumber'] ) {
$faxNumber = new combinedObject ( 'FaxNumber', $shipmnt['shipTo']['faxNumber'] );
$shipTo->appendChild ( $faxNumber );
}
if ( $shipmnt['shipTo']['locationId'] ) {
$locationId = new combinedObject ( 'LocationID', $shipmnt['shipTo']['locationId'] );
$shipTo->appendChild ( $locationId );
}
$shipment = new xmlObject ( 'Shipment', Null, array ( $shipper, $shipTo ) );
// Description
if ( $shipmnt['description'] ) {
$description = new combinedObject ( 'Description', $shipmnt['description'] );
$shipment->appendChild ( $description );
}
// ShipFrom
if ( $shipmnt['shipFrom'] ) {
$companyName = new combinedObject ( 'CompanyName', $shipmnt['shipFrom']['companyName'] );
if ( is_array ( $shipmnt['shipFrom']['phoneNumber'] ) ) {
$phoneDialPlanNumber = new combinedObject ( 'PhoneDialPlanNumber', $shipmnt['shipFrom']['phoneNumber']['phoneDialPlanNumber'] );
$phoneLineNumber = new combinedObject ( 'PhoneLineNumber', $shipmnt['shipFrom']['phoneNumber']['phoneLineNumber'] );
$structuredPhoneNumber = new xmlObject ( 'StructuredPhoneNumber', Null, array ( $phoneDialPlanNumber, $phoneLinenumber ) );
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
if ( $shipmnt['shipFrom']['phoneNumber']['phoneCountryCode'] ) {
$phoneCountryCode = new combinedObject ( 'PhoneCountryCode', $shipmnt['shipFrom']['phoneNumber']['phoneCountryCode'] );
$structuredPhoneNumber->appendChild ( $phoneCountryCode );
}
if ( $shipmnt['shipFrom']['phoneNumber']['phoneExtension'] ) {
$phoneExtension = new combinedObject ( 'PhoneExtension', $shipmnt['shipFrom']['phoneNumber']['phoneExtension'] );
$structuredPhoneNumber->appendChild ( $phoneExtension );
}
$phoneNumber = new xmlObject ( 'PhoneNumber', Null, array ( $structuredPhoneNumber ) );
} else {
$phoneNumber = new combinedObject ( 'PhoneNumber', $shipmnt['shipFrom']['phoneNumber'] );
}
$countryCode = new combinedObject ( 'CountryCode', $shipmnt['shipFrom']['address']['countryCode'] );
$address = new xmlObject ( 'Address', Null, array ( $countryCode ) );
if ( $shipmnt['shipFrom']['address']['addressLine1'] ) {
$addressLine1 = new combinedObject ( 'AddressLine1', $shipmnt['shipFrom']['address']['addressLine1'] );
$address->appendChild ( $addressLine1 );
}
if ( $shipmnt['shipFrom']['address']['addressLine2'] ) {
$addressLine2 = new combinedObject ( 'AddressLine2', $shipmnt['shipFrom']['address']['addressLine2'] );
$address->appendChild ( $addressLine2 );
}
if ( $shipmnt['shipFrom']['address']['addressLine3'] ) {
$addressLine3 = new combinedObject ( 'AddressLine3', $shipmnt['shipFrom']['address']['addressLine3'] );
$address->appendChild ( $addressLine3 );
}
if ( $shipmnt['shipFrom']['address']['city'] ) {
$city = new combinedObject ( 'City', $shipmnt['shipFrom']['address']['city'] );
$address->appendChild ( $city );
}
if ( $shipmnt['shipFrom']['address']['stateProvinceCode'] ) {
$stateProvinceCode = new combinedObject ( 'StateProvinceCode', $shipmnt['shipFrom']['address']['stateProvinceCode'] );
$address->appendChild ( $stateProvinceCode );
}
if ( $shipmnt['shipFrom']['address']['postalCode'] ) {
$postalCode = new combinedObject ( 'PostalCode', $shipmnt['shipFrom']['address']['postalCode'] );
$address->appendChild ( $postalCode );
}
if ( $shipmnt['shipFrom']['address']['residentialAddress'] ) {
$residentialAddress = new combinedObject ( 'ResidentialAddress', $shipmnt['shipFrom']['address']['residentialAddress'] );
$address->appendChild ( $residentialAddress );
}
if ( $shipmnt['shipFrom']['address']['residentialAddressIndicator'] ) {
$residentialAddressIndicator = new combinedObject ( 'ResidentialAddressIndicator', $shipmnt['shipFrom']['address']['residentialAddressIndicator'] );
$address->appendChild ( $residentialAddressIndicator );
}
$shipFrom = new xmlObject ( 'ShipFrom', Null, array ( $companyName, $phoneNumber, $address ) );
if ( $shipmnt['shipFrom']['attentionName'] ) {
$attentionName = new combinedObject ( 'AttentionName', $shipmnt['shipFrom']['attentionName'] );
$shipFrom->appendChild ( $attentionName );
}
if ( $shipmnt['shipFrom']['faxNumber'] ) {
$faxNumber = new combinedObject ( 'FaxNumber', $shipmnt['shipFrom']['faxNumber'] );
$shipFrom->appendChild ( $faxNumber );
}
$shipment->appendChild ( $shipFrom );
}
// ShipmentWeight
if ( $shipmnt['shipmentWeight'] ) {
$code = new combinedObject ( 'Code', $shipmnt['shipmentWeight']['code'] );
$weight = new combinedObject ( 'Weight', $shipmnt['shipmentWeight']['weight'] );
$unitOfMeasurement = new xmlObject ( 'UnitOfMeasurement', Null, array ( $code, $weight ) );
$shipmentWeight = new xmlObject ( 'ShipmentWeight', Null, array ( $unitOfMeasurement ) );
if ( $shipmnt['shipmentWeight']['description'] ) {
$description = new combinedObject ( 'Description', $shipmnt['shipmentWeight']['description'] );
$shipmentWeight->appendChild ( $description );
}
$shipment->appendChild ( $shipmentWeight );
}
// ReferenceNumber
if ( $shipmnt['referenceNumber'] ) {
$code = new combinedObject ( 'Code', $shipmnt['referenceNumber']['code'] );
$value = new combinedObject ( 'Value', $shipmnt['referenceNumber']['value'] );
$referenceNumber = new xmlObject ( 'ReferenceNumber', Null, array ( $code, $value ) );
$shipment->appendChild ( $referenceNumber );
}
// Service
if ( $shipmnt['service'] ) {
$code = new combinedObject ( 'Code', $shipmnt['service']['code'] );
$service = new xmlObject ( 'Service', Null, array ( $code ) );
if ( $shipmnt['service']['description'] ) {
$description = new combinedObject ( 'Description', $shipmnt['service']['description'] );
$service->appendChild ( $description );
}
$shipment->appendChild ( $service );
}
// PickupDate
if ( $shipmnt['pickupDate'] ) {
$pickupDate = new combinedObject ( 'PickupDate', $shipmnt['pickupDate'] );
$shipment->appendChild ( $pickupDate );
}
// ScheduledDeliveryDate
if ( $shipmnt['scheduledDeliveryDate'] ) {
$scheduledDeliveryDate = new combinedObject ( 'ScheduledDeliveryDate', $shipmnt['scheduledDeliveryDate'] );
$shipment->appendChild ( $scheduledDeliveryDate );
}
// ScheduledDeliveryTime
if ( $shipmnt['scheduledDeliveryTime'] ) {
$scheduledDeliveryTime = new combinedObject ( 'ScheduledDeliveryTime', $shipmnt['scheduledDeliveryTime'] );
$shipment->appendChild ( $scheduledDeliveryTime );
}
// AlternateDeliveryTime
if ( $shipmnt['alternateDeliveryTime'] ) {
$alternateDeliveryTime = new combinedObject ( 'AlternateDeliveryTime', $shipmnt['alternateDeliveryTime'] );
$shipment->appendChild ( $alternateDeliveryTime );
}
// DocumentsOnly
if ( $shipmnt['documentsOnly'] ) {
$documentsOnly = new combinedObject ( 'DocumentsOnly', $shipmnt['documentsOnly'] );
$shipment->appendChild ( $documentsOnly );
}