Documentation
¶
Index ¶
- type AttributionData
- type Client
- func (c *Client) AddUserAttribution(userID string, network Network, data AttributionData) error
- func (c *Client) CancelGoogleSubscription(userID string, transactionID string) (Subscriber, error)
- func (c *Client) CreatePurchase(userID string, receipt string, opt *CreatePurchaseOptions) (Subscriber, error)
- func (c *Client) DeferGoogleSubscription(userID string, id string, nextExpiry time.Time) (Subscriber, error)
- func (c *Client) DeferGoogleSubscriptionByDays(userID string, id string, days int) (Subscriber, error)
- func (c *Client) DeleteOfferingOverride(userID string) (Subscriber, error)
- func (c *Client) DeleteSubscriber(userID string) error
- func (c *Client) ExtendAppStoreSubscription(userID string, transactionID string, days int) (Subscriber, error)
- func (c *Client) GetOfferings(userID string) (*Offerings, error)
- func (c *Client) GetSubscriber(userID string) (Subscriber, error)
- func (c *Client) GetSubscriberWithPlatform(userID string, platform string) (Subscriber, error)
- func (c *Client) GrantEntitlement(userID string, id string, duration Duration, startTime time.Time) (Subscriber, error)
- func (c *Client) GrantEntitlementUntil(userID string, id string, endTime time.Time) (Subscriber, error)
- func (c *Client) OverrideOffering(userID string, offeringUUID string) (Subscriber, error)
- func (c *Client) RefundGooglePurchase(userID string, transactionID string) (Subscriber, error)
- func (c *Client) RefundGoogleSubscription(userID string, id string) (Subscriber, error)
- func (c *Client) RevokeEntitlement(userID string, id string) (Subscriber, error)
- func (c *Client) UpdateSubscriberAttributes(userID string, attributes map[string]SubscriberAttribute) error
- type CreatePurchaseOptions
- type Duration
- type Entitlement
- type Error
- type Network
- type NonSubscription
- type Offering
- type Offerings
- type Option
- type OwnershipType
- type Package
- type PackageType
- 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 (*Client) AddUserAttribution ¶
func (c *Client) AddUserAttribution(userID string, network Network, data AttributionData) error
AddUserAttribution attaches attribution data to a subscriber from specific supported networks. https://www.revenuecat.com/docs/api-v1#subscribersattribution
func (*Client) CancelGoogleSubscription ¶ added in v0.11.0
func (c *Client) CancelGoogleSubscription(userID string, transactionID string) (Subscriber, error)
CancelGoogleSubscription cancels a Google subscription without immediately revoking access. https://www.revenuecat.com/docs/api-v1#tag/transactions/operation/cancel-a-google-subscription
func (*Client) CreatePurchase ¶
func (c *Client) CreatePurchase(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://www.revenuecat.com/docs/api-v1#receipts
func (*Client) DeferGoogleSubscription ¶
func (c *Client) DeferGoogleSubscription(userID string, id string, nextExpiry time.Time) (Subscriber, error)
DeferGoogleSubscription defers the purchase of a Google Subscription to a later date. https://www.revenuecat.com/docs/api-v1#defer-a-google-subscription
func (*Client) DeferGoogleSubscriptionByDays ¶ added in v0.11.0
func (c *Client) DeferGoogleSubscriptionByDays(userID string, id string, days int) (Subscriber, error)
DeferGoogleSubscriptionByDays defers a Google Subscription by a number of days. https://www.revenuecat.com/docs/api-v1#tag/transactions/operation/defer-a-google-subscription
func (*Client) DeleteOfferingOverride ¶
func (c *Client) DeleteOfferingOverride(userID string) (Subscriber, error)
DeleteOfferingOverride reset the offering overrides back to the current offering for a specific user. https://www.revenuecat.com/docs/api-v1#delete-offering-override
func (*Client) DeleteSubscriber ¶
DeleteSubscriber permanently deletes a subscriber. https://www.revenuecat.com/docs/api-v1#subscribersapp_user_id
func (*Client) ExtendAppStoreSubscription ¶ added in v0.11.0
func (c *Client) ExtendAppStoreSubscription(userID string, transactionID string, days int) (Subscriber, error)
ExtendAppStoreSubscription extends an App Store subscription renewal date. https://www.revenuecat.com/docs/api-v1#tag/transactions/operation/extend-an-app-store-subscription
func (*Client) GetOfferings ¶
GetOfferings gets the offerings for a specific user. https://www.revenuecat.com/docs/api-v1#get-offerings
func (*Client) GetSubscriber ¶
func (c *Client) GetSubscriber(userID string) (Subscriber, error)
GetSubscriber gets the latest subscriber info or creates one if it doesn't exist. https://www.revenuecat.com/docs/api-v1#subscribers
func (*Client) GetSubscriberWithPlatform ¶
func (c *Client) GetSubscriberWithPlatform(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://www.revenuecat.com/docs/api-v1#subscribers
func (*Client) GrantEntitlement ¶
func (c *Client) GrantEntitlement(userID string, id string, duration Duration, startTime time.Time) (Subscriber, error)
GrantEntitlement grants a user a promotional entitlement. https://www.revenuecat.com/docs/api-v1#grant-a-promotional-entitlement
func (*Client) GrantEntitlementUntil ¶ added in v0.11.0
func (c *Client) GrantEntitlementUntil(userID string, id string, endTime time.Time) (Subscriber, error)
GrantEntitlementUntil grants a user a promotional entitlement until a specific expiration time. https://www.revenuecat.com/docs/api-v1#tag/entitlements/operation/grant-a-promotional-entitlement
func (*Client) OverrideOffering ¶
func (c *Client) OverrideOffering(userID string, offeringUUID string) (Subscriber, error)
OverrideOffering overrides the current Offering for a specific user. https://www.revenuecat.com/docs/api-v1#override-offering
func (*Client) RefundGooglePurchase ¶ added in v0.11.0
func (c *Client) RefundGooglePurchase(userID string, transactionID string) (Subscriber, error)
RefundGooglePurchase issues a refund for a Google transaction and revokes access. https://www.revenuecat.com/docs/api-v1#tag/transactions/operation/refund-a-google-purchase
func (*Client) RefundGoogleSubscription ¶
func (c *Client) RefundGoogleSubscription(userID string, id string) (Subscriber, error)
RefundGoogleSubscription immediately revokes access to a Google Subscription and issues a refund for the last purchase. https://www.revenuecat.com/docs/api-v1#revoke-a-google-subscription
func (*Client) RevokeEntitlement ¶
func (c *Client) RevokeEntitlement(userID string, id string) (Subscriber, error)
RevokeEntitlement revokes all promotional entitlements for a given entitlement identifier and app user ID. https://www.revenuecat.com/docs/api-v1#revoke-promotional-entitlements
func (*Client) UpdateSubscriberAttributes ¶
func (c *Client) UpdateSubscriberAttributes(userID string, attributes map[string]SubscriberAttribute) error
UpdateSubscriberAttributes updates subscriber attributes for a user. https://www.revenuecat.com/docs/api-v1#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"`
PresentedOfferingIdentifier string `json:"presented_offering_identifier,omitempty"`
Attributes map[string]SubscriberAttribute `json:"attributes,omitempty"`
}
CreatePurchaseOptions holds the optional values for creating a purchase. https://www.revenuecat.com/docs/api-v1#receipts
type Duration ¶
type Duration string
Duration holds a predefined entitlement duration.
type Entitlement ¶
type Entitlement struct {
ExpiresDate *time.Time `json:"expires_date"`
GracePeriodExpiresDate *time.Time `json:"grace_period_expires_date"`
PurchaseDate time.Time `json:"purchase_date"`
ProductIdentifier string `json:"product_identifier"`
ProductPlanIdentifier string `json:"product_plan_identifier"`
}
https://www.revenuecat.com/docs/api-v1#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://www.revenuecat.com/docs/api-v1#section-the-non-subscription-object
type Offering ¶
type Offering struct {
Description string `json:"description"`
Identifier string `json:"identifier"`
Packages []Package `json:"packages"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Offering holds an offering.
type Option ¶
type Option func(*Client)
func WithHTTPClient ¶
func WithHTTPClient(client doer) Option
WithHTTPClient - Option to set the HTTP client
func WithSandboxEnabled ¶
WithSandboxEnabled - Option to enable or disable sandbox mode
type OwnershipType ¶
type OwnershipType string
OwnershipType holds the predefined values for a subscription ownership type.
const ( PurchasedOwnershipType OwnershipType = "PURCHASED" )
type Package ¶
type Package struct {
Identifier string `json:"identifier"`
PlatformProductIdentifier string `json:"platform_product_identifier"`
PackageType PackageType `json:"package_type"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Package holds a package.
type PackageType ¶
type PackageType string
PackageType holds the predefined values for a package type.
const ( UnknownPackageType PackageType = "UNKNOWN" CustomPackageType PackageType = "CUSTOM" LifetimePackageType PackageType = "LIFETIME" AnnualPackageType PackageType = "ANNUAL" SixMonthPackageType PackageType = "SIX_MONTH" ThreeMonthPackageType PackageType = "THREE_MONTH" TwoMonthPackageType PackageType = "TWO_MONTH" MonthlyPackageType PackageType = "MONTHLY" WeeklyPackageType PackageType = "WEEKLY" )
https://docs.revenuecat.com/docs/displaying-products#package-types
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://www.revenuecat.com/docs/api-v1#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"`
ManagementURL *string `json:"management_url"`
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) ActiveSubscriptions ¶
func (s Subscriber) ActiveSubscriptions() []string
ActiveSubscriptions returns the identifiers of all active subscriptions.
func (Subscriber) AllPurchasedProductIdentifiers ¶
func (s Subscriber) AllPurchasedProductIdentifiers() []string
AllPurchasedProductIdentifiers returns the identifiers of all products ever purchased.
func (Subscriber) IsEntitledTo ¶
func (s Subscriber) IsEntitledTo(entitlement string) bool
IsEntitledTo returns true if the Subscriber has the given entitlement.
type SubscriberAttribute ¶
https://www.revenuecat.com/docs/api-v1#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"`
AutoResumeDate *time.Time `json:"auto_resume_date"`
GracePeriodExpiresDate *time.Time `json:"grace_period_expires_date"`
RefundedAt *time.Time `json:"refunded_at"`
OwnershipType OwnershipType `json:"ownership_type"`
StoreTransactionID string `json:"store_transaction_id"`
ProductPlanIdentifier string `json:"product_plan_identifier"`
}
https://www.revenuecat.com/docs/api-v1#the-subscription-object