forked from bsm/openrtb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
51 lines (47 loc) · 1.84 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package openrtb
// An "app" object should be included if the ad supported content is part of a mobile application
// (as opposed to a mobile website). A bid request must not contain both an "app" object and a
// "site" object.
type App struct {
Id *string `json:"id,omitempty"` // App ID on the exchange
Name *string `json:"name,omitempty"` // App name
Domain *string `json:"domain,omitempty"`
Cat []string `json:"cat,omitempty"` // Array of IAB content categories
Sectioncat []string `json:"sectioncat,omitempty"` // Array of IAB content categories for subsection
Pagecat []string `json:"pagecat,omitempty"` // Array of IAB content categories for page
Ver *string `json:"ver,omitempty"` // App version
Bundle *string `json:"bundle,omitempty"` // App bundle or package name
Privacypolicy *int `json:"privacypolicy,omitempty"` // Default: 1 ("1": site has a privacy policy)
Paid *int `json:"paid,omitempty"` // "1": Paid, "2": Free
Publisher *Publisher `json:"publisher,omitempty"`
// Content Content
Keywords *string `json:"keywords,omitempty"`
Storeurl *string `json:"storeurl,omitempty"` // App store URL for an installed app
Ext Extensions `json:"ext,omitempty"`
}
// Returns the privacy policy status, with default fallback
func (a *App) IsPrivacyPolicy() bool {
if a.Privacypolicy != nil {
return *a.Privacypolicy == 1
}
return false
}
// Returns the paid status, with default fallback
func (a *App) IsPaid() bool {
if a.Paid != nil {
return *a.Paid == 1
}
return false
}
// Applies defaults
func (a *App) WithDefaults() *App {
if a.Privacypolicy == nil {
a.Privacypolicy = new(int)
*a.Privacypolicy = 0
}
if a.Paid == nil {
a.Paid = new(int)
*a.Paid = 0
}
return a
}