Skip to content

Commit

Permalink
Change PostRecord to use XML encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiante committed Feb 2, 2024
1 parent ba1a4c0 commit 904b1c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
17 changes: 8 additions & 9 deletions r_store_post_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ package easclient

import (
"context"
"encoding/xml"
"strings"

"github.com/google/uuid"
)

type PostRecordResponse struct {
Records []struct {
Id uuid.UUID `json:"id"`
Link struct {
Type string `json:"type"`
Title string `json:"title"`
Href string `json:"href"`
} `json:"link"`
} `json:"records"`
XMLName xml.Name `xml:"recordArchive"`
ID struct {
Value uuid.UUID `xml:",chardata"`
Type string `xml:"type,attr"`
Href string `xml:"href,attr"`
} `xml:"id"`
}

func (c *StoreClient) PostRecord(ctx context.Context, request *RecordRequest) (*PostRecordResponse, error) {
req, err := c.newRequestJSON(ctx)
req, err := c.newRequestXML(ctx)
if err != nil {
return nil, err
}
Expand Down
5 changes: 1 addition & 4 deletions r_store_post_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ func TestStoreClient_PostRecord(t *testing.T) {

require.NoError(t, err)
require.NotNil(t, res)

require.Len(t, res.Records, 1)
require.NoError(t, err)
require.NotEqual(t, uuid.Nil, res.Records[0].Id)
require.NotEqual(t, uuid.Nil, res.ID.Value)
}

0 comments on commit 904b1c1

Please sign in to comment.