Skip to content

Commit

Permalink
Remove unnecesary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
apardods committed Dec 17, 2024
1 parent bf28ebd commit f105a0a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 112 deletions.
23 changes: 0 additions & 23 deletions doc/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,6 @@ func (d *Envelope) BytesIndent() ([]byte, error) {
return toBytesIndent(d)
}

// Envelop wraps the VeriFactu document in a SOAP envelope and includes the expected namespaces
// func (d *VeriFactu) Envelop() ([]byte, error) {
// // Create and set the envelope with namespaces
// env := Envelope{
// XMLNs: EnvNamespace,
// SUM: SUM,
// SUM1: SUM1,
// }
// env.Body.VeriFactu = d

// // Marshal the SOAP envelope into an XML byte slice
// var result bytes.Buffer
// enc := xml.NewEncoder(&result)
// enc.Indent("", " ")
// err := enc.Encode(env)
// if err != nil {
// return nil, err
// }

// // Return the enveloped XML document
// return result.Bytes(), nil
// }

func toBytes(doc any) ([]byte, error) {
buf, err := buffer(doc, xml.Header, false)
if err != nil {
Expand Down
85 changes: 0 additions & 85 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ import (
"testing"
"time"

// "github.com/nbio/xml"

verifactu "github.com/invopop/gobl.verifactu"
"github.com/invopop/gobl.verifactu/doc"
"github.com/invopop/gobl.verifactu/test"

// "github.com/lestrrat-go/libxml2"
// "github.com/lestrrat-go/libxml2/xsd"
// "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -61,18 +56,6 @@ func TestXMLGeneration(t *testing.T) {
valData, err := td.BytesIndent()
require.NoError(t, err)

// valData, err = addNamespaces(valData)
// require.NoError(t, err)

// errs := validateDoc(schema, valData)
// for _, e := range errs {
// assert.NoError(t, e)
// }
// if len(errs) > 0 {
// assert.Fail(t, "Invalid XML:\n"+string(valData))
// return
// }

if *test.UpdateOut {
data, err := td.Bytes()
require.NoError(t, err)
Expand All @@ -92,16 +75,6 @@ func TestXMLGeneration(t *testing.T) {
}
}

// func loadSchema() (*xsd.Schema, error) {
// schemaPath := test.Path("test", "schema", "SuministroLR.xsd")
// schema, err := xsd.ParseFromFile(schemaPath)
// if err != nil {
// return nil, err
// }

// return schema, nil
// }

func loadClient() (*verifactu.Client, error) {
ts, err := time.Parse(time.RFC3339, "2024-11-26T04:00:00Z")
if err != nil {
Expand Down Expand Up @@ -136,61 +109,3 @@ func lookupExamples() ([]string, error) {

return examples, nil
}

// func validateDoc(schema *xsd.Schema, doc []byte) []error {
// vf, err := Unenvelop(doc)
// if err != nil {
// return []error{err}
// }

// ns, err := addNamespaces(vf)
// if err != nil {
// return []error{err}
// }

// xmlDoc, err := libxml2.ParseString(string(ns))
// if err != nil {
// return []error{err}
// }

// err = schema.Validate(xmlDoc)
// if err != nil {
// return err.(xsd.SchemaValidationError).Errors()
// }

// return nil
// }

// Helper function to inject namespaces into XML without using Envelop()
// Just for xsd validation purposes
// func addNamespaces(data []byte) ([]byte, error) {
// xmlString := string(data)
// xmlNamespaces := ` xmlns:sum="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd" xmlns:sum1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd"`
// if !strings.Contains(xmlString, "<sum:RegFactuSistemaFacturacion>") {
// return nil, fmt.Errorf("could not find RegFactuSistemaFacturacion tag in XML")
// }
// xmlString = strings.Replace(xmlString, "<sum:RegFactuSistemaFacturacion>", "<sum:RegFactuSistemaFacturacion"+xmlNamespaces+">", 1)
// finalXMLBytes := []byte(xmlString)
// return finalXMLBytes, nil
// }

// Unenvelop extracts the VeriFactu document from a SOAP envelope
// func Unenvelop(data []byte) ([]byte, error) {
// var env doc.Envelope
// if err := xml.Unmarshal(data, &env); err != nil {
// return nil, err
// }

// // Check if the VeriFactu document is present
// if env.Body.VeriFactu == nil {
// return nil, fmt.Errorf("missing RegFactuSistemaFacturacion in envelope")
// }

// // Marshal the VeriFactu back to XML
// xmlData, err := xml.Marshal(env.Body.VeriFactu)
// if err != nil {
// return nil, err
// }

// return xmlData, nil
// }
4 changes: 0 additions & 4 deletions internal/gateways/gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ func New(env Environment, cert *xmldsig.Certificate) (*Connection, error) {

// Post sends the VeriFactu document to the gateway
func (c *Connection) Post(ctx context.Context, pyl []byte) error {
// pyl, err := doc.Bytes()
// if err != nil {
// return fmt.Errorf("generating payload: %w", err)
// }
return c.post(ctx, TestingBaseURL, pyl)
}

Expand Down

0 comments on commit f105a0a

Please sign in to comment.