Skip to content

Commit

Permalink
Add namespace for classif types, add requestDocs pagination params
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefanos Papadakis committed Sep 12, 2022
1 parent 2b3ab75 commit 2f173a3
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 52 deletions.
36 changes: 36 additions & 0 deletions api/myDATA.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ paths:
- '{aade-user-id}'
type: string
default: '{aade-user-id}'
- name: nextPartitionKey
in: query
description: Παράμετρος για την τμηματική λήψη των αποτελεσμάτων
required: false
schema:
enum:
- '{nextPartitionKey}'
type: string
default: '{nextPartitionKey}'
- name: nextRowKey
in: query
description: Παράμετρος για την τμηματική λήψη των αποτελεσμάτων
required: false
schema:
enum:
- '{nextRowKey}'
type: string
default: '{nextRowKey}'
responses:
'200':
description:
Expand Down Expand Up @@ -98,6 +116,24 @@ paths:
enum:
- '{aade-user-id}'
type: string
- name: nextPartitionKey
in: query
description: Παράμετρος για την τμηματική λήψη των αποτελεσμάτων
required: false
schema:
enum:
- '{nextPartitionKey}'
type: string
default: '{nextPartitionKey}'
- name: nextRowKey
in: query
description: Παράμετρος για την τμηματική λήψη των αποτελεσμάτων
required: false
schema:
enum:
- '{nextRowKey}'
type: string
default: '{nextRowKey}'
responses:
'200':
description:
Expand Down
88 changes: 88 additions & 0 deletions internal/api/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions pkg/models/expense_classification.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package models

import (
"encoding/xml"
"fmt"
)

type ExpensesClassificationsDoc struct {
ExpensesInvoiceClassification []ExpensesInvoiceClassification `xml:"ExpensesInvoiceClassification"`
}
Expand All @@ -16,3 +21,21 @@ type InvoicesExpensesClassificationDetails struct {
LineNumber uint `xml:"lineNumber"`
ExpensesClassificationDetailData []ExpensesClassificationType `xml:"ExpensesClassificationDetailData"`
}

// MarshalXML transforms an ExpensesClassificationType to expensesClassificationType and serializes it in order to
// include the `ecls` namespace for every field.
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
}
28 changes: 28 additions & 0 deletions pkg/models/expense_classification_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package models

import (
"encoding/xml"
"testing"

"github.com/ppapapetrou76/go-testing/assert"
)

func TestExpensesClassificationType_MarshalXML(t *testing.T) {
t.Run("should have `ecls` namespace", func(t *testing.T) {
id := byte(1)
classification := ExpensesClassificationType{
ClassificationType: "type",
ClassificationCategory: "category",
Amount: 12,
ID: &id,
}

ft := assert.NewFluentT(t)

got, err := xml.Marshal(classification)
ft.AssertThat(err).IsNil()

want := []byte(`<ExpensesClassificationType><ecls:classificationType>type</ecls:classificationType><ecls:classificationCategory>category</ecls:classificationCategory><ecls:amount>12</ecls:amount><ecls:id>1</ecls:id></ExpensesClassificationType>`)
ft.AssertThat(got).IsEqualTo(want)
})
}
23 changes: 23 additions & 0 deletions pkg/models/income_classification.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package models

import (
"encoding/xml"
"fmt"
)

type IncomeClassificationsDoc struct {
IncomeInvoiceClassification []IncomeInvoiceClassification `xml:"incomeInvoiceClassification"`
}
Expand All @@ -16,3 +21,21 @@ type InvoicesIncomeClassificationDetails struct {
LineNumber uint `xml:"lineNumber"`
IncomeClassificationDetailData []IncomeClassificationType `xml:"incomeClassificationDetailData"`
}

// MarshalXML transforms an IncomeClassificationType to incomeClassificationType and serializes it in order to include
// the `icls` namespace for every field.
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
}
28 changes: 28 additions & 0 deletions pkg/models/income_classification_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package models

import (
"encoding/xml"
"testing"

"github.com/ppapapetrou76/go-testing/assert"
)

func TestIncomeClassificationType_MarshalXML(t *testing.T) {
t.Run("should have `icls` namespace", func(t *testing.T) {
id := byte(1)
classification := IncomeClassificationType{
ClassificationType: "type",
ClassificationCategory: "category",
Amount: 12,
ID: &id,
}

ft := assert.NewFluentT(t)

got, err := xml.Marshal(classification)
ft.AssertThat(err).IsNil()

want := []byte(`<IncomeClassificationType><icls:classificationType>type</icls:classificationType><icls:classificationCategory>category</icls:classificationCategory><icls:amount>12</icls:amount><icls:id>1</icls:id></IncomeClassificationType>`)
ft.AssertThat(got).IsEqualTo(want)
})
}
Loading

0 comments on commit 2f173a3

Please sign in to comment.