src/ClearSaleID/Entity/Request/Order.php
public function toXML( XMLWriter $XMLWriter )
    {
        $XMLWriter->startElement( 'ClearID_Input' );

        if ($this->fingerPrint) {
            $this->fingerPrint->toXML( $XMLWriter );
        } else {
            throw new RequiredFieldException( 'Field FingerPrint of the Order object is required' );
        }

        $XMLWriter->startElement( 'Pedido' );

        if ($this->id) {
            $XMLWriter->writeElement( 'PedidoID', $this->id );
        } else {
            throw new RequiredFieldException( 'Field ID of the Order object is required' );
        }

        if ($this->date) {
            $XMLWriter->writeElement( 'Data', $this->date->format( self::DATE_TIME_FORMAT ) );
        } else {
            throw new RequiredFieldException( 'Field Date of the Order object is required' );
        }

        if ($this->email) {
            $XMLWriter->writeElement( 'Email', $this->email );
        }

        if ($this->channel) {
            $XMLWriter->writeElement( 'CanalID', $this->channel );
        }

        if ($this->ecommerceType) {
            $XMLWriter->writeElement( 'B2B_B2C', $this->ecommerceType );
        }

        if ($this->shippingValue) {
            $XMLWriter->writeElement( 'ValorFrete', $this->shippingValue );
        }

        if (is_numeric( $this->totalItems )) {
            $XMLWriter->writeElement( 'ValorTotalItens', $this->totalItems );
        } else {
            throw new RequiredFieldException( 'Field TotalItems of the Order object is required' );
        }

        if (is_numeric( $this->totalOrder )) {
            $XMLWriter->writeElement( 'ValorTotalPedido', $this->totalOrder );
        } else {
            throw new RequiredFieldException( 'Field TotalOrder of the Order object is required' );
        }

        if ($this->quantityInstallments) {
            $XMLWriter->writeElement( 'QtdParcelas', $this->quantityInstallments );
        }

        if ($this->deliveryTime) {
            $XMLWriter->writeElement( 'PrazoEntrega', $this->deliveryTime );
        }

        if ($this->quantityItems) {
            $XMLWriter->writeElement( 'QtdItens', $this->quantityItems );
        }

        if ($this->quantityPaymentTypes) {
            $XMLWriter->writeElement( 'QtdFormasPagamento', $this->quantityPaymentTypes );
        }

        if ($this->ip) {
            $XMLWriter->writeElement( 'IP', $this->ip );
        }

        if ($this->notes) {
            $XMLWriter->writeElement( 'Observacao', $this->notes );
        }

        if ($this->status) {
            $XMLWriter->writeElement( 'Status', $this->status );
        }

        if ($this->origin) {
            $XMLWriter->writeElement( 'Origem', $this->origin );
        }

        if ($this->reservationDate) {
            $XMLWriter->writeElement( 'DataReserva', $this->reservationDate->format( self::DATE_TIME_FORMAT ) );
        }

        if ($this->customerBillingData) {
            $this->customerBillingData->toXML( $XMLWriter );
        } else {
            throw new RequiredFieldException( 'Field CustomerBillingData of the Order object is required' );
        }

        if ($this->customerShippingData) {
            $this->customerShippingData->toXML( $XMLWriter );
        } else {
            throw new RequiredFieldException( 'Field CustomerShippingData of the Order object is required' );
        }

        if (count( $this->payments ) > 0) {
            $XMLWriter->startElement( 'Pagamentos' );

            foreach ($this->payments as $payment) {
                $payment->toXML( $XMLWriter );
            }

            $XMLWriter->endElement();
        } else {
            throw new RequiredFieldException( 'Field Payments of the Order object is required' );
        }

        if (count( $this->items ) > 0) {
            $XMLWriter->startElement( 'Itens' );

            foreach ($this->items as $item) {
                $item->toXML( $XMLWriter );
            }

            $XMLWriter->endElement();
        } else {
            throw new RequiredFieldException( 'Field Items of the Order object is required' );
        }

        if (count( $this->passengers ) > 0) {
            $XMLWriter->startElement( 'Passageiros' );

            foreach ($this->passengers as $passenger) {
                $passenger->toXML( $XMLWriter );
            }

            $XMLWriter->endElement();
        }

        if (count( $this->connections ) > 0) {
            $XMLWriter->startElement( 'Conexoes' );

            foreach ($this->connections as $connection) {
                $connection->toXML( $XMLWriter );
            }

            $XMLWriter->endElement();
        }

        $XMLWriter->endElement(); // Pedido
        $XMLWriter->endElement(); // ClearID_Input
    }
public function toXML( XMLWriter $XMLWriter )
    {
        $XMLWriter->startElement( 'ClearID_Input' );

        if ($this->fingerPrint) {
            $this->fingerPrint->toXML( $XMLWriter );
        } else {
            throw new RequiredFieldException( 'Field FingerPrint of the Order object is required' );
        }

        $XMLWriter->startElement( 'Pedido' );

        if ($this->id) {
            $XMLWriter->writeElement( 'PedidoID', $this->id );
        } else {
            throw new RequiredFieldException( 'Field ID of the Order object is required' );
        }

        if ($this->date) {
            $XMLWriter->writeElement( 'Data', $this->date->format( self::DATE_TIME_FORMAT ) );
        } else {
            throw new RequiredFieldException( 'Field Date of the Order object is required' );
        }

        if ($this->email) {
            $XMLWriter->writeElement( 'Email', $this->email );
        }

        if ($this->channel) {
            $XMLWriter->writeElement( 'CanalID', $this->channel );
        }

        if ($this->ecommerceType) {
            $XMLWriter->writeElement( 'B2B_B2C', $this->ecommerceType );
        }

        if ($this->shippingValue) {
            $XMLWriter->writeElement( 'ValorFrete', $this->shippingValue );
        }

        if (is_numeric( $this->totalItems )) {
            $XMLWriter->writeElement( 'ValorTotalItens', $this->totalItems );
        } else {
            throw new RequiredFieldException( 'Field TotalItems of the Order object is required' );
        }

        if (is_numeric( $this->totalOrder )) {
            $XMLWriter->writeElement( 'ValorTotalPedido', $this->totalOrder );
        } else {
            throw new RequiredFieldException( 'Field TotalOrder of the Order object is required' );
        }

        if ($this->quantityInstallments) {
            $XMLWriter->writeElement( 'QtdParcelas', $this->quantityInstallments );
        }

        if ($this->deliveryTime) {
            $XMLWriter->writeElement( 'PrazoEntrega', $this->deliveryTime );
        }

        if ($this->quantityItems) {
            $XMLWriter->writeElement( 'QtdItens', $this->quantityItems );
        }

        if ($this->quantityPaymentTypes) {
            $XMLWriter->writeElement( 'QtdFormasPagamento', $this->quantityPaymentTypes );
        }

        if ($this->ip) {
            $XMLWriter->writeElement( 'IP', $this->ip );
        }

        if ($this->notes) {
            $XMLWriter->writeElement( 'Observacao', $this->notes );
        }

        if ($this->status) {
            $XMLWriter->writeElement( 'Status', $this->status );
        }

        if ($this->origin) {
            $XMLWriter->writeElement( 'Origem', $this->origin );
        }

        if ($this->reservationDate) {
            $XMLWriter->writeElement( 'DataReserva', $this->reservationDate->format( self::DATE_TIME_FORMAT ) );
        }

        if ($this->customerBillingData) {
            $this->customerBillingData->toXML( $XMLWriter );
        } else {
            throw new RequiredFieldException( 'Field CustomerBillingData of the Order object is required' );
        }

        if ($this->customerShippingData) {
            $this->customerShippingData->toXML( $XMLWriter );
        } else {
            throw new RequiredFieldException( 'Field CustomerShippingData of the Order object is required' );
        }

        if (count( $this->payments ) > 0) {
            $XMLWriter->startElement( 'Pagamentos' );

            foreach ($this->payments as $payment) {
                $payment->toXML( $XMLWriter );
            }

            $XMLWriter->endElement();
        } else {
            throw new RequiredFieldException( 'Field Payments of the Order object is required' );
        }

        if (count( $this->items ) > 0) {
            $XMLWriter->startElement( 'Itens' );

            foreach ($this->items as $item) {
                $item->toXML( $XMLWriter );
            }

            $XMLWriter->endElement();
        } else {
            throw new RequiredFieldException( 'Field Items of the Order object is required' );
        }

        if (count( $this->passengers ) > 0) {
            $XMLWriter->startElement( 'Passageiros' );

            foreach ($this->passengers as $passenger) {
                $passenger->toXML( $XMLWriter );
            }

            $XMLWriter->endElement();
        }

        if (count( $this->connections ) > 0) {
            $XMLWriter->startElement( 'Conexoes' );

            foreach ($this->connections as $connection) {
                $connection->toXML( $XMLWriter );
            }

            $XMLWriter->endElement();
        }

        $XMLWriter->endElement(); // Pedido
        $XMLWriter->endElement(); // ClearID_Input
    }
@param  \XMLWriter $XMLWriter

@throws \RodrigoPedra\ClearSaleID\Exception\RequiredFieldException