From fadacfa33e85b1c335a6ac2c8b2ba50fc5963a60 Mon Sep 17 00:00:00 2001 From: Dave Bemiller <27972385+dbemiller@users.noreply.github.com> Date: Mon, 13 Nov 2017 11:26:48 -0500 Subject: [PATCH] Added response types. --- native/response/asset.go | 97 +++++++++++++++++++++++++++++++++++++ native/response/data.go | 42 ++++++++++++++++ native/response/image.go | 49 +++++++++++++++++++ native/response/link.go | 51 +++++++++++++++++++ native/response/response.go | 72 +++++++++++++++++++++++++++ native/response/title.go | 28 +++++++++++ native/response/video.go | 16 ++++++ 7 files changed, 355 insertions(+) create mode 100644 native/response/asset.go create mode 100644 native/response/data.go create mode 100644 native/response/image.go create mode 100644 native/response/link.go create mode 100644 native/response/response.go create mode 100644 native/response/title.go create mode 100644 native/response/video.go diff --git a/native/response/asset.go b/native/response/asset.go new file mode 100644 index 0000000..eac98f5 --- /dev/null +++ b/native/response/asset.go @@ -0,0 +1,97 @@ +package response + +import "github.com/mxmCherry/openrtb" + +// 5.2 Object: Asset +// +// Corresponds to the Asset Object in the request. The main container object for each asset +// requested or supported by Exchange on behalf of the rendering client. Any object that is +// required is to be flagged as such. Only one of the {title,img,video,data} objects should be +// present in each object. All others should be null/absent. The id is to be unique within the +// AssetObject array so that the response can be aligned. +type Asset struct { + // Field: + // id + // Scope: + // required + // Type: + // int + // Description: + // Unique asset ID, assigned by exchange, must match one of the asset IDs in request. + ID int `json:"id"` + + // Field: + // required + // Scope: + // optional + // Type: + // int + // Default: + // 0 + // Description: + // Set to 1 if asset is required. (bidder requires it to be displayed). + Required int `json:"required,omitempty"` + + // Field: + // title + // Scope: + // optional + // Type: + // object + // Description: + // Title object for title assets. + Title *Title `json:"title,omitempty"` + + // Field: + // img + // Scope: + // optional + // Type: + // object + // Description: + // Image object for image assets. + Img *Image `json:"img,omitempty"` + + // Field: + // video + // Scope: + // optional + // Type: + // object + // Description: + // Video object for video assets. See Video response object definition. + // Note that in-stream video ads are not part of Native. + // Native ads may contain a video as the ad creative itself. + Video *Video `json:"video,omitempty"` + + // Field: + // data + // Scope: + // optional + // Type: + // object + // Description: + // Data object for ratings, prices etc. + Data *Data `json:"data,omitempty"` + + // Field: + // link + // Scope: + // optional + // Type: + // object + // Description: + // Link object for call to actions. The link object applies if the asset item is activated (clicked). + // If there is no link object on the asset, the parent link object on the bid response applies. + Link *Link `json:"link,omitempty"` + + // Field: + // ext + // Scope: + // optional + // Type: + // object + // Description: + // This object is a placeholder that may contain custom JSON agreed to by the parties to support flexibility beyond the standard defined in this specification + Ext openrtb.RawJSON `json:"ext,omitempty"` +} diff --git a/native/response/data.go b/native/response/data.go new file mode 100644 index 0000000..74f6f72 --- /dev/null +++ b/native/response/data.go @@ -0,0 +1,42 @@ +package response + +import "github.com/mxmCherry/openrtb" + +// 5.5 Object: Data +// +// Corresponds to the Data Object in the request, with the value filled in. The Data Object is to be +// used for all miscellaneous elements of the native unit such as Brand Name, Ratings, Review +// Count, Stars, Downloads, Price count etc. It is also generic for future native elements not +// contemplated at the time of the writing of this document. +type Data struct { + // Field: + // label + // Scope: + // optional + // Type: + // string + // Description: + // The optional formatted string name of the data type to be displayed. + Label string `json:"label,omitempty"` + + // Field: + // value + // Scope: + // required + // Type: + // string + // Description: + // The formatted string of data to be displayed. + // Can contain a formatted value such as "5 stars" or "$10" or "3.4 stars out of 5". + Value string `json:"value"` + + // Field: + // ext + // Scope: + // optional + // Type: + // object + // Description: + // This object is a placeholder that may contain custom JSON agreed to by the parties to support flexibility beyond the standard defined in this specification + Ext openrtb.RawJSON `json:"ext,omitempty"` +} diff --git a/native/response/image.go b/native/response/image.go new file mode 100644 index 0000000..061528b --- /dev/null +++ b/native/response/image.go @@ -0,0 +1,49 @@ +package response + +import "github.com/mxmCherry/openrtb" + +// 5.4 Object: Image +// +// Corresponds to the Image Object in the request. +// The Image object to be used for all image elements of the Native ad such as Icons, Main Image, etc. +type Image struct { + // Field: + // url + // Scope: + // required + // Type: + // string + // Description: + // URL of the image asset + URL string `json:"url,omitempty"` + + // Field: + // w + // Scope: + // recommended + // Type: + // int + // Description: + // Width of the image in pixels + W int `json:"w,omitempty"` + + // Field: + // h + // Scope: + // recommended + // Type: + // int + // Description: + // Height of the image in pixels + H int `json:"h,omitempty"` + + // Field: + // ext + // Scope: + // optional + // Type: + // object + // Description: + // This object is a placeholder that may contain custom JSON agreed to by the parties to support flexibility beyond the standard defined in this specification + Ext openrtb.RawJSON `json:"ext,omitempty"` +} diff --git a/native/response/link.go b/native/response/link.go new file mode 100644 index 0000000..b33a55a --- /dev/null +++ b/native/response/link.go @@ -0,0 +1,51 @@ +package response + +import "github.com/mxmCherry/openrtb" + +// 5.7 Object: Link +// +// Used for ‘call to action’ assets, or other links from the Native ad. This Object should be +// associated to its peer object in the parent Asset Object or as the master link in the top level +// Native Ad response object. When that peer object is activated (clicked) the action should take +// the user to the location of the link. +type Link struct { + // Field: + // url + // Scope: + // required + // Type: + // string + // Description: + // Landing URL of the clickable link. + URL string `json:"url"` + + // Field: + // clicktrackers + // Scope: + // optional + // Type: + // string array + // Description: + // List of third-party tracker URLs to be fired on click of the URL. + ClickTrackers []string `json:"clicktrackers"` + + // Field: + // fallback + // Scope: + // optional + // Type: + // string + // Description: + // Fallback URL for deeplink. To be used if the URL given in url is not supported by the device. + Fallback string `json:"fallback,omitempty"` + + // Field: + // ext + // Scope: + // optional + // Type: + // object + // Description: + // This object is a placeholder that may contain custom JSON agreed to by the parties to support flexibility beyond the standard defined in this specification + Ext openrtb.RawJSON `json:"ext,omitempty"` +} diff --git a/native/response/response.go b/native/response/response.go new file mode 100644 index 0000000..bad319f --- /dev/null +++ b/native/response/response.go @@ -0,0 +1,72 @@ +package response + +import "github.com/mxmCherry/openrtb" + +// 5.1 Object: Response +// +// The native object is the top level JSON object which identifies a native response. +type Response struct { + // Field: + // ver + // Scope: + // optional + // Type: + // string + // Description: + // Version of the Native Markup version in use. + Ver string `json:"ver,omitempty"` + + // Field: + // assets + // Scope: + // required + // Type: + // object array + // Description: + // List of native ad’s assets. + Assets []Asset `json:"assets"` + + // Field: + // link + // Scope: + // required + // Type: + // object + // Description: + // Destination Link. This is default link object for the ad. + // Individual assets can also have a link object which applies if the asset is activated(clicked). + // If the asset doesn’t have a link object, the parent link object applies. + Link Link `json:"link"` + + // Field: + // imptrackers + // Scope: + // optional + // Type: + // string array + // Description: + // Array of impression tracking URLs, expected to return a 1x1 image or 204 response - typically + // only passed when using 3rd party trackers. + ImpTrackers []string `json:"imptrackers,omitempty"` + + // Field: + // jstracker + // Scope: + // optional + // Type: + // string + // Description: + // Optional JavaScript impression tracker. This is a valid HTML, Javascript is already wrapped in