Class: PiHole::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/pi_hole/endpoint.rb

Overview

The main entrypoint for this SDK. Describes the location and interaction with the PiHole API

Instance Method Summary collapse

Constructor Details

#initialize(location:, api_key:) ⇒ Endpoint

Returns a new instance of Endpoint.

Parameters:

  • location (String)

    The protocol and domain (or IP address) via which PiHole is served

  • api_key (String)

    The API key to access the PiHole API



10
11
12
13
# File 'lib/pi_hole/endpoint.rb', line 10

def initialize(location:, api_key:)
  @location = location
  @api_key = api_key
end

Instance Method Details

#execute(command) ⇒ Object

Parameters:

  • command (#query_string)


16
17
18
19
# File 'lib/pi_hole/endpoint.rb', line 16

def execute(command)
  uri = URI "#{location}/admin/api.php?#{command.query_string}&#{auth_query_string}"
  Net::HTTP.get_response uri
end