Skip to content

Commit

Permalink
Simplify return of GetRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiante committed Feb 2, 2024
1 parent acd630b commit a8a6af9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
10 changes: 8 additions & 2 deletions r_get_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package easclient

import (
"context"
"encoding/xml"
"time"

"github.com/google/uuid"
Expand All @@ -28,7 +29,12 @@ func (c *StoreClient) GetRecord(ctx context.Context, id uuid.UUID) (*Record, err
return nil, err
}

var result Record
type RecordResponse struct {
XMLName xml.Name `xml:"records"`
Record *Record `xml:"record"`
}

var result RecordResponse

req.SetResult(&result)
res, err := req.Get("/record/" + id.String())
Expand All @@ -40,5 +46,5 @@ func (c *StoreClient) GetRecord(ctx context.Context, id uuid.UUID) (*Record, err
return nil, err
}

return &result, nil
return result.Record, nil
}
40 changes: 18 additions & 22 deletions record.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package easclient

import (
"encoding/xml"
"time"

"github.com/google/uuid"
Expand All @@ -24,25 +23,22 @@ type RecordField struct {
}

type Record struct {
XMLName xml.Name `xml:"records"`
Record struct {
DocumentType string `xml:"documentType"`
MasterId uuid.UUID `xml:"masterId"`
ArchiveDateTime time.Time `xml:"archiveDateTime"`
ID uuid.UUID `xml:"id"`
Version string `xml:"version"`
ArchiverLogin string `xml:"archiverLogin"`
Archiver string `xml:"archiver"`
InitialArchiver string `xml:"initialArchiver"`
InitialArchiverLogin string `xml:"initialArchiverLogin"`
InitialArchiveDateTime time.Time `xml:"initialArchiveDateTime"`
Field []*RecordField `xml:"field"`
Attachment struct {
Name string `xml:"name"`
Size string `xml:"size"`
Register string `xml:"register"`
Author string `xml:"author"`
ID string `xml:"id"`
} `xml:"attachment"`
} `xml:"record"`
DocumentType string `xml:"documentType"`
MasterId uuid.UUID `xml:"masterId"`
ArchiveDateTime time.Time `xml:"archiveDateTime"`
ID uuid.UUID `xml:"id"`
Version string `xml:"version"`
ArchiverLogin string `xml:"archiverLogin"`
Archiver string `xml:"archiver"`
InitialArchiver string `xml:"initialArchiver"`
InitialArchiverLogin string `xml:"initialArchiverLogin"`
InitialArchiveDateTime time.Time `xml:"initialArchiveDateTime"`
Fields []*RecordField `xml:"field"`
Attachment struct {
Name string `xml:"name"`
Size string `xml:"size"`
Register string `xml:"register"`
Author string `xml:"author"`
ID string `xml:"id"`
} `xml:"attachment"`
}

0 comments on commit a8a6af9

Please sign in to comment.