Documentation
¶
Overview ¶
Package pereval implements the Pereval network partner API.
Index ¶
- Variables
- type Balance
- type BatchError
- type BatchMember
- type BatchResult
- type BlockRequest
- type BoostState
- type Capabilities
- type CapabilitiesService
- type CheckPhoto
- type City
- type Client
- type CommerceCatalog
- type CommerceGrant
- type CommerceOrder
- type CommerceProduct
- type CommerceQuote
- type CommerceService
- func (s CommerceService) Balance(ctx context.Context) (Balance, error)
- func (s CommerceService) Boost(ctx context.Context, member string) (*BoostState, error)
- func (s CommerceService) Catalog(ctx context.Context) (*CommerceCatalog, error)
- func (s CommerceService) Grants(ctx context.Context, member string) ([]CommerceGrant, error)
- func (s CommerceService) Incognito(ctx context.Context, member string, enabled *bool) (bool, error)
- func (s CommerceService) Order(ctx context.Context, quoteID uuid.UUID, externalOrderRef string) (*CommerceOrder, error)
- func (s CommerceService) Quote(ctx context.Context, member string, sku string, quantity int64) (*CommerceQuote, error)
- func (s CommerceService) SetDelivery(ctx context.Context, format string, enabled bool) (Delivery, error)
- type Config
- type Consent
- type Delivery
- type EndMatchRequest
- type Error
- type Event
- type EventPage
- type EventsService
- type FeedPage
- type FeedParams
- type FeedService
- type HealthService
- type IncomingLike
- type LanguagesService
- type LikeRequest
- type LikeResult
- type LikesService
- func (s LikesService) Create(ctx context.Context, req LikeRequest) (*LikeResult, error)
- func (s LikesService) Dislike(ctx context.Context, from, to string) error
- func (s LikesService) DislikeBatch(ctx context.Context, pairs []Pair) error
- func (s LikesService) List(ctx context.Context, member string, limit int) ([]IncomingLike, error)
- func (s LikesService) UndoDislike(ctx context.Context, from, to string, actionRef string) error
- func (s LikesService) Withdraw(ctx context.Context, from, to string, actionRef string) error
- type MCPService
- type Match
- type MatchesService
- type Member
- type MemberResult
- type MembersService
- func (s MembersService) Deactivate(ctx context.Context, externalID string) error
- func (s MembersService) Reinstate(ctx context.Context, externalID string) error
- func (s MembersService) Remove(ctx context.Context, externalID, reason string) error
- func (s MembersService) Restore(ctx context.Context, externalID string) error
- func (s MembersService) Touch(ctx context.Context, externalID string) error
- func (s MembersService) TouchBatch(ctx context.Context, ids []string) (int, error)
- func (s MembersService) Upsert(ctx context.Context, externalID string, m *Member) (MemberResult, error)
- func (s MembersService) UpsertBatch(ctx context.Context, members []BatchMember) ([]BatchResult, error)
- type Message
- type MessagesService
- type ModerationService
- type Pair
- type Partner
- type PhotoCheck
- type PhotosService
- func (s PhotosService) Browse(ctx context.Context, viewer, peer, key string) ([]byte, string, error)
- func (s PhotosService) CreateCheck(ctx context.Context, ref, lang, returnURL string, photos []CheckPhoto) (*PhotoCheck, error)
- func (s PhotosService) GetCheck(ctx context.Context, id string) (*PhotoCheck, error)
- type Profile
- type Promotion
- type RPCError
- type SendRequest
- type SuperLike
- type Verification
- type Video
- type WebhooksService
Constants ¶
This section is empty.
Variables ¶
var ErrSignature = errors.New("pereval: invalid webhook signature")
ErrSignature indicates a missing secret or an invalid webhook signature.
Functions ¶
This section is empty.
Types ¶
type Balance ¶
type Balance struct {
Currency string `json:"currency"`
TestOnly bool `json:"test_only"`
Balance int64 `json:"balance"`
}
Balance reports the partner account balance and currency.
type BatchError ¶
BatchError describes a single failed item in a successful batch response.
type BatchMember ¶
BatchMember pairs a local external ID with its profile.
type BatchResult ¶
type BatchResult struct {
ExternalID string `json:"external_id"`
MemberResult
Error *BatchError `json:"error,omitempty"`
}
BatchResult contains either a member result or a per-item error.
type BlockRequest ¶
type BlockRequest struct {
From string `json:"from"`
To string `json:"to"`
Erase bool `json:"erase"`
}
BlockRequest controls whether blocking also erases both users' history.
type BoostState ¶
type BoostState struct {
Until *time.Time `json:"boost_until,omitempty"`
Generation uuid.UUID `json:"generation"`
State string `json:"state"`
StartedAt time.Time `json:"started_at"`
RemainingMS int64 `json:"remaining_ms"`
Placements int64 `json:"api_placements"`
}
BoostState reports the remaining visibility boost and placement count.
type Capabilities ¶
type Capabilities struct {
Mode string `json:"mode"`
CommerceEnabled bool `json:"commerce_enabled"`
CommerceLiveZeroOnly bool `json:"commerce_live_zero_only"`
CommercePilot bool `json:"commerce_pilot"`
ProtocolVersion string `json:"protocol_version"`
ClientMessageID bool `json:"client_message_id"`
Videos bool `json:"videos"`
PhotoChecks bool `json:"photo_checks"`
ProfileModeration bool `json:"profile_moderation"`
}
Capabilities describes the protocol, key mode and features available to this partner.
type CapabilitiesService ¶
type CapabilitiesService struct {
// contains filtered or unexported fields
}
CapabilitiesService discovers the protocol and features available to a partner.
func (CapabilitiesService) Get ¶
func (s CapabilitiesService) Get(ctx context.Context) (*Capabilities, error)
Get rejects missing or unknown modes so callers cannot mistake live data for a sandbox.
type CheckPhoto ¶
CheckPhoto identifies a photo submitted for verification.
type City ¶
type City struct {
Name string `json:"name"`
Country string `json:"country"`
Lat *float64 `json:"lat,omitempty"`
Lon *float64 `json:"lon,omitempty"`
}
City keeps the profile city separate from the optional current coordinates.
type Client ¶
type Client struct {
Config
Members MembersService
Feed FeedService
Likes LikesService
Matches MatchesService
Messages MessagesService
Events EventsService
Webhooks WebhooksService
Photos PhotosService
Moderation ModerationService
Commerce CommerceService
Health HealthService
Languages LanguagesService
MCP MCPService
Capabilities CapabilitiesService
}
Client shares its configuration across services. Construct it with New or NewClient. Do not copy it or change settings while requests are in flight.
type CommerceCatalog ¶
type CommerceCatalog struct {
Currency string `json:"currency"`
TestOnly bool `json:"test_only"`
Items []CommerceProduct `json:"items"`
}
CommerceCatalog lists available products in the account's currency.
type CommerceGrant ¶
type CommerceGrant struct {
ID uuid.UUID `json:"id"`
Capability string `json:"capability"`
Quantity int64 `json:"quantity"`
Used int64 `json:"used"`
ValidFrom time.Time `json:"valid_from"`
ValidUntil *time.Time `json:"valid_until"`
RevokedAt *time.Time `json:"revoked_at"`
}
CommerceGrant records the entitlement and its usage.
type CommerceOrder ¶
type CommerceOrder struct {
CreatedAt time.Time `json:"created_at,omitempty"`
Reference string `json:"external_order_ref,omitempty"`
ID uuid.UUID `json:"id"`
QuoteID uuid.UUID `json:"quote_id"`
Total int64 `json:"total"`
Currency string `json:"currency"`
GrantID uuid.UUID `json:"grant_id"`
ValidFrom time.Time `json:"valid_from"`
ValidUntil *time.Time `json:"valid_until"`
}
CommerceOrder describes a purchase and its resulting grant.
type CommerceProduct ¶
type CommerceProduct struct {
Version int64 `json:"version,omitempty"`
Currency string `json:"currency,omitempty"`
SKU string `json:"sku"`
Capability string `json:"capability"`
Unit string `json:"unit"`
UnitPrice int64 `json:"unit_price"`
MinQuantity int64 `json:"min_quantity"`
MaxQuantity int64 `json:"max_quantity"`
Ready bool `json:"fulfillment_ready"`
}
CommerceProduct describes a service and its quantity limits.
type CommerceQuote ¶
type CommerceQuote struct {
CatalogVersion int64 `json:"catalog_version,omitempty"`
ID uuid.UUID `json:"id"`
MemberID uuid.UUID `json:"member_id"`
SKU string `json:"sku"`
Capability string `json:"capability"`
Unit string `json:"unit"`
Quantity int64 `json:"quantity"`
UnitPrice int64 `json:"unit_price"`
Total int64 `json:"total"`
ExpiresAt time.Time `json:"expires_at"`
Currency string `json:"currency"`
}
CommerceQuote locks pricing for the specified quantity until expiry.
type CommerceService ¶
type CommerceService struct {
// contains filtered or unexported fields
}
CommerceService manages quotes, orders and entitlements.
func (CommerceService) Balance ¶
func (s CommerceService) Balance(ctx context.Context) (Balance, error)
Balance returns the account balance.
func (CommerceService) Boost ¶
func (s CommerceService) Boost(ctx context.Context, member string) (*BoostState, error)
Boost gets the current boost state for a local member.
func (CommerceService) Catalog ¶
func (s CommerceService) Catalog(ctx context.Context) (*CommerceCatalog, error)
Catalog lists services and prices.
func (CommerceService) Grants ¶
func (s CommerceService) Grants(ctx context.Context, member string) ([]CommerceGrant, error)
Grants lists entitlements for a local member.
func (CommerceService) Incognito ¶
Incognito reads the current visibility setting when enabled is nil, or updates it otherwise.
func (CommerceService) Order ¶
func (s CommerceService) Order(ctx context.Context, quoteID uuid.UUID, externalOrderRef string) (*CommerceOrder, error)
Order redeems a quote using the commerce key. Reuse the same external reference on retries.
func (CommerceService) Quote ¶
func (s CommerceService) Quote(ctx context.Context, member string, sku string, quantity int64) (*CommerceQuote, error)
Quote requests a price for a local member and SKU.
func (CommerceService) SetDelivery ¶
func (s CommerceService) SetDelivery(ctx context.Context, format string, enabled bool) (Delivery, error)
SetDelivery sets the delivery format and whether the partner accepts promoted placements.
type Config ¶
type Config struct {
BaseURL string
APIKey string
CommerceKey string
WebhookSecret string
HTTP *http.Client
}
Config holds trusted application settings. Use New for public HTTPS endpoints.
type Consent ¶
type Consent struct {
Network bool `json:"network"`
CrossLanguage bool `json:"cross_language"`
World bool `json:"world"`
GivenAt time.Time `json:"given_at"`
TextVersion string `json:"text_version"`
}
Consent records when and how a member opted into network features.
type Delivery ¶
type Delivery struct {
Format string `json:"format"`
Enabled bool `json:"enabled"`
Version int `json:"version"`
}
Delivery describes how promoted profiles are delivered.
type EndMatchRequest ¶
EndMatchRequest controls whether both sides lose history and when they can meet again.
type Event ¶
type Event struct {
Seq int64 `json:"seq,omitempty"`
ID string `json:"id"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"`
Data json.RawMessage `json:"data"`
}
Event is shared by polling and webhooks. Only polling sets Seq. Decode Data according to Type.
type EventsService ¶
type EventsService struct {
// contains filtered or unexported fields
}
EventsService polls for events by sequence number.
type FeedPage ¶
type FeedPage struct {
RemainingToday int `json:"remaining_today,omitempty"`
Items []Profile `json:"items"`
NextCursor string `json:"next_cursor"`
}
FeedPage contains profiles, the remaining allowance and the next page cursor.
type FeedParams ¶
type FeedParams struct {
AgeMin, AgeMax int
Intent, Language, Gender string
Limit int
Scope string
RadiusKM int
HeightMin, HeightMax int
VerifiedOnly bool
Lat, Lon *float64
City, Country string
Cursor, RequestRef string
}
FeedParams selects nearby or world profiles. Supply both coordinates or neither.
type FeedService ¶
type FeedService struct {
// contains filtered or unexported fields
}
FeedService fetches candidate profiles for a member.
func (FeedService) List ¶
func (s FeedService) List(ctx context.Context, externalID string, f FeedParams) (FeedPage, error)
List returns a page of profiles for a local external ID.
type HealthService ¶
type HealthService struct {
// contains filtered or unexported fields
}
HealthService checks service liveness and readiness.
type IncomingLike ¶
IncomingLike describes a pending like received by a local member.
type LanguagesService ¶
type LanguagesService struct {
// contains filtered or unexported fields
}
LanguagesService lists supported languages.
type LikeRequest ¶
type LikeRequest struct {
From string `json:"from"`
To string `json:"to"`
Super bool `json:"super,omitempty"`
Message string `json:"message,omitempty"`
ActionRef string `json:"-"`
}
LikeRequest sends a like or, with Super set, a superlike with an optional message. Reuse ActionRef only for retries of the same action.
type LikeResult ¶
LikeResult reports whether a like created a match.
type LikesService ¶
type LikesService struct {
// contains filtered or unexported fields
}
LikesService manages reactions and incoming likes.
func (LikesService) Create ¶
func (s LikesService) Create(ctx context.Context, req LikeRequest) (*LikeResult, error)
Create records a like and reports whether a new match was made.
func (LikesService) Dislike ¶
func (s LikesService) Dislike(ctx context.Context, from, to string) error
Dislike skips a profile for the current member.
func (LikesService) DislikeBatch ¶
func (s LikesService) DislikeBatch(ctx context.Context, pairs []Pair) error
DislikeBatch submits multiple skips in a single request.
func (LikesService) List ¶
func (s LikesService) List(ctx context.Context, member string, limit int) ([]IncomingLike, error)
List returns incoming likes awaiting a response.
func (LikesService) UndoDislike ¶
UndoDislike returns a skipped profile to the feed.
type MCPService ¶
type MCPService struct {
// contains filtered or unexported fields
}
MCPService calls JSON-RPC methods.
type Match ¶
type Match struct {
MatchID string `json:"match_id"`
With Profile `json:"with"`
CreatedAt time.Time `json:"created_at"`
Frozen bool `json:"frozen"`
FreezeReason string `json:"freeze_reason,omitempty"`
}
Match describes the other member and whether the conversation is frozen.
type MatchesService ¶
type MatchesService struct {
// contains filtered or unexported fields
}
MatchesService lists matches and manages shared history.
func (MatchesService) ClearHistory ¶
func (s MatchesService) ClearHistory(ctx context.Context, matchID, as string) error
ClearHistory clears history for the specified participant only.
func (MatchesService) End ¶
func (s MatchesService) End(ctx context.Context, req EndMatchRequest) error
End closes a match. Set Erase explicitly to remove both users' history.
type Member ¶
type Member struct {
Videos []Video `json:"videos,omitempty"`
Consent Consent `json:"consent"`
DisplayName string `json:"display_name"`
BirthYear int `json:"birth_year"`
Gender string `json:"gender"`
AgeMin int `json:"age_min"`
AgeMax int `json:"age_max"`
Languages []string `json:"languages"`
City City `json:"city"`
Bio string `json:"bio"`
Photos []string `json:"photos"`
PhotoVerified bool `json:"photo_verified"`
Intents []string `json:"intents"`
ArrangementRole string `json:"arrangement_role,omitempty"`
LastActiveAt *time.Time `json:"last_active_at,omitempty"`
HeightCM *int `json:"height_cm,omitempty"`
ShowDistance bool `json:"show_distance,omitempty"`
Verification *Verification `json:"verification,omitempty"`
}
Member is the profile submitted by the member's own platform.
type MemberResult ¶
type MemberResult struct {
NetworkID string `json:"network_id"`
PhotoVerified *bool `json:"photo_verified,omitempty"`
Verification string `json:"verification,omitempty"`
}
MemberResult reports the assigned network ID and photo verification status.
type MembersService ¶
type MembersService struct {
// contains filtered or unexported fields
}
MembersService synchronizes profiles and manages their lifecycle.
func (MembersService) Deactivate ¶
func (s MembersService) Deactivate(ctx context.Context, externalID string) error
Deactivate temporarily hides the member and freezes their matches.
func (MembersService) Reinstate ¶
func (s MembersService) Reinstate(ctx context.Context, externalID string) error
Reinstate restores a member after a moderation decision.
func (MembersService) Remove ¶
func (s MembersService) Remove(ctx context.Context, externalID, reason string) error
Remove removes the member. Use account_deleted or left_network as the reason. An absent member counts as success.
func (MembersService) Restore ¶
func (s MembersService) Restore(ctx context.Context, externalID string) error
Restore reactivates a previously deactivated account.
func (MembersService) Touch ¶
func (s MembersService) Touch(ctx context.Context, externalID string) error
Touch records recent activity for one member.
func (MembersService) TouchBatch ¶
TouchBatch records activity and returns the number of updated members.
func (MembersService) Upsert ¶
func (s MembersService) Upsert(ctx context.Context, externalID string, m *Member) (MemberResult, error)
Upsert creates or updates a profile by its ID on the calling platform.
func (MembersService) UpsertBatch ¶
func (s MembersService) UpsertBatch(ctx context.Context, members []BatchMember) ([]BatchResult, error)
UpsertBatch submits multiple profiles. Inspect each result for an item-specific error.
type Message ¶
type Message struct {
ReadAt *time.Time `json:"read_at,omitempty"`
Flags []string `json:"flags,omitempty"`
Suspicious bool `json:"suspicious,omitempty"`
From string `json:"from,omitempty"`
ClientMessageID string `json:"client_message_id,omitempty"`
ID string `json:"id"`
Text string `json:"text"`
TextOriginal string `json:"text_original"`
Translated bool `json:"translated"`
Lang string `json:"lang"`
CreatedAt time.Time `json:"created_at"`
}
Message includes the text as shown to the viewer and any available original.
type MessagesService ¶
type MessagesService struct {
// contains filtered or unexported fields
}
MessagesService sends, reads and acknowledges messages.
func (MessagesService) List ¶
func (s MessagesService) List(ctx context.Context, matchID, as, before string, limit int) ([]Message, error)
List returns history for the viewer. Leave before empty to read the newest page.
func (MessagesService) MarkRead ¶
func (s MessagesService) MarkRead(ctx context.Context, matchID, as, upTo string) error
MarkRead acknowledges messages through the specified network message ID.
func (MessagesService) Send ¶
func (s MessagesService) Send(ctx context.Context, req SendRequest) (*Message, error)
Send posts a message to the specified match.
type ModerationService ¶
type ModerationService struct {
// contains filtered or unexported fields
}
ModerationService handles blocks and reports.
func (ModerationService) Block ¶
func (s ModerationService) Block(ctx context.Context, req BlockRequest) error
Block prevents future contact between two members.
type PhotoCheck ¶
type PhotoCheck struct {
CreatedAt time.Time `json:"created_at,omitempty"`
Attempts int `json:"attempts,omitempty"`
ID string `json:"id"`
Ref string `json:"ref"`
URL string `json:"url"`
Status string `json:"status"`
Reason string `json:"reason"`
ExpiresAt time.Time `json:"expires_at"`
CheckedAt *time.Time `json:"checked_at"`
DisputeUntil *time.Time `json:"dispute_until"`
DisputedAt *time.Time `json:"disputed_at"`
DecidedAt *time.Time `json:"decided_at"`
Note string `json:"note"`
Photos []struct {
URL string `json:"url"`
ID string `json:"id"`
Verdict string `json:"verdict"`
} `json:"photos"`
}
PhotoCheck describes a verification session and its per-photo verdicts.
type PhotosService ¶
type PhotosService struct {
// contains filtered or unexported fields
}
PhotosService retrieves photos and manages verification checks.
func (PhotosService) Browse ¶
func (s PhotosService) Browse(ctx context.Context, viewer, peer, key string) ([]byte, string, error)
Browse downloads an authenticated profile image and returns its MIME type.
func (PhotosService) CreateCheck ¶
func (s PhotosService) CreateCheck(ctx context.Context, ref, lang, returnURL string, photos []CheckPhoto) (*PhotoCheck, error)
CreateCheck starts a verification session and returns a URL for the member.
func (PhotosService) GetCheck ¶
func (s PhotosService) GetCheck(ctx context.Context, id string) (*PhotoCheck, error)
GetCheck retrieves a verification session by network check ID.
type Profile ¶
type Profile struct {
VerifiedBy string `json:"verified_by,omitempty"`
Promotion *Promotion `json:"promotion,omitempty"`
NetworkID string `json:"network_id"`
Partner Partner `json:"partner"`
DisplayName string `json:"display_name"`
Age int `json:"age"`
Gender string `json:"gender"`
City string `json:"city"`
Country string `json:"country,omitempty"`
DistanceKM *int `json:"distance_km,omitempty"`
Languages []string `json:"languages"`
Bio string `json:"bio"`
BioOriginal string `json:"bio_original,omitempty"`
BioTranslated bool `json:"bio_translated"`
Photos []string `json:"photos"`
Videos []Video `json:"videos,omitempty"`
PhotoVerified bool `json:"photo_verified"`
Intents []string `json:"intents"`
ArrangementRole string `json:"arrangement_role,omitempty"`
HeightCM *int `json:"height_cm,omitempty"`
SuperLike *SuperLike `json:"super_like,omitempty"`
}
Profile is a network profile as seen by the requesting member.
type RPCError ¶
RPCError reports a JSON-RPC failure. Tool errors appear in the result's isError field.
type SendRequest ¶
type SendRequest struct {
MatchID string `json:"-"`
From string `json:"from"`
Text string `json:"text"`
ClientMessageID string `json:"client_message_id,omitempty"`
}
SendRequest identifies a message. Keep ClientMessageID stable across retries.
type SuperLike ¶
type SuperLike struct {
Lang string `json:"lang,omitempty"`
Message string `json:"message,omitempty"`
MessageOriginal string `json:"message_original,omitempty"`
Translated bool `json:"translated"`
Flags []string `json:"flags,omitempty"`
}
SuperLike includes the sender's message and any available translation.
type Verification ¶
type Verification struct {
Method string `json:"method,omitempty"`
Provider string `json:"provider,omitempty"`
VerifiedAt *time.Time `json:"verified_at,omitempty"`
CheckID string `json:"check_id,omitempty"`
}
Verification identifies a partner verification method or a completed Pereval photo check.
type WebhooksService ¶
type WebhooksService struct {
// contains filtered or unexported fields
}
WebhooksService authenticates and decodes incoming events.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
internal/demo
Package demo supplies offline responses for the examples.
|
Package demo supplies offline responses for the examples. |
|
messaging
command
Command messaging sends a greeting when a like creates a match.
|
Command messaging sends a greeting when a like creates a match. |
|
polling
command
Command polling drains a finite stream of example events.
|
Command polling drains a finite stream of example events. |
|
quickstart
command
Command quickstart reads the partner's protocol version and key mode.
|
Command quickstart reads the partner's protocol version and key mode. |
|
webhook
command
Command webhook verifies a signed example event without opening a port.
|
Command webhook verifies a signed example event without opening a port. |