package obtencionCodigo import ( "daemonService/internal/models/obtencionCodigos" "daemonService/internal/models/obtencionCodigos/response" "encoding/xml" ) //type ObtencionCodigoService struct { // obtencionCodigos.CuisServiceModel // Logger *log.Logger //} //// registra un error y devuelve el mismo error //func (s *ObtencionCodigoService) logError(format string, err error, v ...interface{}) error { // args := append([]interface{}{err}, v...) // if s.Logger != nil { // s.Logger.Printf(format, args...) // } // return fmt.Errorf(format, args...) //} func CuisParsearRespSOAP[T any](s *obtencionCodigos.CuisServiceModel, body []byte) (response.SoapBodyCuis, error) { var envelope response.SoapEnvelopeCuis if err := xml.Unmarshal(body, &envelope); err != nil { println("error deserializando en el CUIS XML:", err) //return nil, fmt.Errorf("error deserializando en el CUIS XML: %v", err) } if !envelope.Body.Response.Respuesta.Transaccion { println("transacción fallida en respuesta SOAP:", string(body)) //println("respuestaCUIS:", string(body)) //return nil, fmt.Errorf("transacción fallida en respuesta SOAP") } return envelope.Body, nil } func CufdParsearRespSOAP[T any](s *obtencionCodigos.CuisServiceModel, body []byte) (response.SoapBodyCufd, error) { var envelope response.SoapEnvelopeCufd if err := xml.Unmarshal(body, &envelope); err != nil { println("error deserializando en el CUIS XML:", err) //return nil, fmt.Errorf("error deserializando en el CUIS XML: %v", err) } if !envelope.Body.Response.Respuesta.Transaccion { println("transacción fallida en respuesta SOAP:", string(body)) //println("respuestaCUIS:", string(body)) //return nil, fmt.Errorf("transacción fallida en respuesta SOAP") } return envelope.Body, nil }