class PiHole::Endpoint

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

Attributes

api_key[R]
location[R]

Public Class Methods

new(location:, api_key:) click to toggle source

@param [String] location The protocol and domain (or IP address) via which PiHole is served @param [String] api_key The API key to access the PiHole API

# File lib/pi_hole/endpoint.rb, line 10
def initialize(location:, api_key:)
  @location = location
  @api_key = api_key
end

Public Instance Methods

execute(command) click to toggle source

@param [#query_string] command

# 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

Private Instance Methods

auth_query_string() click to toggle source
# File lib/pi_hole/endpoint.rb, line 25
def auth_query_string
  "auth=#{api_key}"
end