Class: MdNotes::ServiceController

Inherits:
BaseController show all
Defined in:
lib/md_notes/controllers/service_controller.rb

Overview

ServiceController

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#execute_request, #validate_parameters, #validate_response

Constructor Details

#initialize(config, http_call_back: nil) ⇒ ServiceController

Returns a new instance of ServiceController.



9
10
11
# File 'lib/md_notes/controllers/service_controller.rb', line 9

def initialize(config, http_call_back: nil)
  super(config, http_call_back: http_call_back)
end

Instance Method Details

#get_statusServiceStatus

TODO: type endpoint description here

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/md_notes/controllers/service_controller.rb', line 15

def get_status
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/api/status'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)
  validate_response(_response)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  ServiceStatus.from_hash(decoded)
end