Class: Sumo::Client

Inherits:
Object
  • Object
show all
Includes:
Error
Defined in:
lib/sumo/client.rb

Overview

This class has the lowest-level interface to interact with the Sumo Job API.

Constant Summary collapse

DEFAULT_ERROR_MESSAGE =

The error message raised when the result can be parsed from Sumo.

'Error sending API request'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials = Sumo.creds) ⇒ Client

Create a new ‘Sumo::Client` with the given credentials.



11
12
13
14
# File 'lib/sumo/client.rb', line 11

def initialize(credentials = Sumo.creds)
  @email = credentials['email'].freeze
  @password = credentials['password'].freeze
end

Instance Attribute Details

Returns the value of attribute cookie.



5
6
7
# File 'lib/sumo/client.rb', line 5

def cookie
  @cookie
end

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/sumo/client.rb', line 5

def email
  @email
end

#passwordObject (readonly)

Returns the value of attribute password.



5
6
7
# File 'lib/sumo/client.rb', line 5

def password
  @password
end

Instance Method Details

#request(hash, &block) ⇒ Object

Send a HTTP request to the server, handling any errors that may occur.



17
18
19
20
21
22
# File 'lib/sumo/client.rb', line 17

def request(hash, &block)
  response = connection.request(add_defaults(hash), &block)
  handle_errors!(response)
  set_cookie!(response)
  response.body
end