Skip to content

Commit 24a002a

Browse files
committed
Fix JSON output
1 parent c086c6f commit 24a002a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

response_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ import (
66
)
77

88
func TestResponse_JSON(t *testing.T) {
9+
bid := &Bid{}
10+
bid.SetID("BIDID").SetImpID("IMPID").SetPrice(0.0)
11+
12+
sb := &Seatbid{}
13+
sb.Bid = append(sb.Bid, *bid)
14+
915
res := &Response{}
1016
res.Id = new(string)
1117
*res.Id = "RES_ID"
1218
res.Cur = new(string)
1319
*res.Cur = "USD"
20+
res.Seatbid = append(res.Seatbid, *sb)
1421

1522
bytes, err := res.JSON()
1623
assert.Nil(t, err)
17-
assert.Equal(t, string(bytes), `{"id":"RES_ID","seatbid":null,"cur":"USD"}`)
24+
assert.Equal(t, string(bytes), `{"id":"RES_ID","seatbid":[{"bid":[{"id":"BIDID","impid":"IMPID","price":0}]}],"cur":"USD"}`)
1825
}
1926

2027
func TestResponse_Valid(t *testing.T) {

seatbid.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
// Group attribute can be used to specify if a seat is willing to accept any impressions that it can win (default) or if it is
1212
// only interested in winning any if it can win them all (i.e., all or nothing).
1313
type Seatbid struct {
14-
Bid []Bid `json:"id"` // Array of bid objects; each realtes to an imp, if exchange supported can have many bid objects.
15-
Seat *string `json:"seat,omiempty"` // ID of the bidder seat optional string ID of the bidder seat on whose behalf this bid is made.
16-
Group *int `json:"group,omiempty"` // '1' means impression must be won-lost as a group; default is '0'.
17-
Ext Extensions `json:"ext,omiempty"`
14+
Bid []Bid `json:"bid"` // Array of bid objects; each realtes to an imp, if exchange supported can have many bid objects.
15+
Seat *string `json:"seat,omitempty"` // ID of the bidder seat optional string ID of the bidder seat on whose behalf this bid is made.
16+
Group *int `json:"group,omitempty"` // '1' means impression must be won-lost as a group; default is '0'.
17+
Ext Extensions `json:"ext,omitempty"`
1818
}
1919

2020
// Validation errors

0 commit comments

Comments
 (0)