Class: OneAndOne::PingAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/1and1/ping_auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(test: false) ⇒ PingAuth

Returns a new instance of PingAuth.



7
8
9
10
11
12
13
14
15
16
# File 'lib/1and1/ping_auth.rb', line 7

def initialize(test: false)

  # Check if hitting mock api or live api
  if test
    @connection = Excon.new($base_url, :mock => true)
  else
    @connection = Excon.new($base_url)
  end

end

Instance Method Details

#getObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/1and1/ping_auth.rb', line 19

def get

  # Build URL
  path = OneAndOne.build_url('/ping_auth')

  # Perform request
  response = @connection.request(:method => :get,
    :path => path,
    :headers => $header)

  # Check response status
  OneAndOne.check_response(response.body, response.status)

  #JSON-ify the response string
  JSON.parse(response.body)

end