package xml

import (
	
	
	
)

// ErrorComponents represents the error response fields
// that will be deserialized from an xml error response body
type ErrorComponents struct {
	Code    string
	Message string
}

// GetErrorResponseComponents returns the error fields from an xml error response body
func ( io.Reader,  bool) (ErrorComponents, error) {
	if  {
		var  noWrappedErrorResponse
		if  := xml.NewDecoder().Decode(&);  != nil &&  != io.EOF {
			return ErrorComponents{}, fmt.Errorf("error while deserializing xml error response: %w", )
		}
		return ErrorComponents{
			Code:    .Code,
			Message: .Message,
		}, nil
	}

	var  wrappedErrorResponse
	if  := xml.NewDecoder().Decode(&);  != nil &&  != io.EOF {
		return ErrorComponents{}, fmt.Errorf("error while deserializing xml error response: %w", )
	}
	return ErrorComponents{
		Code:    .Code,
		Message: .Message,
	}, nil
}

// noWrappedErrorResponse represents the error response body with
// no internal <Error></Error wrapping
type noWrappedErrorResponse struct {
	Code    string `xml:"Code"`
	Message string `xml:"Message"`
}

// wrappedErrorResponse represents the error response body
// wrapped within <Error>...</Error>
type wrappedErrorResponse struct {
	Code    string `xml:"Error>Code"`
	Message string `xml:"Error>Message"`
}