Documentation
¶
Index ¶
- Constants
- Variables
- type APIClient
- func (ac *APIClient) ActivationCode(ctx context.Context, email, resellerCode string) (*PurchaseResponse, error)
- func (a *APIClient) CompleteChangeEmail(ctx context.Context, newEmail, password, code string) error
- func (a *APIClient) CompleteRecoveryByEmail(ctx context.Context, email, newPassword, code string) error
- func (a *APIClient) DataCapInfo(ctx context.Context) (*DataCapInfo, error)
- func (a *APIClient) DeleteAccount(ctx context.Context, email, password string) error
- func (a *APIClient) Devices() ([]Device, error)
- func (a *APIClient) Login(ctx context.Context, email string, password string, deviceId string) (*protos.LoginResponse, error)
- func (a *APIClient) Logout(ctx context.Context, email string) error
- func (ac *APIClient) NewStripeSubscription(ctx context.Context, email, planID string) (*SubscriptionResponse, error)
- func (ac *APIClient) NewUser(ctx context.Context) (*UserDataResponse, error)
- func (a *APIClient) OAuthLoginUrl(ctx context.Context, provider string) (string, error)
- func (ac *APIClient) PaymentRedirect(ctx context.Context, data PaymentRedirectData) (string, error)
- func (a *APIClient) ReferralAttach(ctx context.Context, code string) (bool, error)
- func (a *APIClient) RemoveDevice(ctx context.Context, deviceID string) (*LinkResponse, error)
- func (a *APIClient) SignUp(ctx context.Context, email, password string) error
- func (a *APIClient) SignupEmailConfirmation(ctx context.Context, email, code string) error
- func (a *APIClient) SignupEmailResendCode(ctx context.Context, email string) error
- func (a *APIClient) StartChangeEmail(ctx context.Context, newEmail string, password string) error
- func (a *APIClient) StartRecoveryByEmail(ctx context.Context, email string) error
- func (ac *APIClient) StripeBillingPortalUrl(ctx context.Context) (string, error)
- func (ac *APIClient) SubscriptionPaymentRedirectURL(ctx context.Context, data PaymentRedirectData) (string, error)
- func (ac *APIClient) SubscriptionPlans(ctx context.Context, channel string) (*SubscriptionPlans, error)
- func (ac *APIClient) UserData(ctx context.Context) (*UserDataResponse, error)
- func (a *APIClient) ValidateEmailRecoveryCode(ctx context.Context, email, code string) error
- func (ac *APIClient) VerifySubscription(ctx context.Context, service SubscriptionService, data map[string]string) (status, subID string, err error)
- type AuthClient
- type DataCapInfo
- type Device
- type LinkResponse
- type PaymentRedirectData
- type PurchaseResponse
- type SubscriptionPlans
- type SubscriptionResponse
- type SubscriptionService
- type SubscriptionType
- type Tier
- type UserDataResponse
Constants ¶
const ( StripeService SubscriptionService = "stripe" AppleService SubscriptionService = "apple" GoogleService SubscriptionService = "google" SubscriptionTypeOneTime SubscriptionType = "one_time" SubscriptionTypeSubscription SubscriptionType = "subscription" )
const ( TierFree = 0 TierPro = 1 )
Variables ¶
var ErrInvalidCode = errors.New("invalid code")
var ErrNoSalt = errors.New("not salt available, call GetSalt/Signup first")
var ErrNotLoggedIn = errors.New("not logged in")
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
func NewAPIClient ¶
func (*APIClient) ActivationCode ¶
func (ac *APIClient) ActivationCode(ctx context.Context, email, resellerCode string) (*PurchaseResponse, error)
ActivationCode is used to purchase a subscription using a reseller code.
func (*APIClient) CompleteChangeEmail ¶
CompleteChangeEmail completes a change of the email address associated with this user account, using the code recieved via email.
func (*APIClient) CompleteRecoveryByEmail ¶
func (a *APIClient) CompleteRecoveryByEmail(ctx context.Context, email, newPassword, code string) error
CompleteRecoveryByEmail completes account recovery using the code received via email.
func (*APIClient) DataCapInfo ¶
func (a *APIClient) DataCapInfo(ctx context.Context) (*DataCapInfo, error)
DataCapInfo returns information about this user's data cap
func (*APIClient) DeleteAccount ¶
DeleteAccount deletes this user account.
func (*APIClient) Login ¶
func (a *APIClient) Login(ctx context.Context, email string, password string, deviceId string) (*protos.LoginResponse, error)
Login logs the user in.
func (*APIClient) NewStripeSubscription ¶
func (ac *APIClient) NewStripeSubscription(ctx context.Context, email, planID string) (*SubscriptionResponse, error)
NewStripeSubscription creates a new Stripe subscription for the given email and plan ID.
func (*APIClient) NewUser ¶
func (ac *APIClient) NewUser(ctx context.Context) (*UserDataResponse, error)
NewUser creates a new user account
func (*APIClient) OAuthLoginUrl ¶
OAuthLoginUrl initiates the OAuth login process for the specified provider.
func (*APIClient) PaymentRedirect ¶
PaymentRedirect is used to get the payment redirect URL with PaymentRedirectData this is used in desktop app and android app
func (*APIClient) ReferralAttach ¶
func (*APIClient) RemoveDevice ¶
RemoveDevice removes a device from the user's account.
func (*APIClient) SignupEmailConfirmation ¶
SignupEmailConfirmation confirms the new account using the sign-up code received via email.
func (*APIClient) SignupEmailResendCode ¶
SignupEmailResendCode requests that the sign-up code be resent via email.
func (*APIClient) StartChangeEmail ¶
StartChangeEmail initializes a change of the email address associated with this user account.
func (*APIClient) StartRecoveryByEmail ¶
StartRecoveryByEmail initializes the account recovery process for the provided email.
func (*APIClient) StripeBillingPortalUrl ¶
StripeBillingPortalUrl generates the Stripe billing portal URL for the given user ID.
func (*APIClient) SubscriptionPaymentRedirectURL ¶
func (ac *APIClient) SubscriptionPaymentRedirectURL(ctx context.Context, data PaymentRedirectData) (string, error)
SubscriptionPaymentRedirectURL generates a redirect URL for subscription payment.
func (*APIClient) SubscriptionPlans ¶
func (ac *APIClient) SubscriptionPlans(ctx context.Context, channel string) (*SubscriptionPlans, error)
SubscriptionPlans retrieves available subscription plans for a given channel.
func (*APIClient) UserData ¶
func (ac *APIClient) UserData(ctx context.Context) (*UserDataResponse, error)
UserData returns the user data
func (*APIClient) ValidateEmailRecoveryCode ¶
ValidateEmailRecoveryCode validates the recovery code received via email.
func (*APIClient) VerifySubscription ¶
func (ac *APIClient) VerifySubscription(ctx context.Context, service SubscriptionService, data map[string]string) (status, subID string, err error)
VerifySubscription verifies a subscription for a given service (Google or Apple). data should contain the information required by service to verify the subscription, such as the purchase token for Google Play or the receipt for Apple. The status and subscription ID are returned along with any error that occurred during the verification process.
type AuthClient ¶
type AuthClient interface {
// Sign up methods
SignUp(ctx context.Context, email string, password string) ([]byte, error)
SignupEmailResendCode(ctx context.Context, data *protos.SignupEmailResendRequest) error
SignupEmailConfirmation(ctx context.Context, data *protos.ConfirmSignupRequest) error
// Login methods
GetSalt(ctx context.Context, email string) (*protos.GetSaltResponse, error)
LoginPrepare(ctx context.Context, loginData *protos.PrepareRequest) (*protos.PrepareResponse, error)
Login(ctx context.Context, email, password, deviceID string, salt []byte) (*protos.LoginResponse, error)
// Recovery methods
StartRecoveryByEmail(ctx context.Context, loginData *protos.StartRecoveryByEmailRequest) error
CompleteRecoveryByEmail(ctx context.Context, loginData *protos.CompleteRecoveryByEmailRequest) error
ValidateEmailRecoveryCode(ctx context.Context, loginData *protos.ValidateRecoveryCodeRequest) (*protos.ValidateRecoveryCodeResponse, error)
// Change email methods
ChangeEmail(ctx context.Context, loginData *protos.ChangeEmailRequest) error
// Complete change email methods
CompleteChangeEmail(ctx context.Context, loginData *protos.CompleteChangeEmailRequest) error
DeleteAccount(ctc context.Context, loginData *protos.DeleteUserRequest) error
// Logout
SignOut(ctx context.Context, logoutData *protos.LogoutRequest) error
}
type DataCapInfo ¶
type DataCapInfo struct {
BytesAllotted, BytesRemaining int
AllotmentStart, AllotmentEnd time.Time
}
DataCapInfo represents information about the data cap for a user account.
type Device ¶
Device is a machine registered to a user account (e.g. an Android phone or a Windows desktop).
type LinkResponse ¶
type LinkResponse struct {
*protos.BaseResponse `json:",inline"`
UserID int `json:"userID"`
ProToken string `json:"token"`
}
type PaymentRedirectData ¶
type PaymentRedirectData struct {
Plan string `json:"plan" validate:"required"`
Provider string `json:"provider" validate:"required"`
Email string `json:"email"`
DeviceName string `json:"deviceName" validate:"required" errorId:"device-name"`
BillingType SubscriptionType `json:"billingType"`
}
PaymentRedirectData contains the data required to generate a payment redirect URL.
type PurchaseResponse ¶
type SubscriptionPlans ¶
type SubscriptionPlans struct {
*protos.BaseResponse `json:",inline"`
Providers map[string][]*protos.PaymentMethod `json:"providers"`
Plans []*protos.Plan `json:"plans"`
}
SubscriptionPlans contains information about available subscription plans and payment providers.
type SubscriptionResponse ¶
type SubscriptionResponse struct {
CustomerId string `json:"customerId"`
SubscriptionId string `json:"subscriptionId"`
ClientSecret string `json:"clientSecret"`
PublishableKey string `json:"publishableKey"`
}
SubscriptionResponse contains information about a created subscription.
type SubscriptionService ¶
type SubscriptionService string
type SubscriptionType ¶
type SubscriptionType string
type UserDataResponse ¶
type UserDataResponse struct {
*protos.BaseResponse `json:",inline"`
*protos.LoginResponse_UserData `json:",inline"`
}