From 07fe175303b29bcdd96db0e7498f8b5013671c18 Mon Sep 17 00:00:00 2001 From: Max Cherry <mxmCherry@gmail.com> Date: Mon, 12 Jun 2017 19:49:49 +0300 Subject: [PATCH] OpenRTB 2.5 Source object added (BidRequest.source) --- bidrequest.go | 1 + source.go | 9 +++++++++ source_test.go | 24 ++++++++++++++++++++++++ testdata/source.json | 6 ++++++ 4 files changed, 40 insertions(+) create mode 100644 source.go create mode 100644 source_test.go create mode 100644 testdata/source.json diff --git a/bidrequest.go b/bidrequest.go index fbf312a..3f34695 100644 --- a/bidrequest.go +++ b/bidrequest.go @@ -30,6 +30,7 @@ type BidRequest struct { Bcat []string `json:"bcat,omitempty"` // Blocked Advertiser Categories. BAdv []string `json:"badv,omitempty"` // Array of strings of blocked toplevel domains of advertisers BApp []string `json:"bapp,omitempty"` // Block list of applications by their platform-specific exchange-independent application identifiers. On Android, these should be bundle or package names (e.g., com.foo.mygame). On iOS, these are numeric IDs. + Source *Source `json:"source,omitempty"` // A Source object that provides data about the inventory source and which entity makes the final decision Regs *Regulations `json:"regs,omitempty"` Ext Extension `json:"ext,omitempty"` diff --git a/source.go b/source.go new file mode 100644 index 0000000..e187215 --- /dev/null +++ b/source.go @@ -0,0 +1,9 @@ +package openrtb + +// Source object describes the nature and behavior of the entity that is the source of the bid request upstream from the exchange. +type Source struct { + FinalSaleDecision int `json:"fd,omitempty"` // Entity responsible for the final impression sale decision, where 0 = exchange, 1 = upstream source. + TransactionID string `json:"tid,omitempty"` // Transaction ID that must be common across all participants in this bid request (e.g., potentially multiple exchanges). + PaymentChain string `json:"pchain,omitempty"` // Payment ID chain string containing embedded syntax described in the TAG Payment ID Protocol v1.0. + Ext Extension `json:"ext,omitempty"` // Placeholder for exchange-specific extensions to OpenRTB. +} diff --git a/source_test.go b/source_test.go new file mode 100644 index 0000000..75c21bf --- /dev/null +++ b/source_test.go @@ -0,0 +1,24 @@ +package openrtb + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Source", func() { + var subject *Source + + BeforeEach(func() { + err := fixture("source", &subject) + Expect(err).NotTo(HaveOccurred()) + }) + + It("should parse correctly", func() { + Expect(subject).To(Equal(&Source{ + FinalSaleDecision: 1, + TransactionID: "transaction-id", + PaymentChain: "payment-chain", + Ext: Extension("{}"), + })) + }) +}) diff --git a/testdata/source.json b/testdata/source.json new file mode 100644 index 0000000..0f1edb3 --- /dev/null +++ b/testdata/source.json @@ -0,0 +1,6 @@ +{ + "fd": 1, + "tid": "transaction-id", + "pchain": "payment-chain", + "ext": {} +}