Skip to content

Commit

Permalink
Added nbr attribute on the response
Browse files Browse the repository at this point in the history
  • Loading branch information
dim committed May 9, 2015
1 parent 20b516b commit d93c9fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Response struct {
Bidid *string `json:"bidid,omitempty"` // Optional response tracking ID for bidders
Cur *string `json:"cur,omitempty"` // Bid currency
Customdata *string `json:"customdata,omitempty"` // Encoded user features
Nbr *int `json:"nbr,omitempty"` // Reason for not bidding, where 0 = unknown error, 1 = technical error, 2 = invalid request, 3 = known web spider, 4 = suspected Non-Human Traffic, 5 = cloud, data center, or proxy IP, 6 = unsupported device, 7 = blocked publisher or site, 8 = unmatched user
Ext Extensions `json:"ext,omitempty"` // Custom specifications in Json
}

Expand Down
14 changes: 14 additions & 0 deletions response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package openrtb

import (
"bytes"
"encoding/json"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("Response", func() {
var subject *Response
var iptr = func(i int) *int { return &i }
var sptr = func(s string) *string { return &s }
var fptr = func(f float32) *float32 { return &f }

Expand All @@ -32,6 +35,17 @@ var _ = Describe("Response", func() {
Expect(ok).To(BeTrue())
})

It("should generate responses", func() {
nobid := Response{
Id: sptr("32a69c6ba388f110487f9d1e63f77b22d86e916b"),
Nbr: iptr(0),
Seatbid: []Seatbid{},
}
bin, err := json.Marshal(nobid)
Expect(err).NotTo(HaveOccurred())
Expect(string(bin)).To(Equal(`{"id":"32a69c6ba388f110487f9d1e63f77b22d86e916b","seatbid":[],"nbr":0}`))
})

It("should parse responses", func() {
resp, err := ParseResponse(bytes.NewBuffer(testFixtures.simpleResponse))
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit d93c9fc

Please sign in to comment.