client

package
v7.5.23 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

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

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) MigrateDeviceID

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

MigrateDeviceID migrates from the old device ID scheme to the new

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 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