webosdev

package
v0.0.2-0...-32917ca Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package webosdev provides a client for interacting with the webOS developer API.

Index

Constants

View Source
const DefaultBaseURL = "https://developer.lge.com"

Variables

View Source
var ErrInvalidTimestamp = errors.New("invalid timestamp")

ErrInvalidTimestamp indicates that the timestamp returned by the API could not be parsed.

View Source
var ErrRequestFailed = errors.New("request failed")

ErrRequestFailed indicates that an API request returned an error.

Functions

func ParseDuration

func ParseDuration(str string) (time.Duration, error)

ParseDuration parses a duration formatted as "H:M:S"

Types

type Client

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

Client represents a client for the webOS developer API.

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a Client for interacting with the webOS developer API. Optional configuration can be provided via Option functions.

func (*Client) CheckExpiration

func (c *Client) CheckExpiration(ctx context.Context) (time.Duration, error)

CheckExpiration checks the remaining time in the current webOS developer session. It parses the response timestamp and returns the remaining duration and any error encountered.

func (*Client) ExtendSession

func (c *Client) ExtendSession(ctx context.Context) error

ExtendSession extends the current webOS developer mode session by making an API call. It returns the decoded response and any error encountered.

type Option

type Option func(c *Client)

Option defines a function that configures a Client instance.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL returns an Option that sets a custom base URL for a Client. The default base URL is "https://developer.lge.com".

func WithInsecureSkipVerify

func WithInsecureSkipVerify(insecureSkipVerify bool) Option

WithInsecureSkipVerify returns an Option that toggles TLS verification for HTTP requests made by a Client.

func WithSessionToken

func WithSessionToken(token string) Option

WithSessionToken returns an Option that sets the session token for a Client. This token is used to authenticate API requests.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout returns an Option that sets a timeout for HTTP requests made by a Client. The timeout specifies the maximum duration for the request, including connection, processing, and reading the response.

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent returns an Option that sets the User-Agent string to be used for HTTP requests made by a Client.

Jump to

Keyboard shortcuts

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