utils

package
v2.21.7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: CC-BY-4.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Log is a global logger
	// initialized in main.go
	// used to log debug messages and errors
	Log *log.Logger
)

Functions

func CheckLoggedIn

func CheckLoggedIn() bool

CheckLoggedIn function checks if user is logged in

func ContainsString added in v2.20.0

func ContainsString(item string, slice []string) bool

ContainsString checks if item string is present in slice

func FileExists

func FileExists(filename string) bool

FileExists function check if given file exists

func GenerateCurrentTime added in v2.19.0

func GenerateCurrentTime() string

GenerateCurrentTime generates current time in YYYYMMDDTHHMMSS format

func GenerateDate added in v2.19.0

func GenerateDate() string

GenerateDate generates date in YYYYMMDD format

func GetCredentialsPath

func GetCredentialsPath() string

GetCredentialsPath returns the file path to credentials file

func GetLogger

func GetLogger() *log.Logger

GetLogger creates a new logger instance with custom settings

func GetRequestClient

func GetRequestClient() *fasthttp.Client

GetRequestClient create a HTTP client with proxy if given Otherwise create a HTTP client without proxy Returns a fasthttp.Client

func Login

func Login(username, password string) (map[string]string, error)

Login is used to login with username and password

func LoginSendOTP

func LoginSendOTP(number string) (bool, error)

LoginSendOTP sends OTP to the given number for login

func LoginVerifyOTP

func LoginVerifyOTP(number, otp string) (map[string]string, error)

LoginVerifyOTP verifies OTP for login

func Logout added in v2.15.19

func Logout() error

Logout function deletes credentials file

func ScheduleFunctionCall

func ScheduleFunctionCall(fn func(), executeTime time.Time)

ScheduleFunctionCall schedules a function call at a given time

func WriteJIOTVCredentials

func WriteJIOTVCredentials(credentials *JIOTV_CREDENTIALS) error

WriteJIOTVCredentials writes credentials data to file

Types

type JIOTV_CREDENTIALS

type JIOTV_CREDENTIALS struct {
	SSOToken             string `json:"ssoToken"`
	UniqueID             string `json:"uniqueId"`
	CRM                  string `json:"crm"`
	AccessToken          string `json:"accessToken"`
	RefreshToken         string `json:"refreshToken"`
	LastTokenRefreshTime string `json:"lastTokenRefreshTime"`
}

JIOTV_CREDENTIALS represents JioTV Go credentials. Includes some mandatory header values required for making requests to JioTV API

func GetJIOTVCredentials

func GetJIOTVCredentials() (*JIOTV_CREDENTIALS, error)

GetJIOTVCredentials return credentials from environment variables or credentials file Important note: If credentials are provided from environment variables, they will be used instead of credentials file

type LoginOTPPayload

type LoginOTPPayload struct {
	Number     string                 `json:"number"`
	OTP        string                 `json:"otp"`
	DeviceInfo LoginPayloadDeviceInfo `json:"deviceInfo"`
}

LoginOTPPayload represents Request payload for OTP based login

type LoginPasswordPayload

type LoginPasswordPayload struct {
	// Username or phone number of the Jio account
	Identifier string `json:"identifier"`
	// Password of the Jio account
	Password string `json:"password"`
	// Remember user after login
	RememberUser         string                 `json:"rememberUser"`
	UpgradeAuth          string                 `json:"upgradeAuth"`
	ReturnSessionDetails string                 `json:"returnSessionDetails"`
	DeviceInfo           LoginPayloadDeviceInfo `json:"deviceInfo"`
}

LoginPasswordPayload represents Request payload for password based login

type LoginPayloadDeviceInfo

type LoginPayloadDeviceInfo struct {
	ConsumptionDeviceName string                     `json:"consumptionDeviceName"`
	Info                  LoginPayloadDeviceInfoInfo `json:"info"`
}

LoginPayloadDeviceInfo represents Device info for the login API

type LoginPayloadDeviceInfoInfo

type LoginPayloadDeviceInfoInfo struct {
	Type      string                             `json:"type"`
	Platform  LoginPayloadDeviceInfoInfoPlatform `json:"platform"`
	AndroidID string                             `json:"androidId"`
}

LoginPayloadDeviceInfoInfo represents Info for the login API

type LoginPayloadDeviceInfoInfoPlatform

type LoginPayloadDeviceInfoInfoPlatform struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

LoginPayloadDeviceInfoInfoPlatform represents Platform info for the login API

type LoginResponse

type LoginResponse struct {
	AuthToken         string `json:"authToken"`
	RefreshToken      string `json:"refreshToken"`
	SSOToken          string `json:"ssoToken"`
	SessionAttributes struct {
		User struct {
			SubscriberID string `json:"subscriberId"`
			Unique       string `json:"unique"`
		} `json:"user"`
	} `json:"sessionAttributes"`
}

LoginResponse represents Response from the JioTV login API

Jump to

Keyboard shortcuts

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