Module: Tibber

Extended by:
WrAPI::Configuration, WrAPI::RespondTo
Defined in:
lib/tibber.rb,
lib/tibber/api.rb,
lib/tibber/const.rb,
lib/tibber/error.rb,
lib/tibber/client.rb,
lib/tibber/request.rb,
lib/tibber/version.rb,
lib/tibber/authorization.rb

Overview

The ‘Tibber` module provides an API client for interacting with the Tibber GraphQL API. It extends `WrAPI::Configuration` and `WrAPI::RespondTo`, enabling configuration handling.

Examples:

Creating a client instance:

client = Tibber.client(api_key: "your-api-key")

Resetting the client configuration:

Tibber.reset

Defined Under Namespace

Modules: Authentication, Request Classes: API, AuthenticationError, Avatar, Client, ConfigurationError, Enum, GraphQLError, HomeType, Resolution, Screens, TibberError

Constant Summary collapse

DEFAULT_UA =

Default User-Agent string for API requests.

"Ruby Tibber API client #{Tibber::VERSION}"
DEFAULT_ENDPOINT =

Default API endpoint for Tibber.

'https://api.tibber.com/v1-beta/gql'
VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.client(options = {}) ⇒ Tibber::Client

Creates a new instance of the Tibber API client.

Examples:

Creating a client with default settings:

client = Tibber.client

Creating a client with a custom user agent:

client = Tibber.client(user_agent: "My Custom UA")

Parameters:

  • options (Hash) (defaults to: {})

    Optional configuration overrides.

Options Hash (options):

  • :user_agent (String)

    Custom user agent string.

  • :endpoint (String)

    Custom API endpoint.

Returns:



39
40
41
# File 'lib/tibber.rb', line 39

def self.client(options = {})
  Tibber::Client.new({ user_agent: DEFAULT_UA, endpoint: DEFAULT_ENDPOINT }.merge(options))
end

.resetvoid

This method returns an undefined value.

Resets the Tibber module’s configuration to default values.

Examples:

Resetting the configuration:

Tibber.reset


49
50
51
52
53
54
# File 'lib/tibber.rb', line 49

def self.reset
  super
  self.endpoint   = nil
  self.user_agent = DEFAULT_UA
  self.endpoint   = DEFAULT_ENDPOINT
end