Class: Opsgenie::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/opsgenie/client.rb

Constant Summary collapse

ROOT_PATH =
"https://api.opsgenie.com".freeze

Class Method Summary collapse

Class Method Details

.api_keyObject

Raises:



29
30
31
32
33
# File 'lib/opsgenie/client.rb', line 29

def api_key
  raise ConfigurationError.new("Missing API key. Use `Opsgenie.configure(api_key: YOUR_API_KEY)` to set the API key") if Config.opsgenie_api_key.nil?

  Config.opsgenie_api_key
end

.auth_headerObject



21
22
23
# File 'lib/opsgenie/client.rb', line 21

def auth_header
  {"Authorization" => "GenieKey #{api_key}"}
end

.get(path) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/opsgenie/client.rb', line 6

def get(path)
  url = [
    ROOT_PATH,
    version,
    path
  ].join("/")
  HTTParty.get(url, headers)
end

.headersObject



15
16
17
18
19
# File 'lib/opsgenie/client.rb', line 15

def headers
  {
    headers: auth_header
  }
end

.versionObject



25
26
27
# File 'lib/opsgenie/client.rb', line 25

def version
  "v2"
end