adzerk

package
v0.0.0-...-3d9ab22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingAdTypes   = errors.New("go-adzerk/adzerk: missing value for Placements.AdTypes")
	ErrMissingDivName   = errors.New("go-adzerk/adzerk: missing value for Placements.NetworkID")
	ErrMissingNetworkID = errors.New("go-adzerk/adzerk: missing value for Placements.NetworkID")
	ErrMissingSiteID    = errors.New("go-adzerk/adzerk: missing value for Placements.SiteID")
	ErrNoPlacements     = errors.New("go-adzerk/adzerk: missing value for RequestData.Placements")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	URL string
	// contains filtered or unexported fields
}

A Client manages communication with the Adzerk API.

func NewClient

func NewClient(c *http.Client) *Client

NewClient returns a new Adzerk client. If a nil httpClient is provided, http.DefaultClient will be used.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) NewRequest

func (c *Client) NewRequest(data RequestData) (*http.Request, error)

NewRequest creates a new POST API request.

type Placement

type Placement struct {
	// Required arguments
	NetworkID int    `json:"networkId"`
	SiteID    int    `json:"siteId"`
	AdTypes   []int  `json:"adTypes"`
	DivName   string `json:"divName"`

	// Optional arguments
	AdID        int         `json:"adId,omitempty"`
	CampaignID  int         `json:"campaignId,omitempty"`
	FlightID    int         `json:"flightId,omitempty"`
	EventIDs    []int       `json:"eventIds,omitempty"`
	ZoneIDs     []int       `json:"zoneIds,omitempty"`
	ClickURL    string      `json:"clickUrl,omitempty"`
	ContentKeys interface{} `json:"contentKeys,omitempty"`
	Overrides   interface{} `json:"overrides,omitempty"`
	Properties  interface{} `json:"properties,omitempty"`
}

A Placement defines the JSON layout of the `placements` object in the request body.

type Request

type Request struct {
	EnableBotFiltering bool        `json:"enableBotFiltering,omitempty"`
	IncludePricingData bool        `json:"includePricingData,omitempty"`
	IsMobile           bool        `json:"isMobile,omitempty"`
	NoTrack            bool        `json:"notrack,omitempty"`
	Time               int64       `json:"time,omitempty"`
	BlockedCreatives   []int       `json:"blockedCreatives,omitempty"`
	IP                 string      `json:"ip,omitempty"`
	Referrer           string      `json:"referrer,omitempty"`
	URL                string      `json:"url,omitempty"`
	Keywords           []string    `json:"keywords,omitempty"`
	User               User        `json:"user,omitempty"`
	Placements         []Placement `json:"placements"`
}

A Request defines the JSON layout of the request body being sent to Adzerk.

type RequestData

type RequestData struct {
	// Required arguments
	Placements []Placement

	// Optional arguments
	EnableBotFiltering bool
	IncludePricingData bool
	IsMobile           bool
	NoTrack            bool
	BlockedCreatives   []int
	IP                 string
	Referrer           string
	URL                string
	UserID             string
	Keywords           []string
}

A RequestData is a parameter object which should be created and populated when generating a new Adzerk request using NewRequest.

type User

type User struct {
	Key string `json:"key"`
}

A User defines the JSON layout of the `user` object in the request body.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL