Class: MetricsApi::V3::Api
- Inherits:
-
Object
- Object
- MetricsApi::V3::Api
- Defined in:
- app/services/metrics_api/v3/api.rb
Overview
API entry point for V3 of the MetricsAPI
It takes in the request parameters and generates the metrics JSON the API should respond with
Constant Summary collapse
- ENDPOINT_BASE =
'MetricsApi::V3::Endpoints::'
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#call ⇒ Array<Hash>
Generates an API response using the parameters passed in when the class is created.
-
#initialize(params, endpoint) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(params, endpoint) ⇒ Api
Returns a new instance of Api.
16 17 18 19 |
# File 'app/services/metrics_api/v3/api.rb', line 16 def initialize(params, endpoint) @params = params @endpoint = (ENDPOINT_BASE + endpoint.to_s.camelize).constantize end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
12 13 14 |
# File 'app/services/metrics_api/v3/api.rb', line 12 def endpoint @endpoint end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
12 13 14 |
# File 'app/services/metrics_api/v3/api.rb', line 12 def params @params end |
Instance Method Details
#call ⇒ Array<Hash>
Generates an API response using the parameters passed in when the class is created. This response has already been presented and is ready to deliver to the client
25 26 27 |
# File 'app/services/metrics_api/v3/api.rb', line 25 def call endpoint.new(params).call end |