-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add states montana texas and colorado. #15
Open
aryehlev
wants to merge
1
commit into
prebid:main
Choose a base branch
from
aryehlev:tx_co_mt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -12,6 +12,9 @@ const ( | |
SectionUSPCO SectionID = 10 | ||
SectionUSPUT SectionID = 11 | ||
SectionUSPCT SectionID = 12 | ||
SectionUSPTX SectionID = 16 | ||
SectionUSPOR SectionID = 15 | ||
SectionUSPMT SectionID = 14 | ||
) | ||
|
||
var SectionNamesByID = map[int]string{ | ||
|
@@ -24,4 +27,6 @@ var SectionNamesByID = map[int]string{ | |
10: "uspco", | ||
11: "usput", | ||
12: "uspct", | ||
16: "usptx", | ||
15: "uspor", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is an entry for Montana missing?
Also, can we sort in descending order? |
||
} |
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,167 @@ | ||
package uspmt | ||
|
||
import ( | ||
"github.com/prebid/go-gpp/constants" | ||
"github.com/prebid/go-gpp/sections" | ||
"github.com/prebid/go-gpp/util" | ||
) | ||
|
||
type USPMTCoreSegment struct { | ||
Version byte | ||
SharingNotice byte | ||
SaleOptOutNotice byte | ||
TargetedAdvertisingOptOutNotice byte | ||
SaleOptOut byte | ||
TargetedAdvertisingOptOut byte | ||
SensitiveDataProcessing []byte | ||
KnownChildSensitiveDataConsents []byte | ||
AdditionalDataProcessingConsent byte | ||
MspaCoveredTransaction byte | ||
MspaOptOutOptionMode byte | ||
MspaServiceProviderMode byte | ||
} | ||
|
||
func NewUSMTCoreSegment(bs *util.BitStream) (USPMTCoreSegment, error) { | ||
var usmt USPMTCoreSegment | ||
var err error | ||
|
||
usmt.Version, err = bs.ReadByte6() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.Version", err) | ||
} | ||
|
||
usmt.SharingNotice, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.SharingNotice", err) | ||
} | ||
|
||
usmt.SaleOptOutNotice, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.SaleOptOutNotice", err) | ||
} | ||
|
||
usmt.TargetedAdvertisingOptOutNotice, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.TargetedAdvertisingOptOutNotice", err) | ||
} | ||
|
||
usmt.SaleOptOut, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.SaleOptOut", err) | ||
} | ||
|
||
usmt.TargetedAdvertisingOptOut, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.TargetedAdvertisingOptOut", err) | ||
} | ||
|
||
usmt.SensitiveDataProcessing, err = bs.ReadTwoBitField(8) | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.SensitiveDataProcessing", err) | ||
} | ||
|
||
usmt.KnownChildSensitiveDataConsents, err = bs.ReadTwoBitField(3) | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.KnownChildSensitiveDataConsentsArr", err) | ||
} | ||
|
||
usmt.AdditionalDataProcessingConsent, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.AdditionalDataProcessingConsent", err) | ||
} | ||
|
||
usmt.MspaCoveredTransaction, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.MspaCoveredTransaction", err) | ||
} | ||
|
||
usmt.MspaOptOutOptionMode, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.MspaOptOutOptionMode", err) | ||
} | ||
|
||
usmt.MspaServiceProviderMode, err = bs.ReadByte2() | ||
if err != nil { | ||
return usmt, sections.ErrorHelper("USMTSegment.MspaServiceProviderMode", err) | ||
} | ||
|
||
return usmt, nil | ||
} | ||
|
||
func (segment USPMTCoreSegment) Encode(bs *util.BitStream) { | ||
bs.WriteByte6(segment.Version) | ||
bs.WriteByte2(segment.SharingNotice) | ||
bs.WriteByte2(segment.SaleOptOutNotice) | ||
bs.WriteByte2(segment.TargetedAdvertisingOptOutNotice) | ||
bs.WriteByte2(segment.SaleOptOut) | ||
bs.WriteByte2(segment.TargetedAdvertisingOptOut) | ||
bs.WriteTwoBitField(segment.SensitiveDataProcessing) | ||
bs.WriteTwoBitField(segment.KnownChildSensitiveDataConsents) | ||
bs.WriteByte2(segment.AdditionalDataProcessingConsent) | ||
bs.WriteByte2(segment.MspaCoveredTransaction) | ||
bs.WriteByte2(segment.MspaOptOutOptionMode) | ||
bs.WriteByte2(segment.MspaServiceProviderMode) | ||
} | ||
|
||
type USPMT struct { | ||
SectionID constants.SectionID | ||
Value string | ||
CoreSegment USPMTCoreSegment | ||
GPCSegment sections.CommonUSGPCSegment | ||
} | ||
|
||
func NewUSPMT(encoded string) (USPMT, error) { | ||
uspmt := USPMT{} | ||
|
||
coreBitStream, gpcBitStream, err := sections.CreateBitStreams(encoded, true) | ||
if err != nil { | ||
return uspmt, err | ||
} | ||
|
||
coreSegment, err := NewUSMTCoreSegment(coreBitStream) | ||
if err != nil { | ||
return uspmt, err | ||
} | ||
|
||
gpcSegment := sections.CommonUSGPCSegment{ | ||
SubsectionType: 1, | ||
Gpc: false, | ||
} | ||
|
||
if gpcBitStream != nil { | ||
gpcSegment, err = sections.NewCommonUSGPCSegment(gpcBitStream) | ||
if err != nil { | ||
return uspmt, err | ||
} | ||
} | ||
|
||
uspmt = USPMT{ | ||
SectionID: constants.SectionUSPMT, | ||
Value: encoded, | ||
CoreSegment: coreSegment, | ||
GPCSegment: gpcSegment, | ||
} | ||
|
||
return uspmt, nil | ||
} | ||
|
||
func (uspmt USPMT) Encode(gpcIncluded bool) []byte { | ||
bs := util.NewBitStreamForWrite() | ||
uspmt.CoreSegment.Encode(bs) | ||
res := bs.Base64Encode() | ||
if !gpcIncluded { | ||
return res | ||
} | ||
bs.Reset() | ||
res = append(res, '.') | ||
uspmt.GPCSegment.Encode(bs) | ||
return append(res, bs.Base64Encode()...) | ||
} | ||
|
||
func (uspmt USPMT) GetID() constants.SectionID { | ||
return uspmt.SectionID | ||
} | ||
|
||
func (uspmt USPMT) GetValue() string { | ||
return uspmt.Value | ||
} |
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,62 @@ | ||
package uspmt | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prebid/go-gpp/constants" | ||
"github.com/prebid/go-gpp/sections" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type uspmtTestData struct { | ||
description string | ||
gppString string | ||
expected USPMT | ||
} | ||
|
||
func TestUSPCO(t *testing.T) { | ||
testData := []uspmtTestData{ | ||
{ | ||
description: "should populate USPMT segments correctly", | ||
gppString: "bSFgmAGU.YA", | ||
/* | ||
011011 01 00 10 00 01 0110000010011000 000000 01 10 01 01 01 1 1110 | ||
*/ | ||
expected: USPMT{ | ||
CoreSegment: USPMTCoreSegment{ | ||
Version: 27, | ||
SharingNotice: 1, | ||
SaleOptOutNotice: 0, | ||
TargetedAdvertisingOptOutNotice: 2, | ||
SaleOptOut: 0, | ||
TargetedAdvertisingOptOut: 1, | ||
SensitiveDataProcessing: []byte{ | ||
1, 2, 0, 0, 2, 1, 2, 0, | ||
}, | ||
KnownChildSensitiveDataConsents: []byte{0, 0, 0}, | ||
AdditionalDataProcessingConsent: 1, | ||
MspaCoveredTransaction: 2, | ||
MspaOptOutOptionMode: 1, | ||
MspaServiceProviderMode: 1, | ||
}, | ||
GPCSegment: sections.CommonUSGPCSegment{ | ||
SubsectionType: 1, | ||
Gpc: true, | ||
}, | ||
SectionID: constants.SectionUSPMT, | ||
Value: "bSFgmAGU.YA", | ||
}, | ||
}, | ||
} | ||
|
||
for _, test := range testData { | ||
result, err := NewUSPMT(test.gppString) | ||
encodedString := string(test.expected.Encode(true)) | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, test.expected, result) | ||
assert.Equal(t, constants.SectionUSPMT, result.GetID()) | ||
assert.Equal(t, test.gppString, result.GetValue()) | ||
assert.Equal(t, test.gppString, encodedString) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is mentioned in the pull request title that Colorado is added but, files
sections/uspor/uspor.go
andsections/uspor/uspor_test.go
as well as this constant's name, seem to hint that the two-letter state code refers to Oregon. Is the pull request title incorrect?