client

package
v7.6.127 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2024 License: GPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Provider_name = map[int32]string{
		0: "PROVIDER_UNSET",
		1: "STRIPE",
		2: "FREEKASSA",
	}
	Provider_value = map[string]int32{
		"PROVIDER_UNSET": 0,
		"STRIPE":         1,
		"FREEKASSA":      2,
	}
)

Enum value maps for Provider.

View Source
var (
	ErrAPIUnavailable = errors.New("API unavailable.")
)
View Source
var File_pro_client_api_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Auth

type Auth struct {
	ID    int64  `json:"userId"`
	Token string `json:"token"`
}

type BaseResponse

type BaseResponse struct {
	Status  string `json:"status"`
	Error   string `json:"error"`
	ErrorId string `json:"errorId"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client, preparePro func(r *http.Request, uc common.UserConfig)) *Client

NewClient creates a new pro client.

func (*Client) DeviceRemove added in v7.6.71

func (c *Client) DeviceRemove(user common.UserConfig, deviceID string) (*LinkResponse, error)

DeviceRemove removes the device with the given ID from a user's Pro account

func (*Client) EmailExists added in v7.6.60

func (c *Client) EmailExists(user common.UserConfig, emailAddress string) error

EmailExists checks whether a Pro account exists with the given email address

func (*Client) LinkCodeApprove added in v7.6.71

func (c *Client) LinkCodeApprove(user common.UserConfig, code string) (*BaseResponse, error)

LinkCodeApprove approves a device linking code when requesting to use a device with a Pro account

func (*Client) MigrateDeviceID

func (c *Client) MigrateDeviceID(user common.UserConfig, oldDeviceID string) error

MigrateDeviceID migrates from the old device ID scheme to the new

func (*Client) PaymentMethodsV3 added in v7.6.72

func (c *Client) PaymentMethodsV3(user common.UserConfig) (*paymentMethodsResponse, error)

PaymentMethodsV3 returns a list of payment options available to the given user

func (*Client) PaymentMethodsV4 added in v7.6.72

func (c *Client) PaymentMethodsV4(user common.UserConfig) (*paymentMethodsResponse, error)

PaymentMethodsV3 returns a list of payment, plans and icons options available to the given user

func (*Client) Plans added in v7.6.34

func (c *Client) Plans(user common.UserConfig) (*plansResponse, error)

Plans returns a list of Pro plans

func (*Client) RecoverProAccount

func (c *Client) RecoverProAccount(user common.UserConfig, emailAddress string) (*LinkResponse, error)

RecoverProAccount attempts to recover an existing Pro account linked to this email address and device ID

func (*Client) RedeemResellerCode

func (c *Client) RedeemResellerCode(user common.UserConfig, emailAddress, resellerCode, deviceName, currency string) (*BaseResponse, error)

RedeemResellerCode redeems a reseller code for the given user

Note: In reality, the response for this route from pro-server is not BaseResponse but of this type https://github.com/getlantern/pro-server-neu/blob/34bcdc042e983bf9504014aa066bba6bdedcebdb/handlers/purchase.go#L201. That being said, we don't really care about the response from pro-server here. We just wanna know if it succeeded or failed, which is encapsulated in the fields of BaseResponse.

func (*Client) RequestDeviceLinkingCode

func (c *Client) RequestDeviceLinkingCode(user common.UserConfig, deviceName string) (*LinkCodeResponse, error)

RequestDeviceLinkingCode requests a new device linking code to allow linking the current device to a pro account via an existing pro device.

func (*Client) RequestRecoveryEmail

func (c *Client) RequestRecoveryEmail(user common.UserConfig, deviceName, emailAddress string) (err error)

RequestRecoveryEmail requests an account recovery email for linking to an existing pro account

func (*Client) UserCreate

func (c *Client) UserCreate(user common.UserConfig) (res *UserDataResponse, err error)

UserCreate creates an user without asking for any payment.

func (*Client) UserData

func (c *Client) UserData(user common.UserConfig) (*UserDataResponse, error)

UserData Returns all user data, including payments, referrals and all available fields.

func (*Client) ValidateDeviceLinkingCode

func (c *Client) ValidateDeviceLinkingCode(user common.UserConfig, deviceName, code string) (*LinkResponse, error)

ValidateDeviceLinkingCode validates a device linking code to allow linking the current device to a pro account via an existing pro device.

func (*Client) ValidateRecoveryCode

func (c *Client) ValidateRecoveryCode(user common.UserConfig, code string) (*LinkResponse, error)

ValidateRecoveryCode validates the given recovery code and finishes linking the device, returning the user_id and pro_token for the account.

type Device

type Device struct {
	Id      string `json:"id"`
	Name    string `json:"name"`
	Created int64  `json:"created"`
}

type LinkCodeResponse

type LinkCodeResponse struct {
	BaseResponse
	Code     string
	ExpireAt int64
}

type LinkResponse

type LinkResponse struct {
	BaseResponse
	UserID   int    `json:"userID"`
	ProToken string `json:"token"`
}

type PaymentMethodsResponse added in v7.6.34

type PaymentMethodsResponse struct {
	Providers map[string]*structpb.ListValue `` /* 159-byte string literal not displayed */
	Icons     map[string]*structpb.ListValue `` /* 151-byte string literal not displayed */
	Plans     []*ProPlan                     `protobuf:"bytes,3,rep,name=plans,proto3" json:"plans,omitempty"`
	// contains filtered or unexported fields
}

func (*PaymentMethodsResponse) Descriptor deprecated added in v7.6.34

func (*PaymentMethodsResponse) Descriptor() ([]byte, []int)

Deprecated: Use PaymentMethodsResponse.ProtoReflect.Descriptor instead.

func (*PaymentMethodsResponse) GetIcons added in v7.6.72

func (x *PaymentMethodsResponse) GetIcons() map[string]*structpb.ListValue

func (*PaymentMethodsResponse) GetPlans added in v7.6.72

func (x *PaymentMethodsResponse) GetPlans() []*ProPlan

func (*PaymentMethodsResponse) GetProviders added in v7.6.34

func (x *PaymentMethodsResponse) GetProviders() map[string]*structpb.ListValue

func (*PaymentMethodsResponse) ProtoMessage added in v7.6.34

func (*PaymentMethodsResponse) ProtoMessage()

func (*PaymentMethodsResponse) ProtoReflect added in v7.6.34

func (x *PaymentMethodsResponse) ProtoReflect() protoreflect.Message

func (*PaymentMethodsResponse) Reset added in v7.6.34

func (x *PaymentMethodsResponse) Reset()

func (*PaymentMethodsResponse) String added in v7.6.34

func (x *PaymentMethodsResponse) String() string

type PlansResponse added in v7.6.34

type PlansResponse struct {
	Plans []*ProPlan `protobuf:"bytes,1,rep,name=plans,proto3" json:"plans,omitempty"`
	// contains filtered or unexported fields
}

func (*PlansResponse) Descriptor deprecated added in v7.6.34

func (*PlansResponse) Descriptor() ([]byte, []int)

Deprecated: Use PlansResponse.ProtoReflect.Descriptor instead.

func (*PlansResponse) GetPlans added in v7.6.34

func (x *PlansResponse) GetPlans() []*ProPlan

func (*PlansResponse) ProtoMessage added in v7.6.34

func (*PlansResponse) ProtoMessage()

func (*PlansResponse) ProtoReflect added in v7.6.34

func (x *PlansResponse) ProtoReflect() protoreflect.Message

func (*PlansResponse) Reset added in v7.6.34

func (x *PlansResponse) Reset()

func (*PlansResponse) String added in v7.6.34

func (x *PlansResponse) String() string

type ProPaymentMethod added in v7.6.44

type ProPaymentMethod struct {
	Method    string                `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
	Providers []*ProPaymentProvider `protobuf:"bytes,2,rep,name=providers,proto3" json:"providers,omitempty"`
	// contains filtered or unexported fields
}

func (*ProPaymentMethod) Descriptor deprecated added in v7.6.44

func (*ProPaymentMethod) Descriptor() ([]byte, []int)

Deprecated: Use ProPaymentMethod.ProtoReflect.Descriptor instead.

func (*ProPaymentMethod) GetMethod added in v7.6.44

func (x *ProPaymentMethod) GetMethod() string

func (*ProPaymentMethod) GetProviders added in v7.6.44

func (x *ProPaymentMethod) GetProviders() []*ProPaymentProvider

func (*ProPaymentMethod) ProtoMessage added in v7.6.44

func (*ProPaymentMethod) ProtoMessage()

func (*ProPaymentMethod) ProtoReflect added in v7.6.44

func (x *ProPaymentMethod) ProtoReflect() protoreflect.Message

func (*ProPaymentMethod) Reset added in v7.6.44

func (x *ProPaymentMethod) Reset()

func (*ProPaymentMethod) String added in v7.6.44

func (x *ProPaymentMethod) String() string

type ProPaymentProvider added in v7.6.44

type ProPaymentProvider struct {
	Name string            `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Data map[string]string `` /* 149-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*ProPaymentProvider) Descriptor deprecated added in v7.6.44

func (*ProPaymentProvider) Descriptor() ([]byte, []int)

Deprecated: Use ProPaymentProvider.ProtoReflect.Descriptor instead.

func (*ProPaymentProvider) GetData added in v7.6.44

func (x *ProPaymentProvider) GetData() map[string]string

func (*ProPaymentProvider) GetName added in v7.6.44

func (x *ProPaymentProvider) GetName() string

func (*ProPaymentProvider) ProtoMessage added in v7.6.44

func (*ProPaymentProvider) ProtoMessage()

func (*ProPaymentProvider) ProtoReflect added in v7.6.44

func (x *ProPaymentProvider) ProtoReflect() protoreflect.Message

func (*ProPaymentProvider) Reset added in v7.6.44

func (x *ProPaymentProvider) Reset()

func (*ProPaymentProvider) String added in v7.6.44

func (x *ProPaymentProvider) String() string

type ProPlan added in v7.6.44

type ProPlan struct {
	Id                     string           `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Description            string           `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	BestValue              bool             `protobuf:"varint,3,opt,name=bestValue,proto3" json:"bestValue,omitempty"`
	UsdPrice               int64            `protobuf:"varint,4,opt,name=usdPrice,proto3" json:"usdPrice,omitempty"`
	Price                  map[string]int64 `` /* 152-byte string literal not displayed */
	ExpectedMonthlyPrice   map[string]int64 `` /* 182-byte string literal not displayed */
	TotalCostBilledOneTime string           `protobuf:"bytes,7,opt,name=totalCostBilledOneTime,proto3" json:"totalCostBilledOneTime,omitempty"`
	OneMonthCost           string           `protobuf:"bytes,8,opt,name=oneMonthCost,proto3" json:"oneMonthCost,omitempty"`
	TotalCost              string           `protobuf:"bytes,9,opt,name=totalCost,proto3" json:"totalCost,omitempty"`
	FormattedBonus         string           `protobuf:"bytes,10,opt,name=formattedBonus,proto3" json:"formattedBonus,omitempty"`
	RenewalText            string           `protobuf:"bytes,11,opt,name=renewalText,proto3" json:"renewalText,omitempty"`
	// contains filtered or unexported fields
}

func (*ProPlan) Descriptor deprecated added in v7.6.44

func (*ProPlan) Descriptor() ([]byte, []int)

Deprecated: Use ProPlan.ProtoReflect.Descriptor instead.

func (*ProPlan) GetBestValue added in v7.6.44

func (x *ProPlan) GetBestValue() bool

func (*ProPlan) GetDescription added in v7.6.44

func (x *ProPlan) GetDescription() string

func (*ProPlan) GetExpectedMonthlyPrice added in v7.6.44

func (x *ProPlan) GetExpectedMonthlyPrice() map[string]int64

func (*ProPlan) GetFormattedBonus added in v7.6.44

func (x *ProPlan) GetFormattedBonus() string

func (*ProPlan) GetId added in v7.6.44

func (x *ProPlan) GetId() string

func (*ProPlan) GetOneMonthCost added in v7.6.44

func (x *ProPlan) GetOneMonthCost() string

func (*ProPlan) GetPrice added in v7.6.44

func (x *ProPlan) GetPrice() map[string]int64

func (*ProPlan) GetRenewalText added in v7.6.44

func (x *ProPlan) GetRenewalText() string

func (*ProPlan) GetTotalCost added in v7.6.44

func (x *ProPlan) GetTotalCost() string

func (*ProPlan) GetTotalCostBilledOneTime added in v7.6.44

func (x *ProPlan) GetTotalCostBilledOneTime() string

func (*ProPlan) GetUsdPrice added in v7.6.44

func (x *ProPlan) GetUsdPrice() int64

func (*ProPlan) ProtoMessage added in v7.6.44

func (*ProPlan) ProtoMessage()

func (*ProPlan) ProtoReflect added in v7.6.44

func (x *ProPlan) ProtoReflect() protoreflect.Message

func (*ProPlan) Reset added in v7.6.44

func (x *ProPlan) Reset()

func (*ProPlan) String added in v7.6.44

func (x *ProPlan) String() string

type Provider added in v7.6.34

type Provider int32
const (
	Provider_PROVIDER_UNSET Provider = 0
	Provider_STRIPE         Provider = 1
	Provider_FREEKASSA      Provider = 2
)

func (Provider) Descriptor added in v7.6.34

func (Provider) Descriptor() protoreflect.EnumDescriptor

func (Provider) Enum added in v7.6.34

func (x Provider) Enum() *Provider

func (Provider) EnumDescriptor deprecated added in v7.6.34

func (Provider) EnumDescriptor() ([]byte, []int)

Deprecated: Use Provider.Descriptor instead.

func (Provider) Number added in v7.6.34

func (x Provider) Number() protoreflect.EnumNumber

func (Provider) String added in v7.6.34

func (x Provider) String() string

func (Provider) Type added in v7.6.34

type PurchaseRequest added in v7.6.34

type PurchaseRequest struct {
	Provider        Provider `protobuf:"varint,1,opt,name=provider,proto3,enum=Provider" json:"provider,omitempty"`
	Email           string   `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
	Plan            string   `protobuf:"bytes,3,opt,name=plan,proto3" json:"plan,omitempty"`
	CardNumber      string   `protobuf:"bytes,4,opt,name=cardNumber,proto3" json:"cardNumber,omitempty"`
	ExpDate         string   `protobuf:"bytes,5,opt,name=expDate,proto3" json:"expDate,omitempty"`
	Cvc             string   `protobuf:"bytes,6,opt,name=cvc,proto3" json:"cvc,omitempty"`
	Currency        string   `protobuf:"bytes,7,opt,name=currency,proto3" json:"currency,omitempty"`
	DeviceName      string   `protobuf:"bytes,8,opt,name=deviceName,proto3" json:"deviceName,omitempty"`
	StripePublicKey string   `protobuf:"bytes,9,opt,name=stripePublicKey,proto3" json:"stripePublicKey,omitempty"`
	StripeEmail     string   `protobuf:"bytes,10,opt,name=stripeEmail,proto3" json:"stripeEmail,omitempty"`
	StripeToken     string   `protobuf:"bytes,11,opt,name=stripeToken,proto3" json:"stripeToken,omitempty"`
	Token           string   `protobuf:"bytes,12,opt,name=token,proto3" json:"token,omitempty"`
	ResellerCode    string   `protobuf:"bytes,13,opt,name=resellerCode,proto3" json:"resellerCode,omitempty"`
	// contains filtered or unexported fields
}

func (*PurchaseRequest) Descriptor deprecated added in v7.6.34

func (*PurchaseRequest) Descriptor() ([]byte, []int)

Deprecated: Use PurchaseRequest.ProtoReflect.Descriptor instead.

func (*PurchaseRequest) GetCardNumber added in v7.6.34

func (x *PurchaseRequest) GetCardNumber() string

func (*PurchaseRequest) GetCurrency added in v7.6.34

func (x *PurchaseRequest) GetCurrency() string

func (*PurchaseRequest) GetCvc added in v7.6.34

func (x *PurchaseRequest) GetCvc() string

func (*PurchaseRequest) GetDeviceName added in v7.6.34

func (x *PurchaseRequest) GetDeviceName() string

func (*PurchaseRequest) GetEmail added in v7.6.34

func (x *PurchaseRequest) GetEmail() string

func (*PurchaseRequest) GetExpDate added in v7.6.34

func (x *PurchaseRequest) GetExpDate() string

func (*PurchaseRequest) GetPlan added in v7.6.34

func (x *PurchaseRequest) GetPlan() string

func (*PurchaseRequest) GetProvider added in v7.6.34

func (x *PurchaseRequest) GetProvider() Provider

func (*PurchaseRequest) GetResellerCode added in v7.6.34

func (x *PurchaseRequest) GetResellerCode() string

func (*PurchaseRequest) GetStripeEmail added in v7.6.34

func (x *PurchaseRequest) GetStripeEmail() string

func (*PurchaseRequest) GetStripePublicKey added in v7.6.34

func (x *PurchaseRequest) GetStripePublicKey() string

func (*PurchaseRequest) GetStripeToken added in v7.6.34

func (x *PurchaseRequest) GetStripeToken() string

func (*PurchaseRequest) GetToken added in v7.6.34

func (x *PurchaseRequest) GetToken() string

func (*PurchaseRequest) ProtoMessage added in v7.6.34

func (*PurchaseRequest) ProtoMessage()

func (*PurchaseRequest) ProtoReflect added in v7.6.34

func (x *PurchaseRequest) ProtoReflect() protoreflect.Message

func (*PurchaseRequest) Reset added in v7.6.34

func (x *PurchaseRequest) Reset()

func (*PurchaseRequest) String added in v7.6.34

func (x *PurchaseRequest) String() string

type PurchaseResponse added in v7.6.34

type PurchaseResponse struct {
	Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	// contains filtered or unexported fields
}

func (*PurchaseResponse) Descriptor deprecated added in v7.6.34

func (*PurchaseResponse) Descriptor() ([]byte, []int)

Deprecated: Use PurchaseResponse.ProtoReflect.Descriptor instead.

func (*PurchaseResponse) GetSuccess added in v7.6.34

func (x *PurchaseResponse) GetSuccess() bool

func (*PurchaseResponse) ProtoMessage added in v7.6.34

func (*PurchaseResponse) ProtoMessage()

func (*PurchaseResponse) ProtoReflect added in v7.6.34

func (x *PurchaseResponse) ProtoReflect() protoreflect.Message

func (*PurchaseResponse) Reset added in v7.6.34

func (x *PurchaseResponse) Reset()

func (*PurchaseResponse) String added in v7.6.34

func (x *PurchaseResponse) String() string

type User

type User struct {
	Auth         `json:",inline"`
	Email        string   `json:"email"`
	PhoneNumber  string   `json:"telephone"`
	UserStatus   string   `json:"userStatus"`
	Locale       string   `json:"locale"`
	Expiration   int64    `json:"expiration"`
	Devices      []Device `json:"devices"`
	Code         string   `json:"code"`
	ExpireAt     int64    `json:"expireAt"`
	Referral     string   `json:"referral"`
	YinbiEnabled bool     `json:"yinbiEnabled"`
}

type UserDataResponse

type UserDataResponse struct {
	BaseResponse
	User `json:",inline"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL