facebookgen

package
v0.0.0-...-4526b33 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 20 Imported by: 0

README

Go API client for swagger

The Conversions API (for web) allows advertisers to send web events from their servers directly to Facebook. Conversions API events are linked to a pixel and are processed like browser pixel events. This means that these conversion events are used in measurement, reporting, and optimization in the same way as browser pixel events.

Overview

This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you can easily generate an API client.

  • API version: 1.0.0
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.languages.GoClientCodegen

Installation

Put the package under your project folder and add the following in import:

import "./swagger"

Documentation for API Endpoints

All URIs are relative to https://graph.facebook.com/v13.0

Class Method HTTP request Description
DefaultApi PixelIdEventsPost Post /{pixelId}/events

Documentation For Models

Documentation For Authorization

facebook_api_key

  • Type: API key

Example

auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
	Key: "APIKEY",
	Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)

Author

web_signals_integrations@fb.com

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	DefaultApi *DefaultApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the Facebook Conversions API (for Web) API v1.0.0 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the swagger operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type Content

type Content struct {
	// Product Id
	Id string `json:"id,omitempty"`
	// number of product
	Quantity int32 `json:"quantity,omitempty"`
	// Item Price.
	ItemPrice float32 `json:"item_price,omitempty"`
}

An object that contain the product IDs associated with the event plus information about the products.

type CustomData

type CustomData struct {
	// A numeric value associated with this event. This could be a monetary value or a value in some other metric.
	Value float32 `json:"value,omitempty"`
	// The currency for the value specified, if applicable. Currency must be a valid ISO 4217 (https://en.wikipedia.org/wiki/ISO_4217) three digit currency code.
	Currency string `json:"currency,omitempty"`
	// The name of the page or product associated with the event.
	ContentName string `json:"content_name,omitempty"`
	// The category of the content associated with the event.
	ContentCategory string `json:"content_category,omitempty"`
	// The content IDs associated with the event, such as product SKUs for items in an AddToCart event: ['ABC123', 'XYZ789']. If content_type is a product, then your content IDs must be an array with a single string value. Otherwise, this array can contain any number of string values.
	ContentIds []string `json:"content_ids,omitempty"`
	// A list of Content objects that contain the product IDs associated with the event plus information about the products. id, quantity, and item_price are available fields.
	Contents []Content `json:"contents,omitempty"`
	// It should be set to 'product' or 'product_group'. Use 'product', if the keys you send represent products. Sent keys could be content_ids or contents. Use product_group, if the keys you send in content_ids represent product groups. Product groups are used to distinguish products that are identical but have variations such as color, material, size or pattern.
	ContentType string `json:"content_type,omitempty"`
	// The order ID for this transaction as a String.
	OrderId string `json:"order_id,omitempty"`
	// The predicted lifetime value of a conversion event, as a String.
	PredictedLtv float32 `json:"predicted_ltv,omitempty"`
	// Use only with InitiateCheckout events. The number of items that a user tries to buy during checkout.
	NumItems int32 `json:"num_items,omitempty"`
	// Use only with Search events. A search query made by a user.
	SearchString string `json:"search_string,omitempty"`
	// Use only with CompleteRegistration events. The status of the registration event
	Status string `json:"status,omitempty"`
}

An object that includes additional business data about the event which can be used for ads delivery optimization. If our predefined object properties don't suit your needs, you can include your own, custom properties. Custom properties can be used with both standard and custom events, and can help you further define custom audiences.

type DefaultApiService

type DefaultApiService service

func (*DefaultApiService) PixelIdEventsPost

func (a *DefaultApiService) PixelIdEventsPost(ctx context.Context, body EventRequest, pixelId string) (ResponseSuccess, *http.Response, error)

DefaultApiService

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body Facebook Conversions API (for Web) post request
  • @param pixelId

@return ResponseSuccess

type Event

type Event struct {
	// A Facebook pixel Standard Event or Custom Event name. This field is used to deduplicate events sent by both Facebook Pixel and Conversions API. event_id is also used in deduplication. For the same customer action, event from the browser event match event_name from the server event. If we find a match between events sent within 48 hours of each other, we only consider the first one. If a server and browser event arrive at approximately the same time (within 5 minutes of each other), we favor the browser event.
	EventName string `json:"event_name"`
	// A Unix timestamp in seconds indicating when the actual event occurred. The specified time may be earlier than the time you send the event to Facebook. This is to enable batch processing and server performance optimization. event_time can be up to 7 days before you send an event to Facebook. If any event_time in data is greater than 7 days in the past, we return an error for the entire request and process no events.
	EventTime int64 `json:"event_time"`
	// The browser URL where the event happened.
	EventSourceUrl string `json:"event_source_url,omitempty"`
	// A flag that indicates we should not use this event for ads delivery optimization. If set to true, we only use the event for attribution.
	OptOut bool `json:"opt_out,omitempty"`
	// This ID can be any unique string chosen by the advertiser. event_id is used to deduplicate events sent by both Facebook Pixel and Conversions API. event_name is also used in deduplication. For deduplication, the eventID from a browser event must match the event_id in the corresponding server event.
	EventId string `json:"event_id,omitempty"`
	// This field allows you to specify where your conversions occurred. Knowing where your events took place helps ensure your ads go to the right people. See docs for the allowable values. https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event#action-source
	ActionSource string      `json:"action_source"`
	UserData     *UserData   `json:"user_data"`
	CustomData   *CustomData `json:"custom_data,omitempty"`
	// Processing options you would like to enable for a specific event. For more details see: https://developers.facebook.com/docs/marketing-apis/data-processing-options.
	DataProcessingOptions []string `json:"data_processing_options,omitempty"`
	// The country that you want to associate to this data processing option. If you set a country, you must also set a state. For more details see: https://developers.facebook.com/docs/marketing-apis/data-processing-options
	DataProcessingOptionsCountry int32 `json:"data_processing_options_country,omitempty"`
	// The state that you want to associate with this data processing option. For more details see: https://developers.facebook.com/docs/marketing-apis/data-processing-options.
	DataProcessingOptionsState int32 `json:"data_processing_options_state,omitempty"`
}

type EventRequest

type EventRequest struct {
	// An array of Server Event objects.
	Data []Event `json:"data"`
	// Code used to verify that your server events are received correctly by Facebook. Use this code to test your server events in the Test Events feature in Events Manager. See Test Events Tool (https://developers.facebook.com/docs/marketing-api/conversions-api/using-the-api#testEvents) for an example.
	TestEventCode string `json:"test_event_code,omitempty"`
	// Partner agent string.
	PartnerAgent string `json:"partner_agent"`
}

type GenericSwaggerError

type GenericSwaggerError struct {
	// contains filtered or unexported fields
}

GenericSwaggerError Provides access to the body, error and model on returned errors.

func (GenericSwaggerError) Body

func (e GenericSwaggerError) Body() []byte

Body returns the raw bytes of the response

func (GenericSwaggerError) Error

func (e GenericSwaggerError) Error() string

Error returns non-empty string if there was an error.

func (GenericSwaggerError) Model

func (e GenericSwaggerError) Model() interface{}

Model returns the unpacked model of the error

type ResponseError

type ResponseError struct {
	Error_ *ResponseErrorError `json:"error,omitempty"`
}

type ResponseErrorError

type ResponseErrorError struct {
	Code           string `json:"code,omitempty"`
	Messages       string `json:"messages,omitempty"`
	Type_          string `json:"type,omitempty"`
	FbtraceId      string `json:"fbtrace_id,omitempty"`
	ErrorSubcode   string `json:"error_subcode,omitempty"`
	IsTransient    string `json:"is_transient,omitempty"`
	ErrorUserTitle string `json:"error_user_title,omitempty"`
	ErrorUserMsg   string `json:"error_user_msg,omitempty"`
}

type ResponseSuccess

type ResponseSuccess struct {
	EventsReceived int32    `json:"events_received,omitempty"`
	Messages       []string `json:"messages,omitempty"`
	FbtraceId      string   `json:"fbtrace_id,omitempty"`
}

type UserData

type UserData struct {
	// A hashed email address in lower case using SHA-256 algorithm.
	Em string `json:"em,omitempty"`
	// A hashed phone number using SHA-256 algorithm. Include only digits with country code, area code, and number.
	Ph string `json:"ph,omitempty"`
	// A hashed gender (f or m) using SHA-256 algorithm.
	Ge string `json:"ge,omitempty"`
	// A hashed date of birth given as year, month, and day using SHA-256 algorithm
	Db string `json:"db,omitempty"`
	// A hashed last name in lowercase using SHA-256 algorithm.
	Ln string `json:"ln,omitempty"`
	// A hashed first name in lowercase using SHA-256 algorithm.
	Fn string `json:"fn,omitempty"`
	// A hashed city in lower-case without spaces or punctuation using SHA-256 algorithm.
	Ct string `json:"ct,omitempty"`
	// A hashed two-letter country code in lowercase using SHA-256 algorithm.
	Country string `json:"country,omitempty"`
	// A hashed two-letter state code in lowercase using SHA-256 algorithm.
	St string `json:"st,omitempty"`
	// A hashed zip code using SHA-256 algorithm. If you are in the United States, this is a five-digit zip code. For other locations, follow each country's standards.
	Zp string `json:"zp,omitempty"`
	// Any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs. If External ID is being sent via other channels, it should be sent in the same format via Conversions API. Hashing external_id using SHA-256 algorithm is optional.
	ExternalId string `json:"external_id,omitempty"`
	// The IP address of the browser corresponding to the event.
	ClientIpAddress string `json:"client_ip_address,omitempty"`
	// The user agent for the browser corresponding to the event.
	ClientUserAgent string `json:"client_user_agent,omitempty"`
	// The Facebook click ID value stored in the _fbc browser cookie under your domain. See Managing fbc and fbp Parameters for how to get this value (https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc), or generate this value from a fbclid query parameter.
	Fbc string `json:"fbc,omitempty"`
	// The Facebook browser ID value stored in the _fbp browser cookie under your domain. See Managing fbc and fbp Parameters for how to get this value (https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc).
	Fbp string `json:"fbp,omitempty"`
	// The subscription ID for the user in this transaction. This is similar to the order ID for an individual product.
	SubscriptionId string `json:"subscription_id,omitempty"`
	// Do not hash. The ID issued by Facebook when a person first logs into an instance of an app. This is also known as App-Scoped ID.
	FbLoginId int64 `json:"fb_login_id,omitempty"`
}

user_data is a set of identifiers Facebook can use for targeted attribution. You must provide at least one of the following user_data keys in your request

Jump to

Keyboard shortcuts

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