forked from bsm/openrtb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
82 changed files
with
2,665 additions
and
1,517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{json,rb,md,yml,yaml,feature}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: go | ||
install: make test | ||
sudo: false | ||
go: | ||
- 1.2 | ||
- 1.3 | ||
- 1.4 | ||
|
||
- 1.6.4 | ||
- 1.7.4 | ||
install: | ||
- go get -u -t ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
default: test | ||
default: vet test | ||
|
||
deps: | ||
go get -t ./... | ||
test: | ||
go test -a ./... | ||
|
||
test: deps | ||
go test ./... | ||
bench: | ||
go test ./... -bench=. -run=NONE | ||
|
||
vet: | ||
go vet ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package openrtb | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
) | ||
|
||
// Validation errors | ||
var ( | ||
ErrInvalidAudioNoMimes = errors.New("openrtb: audio has no mimes") | ||
) | ||
|
||
// The "audio" object must be included directly in the impression object | ||
type Audio struct { | ||
Mimes []string `json:"mimes"` // Content MIME types supported. | ||
MinDuration int `json:"minduration,omitempty"` // Minimum video ad duration in seconds | ||
MaxDuration int `json:"maxduration,omitempty"` // Maximum video ad duration in seconds | ||
Protocols []int `json:"protocols,omitempty"` // Video bid response protocols | ||
StartDelay int `json:"startdelay,omitempty"` // Indicates the start delay in seconds | ||
Sequence int `json:"sequence,omitempty"` // Default: 1 | ||
BAttr []int `json:"battr,omitempty"` // Blocked creative attributes | ||
MaxExtended int `json:"maxextended,omitempty"` // Maximum extended video ad duration | ||
MinBitrate int `json:"minbitrate,omitempty"` // Minimum bit rate in Kbps | ||
MaxBitrate int `json:"maxbitrate,omitempty"` // Maximum bit rate in Kbps | ||
Delivery []int `json:"delivery,omitempty"` // List of supported delivery methods | ||
CompanionAd []Banner `json:"companionad,omitempty"` | ||
API []int `json:"api,omitempty"` | ||
CompanionType []int `json:"companiontype,omitempty"` | ||
MaxSequence int `json:"maxseq,omitempty"` // The maximumnumber of ads that canbe played in an ad pod. | ||
Feed int `json:"feed,omitempty"` // Type of audio feed. | ||
Stitched int `json:"stitched,omitempty"` // Indicates if the ad is stitched with audio content or delivered independently | ||
NVol int `json:"nvol,omitempty"` // Volume normalization mode. | ||
Ext Extension `json:"ext,omitempty"` | ||
} | ||
|
||
type jsonAudio Audio | ||
|
||
// Validates the object | ||
func (a *Audio) Validate() error { | ||
if len(a.Mimes) == 0 { | ||
return ErrInvalidAudioNoMimes | ||
} | ||
return nil | ||
} | ||
|
||
// MarshalJSON custom marshalling with normalization | ||
func (a *Audio) MarshalJSON() ([]byte, error) { | ||
a.normalize() | ||
return json.Marshal((*jsonAudio)(a)) | ||
} | ||
|
||
// UnmarshalJSON custom unmarshalling with normalization | ||
func (a *Audio) UnmarshalJSON(data []byte) error { | ||
var h jsonAudio | ||
if err := json.Unmarshal(data, &h); err != nil { | ||
return err | ||
} | ||
|
||
*a = (Audio)(h) | ||
a.normalize() | ||
return nil | ||
} | ||
|
||
func (a *Audio) normalize() { | ||
if a.Sequence == 0 { | ||
a.Sequence = 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package openrtb | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Audio", func() { | ||
var subject *Audio | ||
|
||
BeforeEach(func() { | ||
err := fixture("audio", &subject) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
It("should parse correctly", func() { | ||
Expect(subject).To(Equal(&Audio{ | ||
Mimes: []string{ | ||
"audio/mp4", | ||
}, | ||
MinDuration: 5, | ||
MaxDuration: 30, | ||
Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper}, | ||
Sequence: 1, | ||
BAttr: []int{13, 14}, | ||
MaxExtended: 30, | ||
MinBitrate: 300, | ||
MaxBitrate: 1500, | ||
Delivery: []int{2}, | ||
CompanionAd: []Banner{ | ||
{W: 300, H: 250, ID: "1234567893-1", Pos: 1, BAttr: []int{13, 14}, ExpDir: []int{ExpDirRight, ExpDirDown}}, | ||
{W: 728, H: 90, ID: "1234567893-2", Pos: 1, BAttr: []int{13, 14}}, | ||
}, | ||
API: []int{1, 2}, | ||
CompanionType: []int{1, 2}, | ||
})) | ||
}) | ||
|
||
It("should validate", func() { | ||
Expect((&Audio{ | ||
MinDuration: 5, | ||
MaxDuration: 30, | ||
Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper}, | ||
Sequence: 1, | ||
BAttr: []int{13, 14}, | ||
MaxExtended: 30, | ||
MinBitrate: 300, | ||
MaxBitrate: 1500, | ||
Delivery: []int{2}, | ||
CompanionAd: []Banner{ | ||
{W: 300, H: 250, ID: "1234567893-1", Pos: 1, BAttr: []int{13, 14}, ExpDir: []int{ExpDirRight, ExpDirDown}}, | ||
{W: 728, H: 90, ID: "1234567893-2", Pos: 1, BAttr: []int{13, 14}}, | ||
}, | ||
CompanionType: []int{1, 2}, | ||
}).Validate()).To(Equal(ErrInvalidAudioNoMimes)) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.