Class: MoesifApi::BaseController
- Inherits:
-
Object
- Object
- MoesifApi::BaseController
- Defined in:
- lib/moesif_api/controllers/base_controller.rb
Direct Known Subclasses
Constant Summary collapse
- @@faraday_http_client =
FaradayClient.new
Instance Attribute Summary collapse
-
#http_call_back ⇒ Object
Returns the value of attribute http_call_back.
-
#http_client ⇒ Object
Returns the value of attribute http_client.
Instance Method Summary collapse
- #build_request_headers ⇒ Object
-
#initialize(http_client: nil, http_call_back: nil) ⇒ BaseController
constructor
A new instance of BaseController.
- #validate_response(context) ⇒ Object
Constructor Details
#initialize(http_client: nil, http_call_back: nil) ⇒ BaseController
Returns a new instance of BaseController.
7 8 9 10 |
# File 'lib/moesif_api/controllers/base_controller.rb', line 7 def initialize(http_client: nil, http_call_back: nil) @http_client = http_client ||= @@faraday_http_client @http_call_back = http_call_back end |
Instance Attribute Details
#http_call_back ⇒ Object
Returns the value of attribute http_call_back.
3 4 5 |
# File 'lib/moesif_api/controllers/base_controller.rb', line 3 def http_call_back @http_call_back end |
#http_client ⇒ Object
Returns the value of attribute http_client.
3 4 5 |
# File 'lib/moesif_api/controllers/base_controller.rb', line 3 def http_client @http_client end |
Instance Method Details
#build_request_headers ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/moesif_api/controllers/base_controller.rb', line 12 def build_request_headers { 'content-type' => 'application/json; charset=utf-8', 'X-Moesif-Application-Id' => Configuration.application_id, 'User-Agent' => Configuration.user_agent || ('moesifapi-ruby/' + Configuration.version) } end |
#validate_response(context) ⇒ Object
20 21 22 23 24 |
# File 'lib/moesif_api/controllers/base_controller.rb', line 20 def validate_response(context) return if context.response.status_code.between?(200, 208) # [200,208] = HTTP OK raise APIException.new 'HTTP Response Not OK', context end |