diff --git a/cmd/efactura-cli/cmd/api_get_messages_list.go b/cmd/efactura-cli/cmd/api_get_messages_list.go index 140ccee..7b3e560 100644 --- a/cmd/efactura-cli/cmd/api_get_messages_list.go +++ b/cmd/efactura-cli/cmd/api_get_messages_list.go @@ -20,7 +20,7 @@ import ( "fmt" "time" - "github.com/printesoi/e-factura-go/efactura" + "github.com/printesoi/e-factura-go/pkg/efactura" "github.com/spf13/cobra" ) diff --git a/cmd/efactura-cli/cmd/api_validate.go b/cmd/efactura-cli/cmd/api_validate.go index f22ec7d..99442ef 100644 --- a/cmd/efactura-cli/cmd/api_validate.go +++ b/cmd/efactura-cli/cmd/api_validate.go @@ -18,9 +18,10 @@ import ( "bytes" "context" "fmt" - "github.com/printesoi/e-factura-go/efactura" - "github.com/spf13/cobra" "os" + + "github.com/printesoi/e-factura-go/pkg/efactura" + "github.com/spf13/cobra" ) const ( diff --git a/cmd/efactura-cli/cmd/api_xml2pdf.go b/cmd/efactura-cli/cmd/api_xml2pdf.go index c1b505f..7bcd852 100644 --- a/cmd/efactura-cli/cmd/api_xml2pdf.go +++ b/cmd/efactura-cli/cmd/api_xml2pdf.go @@ -19,7 +19,7 @@ import ( "fmt" "os" - "github.com/printesoi/e-factura-go/efactura" + "github.com/printesoi/e-factura-go/pkg/efactura" "github.com/spf13/cobra" ) diff --git a/cmd/efactura-cli/cmd/helpers.go b/cmd/efactura-cli/cmd/helpers.go index 11e2d2c..75ea3d4 100644 --- a/cmd/efactura-cli/cmd/helpers.go +++ b/cmd/efactura-cli/cmd/helpers.go @@ -20,10 +20,10 @@ import ( "github.com/spf13/cobra" - efacturaclient "github.com/printesoi/e-factura-go/client" - "github.com/printesoi/e-factura-go/constants" - "github.com/printesoi/e-factura-go/efactura" - "github.com/printesoi/e-factura-go/oauth2" + efacturaclient "github.com/printesoi/e-factura-go/pkg/client" + "github.com/printesoi/e-factura-go/pkg/constants" + "github.com/printesoi/e-factura-go/pkg/efactura" + "github.com/printesoi/e-factura-go/pkg/oauth2" ) func newOAuth2Config(cmd *cobra.Command) (cfg oauth2.Config, err error) { diff --git a/cmd/efactura-cli/cmd/public_api_validate_xml.go b/cmd/efactura-cli/cmd/public_api_validate_xml.go index 6016573..32551e0 100644 --- a/cmd/efactura-cli/cmd/public_api_validate_xml.go +++ b/cmd/efactura-cli/cmd/public_api_validate_xml.go @@ -19,7 +19,7 @@ import ( "fmt" "os" - "github.com/printesoi/e-factura-go/efactura" + "github.com/printesoi/e-factura-go/pkg/efactura" "github.com/spf13/cobra" ) diff --git a/cmd/efactura-cli/cmd/public_api_xml2pdf.go b/cmd/efactura-cli/cmd/public_api_xml2pdf.go index 984a949..3325b8e 100644 --- a/cmd/efactura-cli/cmd/public_api_xml2pdf.go +++ b/cmd/efactura-cli/cmd/public_api_xml2pdf.go @@ -19,7 +19,7 @@ import ( "fmt" "os" - "github.com/printesoi/e-factura-go/efactura" + "github.com/printesoi/e-factura-go/pkg/efactura" "github.com/spf13/cobra" ) diff --git a/cmd/etransport-cli/cmd/helpers.go b/cmd/etransport-cli/cmd/helpers.go index 390dbe8..01898ca 100644 --- a/cmd/etransport-cli/cmd/helpers.go +++ b/cmd/etransport-cli/cmd/helpers.go @@ -20,8 +20,8 @@ import ( "github.com/spf13/cobra" - "github.com/printesoi/e-factura-go/etransport" - "github.com/printesoi/e-factura-go/oauth2" + "github.com/printesoi/e-factura-go/pkg/etransport" + "github.com/printesoi/e-factura-go/pkg/oauth2" ) func newOAuth2Config(cmd *cobra.Command) (cfg oauth2.Config, err error) { diff --git a/internal/errors/errors.go b/internal/errors/errors.go index 88a2c52..e0bbfd0 100644 --- a/internal/errors/errors.go +++ b/internal/errors/errors.go @@ -23,10 +23,10 @@ import ( "regexp" "strconv" - errors "github.com/printesoi/e-factura-go/errors" api_helpers "github.com/printesoi/e-factura-go/internal/helpers/api" "github.com/printesoi/e-factura-go/internal/ptr" iregexp "github.com/printesoi/e-factura-go/internal/regexp" + errors "github.com/printesoi/e-factura-go/pkg/errors" ) var ( diff --git a/client/client.go b/pkg/client/client.go similarity index 98% rename from client/client.go rename to pkg/client/client.go index 0d74362..95c504b 100644 --- a/client/client.go +++ b/pkg/client/client.go @@ -26,10 +26,10 @@ import ( xoauth2 "golang.org/x/oauth2" - "github.com/printesoi/e-factura-go/constants" ierrors "github.com/printesoi/e-factura-go/internal/errors" api_helpers "github.com/printesoi/e-factura-go/internal/helpers/api" - "github.com/printesoi/e-factura-go/xml" + "github.com/printesoi/e-factura-go/pkg/constants" + "github.com/printesoi/e-factura-go/pkg/xml" ) const ( diff --git a/client/client_2_test_.go b/pkg/client/client_2_test_.go similarity index 100% rename from client/client_2_test_.go rename to pkg/client/client_2_test_.go diff --git a/client/client_test.go b/pkg/client/client_test.go similarity index 98% rename from client/client_test.go rename to pkg/client/client_test.go index c3d6659..01732c5 100644 --- a/client/client_test.go +++ b/pkg/client/client_test.go @@ -25,9 +25,9 @@ import ( "testing" "time" - "github.com/printesoi/e-factura-go/constants" api_helpers "github.com/printesoi/e-factura-go/internal/helpers/api" - "github.com/printesoi/e-factura-go/oauth2" + "github.com/printesoi/e-factura-go/pkg/constants" + "github.com/printesoi/e-factura-go/pkg/oauth2" "github.com/stretchr/testify/assert" xoauth2 "golang.org/x/oauth2" ) diff --git a/client/config.go b/pkg/client/config.go similarity index 100% rename from client/config.go rename to pkg/client/config.go diff --git a/client/debug.go b/pkg/client/debug.go similarity index 100% rename from client/debug.go rename to pkg/client/debug.go diff --git a/client/revoke.go b/pkg/client/revoke.go similarity index 96% rename from client/revoke.go rename to pkg/client/revoke.go index 8514140..4ba8fb8 100644 --- a/client/revoke.go +++ b/pkg/client/revoke.go @@ -20,7 +20,7 @@ import ( "net/http" "net/url" - "github.com/printesoi/e-factura-go/oauth2" + "github.com/printesoi/e-factura-go/pkg/oauth2" ) func (c *ApiClient) RevokeAccessToken(ctx context.Context, accessToken string) error { diff --git a/constants/api.go b/pkg/constants/api.go similarity index 100% rename from constants/api.go rename to pkg/constants/api.go diff --git a/constants/version.go b/pkg/constants/version.go similarity index 100% rename from constants/version.go rename to pkg/constants/version.go diff --git a/efactura/builders.go b/pkg/efactura/builders.go similarity index 99% rename from efactura/builders.go rename to pkg/efactura/builders.go index 31a9358..f356e85 100644 --- a/efactura/builders.go +++ b/pkg/efactura/builders.go @@ -17,7 +17,7 @@ package efactura import ( ierrors "github.com/printesoi/e-factura-go/internal/errors" "github.com/printesoi/e-factura-go/internal/ptr" - "github.com/printesoi/e-factura-go/types" + "github.com/printesoi/e-factura-go/pkg/types" ) // InvoiceLineAllowanceChargeBuilder builds an InvoiceLineAllowanceCharge object diff --git a/efactura/builders_test.go b/pkg/efactura/builders_test.go similarity index 99% rename from efactura/builders_test.go rename to pkg/efactura/builders_test.go index 45f35db..52849cb 100644 --- a/efactura/builders_test.go +++ b/pkg/efactura/builders_test.go @@ -20,8 +20,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/printesoi/e-factura-go/text" - "github.com/printesoi/e-factura-go/types" + "github.com/printesoi/e-factura-go/pkg/text" + "github.com/printesoi/e-factura-go/pkg/types" ) const ( diff --git a/efactura/client.go b/pkg/efactura/client.go similarity index 97% rename from efactura/client.go rename to pkg/efactura/client.go index 7391699..f9d427a 100644 --- a/efactura/client.go +++ b/pkg/efactura/client.go @@ -19,8 +19,8 @@ import ( xoauth2 "golang.org/x/oauth2" - "github.com/printesoi/e-factura-go/client" - "github.com/printesoi/e-factura-go/constants" + "github.com/printesoi/e-factura-go/pkg/client" + "github.com/printesoi/e-factura-go/pkg/constants" ) // ClientConfig is the config used to create a Client diff --git a/efactura/client_test.go b/pkg/efactura/client_test.go similarity index 98% rename from efactura/client_test.go rename to pkg/efactura/client_test.go index 4265f83..ba1138a 100644 --- a/efactura/client_test.go +++ b/pkg/efactura/client_test.go @@ -23,7 +23,7 @@ import ( xoauth2 "golang.org/x/oauth2" - "github.com/printesoi/e-factura-go/oauth2" + "github.com/printesoi/e-factura-go/pkg/oauth2" ) func getTestCIF() string { diff --git a/efactura/codes.go b/pkg/efactura/codes.go similarity index 99% rename from efactura/codes.go rename to pkg/efactura/codes.go index 310f511..2430072 100644 --- a/efactura/codes.go +++ b/pkg/efactura/codes.go @@ -17,7 +17,7 @@ package efactura import ( "strings" - "github.com/printesoi/e-factura-go/text" + "github.com/printesoi/e-factura-go/pkg/text" ) // https://unece.org/fileadmin/DAM/trade/untdid/d16b/tred/tred1001.htm diff --git a/efactura/doc.go b/pkg/efactura/doc.go similarity index 100% rename from efactura/doc.go rename to pkg/efactura/doc.go diff --git a/efactura/helpers.go b/pkg/efactura/helpers.go similarity index 100% rename from efactura/helpers.go rename to pkg/efactura/helpers.go diff --git a/efactura/invoice.go b/pkg/efactura/invoice.go similarity index 99% rename from efactura/invoice.go rename to pkg/efactura/invoice.go index f6caee9..dfd54a9 100644 --- a/efactura/invoice.go +++ b/pkg/efactura/invoice.go @@ -17,8 +17,8 @@ package efactura import ( "fmt" - "github.com/printesoi/e-factura-go/types" - ixml "github.com/printesoi/e-factura-go/xml" + "github.com/printesoi/e-factura-go/pkg/types" + pxml "github.com/printesoi/e-factura-go/pkg/xml" "github.com/printesoi/xml-go" ) @@ -198,9 +198,9 @@ type Invoice struct { // Prefill sets the NS, NScac, NScbc and Comment properties for ensuring that // the required attributes and properties are set for a valid UBL XML. func (iv *Invoice) Prefill() { - iv.Namespace = ixml.XMLNSUBLInvoice2 - iv.NamespaceCAC = ixml.XMLNSUBLcac - iv.NamespaceCBC = ixml.XMLNSUBLcbc + iv.Namespace = pxml.XMLNSUBLInvoice2 + iv.NamespaceCAC = pxml.XMLNSUBLcac + iv.NamespaceCBC = pxml.XMLNSUBLcbc iv.UBLVersionID = UBLVersionID iv.CustomizationID = CIUSRO_v101 if iv.Comment == "" { @@ -210,21 +210,21 @@ func (iv *Invoice) Prefill() { func (iv Invoice) MarshalXML(e *xml.Encoder, start xml.StartElement) error { type invoice Invoice - ixml.SetupUBLXMLEncoder(e) + pxml.SetupUBLXMLEncoder(e) iv.Prefill() return e.EncodeElement(invoice(iv), start) } // XML returns the XML encoding of the Invoice func (iv Invoice) XML() ([]byte, error) { - return ixml.MarshalXMLWithHeader(iv) + return pxml.MarshalXMLWithHeader(iv) } // XMLIndent works like XML, but each XML element begins on a new // indented line that starts with prefix and is followed by one or more // copies of indent according to the nesting depth. func (iv Invoice) XMLIndent(prefix, indent string) ([]byte, error) { - return ixml.MarshalIndentXMLWithHeader(iv, prefix, indent) + return pxml.MarshalIndentXMLWithHeader(iv, prefix, indent) } // UnmarshalInvoice unmarshals an Invoice from XML data. Only use this method @@ -232,7 +232,7 @@ func (iv Invoice) XMLIndent(prefix, indent string) ([]byte, error) { // properly unmarshal a struct like Invoice due to namespace prefixes. This // method does not check if the unmarshaled Invoice is valid. func UnmarshalInvoice(xmlData []byte, invoice *Invoice) error { - return ixml.UnmarshalXML(xmlData, invoice) + return pxml.UnmarshalXML(xmlData, invoice) } type InvoiceBillingReference struct { diff --git a/efactura/rest.go b/pkg/efactura/rest.go similarity index 97% rename from efactura/rest.go rename to pkg/efactura/rest.go index fdd1314..19e0da0 100644 --- a/efactura/rest.go +++ b/pkg/efactura/rest.go @@ -33,8 +33,8 @@ import ( api_helpers "github.com/printesoi/e-factura-go/internal/helpers/api" "github.com/printesoi/e-factura-go/internal/ptr" iregexp "github.com/printesoi/e-factura-go/internal/regexp" - itime "github.com/printesoi/e-factura-go/time" - ixml "github.com/printesoi/e-factura-go/xml" + ptime "github.com/printesoi/e-factura-go/pkg/time" + pxml "github.com/printesoi/e-factura-go/pkg/xml" ) type ( @@ -458,7 +458,7 @@ func (m Message) GetBuyerCIF() (buyerCIF string) { // GetCreationDate parsed CreationDate and returns a time.Time in // RoZoneLocation. func (m Message) GetCreationDate() (time.Time, bool) { - t, err := itime.ParseInRomania(messageTimeLayout, m.CreationDate) + t, err := ptime.ParseInRomania(messageTimeLayout, m.CreationDate) return t, err == nil } @@ -514,7 +514,7 @@ func (c *Client) ValidateXML(ctx context.Context, xml io.Reader, st ValidateStan // ValidateInvoice validate the provided Invoice func (c *Client) ValidateInvoice(ctx context.Context, invoice Invoice) (*ValidateResponse, error) { - xmlReader, err := ixml.MarshalXMLToReader(invoice) + xmlReader, err := pxml.MarshalXMLToReader(invoice) if err != nil { return nil, err } @@ -573,7 +573,7 @@ func (c *Client) XMLToPDF(ctx context.Context, xml io.Reader, st ValidateStandar // InvoiceToPDF convert the given Invoice to PDF. See XMLToPDF for return // values. func (c *Client) InvoiceToPDF(ctx context.Context, invoice Invoice, noValidate bool) (response *GeneratePDFResponse, err error) { - xmlReader, err := ixml.MarshalXMLToReader(invoice) + xmlReader, err := pxml.MarshalXMLToReader(invoice) if err != nil { return nil, err } @@ -642,7 +642,7 @@ func (c *Client) UploadXML( func (c *Client) UploadInvoice( ctx context.Context, invoice Invoice, cif string, opts ...UploadOption, ) (response *UploadResponse, err error) { - xmlReader, err := ixml.MarshalXMLToReader(invoice) + xmlReader, err := pxml.MarshalXMLToReader(invoice) if err != nil { return nil, err } @@ -654,7 +654,7 @@ func (c *Client) UploadInvoice( func (c *Client) UploadRaspMessage( ctx context.Context, msg RaspMessage, cif string, ) (response *UploadResponse, err error) { - xmlReader, err := ixml.MarshalXMLToReader(msg) + xmlReader, err := pxml.MarshalXMLToReader(msg) if err != nil { return nil, err } @@ -891,20 +891,20 @@ func parseDownloadedInvoiceXML(ctx context.Context, invoiceXML []byte) (invoice XMLName xml.Name } var doc docName - if err = ixml.UnmarshalXML(invoiceXML, &doc); err != nil { + if err = pxml.UnmarshalXML(invoiceXML, &doc); err != nil { return } switch doc.XMLName.Space { - case ixml.XMLNSUBLInvoice2: + case pxml.XMLNSUBLInvoice2: iv := new(Invoice) - if err = ixml.UnmarshalXML(invoiceXML, iv); err != nil { + if err = pxml.UnmarshalXML(invoiceXML, iv); err != nil { return } invoice = iv case XMLNSMsgErrorV1: ie := new(InvoiceErrorMessage) - if err = ixml.UnmarshalXML(invoiceXML, &ie); err != nil { + if err = pxml.UnmarshalXML(invoiceXML, &ie); err != nil { return } invoiceError = ie diff --git a/efactura/rest_test.go b/pkg/efactura/rest_test.go similarity index 100% rename from efactura/rest_test.go rename to pkg/efactura/rest_test.go diff --git a/efactura/xml_types.go b/pkg/efactura/xml_types.go similarity index 98% rename from efactura/xml_types.go rename to pkg/efactura/xml_types.go index e02e7ab..9cca5ec 100644 --- a/efactura/xml_types.go +++ b/pkg/efactura/xml_types.go @@ -15,7 +15,7 @@ package efactura import ( - "github.com/printesoi/e-factura-go/types" + "github.com/printesoi/e-factura-go/pkg/types" "github.com/printesoi/xml-go" ) diff --git a/efactura/xmlns.go b/pkg/efactura/xmlns.go similarity index 100% rename from efactura/xmlns.go rename to pkg/efactura/xmlns.go diff --git a/errors/errors.go b/pkg/errors/errors.go similarity index 100% rename from errors/errors.go rename to pkg/errors/errors.go diff --git a/etransport/client.go b/pkg/etransport/client.go similarity index 98% rename from etransport/client.go rename to pkg/etransport/client.go index 24557ef..9e836d9 100644 --- a/etransport/client.go +++ b/pkg/etransport/client.go @@ -19,7 +19,7 @@ import ( xoauth2 "golang.org/x/oauth2" - "github.com/printesoi/e-factura-go/client" + "github.com/printesoi/e-factura-go/pkg/client" ) // ClientConfig is the config used to create a Client diff --git a/etransport/client_test.go b/pkg/etransport/client_test.go similarity index 98% rename from etransport/client_test.go rename to pkg/etransport/client_test.go index 02b9930..8b1ea9a 100644 --- a/etransport/client_test.go +++ b/pkg/etransport/client_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/assert" xoauth2 "golang.org/x/oauth2" - "github.com/printesoi/e-factura-go/oauth2" + "github.com/printesoi/e-factura-go/pkg/oauth2" ) func getTestCIF() string { diff --git a/etransport/codes.go b/pkg/etransport/codes.go similarity index 99% rename from etransport/codes.go rename to pkg/etransport/codes.go index 9f2781a..1cce0a9 100644 --- a/etransport/codes.go +++ b/pkg/etransport/codes.go @@ -17,7 +17,7 @@ package etransport import ( "strings" - "github.com/printesoi/e-factura-go/text" + "github.com/printesoi/e-factura-go/pkg/text" ) type DeclPostIncidentType string diff --git a/etransport/declaration.go b/pkg/etransport/declaration.go similarity index 99% rename from etransport/declaration.go rename to pkg/etransport/declaration.go index 9cc8091..f452425 100644 --- a/etransport/declaration.go +++ b/pkg/etransport/declaration.go @@ -17,8 +17,8 @@ package etransport import ( "errors" - "github.com/printesoi/e-factura-go/types" - ixml "github.com/printesoi/e-factura-go/xml" + "github.com/printesoi/e-factura-go/pkg/types" + ixml "github.com/printesoi/e-factura-go/pkg/xml" "github.com/printesoi/xml-go" ) diff --git a/etransport/rest.go b/pkg/etransport/rest.go similarity index 99% rename from etransport/rest.go rename to pkg/etransport/rest.go index 0b6ab32..a26073b 100644 --- a/etransport/rest.go +++ b/pkg/etransport/rest.go @@ -23,8 +23,8 @@ import ( "strings" ierrors "github.com/printesoi/e-factura-go/internal/errors" - "github.com/printesoi/e-factura-go/types" - ixml "github.com/printesoi/e-factura-go/xml" + "github.com/printesoi/e-factura-go/pkg/types" + ixml "github.com/printesoi/e-factura-go/pkg/xml" ) const ( diff --git a/oauth2/config.go b/pkg/oauth2/config.go similarity index 99% rename from oauth2/config.go rename to pkg/oauth2/config.go index 9b91e24..fe2b6d4 100644 --- a/oauth2/config.go +++ b/pkg/oauth2/config.go @@ -20,7 +20,7 @@ import ( "fmt" "time" - "github.com/printesoi/e-factura-go/errors" + "github.com/printesoi/e-factura-go/pkg/errors" xoauth2 "golang.org/x/oauth2" ) diff --git a/oauth2/doc.go b/pkg/oauth2/doc.go similarity index 100% rename from oauth2/doc.go rename to pkg/oauth2/doc.go diff --git a/oauth2/token_source.go b/pkg/oauth2/token_source.go similarity index 100% rename from oauth2/token_source.go rename to pkg/oauth2/token_source.go diff --git a/text/text.go b/pkg/text/text.go similarity index 100% rename from text/text.go rename to pkg/text/text.go diff --git a/time/location.go b/pkg/time/location.go similarity index 100% rename from time/location.go rename to pkg/time/location.go diff --git a/types/date.go b/pkg/types/date.go similarity index 98% rename from types/date.go rename to pkg/types/date.go index 792caa9..f8ccf3a 100644 --- a/types/date.go +++ b/pkg/types/date.go @@ -19,7 +19,7 @@ import ( "github.com/printesoi/xml-go" - itime "github.com/printesoi/e-factura-go/time" + itime "github.com/printesoi/e-factura-go/pkg/time" ) // Date is a wrapper of the time.Time type which marshals to XML in the diff --git a/types/decimal.go b/pkg/types/decimal.go similarity index 100% rename from types/decimal.go rename to pkg/types/decimal.go diff --git a/util/conv.go b/pkg/util/conv.go similarity index 98% rename from util/conv.go rename to pkg/util/conv.go index 43d7bac..b7fbab5 100644 --- a/util/conv.go +++ b/pkg/util/conv.go @@ -15,8 +15,8 @@ package util import ( - "github.com/printesoi/e-factura-go/efactura" - "github.com/printesoi/e-factura-go/etransport" + "github.com/printesoi/e-factura-go/pkg/efactura" + "github.com/printesoi/e-factura-go/pkg/etransport" ) // EfacturaRoCountrySubentityToEtransportCountyCode convert the given diff --git a/xml/ubl.go b/pkg/xml/ubl.go similarity index 100% rename from xml/ubl.go rename to pkg/xml/ubl.go diff --git a/xml/xml.go b/pkg/xml/xml.go similarity index 100% rename from xml/xml.go rename to pkg/xml/xml.go