Class: Rents::Status

Inherits:
Connection show all
Defined in:
lib/rents/status.rb

Instance Attribute Summary collapse

Attributes inherited from Connection

#api_version, #auth, #domain, #end_point, #end_point_versioned, #path, #request_params

Instance Method Summary collapse

Methods inherited from Connection

#get_json_request, #get_request, #post_json_request, #post_request, #url_requested

Constructor Details

#initialize(params = {}) ⇒ Status

Constructor



9
10
11
12
13
# File 'lib/rents/status.rb', line 9

def initialize(params = {})
  super # call it super initialize
  self.path = "status"
  check_it
end

Instance Attribute Details

#api_codeObject

Internal system response code



6
7
8
# File 'lib/rents/status.rb', line 6

def api_code
  @api_code
end

#http_codeObject

HTTP Code for the request



5
6
7
# File 'lib/rents/status.rb', line 5

def http_code
  @http_code
end

#messageObject

Attrs



4
5
6
# File 'lib/rents/status.rb', line 4

def message
  @message
end

Instance Method Details

#check_itObject

Check it status and “setup” it attrs



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rents/status.rb', line 16

def check_it
  self.path = 'status'
  resp = get_request
  hash_resp = JSON.parse(resp).it_keys_to_sym
  self.http_code = resp.code
  self.message = "EndPoint not response(connection error): #{self.url_requested}" if self.http_code != 200
  self.message = hash_resp[:message] if self.http_code == 200
  self.api_code = hash_resp[:api_code]

  return self
end