Class: FontsDotCom::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/fonts_dot_com/response.rb

Defined Under Namespace

Classes: ApiError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, options = {}) ⇒ Response

Returns a new instance of Response.

Raises:



18
19
20
21
22
23
24
25
26
27
# File 'lib/fonts_dot_com/response.rb', line 18

def initialize(response, options={})
  @original_response_object = response

  json  = JSON.parse(response.body)

  @body = json
  @code = response.code

  raise error.new(self) if returned_error
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



16
17
18
# File 'lib/fonts_dot_com/response.rb', line 16

def body
  @body
end

#codeObject

Returns the value of attribute code.



16
17
18
# File 'lib/fonts_dot_com/response.rb', line 16

def code
  @code
end

#original_response_objectObject

Returns the value of attribute original_response_object.



16
17
18
# File 'lib/fonts_dot_com/response.rb', line 16

def original_response_object
  @original_response_object
end

Instance Method Details

#errorObject



41
42
43
44
# File 'lib/fonts_dot_com/response.rb', line 41

def error
  # TODO
  ApiError
end

#returned_errorObject



37
38
39
# File 'lib/fonts_dot_com/response.rb', line 37

def returned_error
  code[0].to_i > 2
end

#session_keyObject



33
34
35
# File 'lib/fonts_dot_com/response.rb', line 33

def session_key
  records[0].fetch(:sessionKey) 
end

#statusObject



29
30
31
# File 'lib/fonts_dot_com/response.rb', line 29

def status
  raise 'TODO'
end