Documentation ¶
Index ¶
- Constants
- func ErrorCodes(err error) (code int, subcode int)
- func ErrorMessages(err error) (message string, errorusertitle string, errorusermsg string)
- func IsErrorWithFundraiserCoverPhoto(err error) bool
- func WithFundraiserCoverPhotoImage(name string, content io.Reader) func(*multipart.Writer) error
- func WithFundraiserCoverPhotoURL(name string, content url.URL) func(*multipart.Writer) error
- func WithFundraiserField(name string, value string) func(*multipart.Writer) error
- func WithLogger(logger Logger, debug bool) func(*APIClient) error
- type APIClient
- type CreateFundraiserParams
- type Logger
- type LoggerFunc
- type RestrictedReader
Constants ¶
const (
CreateFundraiserEndpoint = "https://graph.facebook.com/v2.8/me/fundraisers"
)
Facebook API endpoints.
const FundraiserCoverPhotoImageMaxSize = (4 * 1024 * 1024) - 1
FundraiserCoverPhotoImageMaxSize defines the maximum size for fundraiser cover photo images.
Variables ¶
This section is empty.
Functions ¶
func ErrorCodes ¶
ErrorCodes extracts any Facebook error codes from err. See https://developers.facebook.com/docs/graph-api/using-graph-api/error-handling/
func ErrorMessages ¶
ErrorMessages extracts any Facebook error messages from err. See https://developers.facebook.com/docs/graph-api/using-graph-api/error-handling/
func IsErrorWithFundraiserCoverPhoto ¶
IsErrorWithFundraiserCoverPhoto returns true if err was returned from WithFundraiserCoverPhotoURL option.
func WithFundraiserCoverPhotoImage ¶
WithFundraiserCoverPhotoImage adds an optional cover photo image when creating a new Facebook Fundraiser.
func WithFundraiserCoverPhotoURL ¶
WithFundraiserCoverPhotoURL adds an optional cover photo when creating a new Facebook Fundraiser.
func WithFundraiserField ¶
WithFundraiserField adds an optional field when creating a new Facebook Fundraiser.
The Facebook Fundraiser API supports the following optional fields:
external_fundraiser_uri - URI of the fundraiser on the external site
external_event_name - Name of the event this fundraiser belongs to
external_event_uri - URI of the event this fundraiser belongs to
external_event_start_time - Unix timestamp of the day when the event takes place
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient represents a HTTP client to the Facebook APIs.
func CreateAPIClient ¶
CreateAPIClient creates a new HTTP client to the Facebook APIs with the provided options.
func (APIClient) CreateFundraiser ¶
func (c APIClient) CreateFundraiser(params CreateFundraiserParams, options ...func(*multipart.Writer) error) (status int, result map[string]interface{}, err error)
CreateFundraiser creates a new Facebook Fundraiser. Required parameters are set with params. Optional parameters are set with options.
type CreateFundraiserParams ¶
type CreateFundraiserParams struct { // AccessToken as provided by Facebook Login for the user creating the fundraiser. AccessToken string // Charity ID is the Facebook Charity ID CharityID string // Title of the Facebook Fundraiser, can be up to 70 characters long. Title string // Description of the Facebook Fundraiser, can be up to 50k characters long. Description string // Goal in currency’s smallest unit. Fundraisers currently support only whole values, so for currencies with cents like USD, // you must round to an integer number and then multiply by 100 to get the value in cents. For zero-decimal currencies like JPY, // simply provide the integer amount without multiplying by 100. Goal int // Currency ISO 4127 code for the goal amount. Currency string // EndTime is a timestamp of when the fundraiser will stop accepting donations. Must be within 5 years from now. // Facebook converts this to 11:59pm in the timezone of the facebook user (as identified by the AccessToken) EndTime time.Time // ExternalID is generated by you to identify the fundraiser in your system. ExternalID string }
CreateFundraiserParams is the set of parameters required to create a Facebook Fundraiser.
type Logger ¶
type Logger interface {
Logf(format string, args ...interface{})
}
Logger is the interface implemented by the APIClient when logging API calls.
type LoggerFunc ¶
type LoggerFunc func(format string, args ...interface{})
The LoggerFunc type is an adapter to allow the use of ordinary functions as Loggers. If f is a function with the appropriate signature, LoggerFunc(f) is a Logger that calls f.
func (LoggerFunc) Logf ¶
func (f LoggerFunc) Logf(format string, args ...interface{})
Logf calls f(format, args...).
type RestrictedReader ¶
A RestrictedReader wraps the provided Reader restricting the amount of data read to the specified MaxSize of bytes. Each call to Read updates BytesRead to reflect the new total. If the MaxSize is exceeded an error is returned.
func (*RestrictedReader) IsMaxSizeExceeded ¶
func (r *RestrictedReader) IsMaxSizeExceeded(err error) bool
IsMaxSizeExceeded returns true if err is max size exceeded.