Documentation
¶
Overview ¶
Package agilisads is the official Go client for the Agilis Advertising REST API.
Create a client with an API key (or leave it empty to read AGILIS_API_KEY from the environment) and call the operations grouped by resource:
client := agilisads.NewClient("pk_test_...")
categories, err := client.Categories.List(ctx)
The key decides the mode: a pk_test_ key works in TEST mode and a pk_live_ key in LIVE mode. Operations that take an environment fill it in from the key when it is left empty.
Index ¶
- Constants
- Variables
- func Bool(v bool) *bool
- func Float64(v float64) *float64
- func Int(v int) *int
- func Int64(v int64) *int64
- func String(v string) *string
- func VerifySignature(payload []byte, header, secret string, opts ...WebhookOption) error
- type APIError
- type ActionResult
- type AgilisError
- type AnalyticsParams
- type AuthenticationError
- type Band
- type CancelledEvent
- type CategoriesService
- type Category
- type CategoryList
- type Client
- type ConflictError
- type ConnectionError
- type CreateOfferParams
- type CreateWebhookEndpointParams
- type CreatedOffer
- type Crop
- type CropArea
- type DeleteParams
- type DeletedWebhookEndpoint
- type EditEventParams
- type EditedEvent
- type Environment
- type EstimateOfferPriceParams
- type Event
- type EventAnalytics
- type EventCategoriesService
- type EventCategory
- type EventCategoryList
- type EventCategoryRef
- type EventConfig
- type EventConfigService
- type EventCurrenciesService
- type EventCurrencyList
- type EventDetails
- type EventHistoryEntry
- type EventImageLimits
- type EventImageMaster
- type EventList
- type EventMetrics
- type EventOwner
- type EventPreview
- type EventPreviewImage
- type EventsService
- func (s *EventsService) Analytics(ctx context.Context, eventID int64, params *AnalyticsParams) (*EventAnalytics, error)
- func (s *EventsService) Cancel(ctx context.Context, eventID int64, params *DeleteParams) (*CancelledEvent, error)
- func (s *EventsService) Delete(ctx context.Context, eventID int64, params *DeleteParams) (*ActionResult, error)
- func (s *EventsService) Edit(ctx context.Context, eventID int64, params *EditEventParams) (*EditedEvent, error)
- func (s *EventsService) Get(ctx context.Context, eventID int64) (*EventDetails, error)
- func (s *EventsService) List(ctx context.Context, params *ListEventsParams) (*EventList, error)
- func (s *EventsService) ListAutoPaging(ctx context.Context, params *ListEventsParams) *Iter[Event]
- func (s *EventsService) Preview(ctx context.Context, params *PreviewEventParams) (*EventPreview, error)
- func (s *EventsService) Publish(ctx context.Context, params *PublishEventParams) (*PublishedEvent, error)
- func (s *EventsService) Reschedule(ctx context.Context, eventID int64, params *RescheduleEventParams) (*RescheduledEvent, error)
- type File
- type HTTPDoer
- type Interest
- type InterestList
- type InterestsService
- type InvalidRequestError
- type Iter
- type LatLng
- type ListEventsParams
- type ListOffersParams
- type ListWebhookEventsParams
- type Mode
- type NotFoundError
- type Offer
- type OfferAnalytics
- type OfferList
- type OfferMetrics
- type OfferPriceEstimate
- type OffersService
- func (s *OffersService) Analytics(ctx context.Context, offerID int64, params *AnalyticsParams) (*OfferAnalytics, error)
- func (s *OffersService) Create(ctx context.Context, params *CreateOfferParams) (*CreatedOffer, error)
- func (s *OffersService) Delete(ctx context.Context, offerID int64, params *DeleteParams) (*ActionResult, error)
- func (s *OffersService) EstimatePrice(ctx context.Context, params *EstimateOfferPriceParams) (*OfferPriceEstimate, error)
- func (s *OffersService) List(ctx context.Context, params *ListOffersParams) (*OfferList, error)
- func (s *OffersService) ListAutoPaging(ctx context.Context, params *ListOffersParams) *Iter[Offer]
- func (s *OffersService) Pause(ctx context.Context, offerID int64) (*ActionResult, error)
- func (s *OffersService) Resume(ctx context.Context, offerID int64) (*ActionResult, error)
- type Option
- type Pagination
- type PermissionError
- type PreviewEventParams
- type PublishEventParams
- type PublishedEvent
- type RateLimitError
- type RescheduleEventParams
- type RescheduledEvent
- type ResendWebhookEventParams
- type ResentWebhookEvent
- type Response
- type RollWebhookSecretParams
- type SendTestWebhookParams
- type SignatureVerificationError
- type TestWebhookResult
- type UpdateWebhookEndpointParams
- type WebhookDelivery
- type WebhookEndpoint
- type WebhookEndpointList
- type WebhookEndpointsService
- func (s *WebhookEndpointsService) Create(ctx context.Context, params *CreateWebhookEndpointParams) (*WebhookEndpoint, error)
- func (s *WebhookEndpointsService) Delete(ctx context.Context, endpointID string) (*DeletedWebhookEndpoint, error)
- func (s *WebhookEndpointsService) Get(ctx context.Context, endpointID string) (*WebhookEndpoint, error)
- func (s *WebhookEndpointsService) List(ctx context.Context) (*WebhookEndpointList, error)
- func (s *WebhookEndpointsService) RollSecret(ctx context.Context, endpointID string, params *RollWebhookSecretParams) (*WebhookEndpoint, error)
- func (s *WebhookEndpointsService) SendTest(ctx context.Context, endpointID string, params *SendTestWebhookParams) (*TestWebhookResult, error)
- func (s *WebhookEndpointsService) Update(ctx context.Context, endpointID string, params *UpdateWebhookEndpointParams) (*WebhookEndpoint, error)
- type WebhookEvent
- type WebhookEventData
- type WebhookEventList
- type WebhookEventRequest
- type WebhookEventsService
- func (s *WebhookEventsService) Get(ctx context.Context, webhookEventID string) (*WebhookEvent, error)
- func (s *WebhookEventsService) List(ctx context.Context, params *ListWebhookEventsParams) (*WebhookEventList, error)
- func (s *WebhookEventsService) ListAutoPaging(ctx context.Context, params *ListWebhookEventsParams) *Iter[WebhookEvent]
- func (s *WebhookEventsService) Resend(ctx context.Context, webhookEventID string, params *ResendWebhookEventParams) (*ResentWebhookEvent, error)
- type WebhookOption
Constants ¶
const ( GenderMale = "Male" GenderFemale = "Female" GenderNonBinary = "Non-binary" GenderAll = "All" )
Gender values for Offer targeting.
const ( // PaymentMethodLink sends a Stripe payment link by email (Offers only). PaymentMethodLink = "E" // PaymentMethodBalance deducts the price from the balance of the mode. PaymentMethodBalance = "B" )
Payment methods. An Event can only be paid from the balance.
const ( ButtonClaimOffer = "claim_offer" ButtonVisitWebsite = "visit_website" ButtonInstallApp = "install_app" ButtonBookNow = "book_now" ButtonGetDirections = "get_directions" ButtonCustom = "custom" )
Button presets for an Offer's button.
const ( Interval24Hours = "24h" Interval7Days = "7d" Interval30Days = "30d" Interval60Days = "60d" Interval90Days = "90d" IntervalAll = "all" )
Analytics intervals.
const ( EventTypeAll = "*" EventTypeOfferCreated = "offer.created" EventTypeOfferPaymentSucceeded = "offer.payment_succeeded" EventTypeOfferPaymentFailed = "offer.payment_failed" EventTypeOfferStarted = "offer.started" EventTypeOfferPaused = "offer.paused" EventTypeOfferResumed = "offer.resumed" EventTypeOfferEnded = "offer.ended" EventTypeOfferDeleted = "offer.deleted" EventTypeOfferDisabled = "offer.disabled" EventTypeOfferEnabled = "offer.enabled" EventTypeEventPublished = "event.published" EventTypeEventUpdated = "event.updated" EventTypeEventRescheduled = "event.rescheduled" EventTypeEventCancelled = "event.cancelled" EventTypeEventDeleted = "event.deleted" EventTypeEventEnded = "event.ended" EventTypeBalanceToppedUp = "balance.topped_up" EventTypeBalanceLow = "balance.low" EventTypeInvoiceCreated = "invoice.created" EventTypeTermsVersionIssued = "terms.version_issued" )
Webhook event types.
const DefaultBaseURL = "https://ads.agilis.dating"
DefaultBaseURL is the address of the Agilis Advertising API.
const DefaultMaxRetries = 2
DefaultMaxRetries is how many times a failed request is retried.
const DefaultTimeout = 60 * time.Second
DefaultTimeout is how long a single attempt may take before it is abandoned.
const DefaultTolerance = 300 * time.Second
DefaultTolerance is how far a webhook timestamp may be from now.
const SignatureHeader = "Agilis-Signature"
SignatureHeader is the header that carries a webhook message's signature.
const Version = "0.1.0"
Version is the version of this module.
Variables ¶
var ErrNoAPIKey = errors.New("agilisads: no API key: pass one to NewClient or set AGILIS_API_KEY")
ErrNoAPIKey is returned by every operation when the client has no API key: none was passed to NewClient and AGILIS_API_KEY is not set.
Functions ¶
func VerifySignature ¶
func VerifySignature(payload []byte, header, secret string, opts ...WebhookOption) error
VerifySignature checks a webhook message's signature without decoding it. It returns nil or a *SignatureVerificationError.
Types ¶
type APIError ¶
type APIError struct{ AgilisError }
APIError is returned for HTTP 5xx and any other unexpected status, and when a successful response cannot be decoded.
type ActionResult ¶
type ActionResult struct {
Response
ReturnCode string `json:"return_code"`
Message string `json:"message"`
DryRun bool `json:"dry_run"`
}
ActionResult is the response of an action such as pausing or deleting.
type AgilisError ¶
type AgilisError struct {
// StatusCode is the HTTP status, or 0 when there was no response.
StatusCode int
// ReturnCode is the API's return_code, such as "E1", when there is one.
ReturnCode string
// Message is the API's message, or a description of the failure.
Message string
// Body is the raw response body.
Body []byte
// Data is the parsed response body when it is a JSON object.
Data map[string]any
// Header holds the response headers.
Header http.Header
}
AgilisError is the base of every error the API returns. Each error the SDK returns for a failed request is one of the types below, and each of them unwraps to *AgilisError, so either can be used with errors.As:
var nf *agilisads.NotFoundError
if errors.As(err, &nf) { ... }
var ae *agilisads.AgilisError
if errors.As(err, &ae) { fmt.Println(ae.StatusCode, ae.ReturnCode) }
The API key never appears in an error.
func (*AgilisError) Error ¶
func (e *AgilisError) Error() string
type AnalyticsParams ¶
type AnalyticsParams struct {
// Interval is one of the Interval constants. Required.
Interval string
}
AnalyticsParams are the parameters of Offers.Analytics and Events.Analytics.
type AuthenticationError ¶
type AuthenticationError struct{ AgilisError }
AuthenticationError is returned for HTTP 401: the key is missing, unknown, disabled or expired.
func (*AuthenticationError) Unwrap ¶
func (e *AuthenticationError) Unwrap() error
Unwrap returns the base error.
type Band ¶
type Band string
Band is a figure the API gives as a band, such as "10-25", never an exact number. It also accepts a JSON number.
func (*Band) UnmarshalJSON ¶
UnmarshalJSON accepts a string, a number or null.
type CancelledEvent ¶
type CancelledEvent struct {
Response
ReturnCode string `json:"return_code"`
Message string `json:"message"`
EventID int64 `json:"event_id"`
Status string `json:"status"`
DryRun bool `json:"dry_run"`
}
CancelledEvent is the response of Events.Cancel.
type CategoriesService ¶
type CategoriesService struct {
// contains filtered or unexported fields
}
CategoriesService lists Offer categories.
func (*CategoriesService) List ¶
func (s *CategoriesService) List(ctx context.Context) (*CategoryList, error)
List returns the Offer categories (GET /categories).
type Category ¶
type Category struct {
CategoryID int64 `json:"category_id"`
CategoryName string `json:"category_name"`
}
Category is an Offer category.
type CategoryList ¶
CategoryList is the response of Categories.List.
type Client ¶
type Client struct {
Categories *CategoriesService
Interests *InterestsService
Offers *OffersService
EventCategories *EventCategoriesService
EventCurrencies *EventCurrenciesService
EventConfig *EventConfigService
Events *EventsService
WebhookEndpoints *WebhookEndpointsService
WebhookEvents *WebhookEventsService
// contains filtered or unexported fields
}
Client is a client for the Agilis Advertising API. It is safe for concurrent use.
func NewClient ¶
NewClient returns a client that uses apiKey. When apiKey is empty, the key is read from the AGILIS_API_KEY environment variable.
type ConflictError ¶
type ConflictError struct{ AgilisError }
ConflictError is returned for HTTP 409, for example when an Idempotency-Key is reused while the first request is still being processed.
func (*ConflictError) Unwrap ¶
func (e *ConflictError) Unwrap() error
Unwrap returns the base error.
type ConnectionError ¶
type ConnectionError struct {
AgilisError
// Err is the underlying error.
Err error
}
ConnectionError is returned when no response was received: the connection failed, the attempt timed out or the context ended.
func (*ConnectionError) Unwrap ¶
func (e *ConnectionError) Unwrap() []error
Unwrap returns the base error and the underlying error.
type CreateOfferParams ¶
type CreateOfferParams struct {
CategoryID int64
Title string
Description string
TermsAndConditions *string
AdvertisedName *string
PushNotificationTitle string
PushNotificationMessage string
// ButtonPreset is one of the Button constants; empty means claim_offer.
ButtonPreset string
// ButtonText is required when ButtonPreset is ButtonCustom.
ButtonText *string
URL string
Image *File
Location LatLng
// Radius is in miles.
Radius int
Gender []string
Interests []int64
// StartDatetime and ExpiryDatetime are ISO 8601, UTC.
StartDatetime string
ExpiryDatetime string
// PaymentMethod is PaymentMethodLink or PaymentMethodBalance.
PaymentMethod string
// Environment is filled in from the key when empty.
Environment Environment
// IdempotencyKey is generated (a UUID v4) when empty, and reused on
// every retry of the call.
IdempotencyKey string
// DryRun checks everything and answers with the cost, creating nothing.
DryRun bool
}
CreateOfferParams are the parameters of Offers.Create.
type CreateWebhookEndpointParams ¶
type CreateWebhookEndpointParams struct {
URL string `json:"url"`
EnabledEvents []string `json:"enabled_events"`
Description *string `json:"description,omitempty"`
}
CreateWebhookEndpointParams are the parameters of WebhookEndpoints.Create.
type CreatedOffer ¶
type CreatedOffer struct {
Response
ReturnCode string `json:"return_code"`
OfferID int64 `json:"offer_id"`
Status string `json:"status"`
PaymentURL *string `json:"payment_url"`
Currency string `json:"currency"`
DryRun bool `json:"dry_run"`
// IdempotencyKey is the key that was sent.
IdempotencyKey string `json:"-"`
}
CreatedOffer is the response of Offers.Create. A dry run's price, matching_members, balance_after and card_amount are reachable with Field.
type Crop ¶
Crop is the area of an uploaded event image to use: the top-left corner and the width, in pixels. The height is derived from the 16:9 frame.
type DeleteParams ¶
type DeleteParams struct {
// DryRun answers with what the operation would do, changing nothing.
DryRun bool
}
DeleteParams are the optional parameters of the delete and cancel operations.
type DeletedWebhookEndpoint ¶
type DeletedWebhookEndpoint struct {
Response
ReturnCode string `json:"return_code"`
ID string `json:"id"`
Deleted bool `json:"deleted"`
}
DeletedWebhookEndpoint is the response of WebhookEndpoints.Delete.
type EditEventParams ¶
type EditEventParams struct {
Title *string
Description *string
URL *string
// AdvertisedName set to "" goes back to the trading name.
AdvertisedName *string
VenueName *string
Address *string
City *string
CountryCode *string
Location *LatLng
// A price change must send PriceMin, PriceMax and Currency together.
PriceMin *float64
PriceMax *float64
Currency *string
// ClearPrice sends all three price fields blank, to show no price.
ClearPrice bool
Image *File
PreviewToken *string
SourceEventID *int64
// Crop on its own re-frames the existing image; with Image it is the area
// of the new picture.
Crop *Crop
}
EditEventParams are the parameters of Events.Edit. Set only the fields to change. Dates cannot be edited: use Events.Reschedule.
type EditedEvent ¶
type EditedEvent struct {
Response
ReturnCode string `json:"return_code"`
Message string `json:"message"`
EventID int64 `json:"event_id"`
Status string `json:"status"`
Category EventCategoryRef `json:"category"`
ChangedFields []string `json:"changed_fields"`
Image string `json:"image"`
ImageLarge string `json:"image_large"`
VenueChanged bool `json:"venue_changed"`
}
EditedEvent is the response of Events.Edit.
type Environment ¶
type Environment string
Environment is the environment parameter of the API: TEST or LIVE.
const ( EnvironmentTest Environment = "TEST" EnvironmentLive Environment = "LIVE" )
The environments of the API.
type EstimateOfferPriceParams ¶
type EstimateOfferPriceParams struct {
StartDatetime string `json:"start_datetime"`
EndDatetime string `json:"end_datetime"`
Location LatLng `json:"location"`
Radius int `json:"radius"`
Gender []string `json:"gender,omitempty"`
Interests []int64 `json:"interests,omitempty"`
Environment Environment `json:"environment,omitempty"`
}
EstimateOfferPriceParams are the parameters of Offers.EstimatePrice.
type Event ¶
type Event struct {
EventID int64 `json:"event_id"`
Title string `json:"title"`
Description string `json:"description"`
Category EventCategoryRef `json:"category"`
VenueName string `json:"venue_name"`
Address string `json:"address"`
City string `json:"city"`
CountryCode string `json:"country_code"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
StartsAt string `json:"starts_at"`
EndsAt string `json:"ends_at"`
URL string `json:"url"`
AdvertisedName *string `json:"advertised_name"`
PriceMin *float64 `json:"price_min"`
PriceMax *float64 `json:"price_max"`
Currency *string `json:"currency"`
Image string `json:"image"`
ImageLarge string `json:"image_large"`
ImageThumb string `json:"image_thumb"`
EventStatus string `json:"event_status"`
Attendees Band `json:"attendees"`
Owner *EventOwner `json:"owner"`
Environment string `json:"environment"`
RescheduleCount int `json:"reschedule_count"`
ClonedFromEventID *int64 `json:"cloned_from_event_id"`
CreationDatetime string `json:"creation_datetime"`
LastEditedAt *string `json:"last_edited_at"`
}
Event is an Event as the list returns it.
type EventAnalytics ¶
type EventAnalytics struct {
Response
EventID int64 `json:"event_id"`
Interval string `json:"interval"`
StartsAt string `json:"starts_at"`
EndsAt string `json:"ends_at"`
Status string `json:"status"`
Metrics EventMetrics `json:"metrics"`
// AsOf is when the figures were refreshed, nil until the first member
// interaction.
AsOf *string `json:"as_of"`
}
EventAnalytics is the response of Events.Analytics.
type EventCategoriesService ¶
type EventCategoriesService struct {
// contains filtered or unexported fields
}
EventCategoriesService lists Event categories.
func (*EventCategoriesService) List ¶
func (s *EventCategoriesService) List(ctx context.Context) (*EventCategoryList, error)
List returns the Event categories (GET /event-categories).
type EventCategory ¶
type EventCategory struct {
CategoryID int64 `json:"category_id"`
Code string `json:"code"`
CategoryName string `json:"category_name"`
}
EventCategory is an Event category.
type EventCategoryList ¶
type EventCategoryList struct {
Response
Categories []EventCategory `json:"categories"`
}
EventCategoryList is the response of EventCategories.List.
type EventCategoryRef ¶
type EventCategoryRef struct {
CategoryID int64 `json:"category_id"`
CategoryName string `json:"category_name"`
}
EventCategoryRef is the category determined for an Event.
type EventConfig ¶
type EventConfig struct {
Response
// ListingFee, Currency, ExchangeRatePerGBP and ExchangeRateDate are nil
// when the billing currency cannot be billed right now.
ListingFee *float64 `json:"listing_fee"`
Currency *string `json:"currency"`
ExchangeRatePerGBP *float64 `json:"exchange_rate_per_gbp"`
ExchangeRateDate *string `json:"exchange_rate_date"`
Environment string `json:"environment"`
Balance float64 `json:"balance"`
OrganisationBalance float64 `json:"organisation_balance"`
LivePublishingOpen bool `json:"live_publishing_open"`
Currencies []string `json:"currencies"`
Image EventImageLimits `json:"image"`
MaxYearsAhead int `json:"max_years_ahead"`
}
EventConfig is the response of EventConfig.Get: what publishing an Event costs, the balance of the key's mode and the image limits.
type EventConfigService ¶
type EventConfigService struct {
// contains filtered or unexported fields
}
EventConfigService reads the Event configuration.
func (*EventConfigService) Get ¶
func (s *EventConfigService) Get(ctx context.Context) (*EventConfig, error)
Get returns the Event configuration (GET /event-config).
type EventCurrenciesService ¶
type EventCurrenciesService struct {
// contains filtered or unexported fields
}
EventCurrenciesService lists the currencies an Event's ticket price can use.
func (*EventCurrenciesService) List ¶
func (s *EventCurrenciesService) List(ctx context.Context) (*EventCurrencyList, error)
List returns the currencies an Event's ticket price can use (GET /event-currencies).
type EventCurrencyList ¶
EventCurrencyList is the response of EventCurrencies.List.
type EventDetails ¶
type EventDetails struct {
Response
Event
CanManage bool `json:"can_manage"`
CanDelete bool `json:"can_delete"`
ListingPrice *float64 `json:"listing_price"`
BillingCurrency *string `json:"billing_currency"`
InvoiceID *string `json:"invoice_id"`
AppSyncedAt *string `json:"app_synced_at"`
HasMemberInteraction bool `json:"has_member_interaction"`
ImageMaster *EventImageMaster `json:"image_master"`
History []EventHistoryEntry `json:"history"`
}
EventDetails is the response of Events.Get: every field of the list row, plus the cost, permissions, image and history.
type EventHistoryEntry ¶
type EventHistoryEntry struct {
Action string `json:"action"`
Channel string `json:"channel"`
ActedByUserID *int64 `json:"acted_by_user_id"`
ActedBy *string `json:"acted_by"`
Details json.RawMessage `json:"details"`
Acknowledged bool `json:"acknowledged"`
At string `json:"at"`
}
EventHistoryEntry is one action taken on an Event.
type EventImageLimits ¶
type EventImageLimits struct {
MaxMB float64 `json:"max_mb"`
MinWidth int `json:"min_width"`
MinHeight int `json:"min_height"`
}
EventImageLimits are the limits on an Event image.
type EventImageMaster ¶
type EventImageMaster struct {
Width int `json:"width"`
Height int `json:"height"`
Crop CropArea `json:"crop"`
URL *string `json:"url"`
}
EventImageMaster is the stored original of an Event image.
type EventList ¶
type EventList struct {
Response
Data []Event `json:"data"`
Pagination Pagination `json:"pagination"`
}
EventList is one page of Events.
type EventMetrics ¶
type EventMetrics struct {
Clicks int64 `json:"clicks"`
Attendees Band `json:"attendees"`
InvitesSent Band `json:"invites_sent"`
InvitesAccepted Band `json:"invites_accepted"`
}
EventMetrics are an Event's figures. Clicks is exact; the others are bands.
type EventOwner ¶
EventOwner is the user who published an Event.
type EventPreview ¶
type EventPreview struct {
Response
ReturnCode string `json:"return_code"`
Category EventCategoryRef `json:"category"`
ListingFee *float64 `json:"listing_fee"`
Currency string `json:"currency"`
Balance float64 `json:"balance"`
BalanceAfter float64 `json:"balance_after"`
BalanceSufficient bool `json:"balance_sufficient"`
LivePublishingOpen bool `json:"live_publishing_open"`
PriceGBP *float64 `json:"price_gbp"`
Image *EventPreviewImage `json:"image"`
}
EventPreview is the response of Events.Preview.
type EventPreviewImage ¶
type EventPreviewImage struct {
PreviewURL string `json:"preview_url"`
Width int `json:"width"`
Height int `json:"height"`
MasterWidth int `json:"master_width"`
MasterHeight int `json:"master_height"`
Crop CropArea `json:"crop"`
// PreviewToken can be passed to Events.Publish instead of the image.
PreviewToken string `json:"preview_token"`
ExpiresAt string `json:"expires_at"`
}
EventPreviewImage is the processed image of a preview.
type EventsService ¶
type EventsService struct {
// contains filtered or unexported fields
}
EventsService publishes and manages Events.
func (*EventsService) Analytics ¶
func (s *EventsService) Analytics(ctx context.Context, eventID int64, params *AnalyticsParams) (*EventAnalytics, error)
Analytics returns an Event's figures over an interval (GET /events/{event_id}/analytics).
func (*EventsService) Cancel ¶
func (s *EventsService) Cancel(ctx context.Context, eventID int64, params *DeleteParams) (*CancelledEvent, error)
Cancel cancels an Event (POST /events/{event_id}/cancel). params may be nil.
func (*EventsService) Delete ¶
func (s *EventsService) Delete(ctx context.Context, eventID int64, params *DeleteParams) (*ActionResult, error)
Delete deletes an Event (DELETE /events/{event_id}). params may be nil.
func (*EventsService) Edit ¶
func (s *EventsService) Edit(ctx context.Context, eventID int64, params *EditEventParams) (*EditedEvent, error)
Edit changes a published Event, free of charge (PATCH /events/{event_id}). It is always sent as a multipart POST with X-HTTP-Method-Override: PATCH, with or without an image.
func (*EventsService) Get ¶
func (s *EventsService) Get(ctx context.Context, eventID int64) (*EventDetails, error)
Get returns one Event (GET /events/{event_id}).
func (*EventsService) List ¶
func (s *EventsService) List(ctx context.Context, params *ListEventsParams) (*EventList, error)
List returns one page of Events (GET /events).
func (*EventsService) ListAutoPaging ¶
func (s *EventsService) ListAutoPaging(ctx context.Context, params *ListEventsParams) *Iter[Event]
ListAutoPaging returns an iterator over every Event, following next_cursor until has_more is false.
func (*EventsService) Preview ¶
func (s *EventsService) Preview(ctx context.Context, params *PreviewEventParams) (*EventPreview, error)
Preview shows what publishing would do, without publishing or charging (POST /events/preview).
func (*EventsService) Publish ¶
func (s *EventsService) Publish(ctx context.Context, params *PublishEventParams) (*PublishedEvent, error)
Publish publishes an Event, paid from the balance (POST /events).
func (*EventsService) Reschedule ¶
func (s *EventsService) Reschedule(ctx context.Context, eventID int64, params *RescheduleEventParams) (*RescheduledEvent, error)
Reschedule moves an Event to new dates (POST /events/{event_id}/reschedule).
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is an image to upload. Create one with FileFromPath, FileFromBytes or FileFromReader. The content type is detected from the file name unless set with WithContentType.
func FileFromBytes ¶
FileFromBytes uploads data with the given file name.
func FileFromPath ¶
FileFromPath uploads the file at path. It is read when the request is sent.
func FileFromReader ¶
FileFromReader uploads what r holds, with the given file name. The reader is read once, when the request is first sent, and the bytes are reused if the request is retried.
func (*File) ContentType ¶
ContentType returns the content type sent with the upload.
func (*File) WithContentType ¶
WithContentType sets the content type instead of detecting it from the name, and returns f.
type Interest ¶
type Interest struct {
InterestID int64 `json:"interest_id"`
InterestName string `json:"interest_name"`
}
Interest is a member interest that an Offer can target.
type InterestList ¶
InterestList is the response of Interests.List.
type InterestsService ¶
type InterestsService struct {
// contains filtered or unexported fields
}
InterestsService lists interests.
func (*InterestsService) List ¶
func (s *InterestsService) List(ctx context.Context) (*InterestList, error)
List returns the interests Offers can target (GET /interests).
type InvalidRequestError ¶
type InvalidRequestError struct{ AgilisError }
InvalidRequestError is returned for HTTP 400 and 422, and for a refusal that arrives as HTTP 200 with a return_code starting with "E" (for example E3, when the balance is too low). StatusCode is 200 in that case.
func (*InvalidRequestError) Unwrap ¶
func (e *InvalidRequestError) Unwrap() error
Unwrap returns the base error.
type Iter ¶
type Iter[T any] struct { // contains filtered or unexported fields }
Iter walks every item of a list, fetching the next page when the current one is used up, until has_more is false:
it := client.Offers.ListAutoPaging(ctx, nil)
for it.Next() {
offer := it.Current()
...
}
if err := it.Err(); err != nil { ... }
type LatLng ¶
LatLng is a position: latitude first, then longitude. In JSON it is the array [latitude, longitude]; in a multipart form it is two location[] parts.
func (LatLng) MarshalJSON ¶
MarshalJSON encodes the position as [latitude, longitude].
type ListEventsParams ¶
type ListEventsParams struct {
// Environment is filled in from the key when empty.
Environment Environment
// Limit is the page size.
Limit int
// Cursor is the next_cursor of the previous page.
Cursor string
// EventStatus is upcoming, scheduled, rescheduled, cancelled or ended.
EventStatus string
// OwnerUserID lists only the Events of this user.
OwnerUserID int64
// CreatedAfter and CreatedBefore are ISO 8601, UTC.
CreatedAfter string
CreatedBefore string
}
ListEventsParams are the parameters of Events.List. All are optional.
type ListOffersParams ¶
type ListOffersParams struct {
// Environment is filled in from the key when empty.
Environment Environment
// Limit is the page size: default 20, at most 100.
Limit int
// Cursor is the next_cursor of the previous page.
Cursor string
// OfferStatus is awaiting_payment, active, paused or ended.
OfferStatus string
// CreatedAfter and CreatedBefore are ISO 8601, UTC.
CreatedAfter string
CreatedBefore string
}
ListOffersParams are the parameters of Offers.List. All are optional.
type ListWebhookEventsParams ¶
type ListWebhookEventsParams struct {
// Type lists only events of this type.
Type string
// DeliverySuccess false lists only events not yet delivered to every
// endpoint; true only events delivered everywhere.
DeliverySuccess *bool
// Limit is the page size, 1 to 100.
Limit int
// Cursor is the next_cursor of the previous page.
Cursor string
}
ListWebhookEventsParams are the parameters of WebhookEvents.List. All are optional.
type Mode ¶
type Mode string
Mode is the mode an API key works in.
The modes an API key can have.
func ModeFromKey ¶
ModeFromKey returns the mode of an API key from its prefix.
func (Mode) Environment ¶
func (m Mode) Environment() Environment
Environment returns the environment value the API uses for this mode, or "" when the mode is unknown.
type NotFoundError ¶
type NotFoundError struct{ AgilisError }
NotFoundError is returned for HTTP 404.
func (*NotFoundError) Unwrap ¶
func (e *NotFoundError) Unwrap() error
Unwrap returns the base error.
type Offer ¶
type Offer struct {
OfferID int64 `json:"offer_id"`
Title string `json:"title"`
Category string `json:"category"`
Description string `json:"description"`
TermsAndConditions *string `json:"terms_and_conditions"`
AdvertisedName *string `json:"advertised_name"`
PushNotificationTitle *string `json:"push_notification_title"`
PushNotificationMessage *string `json:"push_notification_message"`
ButtonPreset string `json:"button_preset"`
ButtonText *string `json:"button_text"`
URL string `json:"url"`
Image string `json:"image"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Radius float64 `json:"radius"`
Gender []string `json:"gender"`
Interests []Interest `json:"interests"`
StartDatetime string `json:"start_datetime"`
ExpiryDatetime string `json:"expiry_datetime"`
CreationDatetime string `json:"creation_datetime"`
// OfferStatus is Awaiting Payment, Active, Scheduled, Paused or Ended.
OfferStatus string `json:"offer_status"`
// Status is enabled or disabled.
Status string `json:"status"`
}
Offer is an Offer as the list returns it.
type OfferAnalytics ¶
type OfferAnalytics struct {
Response
OfferID int64 `json:"offer_id"`
Interval string `json:"interval"`
StartDatetime string `json:"start_datetime"`
EndDatetime string `json:"end_datetime"`
Status string `json:"status"`
Metrics OfferMetrics `json:"metrics"`
}
OfferAnalytics is the response of Offers.Analytics.
type OfferList ¶
type OfferList struct {
Response
Data []Offer `json:"data"`
Pagination Pagination `json:"pagination"`
}
OfferList is one page of Offers.
type OfferMetrics ¶
OfferMetrics are an Offer's figures.
type OfferPriceEstimate ¶
type OfferPriceEstimate struct {
Response
ReturnCode string `json:"return_code"`
PriceEstimate float64 `json:"price_estimate"`
MatchingUsers int64 `json:"matching_users"`
AdUnits int64 `json:"ad_units"`
AdUnitPrice float64 `json:"ad_unit_price"`
EstimatedCost float64 `json:"estimated_cost"`
Currency string `json:"currency"`
ExchangeRatePerGBP *float64 `json:"exchange_rate_per_gbp"`
ExchangeRateDate *string `json:"exchange_rate_date"`
}
OfferPriceEstimate is the response of Offers.EstimatePrice.
type OffersService ¶
type OffersService struct {
// contains filtered or unexported fields
}
OffersService creates and manages Offers.
func (*OffersService) Analytics ¶
func (s *OffersService) Analytics(ctx context.Context, offerID int64, params *AnalyticsParams) (*OfferAnalytics, error)
Analytics returns an Offer's figures over an interval (GET /offers/{offer_id}/analytics).
func (*OffersService) Create ¶
func (s *OffersService) Create(ctx context.Context, params *CreateOfferParams) (*CreatedOffer, error)
Create creates an Offer (POST /offers), sent as multipart/form-data with its image.
func (*OffersService) Delete ¶
func (s *OffersService) Delete(ctx context.Context, offerID int64, params *DeleteParams) (*ActionResult, error)
Delete deletes an Offer (DELETE /offers/{offer_id}). A dry run's refund is reachable with Field("refund"). params may be nil.
func (*OffersService) EstimatePrice ¶
func (s *OffersService) EstimatePrice(ctx context.Context, params *EstimateOfferPriceParams) (*OfferPriceEstimate, error)
EstimatePrice estimates what an Offer would cost (POST /offers/price-estimate). The environment is filled in from the key when left empty.
func (*OffersService) List ¶
func (s *OffersService) List(ctx context.Context, params *ListOffersParams) (*OfferList, error)
List returns one page of Offers, newest first (GET /offers).
func (*OffersService) ListAutoPaging ¶
func (s *OffersService) ListAutoPaging(ctx context.Context, params *ListOffersParams) *Iter[Offer]
ListAutoPaging returns an iterator over every Offer, following next_cursor until has_more is false.
func (*OffersService) Pause ¶
func (s *OffersService) Pause(ctx context.Context, offerID int64) (*ActionResult, error)
Pause pauses an Offer (POST /offers/{offer_id}/pause).
func (*OffersService) Resume ¶
func (s *OffersService) Resume(ctx context.Context, offerID int64) (*ActionResult, error)
Resume resumes a paused Offer (POST /offers/{offer_id}/resume). Its return_code is S2.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL sets the API address. The default is DefaultBaseURL.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client used to send requests. The default is a new *http.Client.
func WithMaxRetries ¶
WithMaxRetries sets how many times a failed request is retried. The default is DefaultMaxRetries. Zero turns retries off.
func WithTimeout ¶
WithTimeout sets how long a single attempt may take. The default is DefaultTimeout. Zero or less means no timeout beyond the context's own.
type Pagination ¶
type Pagination struct {
Limit int `json:"limit"`
Count int `json:"count"`
HasMore bool `json:"has_more"`
NextCursor *string `json:"next_cursor"`
}
Pagination is the pagination block of a list response.
type PermissionError ¶
type PermissionError struct{ AgilisError }
PermissionError is returned for HTTP 403, for example when the environment is not the key's own mode.
func (*PermissionError) Unwrap ¶
func (e *PermissionError) Unwrap() error
Unwrap returns the base error.
type PreviewEventParams ¶
type PreviewEventParams struct {
Title string
Description string
VenueName string
Address string
City string
CountryCode string
Location *LatLng
StartsAt string
EndsAt string
URL string
AdvertisedName *string
PriceMin *float64
PriceMax *float64
Currency string
Image *File
Crop *Crop
PaymentMethod string
Environment Environment
}
PreviewEventParams are the parameters of Events.Preview. Every field is optional except the environment, which is filled in from the key when empty.
type PublishEventParams ¶
type PublishEventParams struct {
Title string
Description string
VenueName string
Address string
City string
// CountryCode is ISO 3166-1 alpha-2, for example GB.
CountryCode string
Location LatLng
// StartsAt and EndsAt are ISO 8601, UTC.
StartsAt string
EndsAt string
// URL is your own booking page.
URL string
AdvertisedName *string
// PriceMin, PriceMax and Currency are the ticket price. Omit all three to
// show no price; send 0 for both to mark the event as free.
PriceMin *float64
PriceMax *float64
Currency string
Image *File
PreviewToken string
SourceEventID *int64
Crop *Crop
// PaymentMethod defaults to PaymentMethodBalance, the only one Events take.
PaymentMethod string
// Environment is filled in from the key when empty.
Environment Environment
// IdempotencyKey is generated (a UUID v4) when empty, and reused on
// every retry of the call.
IdempotencyKey string
// DryRun checks everything and answers with the cost, creating nothing.
DryRun bool
}
PublishEventParams are the parameters of Events.Publish. Give one image source: Image, PreviewToken or SourceEventID.
type PublishedEvent ¶
type PublishedEvent struct {
Response
ReturnCode string `json:"return_code"`
EventID int64 `json:"event_id"`
Status string `json:"status"`
PaymentURL *string `json:"payment_url"`
AmountCharged float64 `json:"amount_charged"`
Currency string `json:"currency"`
Category EventCategoryRef `json:"category"`
DryRun bool `json:"dry_run"`
// IdempotencyKey is the key that was sent.
IdempotencyKey string `json:"-"`
}
PublishedEvent is the response of Events.Publish. A dry run's listing_fee, amount_to_charge and balance_after are reachable with Field.
type RateLimitError ¶
type RateLimitError struct {
AgilisError
// RetryAfter is the wait the API asked for, or 0 when it gave none.
RetryAfter time.Duration
}
RateLimitError is returned for HTTP 429 once the retries are used up.
func (*RateLimitError) Unwrap ¶
func (e *RateLimitError) Unwrap() error
Unwrap returns the base error.
type RescheduleEventParams ¶
type RescheduleEventParams struct {
// StartsAt and EndsAt are ISO 8601, UTC.
StartsAt string `json:"starts_at"`
EndsAt string `json:"ends_at"`
}
RescheduleEventParams are the parameters of Events.Reschedule.
type RescheduledEvent ¶
type RescheduledEvent struct {
Response
ReturnCode string `json:"return_code"`
Message string `json:"message"`
EventID int64 `json:"event_id"`
Status string `json:"status"`
StartsAt string `json:"starts_at"`
EndsAt string `json:"ends_at"`
}
RescheduledEvent is the response of Events.Reschedule.
type ResendWebhookEventParams ¶
type ResendWebhookEventParams struct {
// EndpointID sends to this endpoint only. Empty sends to every endpoint
// the event went to.
EndpointID string `json:"endpoint_id,omitempty"`
}
ResendWebhookEventParams are the optional parameters of WebhookEvents.Resend.
type ResentWebhookEvent ¶
type ResentWebhookEvent struct {
Response
ReturnCode string `json:"return_code"`
WebhookEventID string `json:"webhook_event_id"`
Deliveries []WebhookDelivery `json:"deliveries"`
}
ResentWebhookEvent is the response of WebhookEvents.Resend.
type Response ¶
type Response struct {
// StatusCode is the HTTP status.
StatusCode int `json:"-"`
// Header holds the response headers.
Header http.Header `json:"-"`
// RawJSON is the response body as received.
RawJSON json.RawMessage `json:"-"`
}
Response holds the HTTP details of a response. Every response type embeds it, so the status, the headers (for example X-RateLimit-Remaining) and the raw JSON, including any fields this version of the SDK does not know, stay reachable.
func (*Response) Field ¶
func (r *Response) Field(name string) json.RawMessage
Field returns the raw JSON of a top-level field of the response, or nil when it is absent. Use it for fields this version of the SDK does not type.
func (*Response) RateLimitRemaining ¶
RateLimitRemaining returns the X-RateLimit-Remaining header, or -1 when it is absent.
type RollWebhookSecretParams ¶
type RollWebhookSecretParams struct {
// ExpiresIn is how long the old secret keeps signing: now, 1h, 24h or 7d.
ExpiresIn string `json:"expires_in,omitempty"`
}
RollWebhookSecretParams are the optional parameters of WebhookEndpoints.RollSecret.
type SendTestWebhookParams ¶
type SendTestWebhookParams struct {
// Type is the event type to send.
Type string `json:"type,omitempty"`
}
SendTestWebhookParams are the optional parameters of WebhookEndpoints.SendTest.
type SignatureVerificationError ¶
type SignatureVerificationError struct {
AgilisError
// Reason is "header" (the signature header is missing or malformed),
// "timestamp" (outside the tolerance) or "signature" (no v1 matches).
Reason string
}
SignatureVerificationError is returned by ConstructEvent when a webhook message cannot be verified.
func (*SignatureVerificationError) Unwrap ¶
func (e *SignatureVerificationError) Unwrap() error
Unwrap returns the base error.
type TestWebhookResult ¶
type TestWebhookResult struct {
Response
ReturnCode string `json:"return_code"`
WebhookEventID string `json:"webhook_event_id"`
Type string `json:"type"`
Test bool `json:"test"`
Delivery *WebhookDelivery `json:"delivery"`
}
TestWebhookResult is the response of WebhookEndpoints.SendTest.
type UpdateWebhookEndpointParams ¶
type UpdateWebhookEndpointParams struct {
URL *string `json:"url,omitempty"`
EnabledEvents []string `json:"enabled_events,omitempty"`
Description *string `json:"description,omitempty"`
// Status is enabled or disabled.
Status *string `json:"status,omitempty"`
}
UpdateWebhookEndpointParams are the parameters of WebhookEndpoints.Update. Set only the fields to change.
type WebhookDelivery ¶
type WebhookDelivery struct {
EndpointID string `json:"endpoint_id"`
Status string `json:"status"`
Attempts int `json:"attempts"`
LastHTTPStatus *int `json:"last_http_status"`
LastError *string `json:"last_error"`
NextAttemptAt *string `json:"next_attempt_at"`
DeliveredAt *string `json:"delivered_at"`
}
WebhookDelivery is the delivery of a webhook event to one endpoint.
type WebhookEndpoint ¶
type WebhookEndpoint struct {
Response
ReturnCode string `json:"return_code,omitempty"`
ID string `json:"id"`
URL string `json:"url"`
Description *string `json:"description"`
EnabledEvents []string `json:"enabled_events"`
Status string `json:"status"`
Livemode bool `json:"livemode"`
Created string `json:"created"`
LastSuccessAt *string `json:"last_success_at"`
FailingSince *string `json:"failing_since"`
DisabledBy *string `json:"disabled_by"`
DisabledReason *string `json:"disabled_reason"`
PreviousSecretExpiresAt *string `json:"previous_secret_expires_at"`
// Secret is set only when the endpoint is created and when its secret is
// rolled. Store it: it is not shown again.
Secret string `json:"secret,omitempty"`
}
WebhookEndpoint is a webhook endpoint.
type WebhookEndpointList ¶
type WebhookEndpointList struct {
Response
ReturnCode string `json:"return_code"`
Data []WebhookEndpoint `json:"data"`
}
WebhookEndpointList is the response of WebhookEndpoints.List.
type WebhookEndpointsService ¶
type WebhookEndpointsService struct {
// contains filtered or unexported fields
}
WebhookEndpointsService manages webhook endpoints.
func (*WebhookEndpointsService) Create ¶
func (s *WebhookEndpointsService) Create(ctx context.Context, params *CreateWebhookEndpointParams) (*WebhookEndpoint, error)
Create adds a webhook endpoint (POST /webhook-endpoints). The response holds the signing secret, once.
func (*WebhookEndpointsService) Delete ¶
func (s *WebhookEndpointsService) Delete(ctx context.Context, endpointID string) (*DeletedWebhookEndpoint, error)
Delete deletes a webhook endpoint (DELETE /webhook-endpoints/{endpoint_id}).
func (*WebhookEndpointsService) Get ¶
func (s *WebhookEndpointsService) Get(ctx context.Context, endpointID string) (*WebhookEndpoint, error)
Get returns one webhook endpoint (GET /webhook-endpoints/{endpoint_id}).
func (*WebhookEndpointsService) List ¶
func (s *WebhookEndpointsService) List(ctx context.Context) (*WebhookEndpointList, error)
List returns the webhook endpoints of the key's mode (GET /webhook-endpoints).
func (*WebhookEndpointsService) RollSecret ¶
func (s *WebhookEndpointsService) RollSecret(ctx context.Context, endpointID string, params *RollWebhookSecretParams) (*WebhookEndpoint, error)
RollSecret replaces an endpoint's signing secret (POST /webhook-endpoints/{endpoint_id}/roll-secret). The new secret is in the response, once. params may be nil.
func (*WebhookEndpointsService) SendTest ¶
func (s *WebhookEndpointsService) SendTest(ctx context.Context, endpointID string, params *SendTestWebhookParams) (*TestWebhookResult, error)
SendTest sends a test event to an endpoint (POST /webhook-endpoints/{endpoint_id}/test). params may be nil.
func (*WebhookEndpointsService) Update ¶
func (s *WebhookEndpointsService) Update(ctx context.Context, endpointID string, params *UpdateWebhookEndpointParams) (*WebhookEndpoint, error)
Update changes a webhook endpoint (PATCH /webhook-endpoints/{endpoint_id}).
type WebhookEvent ¶
type WebhookEvent struct {
Response
ReturnCode string `json:"return_code,omitempty"`
// ID is the event id (whevt_...). Use it to ignore repeats.
ID string `json:"id"`
Object string `json:"object,omitempty"`
// Type is the event type, one of the EventType constants.
Type string `json:"type"`
// Created is when the event happened, in Unix seconds.
Created int64 `json:"created"`
Livemode bool `json:"livemode"`
Version int `json:"version,omitempty"`
Test bool `json:"test"`
Data WebhookEventData `json:"data"`
Request WebhookEventRequest `json:"request"`
// Deliveries is set by WebhookEvents.Get and List.
Deliveries []WebhookDelivery `json:"deliveries,omitempty"`
}
WebhookEvent is a webhook event: what ConstructEvent returns for a received message, and what WebhookEvents.Get and List return.
func ConstructEvent ¶
func ConstructEvent(payload []byte, header, secret string, opts ...WebhookOption) (*WebhookEvent, error)
ConstructEvent verifies a received webhook message and returns its event.
payload is the request body exactly as received, header the value of the Agilis-Signature header and secret the endpoint's signing secret (whsec_...). The signature is the hex HMAC-SHA256 of "<t>.<payload>"; any matching v1 is accepted (there are two while a secret is being rolled), compared in constant time, and the timestamp must be within the tolerance.
It returns a *SignatureVerificationError when the message cannot be verified.
type WebhookEventData ¶
type WebhookEventData struct {
// Object is the raw JSON of data.object. Decode it with Offer, Event or
// DecodeObject.
Object json.RawMessage
// Fields holds every field of data, including object, as raw JSON. Extra
// facts such as amount_charged are here.
Fields map[string]json.RawMessage
}
WebhookEventData is the data of a webhook event: the object (the Offer, Event or invoice, as the API returns it elsewhere) and any extra facts.
func (*WebhookEventData) DecodeObject ¶
func (d *WebhookEventData) DecodeObject(v any) error
DecodeObject decodes data.object into v.
func (*WebhookEventData) Event ¶
func (d *WebhookEventData) Event() (*Event, error)
Event decodes data.object as an Event, for event.* events.
func (WebhookEventData) MarshalJSON ¶
func (d WebhookEventData) MarshalJSON() ([]byte, error)
MarshalJSON writes the data back as received.
func (*WebhookEventData) Offer ¶
func (d *WebhookEventData) Offer() (*Offer, error)
Offer decodes data.object as an Offer, for offer.* events.
func (*WebhookEventData) UnmarshalJSON ¶
func (d *WebhookEventData) UnmarshalJSON(b []byte) error
UnmarshalJSON keeps every field of data.
type WebhookEventList ¶
type WebhookEventList struct {
Response
ReturnCode string `json:"return_code"`
Data []WebhookEvent `json:"data"`
Pagination Pagination `json:"pagination"`
}
WebhookEventList is one page of webhook events.
type WebhookEventRequest ¶
type WebhookEventRequest struct {
// Source is api, mcp, ad_portal, agilis or system.
Source string `json:"source"`
IdempotencyKey *string `json:"idempotency_key"`
}
WebhookEventRequest says where the change behind a webhook event came from.
type WebhookEventsService ¶
type WebhookEventsService struct {
// contains filtered or unexported fields
}
WebhookEventsService lists and resends webhook events.
func (*WebhookEventsService) Get ¶
func (s *WebhookEventsService) Get(ctx context.Context, webhookEventID string) (*WebhookEvent, error)
Get returns one webhook event with its deliveries (GET /webhook-events/{webhook_event_id}).
func (*WebhookEventsService) List ¶
func (s *WebhookEventsService) List(ctx context.Context, params *ListWebhookEventsParams) (*WebhookEventList, error)
List returns one page of the webhook events of the last 30 days, newest first (GET /webhook-events).
func (*WebhookEventsService) ListAutoPaging ¶
func (s *WebhookEventsService) ListAutoPaging(ctx context.Context, params *ListWebhookEventsParams) *Iter[WebhookEvent]
ListAutoPaging returns an iterator over every webhook event, following next_cursor until has_more is false.
func (*WebhookEventsService) Resend ¶
func (s *WebhookEventsService) Resend(ctx context.Context, webhookEventID string, params *ResendWebhookEventParams) (*ResentWebhookEvent, error)
Resend sends a webhook event again now (POST /webhook-events/{webhook_event_id}/resend). params may be nil.
type WebhookOption ¶
type WebhookOption func(*webhookConfig)
WebhookOption configures ConstructEvent.
func WithNow ¶
func WithNow(now func() time.Time) WebhookOption
WithNow sets the clock used for the timestamp check.
func WithTolerance ¶
func WithTolerance(d time.Duration) WebhookOption
WithTolerance sets how far the signature's timestamp may be from now. The default is DefaultTolerance. Zero or less turns the timestamp check off.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
testmode
command
Command testmode lists your categories and Offers with a Test key, then estimates a price and sends an Offer create as a dry run.
|
Command testmode lists your categories and Offers with a Test key, then estimates a price and sends an Offer create as a dry run. |
|
webhook
command
Command webhook is a minimal webhook receiver.
|
Command webhook is a minimal webhook receiver. |