Skip to content

Commit 8b814bf

Browse files
author
Ev Dolzhenko
committed
Rename consts
1 parent dd8b894 commit 8b814bf

File tree

4 files changed

+78
-77
lines changed

4 files changed

+78
-77
lines changed

native/request/data.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ package request
22

33
import "encoding/json"
44

5-
type Data_Type int
5+
type DataTypeID int
66

77
const (
8-
Data_Sponsored Data_Type = 1 // Sponsored By message where response should contain the brand name of the sponsor
9-
Data_Desc Data_Type = 2 // Descriptive text associated with the product or service being advertised
10-
Data_Rating Data_Type = 3 // Rating of the product being offered to the user
11-
Data_Likes Data_Type = 4 // Number of social ratings or “likes” of the product being offered to the user
12-
Data_Downloads Data_Type = 5 // Number downloads/installs of this product
13-
Data_Price Data_Type = 6 // Price for product / app / in-app purchase. Value should include currency symbol in localised format
14-
Data_SalePrice Data_Type = 7 // Sale price that can be used together with price to indicate a discounted price compared to a regular price. Value should include currency symbol in localised format
15-
Data_Phone Data_Type = 8 // Phone number
16-
Data_Address Data_Type = 9 // Address
17-
Data_DescAdditional Data_Type = 10 // Additional descriptive text associated with the product or service being advertised
18-
Data_DisplayURL Data_Type = 11 // Display URL for the text ad. To be used when sponsoring entity doesn’t own the content. IE sponsored by BRAND on SITE (where SITE is transmitted in this field)
19-
Data_CTADesc Data_Type = 12 // CTA description - descriptive text describing a ‘call to action’ button for the destination URL
8+
DataTypeSponsored DataTypeID = 1 // Sponsored By message where response should contain the brand name of the sponsor
9+
DataTypeDesc DataTypeID = 2 // Descriptive text associated with the product or service being advertised
10+
DataTypeRating DataTypeID = 3 // Rating of the product being offered to the user
11+
DataTypeLikes DataTypeID = 4 // Number of social ratings or “likes” of the product being offered to the user
12+
DataTypeDownloads DataTypeID = 5 // Number downloads/installs of this product
13+
DataTypePrice DataTypeID = 6 // Price for product / app / in-app purchase. Value should include currency symbol in localised format
14+
DataTypeSalePrice DataTypeID = 7 // Sale price that can be used together with price to indicate a discounted price compared to a regular price. Value should include currency symbol in localised format
15+
DataTypePhone DataTypeID = 8 // Phone number
16+
DataTypeAddress DataTypeID = 9 // Address
17+
DataTypeDescAdditional DataTypeID = 10 // Additional descriptive text associated with the product or service being advertised
18+
DataTypeDisplayURL DataTypeID = 11 // Display URL for the text ad. To be used when sponsoring entity doesn’t own the content. IE sponsored by BRAND on SITE (where SITE is transmitted in this field)
19+
DataTypeCTADesc DataTypeID = 12 // CTA description - descriptive text describing a ‘call to action’ button for the destination URL
2020

2121
)
2222

2323
type Data struct {
24-
Type Data_Type `json:"type"` // Type ID of the element supported by the publisher. The publisher can display this information in an appropriate format
24+
TypeID DataTypeID `json:"type"` // Type ID of the element supported by the publisher. The publisher can display this information in an appropriate format
2525
Length int `json:"len"` // Maximum length of the text in the element’s response
2626
Ext json.RawMessage `json:"ext,omitempty"`
2727
}

native/request/image.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package request
22

33
import "encoding/json"
44

5-
type Image_Type int
5+
type ImageTypeID int
66

77
const (
8-
Image_Icon Image_Type = 1 // Icon image
9-
Image_Logo Image_Type = 2 // Logo image for the brand/app
10-
Image_Main Image_Type = 3 // Large image preview for the ad
8+
ImageTypeIcon ImageTypeID = 1 // Icon image
9+
ImageTypeLogo ImageTypeID = 2 // Logo image for the brand/app
10+
ImageTypeMain ImageTypeID = 3 // Large image preview for the ad
1111
)
1212

1313
type Image struct {
14-
Type Image_Type `json:"type,omitempty"` // Type ID of the image element supported by the publisher
14+
TypeID ImageTypeID `json:"type,omitempty"` // Type ID of the image element supported by the publisher
1515

1616
Width int `json:"w,omitempty"` // Width of the image in pixels
1717
WidthMin int `json:"wmin,omitempty"` // The minimum requested width of the image in pixels

native/request/request.go

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,60 @@ package request
22

33
import "encoding/json"
44

5-
type Request_Layout int
5+
type LayoutID int
66

77
const (
8-
Request_ContentWall Request_Layout = 1
9-
Request_AppWall Request_Layout = 2
10-
Request_NewsFeed Request_Layout = 3
11-
Request_ChatList Request_Layout = 4
12-
Request_Carousel Request_Layout = 5
13-
Request_ContentStream Request_Layout = 6
14-
Request_GridAdjoiningContent Request_Layout = 7
8+
LayoutContentWall LayoutID = 1
9+
LayoutAppWall LayoutID = 2
10+
LayoutNewsFeed LayoutID = 3
11+
LayoutChatList LayoutID = 4
12+
LayoutCarousel LayoutID = 5
13+
LayoutContentStream LayoutID = 6
14+
LayoutGridAdjoiningContent LayoutID = 7
1515
)
1616

17-
type Request_AdUnit int
17+
type AdUnitID int
1818

1919
const (
20-
Request_PaidSearchUnits Request_AdUnit = 1
21-
Request_RecommendationWidgets Request_AdUnit = 2
22-
Request_PromotedListings Request_AdUnit = 3
23-
Request_InAdWithNativeElementUnits Request_AdUnit = 4
24-
Request_Custom Request_AdUnit = 5
20+
AdUnitPaidSearch AdUnitID = 1
21+
AdUnitRecommendationWidget AdUnitID = 2
22+
AdUnitPromotedListings AdUnitID = 3
23+
AdUnitInAdWithNativeElement AdUnitID = 4
24+
AdUnitCustom AdUnitID = 5
2525
)
2626

27-
type Request_Context int
27+
type ContextTypeID int
2828

2929
const (
30-
Request_Content Request_Context = 1 // newsfeed, article, image gallery, video gallery
31-
Request_Social Request_Context = 2 // social network feed, email, chat
32-
Request_Product Request_Context = 3 // product listings, details, recommendations, reviews
30+
ContextTypeContent ContextTypeID = 1 // newsfeed, article, image gallery, video gallery
31+
ContextTypeSocial ContextTypeID = 2 // social network feed, email, chat
32+
ContextTypeProduct ContextTypeID = 3 // product listings, details, recommendations, reviews
3333
)
3434

35-
type Request_ContextSubType int
35+
type ContextSubTypeID int
3636

3737
const (
38-
Request_General Request_ContextSubType = 10
39-
Request_Article Request_ContextSubType = 11
40-
Request_Video Request_ContextSubType = 12
41-
Request_Audio Request_ContextSubType = 13
42-
Request_Image Request_ContextSubType = 14
43-
Request_UserGenerated Request_ContextSubType = 15
44-
Request_SubSocial Request_ContextSubType = 20
45-
Request_Email Request_ContextSubType = 21
46-
Request_Chat Request_ContextSubType = 22
47-
Request_Selling Request_ContextSubType = 30
48-
Request_AppStore Request_ContextSubType = 31
49-
Request_ProductReviews Request_ContextSubType = 32
38+
ContextSubTypeGeneral ContextSubTypeID = 10
39+
ContextSubTypeArticle ContextSubTypeID = 11
40+
ContextSubTypeVideo ContextSubTypeID = 12
41+
ContextSubTypeAudio ContextSubTypeID = 13
42+
ContextSubTypeImage ContextSubTypeID = 14
43+
ContextSubTypeUserGenerated ContextSubTypeID = 15
44+
ContextSubTypeSocial ContextSubTypeID = 20
45+
ContextSubTypeEmail ContextSubTypeID = 21
46+
ContextSubTypeChat ContextSubTypeID = 22
47+
ContextSubTypeSelling ContextSubTypeID = 30
48+
ContextSubTypeAppStore ContextSubTypeID = 31
49+
ContextSubTypeProductReviews ContextSubTypeID = 32
5050
)
5151

52-
type Request_PlacementType int
52+
type PlacementTypeID int
5353

5454
const (
55-
Request_InFeed Request_PlacementType = 1 // In the feed of content - for example as an item inside the organic feed/grid/listing/carousel
56-
Request_Atomic Request_PlacementType = 2 // In the atomic unit of the content - IE in the article page or single image page
57-
Request_Outside Request_PlacementType = 3 // Outside the core content - for example in the ads section on the right rail, as a banner-style placement near the content, etc.
58-
Request_Recommendation Request_PlacementType = 4 // Recommendation widget, most commonly presented below the article content
55+
PlacementTypeInFeed PlacementTypeID = 1 // In the feed of content - for example as an item inside the organic feed/grid/listing/carousel
56+
PlacementTypeAtomic PlacementTypeID = 2 // In the atomic unit of the content - IE in the article page or single image page
57+
PlacementTypeOutside PlacementTypeID = 3 // Outside the core content - for example in the ads section on the right rail, as a banner-style placement near the content, etc.
58+
PlacementTypeRecommendation PlacementTypeID = 4 // Recommendation widget, most commonly presented below the article content
5959
)
6060

6161
// This object represents a native type impression. Native ad units are intended to blend seamlessly into
@@ -66,14 +66,14 @@ const (
6666
// banner and/or video by also including as Imp subordinates the Banner and/or Video objects,
6767
// respectively. However, any given bid for the impression must conform to one of the offered types.
6868
type Request struct {
69-
Ver string `json:"ver,omitempty"` // Version of the Native Markup
70-
Layout Request_Layout `json:"layout,omitempty"` // DEPRECATED The Layout ID of the native ad
71-
AdUnit Request_AdUnit `json:"adunit,omitempty"` // DEPRECATED The Ad unit ID of the native ad
72-
Context Request_Context `json:"context,omitempty` // The context in which the ad appears
73-
ContextSubType Request_ContextSubType `json:"contextsubtype,omitempty"` // A more detailed context in which the ad appears
74-
PlacementType Request_PlacementType `json:"plcmttype,omitempty"` // The design/format/layout of the ad unit being offered
75-
PlacementCount int `json:"plcmtcnt,omitempty"` // The number of identical placements in this Layout
76-
Sequence int `json:"seq,omitempty"` // 0 for the first ad, 1 for the second ad, and so on
77-
Assets []Asset `json:"assets"` // An array of Asset Objects
78-
Ext json.RawMessage `json:"ext,omitempty"`
69+
Ver string `json:"ver,omitempty"` // Version of the Native Markup
70+
LayoutID LayoutID `json:"layout,omitempty"` // DEPRECATED The Layout ID of the native ad
71+
AdUnitID AdUnitID `json:"adunit,omitempty"` // DEPRECATED The Ad unit ID of the native ad
72+
ContextTypeID ContextTypeID `json:"context,omitempty"` // The context in which the ad appears
73+
ContextSubTypeID ContextSubTypeID `json:"contextsubtype,omitempty"` // A more detailed context in which the ad appears
74+
PlacementTypeID PlacementTypeID `json:"plcmttype,omitempty"` // The design/format/layout of the ad unit being offered
75+
PlacementCount int `json:"plcmtcnt,omitempty"` // The number of identical placements in this Layout
76+
Sequence int `json:"seq,omitempty"` // 0 for the first ad, 1 for the second ad, and so on
77+
Assets []Asset `json:"assets"` // An array of Asset Objects
78+
Ext json.RawMessage `json:"ext,omitempty"`
7979
}

native/request/request_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ import (
1111

1212
var _ = Describe("Request", func() {
1313
It("should parse correctly", func() {
14-
Expect(fixture("testdata/request1.json")).To(Equal(Request{
15-
Ver: "1.1",
16-
Context: Request_Social,
17-
ContextSubType: Request_SubSocial,
18-
PlacementType: Request_PlacementType(11),
19-
PlacementCount: 1,
20-
Sequence: 2,
14+
req := fixture("testdata/request1.json")
15+
Expect(req).To(Equal(&Request{
16+
Ver: "1.1",
17+
ContextTypeID: ContextTypeSocial,
18+
ContextSubTypeID: ContextSubTypeSocial,
19+
PlacementTypeID: PlacementTypeID(11),
20+
PlacementCount: 1,
21+
Sequence: 2,
2122
Assets: []Asset{
2223
{ID: 123, Required: 1, Title: &Title{Length: 140}},
23-
{ID: 128, Image: &Image{Type: Image_Main, WidthMin: 836, HeightMin: 627, Width: 1000, Height: 800, Mimes: []string{"image/jpg"}}},
24-
{ID: 126, Required: 1, Data: &Data{Type: Data_Sponsored, Length: 25}},
25-
{ID: 127, Required: 1, Data: &Data{Type: Data_Desc, Length: 140}},
24+
{ID: 128, Image: &Image{TypeID: ImageTypeMain, WidthMin: 836, HeightMin: 627, Width: 1000, Height: 800, Mimes: []string{"image/jpg"}}},
25+
{ID: 126, Required: 1, Data: &Data{TypeID: DataTypeSponsored, Length: 25}},
26+
{ID: 127, Required: 1, Data: &Data{TypeID: DataTypeDesc, Length: 140}},
2627
{ID: 4, Video: &Video{MinDuration: 15, MaxDuration: 30, Protocols: []int{2, 3}, Mimes: []string{"video/mp4"}}},
2728
},
2829
}))
@@ -34,10 +35,10 @@ func TestSuite(t *testing.T) {
3435
RunSpecs(t, "openrtb/native/request")
3536
}
3637

37-
func fixture(path string) Request {
38+
func fixture(path string) *Request {
3839
var subject Request
3940
enc, err := ioutil.ReadFile(path)
4041
Expect(err).ToNot(HaveOccurred())
4142
Expect(json.Unmarshal(enc, &subject)).To(Succeed())
42-
return subject
43+
return &subject
4344
}

0 commit comments

Comments
 (0)