-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Namespace for classification types #11
Conversation
Codecov Report
@@ Coverage Diff @@
## main #11 +/- ##
==========================================
- Coverage 93.70% 92.72% -0.98%
==========================================
Files 3 5 +2
Lines 127 165 +38
==========================================
+ Hits 119 153 +34
- Misses 4 6 +2
- Partials 4 6 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
pkg/models/expense_classification.go
Outdated
|
||
func (classification ExpensesClassificationType) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { | ||
type expensesClassificationType struct { | ||
ClassificationType string `xml:"ecls:classificationType"` | ||
ClassificationCategory string `xml:"ecls:classificationCategory"` | ||
Amount float64 `xml:"ecls:amount"` | ||
ID *byte `xml:"ecls:id"` | ||
} | ||
|
||
err := enc.EncodeElement(expensesClassificationType(classification), start) | ||
if err != nil { | ||
return fmt.Errorf("xml marshal expense classification: %w", err) | ||
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice i made a new duplicate struct of the ExpenseClassificationType
here with just the namespace prefix added ecls:
.
The reason for this is because I came across an issue when marshaling/unmarshaling ExpensesClassificationType
&. IncomeClassificationType
xml with namespaces and then trying to retrieve them with RequestDocs
golang/go#11496
golang/go#9519
func (classification IncomeClassificationType) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { | ||
type incomeClassificationType struct { | ||
ClassificationType string `xml:"icls:classificationType"` | ||
ClassificationCategory string `xml:"icls:classificationCategory"` | ||
Amount float64 `xml:"icls:amount"` | ||
ID *byte `xml:"icls:id"` | ||
} | ||
|
||
err := enc.EncodeElement(incomeClassificationType(classification), start) | ||
if err != nil { | ||
return fmt.Errorf("xml marshal income classification: %w", err) | ||
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as ExpensesClassificationType
reasoning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thank you!! - could you please consider adding a few UTs ?
Coverage looking better after adding some test cases. Let me know what you think : ) |
Kudos, SonarCloud Quality Gate passed! |
I just noticed I had to sign all of my changes so I squashed them as well. No new changes introduced in todays commit. Also I get the message |
This PR addresses issue #8