mirror of
https://github.com/FlipsideCrypto/go-data-bridge-client.git
synced 2026-02-06 02:37:33 +00:00
change record back to using record with interface value for data
This commit is contained in:
parent
b678dbe4db
commit
7f04bd70ec
@ -22,15 +22,14 @@ func TestClient_GetUnreadCount(t *testing.T) {
|
||||
|
||||
func TestClient_GetNextRecord(t *testing.T) {
|
||||
client := getClient(t)
|
||||
r, err := client.GetNextRecord("b053b974-608e-4f1b-9969-871a02cfbf92")
|
||||
record, err := client.GetNextRecord("b053b974-608e-4f1b-9969-871a02cfbf92")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
if r == nil {
|
||||
t.Fatal("Result is nil")
|
||||
if record == nil {
|
||||
t.Fatal("record is nil")
|
||||
}
|
||||
|
||||
record := string(*r)
|
||||
fmt.Fprintln(os.Stdout, "GetNextRecord")
|
||||
fmt.Fprintln(os.Stdout, record)
|
||||
}
|
||||
|
||||
12
record.go
12
record.go
@ -11,8 +11,8 @@ import (
|
||||
|
||||
// Record represents a Data Bridge data record
|
||||
type Record struct {
|
||||
ID string `json:"id"`
|
||||
Data []map[string]interface{} `json:"data"`
|
||||
ID string `json:"id"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
// GetUnreadCount returns the count of unread records in the given topic in the context of the api key
|
||||
@ -51,7 +51,7 @@ func (c Client) GetUnreadCount() (*int32, error) {
|
||||
}
|
||||
|
||||
// GetNextRecord returns the topic's next record. Will return nil without an error when there are no more records.
|
||||
func (c Client) GetNextRecord(consumerID string) (*json.RawMessage, error) {
|
||||
func (c Client) GetNextRecord(consumerID string) (*Record, error) {
|
||||
count, err := c.GetUnreadCount()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -79,14 +79,14 @@ func (c Client) GetNextRecord(consumerID string) (*json.RawMessage, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var result json.RawMessage
|
||||
var record Record
|
||||
|
||||
err = json.Unmarshal([]byte(body), &result)
|
||||
err = json.Unmarshal([]byte(body), &record)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
return &record, nil
|
||||
}
|
||||
|
||||
// CompleteRecord allows the record to be marked as completed
|
||||
|
||||
Loading…
Reference in New Issue
Block a user