export interface APIResponseData<Result = unknown> {
	success: boolean
	result: Result
}
export interface APIResponseDataError extends APIResponseData {
	error_code: string
	msg: string
}
export interface APIResponseDataVersion {
	api_version: string			// The current API version on the Freebox
	api_base_url: string		// The API root path on the HTTP server
	uid: string					// The device unique id
	api_domain: string			// The domain to use in place of hardcoded Freebox ip
	device_name: string			// The device name
	box_model: string			// Box model
	box_model_name: string		// Box model display name
	https_available: boolean	// Tells if https has been configured on the Freebox
	https_port: number			// Port to use for remote https access to the Freebox Api
}

// -------------- //
// AUTHENTICATION //
// -------------- //
export interface TokenRequest {
	app_id: string
	app_name: string
	app_version: string
	device_name: string
}

export interface RequestAuthorization {
	app_token: string
	track_id: string
}

export interface TrackAuthorizationProgress {
	status: "unknown"	// the app_token is invalid or has been revoked
		|   "pending"	// the user has not confirmed the authorization request yet
		|   "timeout"	// the user did not confirmed the authorization within the given time
		|   "granted"	// the app_token is valid and can be used to open a session
		|   "denied"	// the user denied the authorization request

	challenge: string
}

export interface GetChallenge {
	logged_in: boolean
	challenge: string
}

export interface OpenSession {
	challenge: string
	session_token?: string
	permissions?: SessionPermissions
}
interface SessionPermissions {
	settings?: boolean		// Allow modifying the Freebox settings (reading settings is always allowed)
	contacts?: boolean		// Access to contact list
	calls?: boolean			// Access to call logs
	explorer?: boolean		// Access to filesystem
	downloader?: boolean	// Access to downloader
	parental?: boolean		// Access to parental control (obsolete)
	pvr?: boolean			// Access personal video recorder
	profile?: boolean		// Access to user profile management
}

export interface SessionStart {
	app_id: string
	app_version: string
	password: string
}
// -------------- //
// -------------- //
// -------------- //

export interface ConnectionStatus {
	state: "going_up"	// connection is initializing
		|  "up"			// connection is active
		|  "going_down"	// connection is about to become inactive
		|  "down"		// connection is inactive

	type:  "ethernet"	// FTTH/ethernet
		|  "rfc2684"	// xDSL (unbundled)
		|  "pppoatm"	// xDSL

	media:  "ftth"		// FTTH
		|  "ethernet"	// Ethernet
		|  "xdsl"		// xDSL
		|  "backup_4g"	// Internet Backup

	ipv4: string			// Freebox IPv4 address
	ipv6: string			// Freebox IPv6 address
	rate_up: number			// current upload rate in byte/s
	rate_down: number		// current download rate in byte/s
	bandwidth_up: number	// available upload bandwidth in bit/s
	bandwidth_down: number	// available download bandwidth in bit/s
	bytes_up: number		// total uploaded bytes since last connection
	bytes_down: number		// total downloaded bytes since last connection
	ipv4_port_range: string	// limited range of ports available for the Freebox to use for NAT
}

export interface LcdConfig {
	brightness?: number
	orientation?: number
	orientation_forced?: boolean
	hide_wifi_key?: boolean
	hide_status_led?: boolean
	led_strip_enabled?: boolean
	led_strip_brightness?: number
	led_strip_animation?: string
	available_led_strip_animations?: string[]
}
