Documentation
¶
Index ¶
- type AttributionData
- type Client
- func (c *Client) AddUserAttribution(ctx context.Context, userID string, network Network, data AttributionData) error
- func (c *Client) CreatePurchase(ctx context.Context, userID string, receipt string, opt *CreatePurchaseOptions) (Subscriber, error)
- func (c *Client) DeferGoogleSubscription(ctx context.Context, userID string, id string, nextExpiry time.Time) (Subscriber, error)
- func (c *Client) DeleteOfferingOverride(ctx context.Context, userID string) (Subscriber, error)
- func (c *Client) DeleteSubscriber(ctx context.Context, userID string) error
- func (c *Client) GetSubscriber(ctx context.Context, userID string) (Subscriber, error)
- func (c *Client) GetSubscriberWithPlatform(ctx context.Context, userID string, platform string) (Subscriber, error)
- func (c *Client) GrantEntitlement(ctx context.Context, userID string, id string, duration Duration, ...) (Subscriber, error)
- func (c *Client) OverrideOffering(ctx context.Context, userID string, offeringUUID string) (Subscriber, error)
- func (c *Client) RefundGoogleSubscription(ctx context.Context, userID string, id string) (Subscriber, error)
- func (c *Client) RevokeEntitlement(ctx context.Context, userID string, id string) (Subscriber, error)
- func (c *Client) UpdateSubscriberAttributes(ctx context.Context, userID string, attributes map[string]SubscriberAttribute) error
- type CreatePurchaseOptions
- type Duration
- type Entitlement
- type Error
- type Network
- type NonSubscription
- type PeriodType
- type Store
- type Subscriber
- type SubscriberAttribute
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributionData ¶
type AttributionData struct { IDFA string `json:"rc_idfa,omitempty"` PlayServicesID string `json:"rc_gps_adid,omitempty"` }
AttributionData holds the identifier value for either the App Store or Play Services.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client makes authorized calls to the RevenueCat API.
func New ¶
New returns a new *Client for the provided API key. For more information on authentication, see https://docs.revenuecat.com/docs/authentication.
func NewWithClient ¶
NewWithClient returns a new *Client for the provided API key and http.Client. For more information on authentication, see https://docs.revenuecat.com/docs/authentication.
func (*Client) AddUserAttribution ¶
func (c *Client) AddUserAttribution(ctx context.Context, userID string, network Network, data AttributionData) error
AddUserAttribution attaches attribution data to a subscriber from specific supported networks. https://docs.revenuecat.com/reference#subscribersattribution
func (*Client) CreatePurchase ¶
func (c *Client) CreatePurchase( ctx context.Context, userID string, receipt string, opt *CreatePurchaseOptions, ) (Subscriber, error)
CreatePurchase records a purchase for a user from iOS, Android, or Stripe and will create a user if they don't already exist. https://docs.revenuecat.com/reference#receipts
func (*Client) DeferGoogleSubscription ¶
func (c *Client) DeferGoogleSubscription( ctx context.Context, userID string, id string, nextExpiry time.Time, ) (Subscriber, error)
DeferGoogleSubscription defers the purchase of a Google Subscription to a later date. https://docs.revenuecat.com/reference#defer-a-google-subscription
func (*Client) DeleteOfferingOverride ¶
DeleteOfferingOverride reset the offering overrides back to the current offering for a specific user. https://docs.revenuecat.com/reference#delete-offering-override
func (*Client) DeleteSubscriber ¶
DeleteSubscriber permanently deletes a subscriber. https://docs.revenuecat.com/reference#subscribersapp_user_id
func (*Client) GetSubscriber ¶
GetSubscriber gets the latest subscriber info or creates one if it doesn't exist. https://docs.revenuecat.com/reference#subscribers
func (*Client) GetSubscriberWithPlatform ¶
func (c *Client) GetSubscriberWithPlatform(ctx context.Context, userID string, platform string) (Subscriber, error)
GetSubscriberWithPlatform gets the latest subscriber info or creates one if it doesn't exist, updating the subscriber record's last_seen value for the platform provided. https://docs.revenuecat.com/reference#subscribers
func (*Client) GrantEntitlement ¶
func (c *Client) GrantEntitlement( ctx context.Context, userID string, id string, duration Duration, startTime time.Time, ) (Subscriber, error)
GrantEntitlement grants a user a promotional entitlement. https://docs.revenuecat.com/reference#grant-a-promotional-entitlement
func (*Client) OverrideOffering ¶
func (c *Client) OverrideOffering(ctx context.Context, userID string, offeringUUID string) (Subscriber, error)
OverrideOffering overrides the current Offering for a specific user. https://docs.revenuecat.com/reference#override-offering
func (*Client) RefundGoogleSubscription ¶
func (c *Client) RefundGoogleSubscription(ctx context.Context, userID string, id string) (Subscriber, error)
RefundGoogleSubscription immediately revokes access to a Google Subscription and issues a refund for the last purchase. https://docs.revenuecat.com/reference#revoke-a-google-subscription
func (*Client) RevokeEntitlement ¶
func (c *Client) RevokeEntitlement(ctx context.Context, userID string, id string) (Subscriber, error)
RevokeEntitlement revokes all promotional entitlements for a given entitlement identifier and app user ID. https://docs.revenuecat.com/reference#revoke-promotional-entitlements
func (*Client) UpdateSubscriberAttributes ¶
func (c *Client) UpdateSubscriberAttributes( ctx context.Context, userID string, attributes map[string]SubscriberAttribute, ) error
UpdateSubscriberAttributes updates subscriber attributes for a user. https://docs.revenuecat.com/reference#update-subscriber-attributes
type CreatePurchaseOptions ¶
type CreatePurchaseOptions struct { Platform string `json:"-"` ProductID string `json:"product_id,omitempty"` Price float32 `json:"price,omitempty"` Currency string `json:"currency,omitempty"` PaymentMode string `json:"payment_mode,omitempty"` IntroductoryPrice float32 `json:"introductory_price,omitempty"` IsRestore bool `json:"is_restore,omitempty"` Attributes map[string]SubscriberAttribute `json:"attributes,omitempty"` }
CreatePurchaseOptions holds the optional values for creating a purchase. https://docs.revenuecat.com/reference#receipts
type Duration ¶
type Duration string
Duration holds a predefined entitlement duration.
type Entitlement ¶
type Entitlement struct { ExpiresDate time.Time `json:"expires_date"` PurchaseDate time.Time `json:"purchase_date"` ProductIdentifier string `json:"product_identifier"` }
https://docs.revenuecat.com/reference#the-entitlement-object
type Network ¶
type Network int
Network represents a predefined attribution channel.
type NonSubscription ¶
type NonSubscription struct { ID string `json:"id"` PurchaseDate time.Time `json:"purchase_date"` Store Store `json:"store"` IsSandbox bool `json:"is_sandbox"` }
https://docs.revenuecat.com/reference#section-the-non-subscription-object
type PeriodType ¶
type PeriodType string
PeriodType holds the predefined values for a subscription period.
const ( NormalPeriodType PeriodType = "normal" TrialPeriodType PeriodType = "trial" IntroPeriodType PeriodType = "intro" )
https://docs.revenuecat.com/reference#the-subscription-object
type Subscriber ¶
type Subscriber struct { OriginalAppUserID string `json:"original_app_user_id"` OriginalApplicationVersion *string `json:"original_application_version"` FirstSeen time.Time `json:"first_seen"` LastSeen time.Time `json:"last_seen"` Entitlements map[string]Entitlement `json:"entitlements"` Subscriptions map[string]Subscription `json:"subscriptions"` NonSubscriptions map[string]NonSubscription `json:"non_subscriptions"` SubscriberAttributes map[string]SubscriberAttribute `json:"subscriber_attributes"` }
Subscriber holds a subscriber returned by the RevenueCat API.
func (Subscriber) IsEntitledTo ¶
func (s Subscriber) IsEntitledTo(entitlement string) bool
IsEntitledTo returns true if the Subscriber has the given entitlement.
type SubscriberAttribute ¶
https://docs.revenuecat.com/reference#section-the-subscriber-attribute-object
func (SubscriberAttribute) MarshalJSON ¶
func (attr SubscriberAttribute) MarshalJSON() ([]byte, error)
func (*SubscriberAttribute) UnmarshalJSON ¶
func (attr *SubscriberAttribute) UnmarshalJSON(data []byte) error
type Subscription ¶
type Subscription struct { ExpiresDate *time.Time `json:"expires_date"` PurchaseDate time.Time `json:"purchase_date"` OriginalPurchaseDate time.Time `json:"original_purchase_date"` PeriodType PeriodType `json:"period_type"` Store Store `json:"store"` IsSandbox bool `json:"is_sandbox"` UnsubscribeDetectedAt *time.Time `json:"unsubscribe_detected_at"` BillingIssuesDetectedAt *time.Time `json:"billing_issues_detected_at"` }
https://docs.revenuecat.com/reference#the-subscription-object