Class: VtApi::Endpoint
- Inherits:
-
Object
- Object
- VtApi::Endpoint
- Defined in:
- lib/vt_api/internal/endpoint.rb
Overview
API endpoint interface class.
Instance Attribute Summary collapse
-
#method ⇒ Object
Returns the value of attribute method.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, method, params = {}) ⇒ Endpoint
constructor
Initialize new endpoint.
-
#missing_params(passed_params) ⇒ Array
Get a list of missing parameters.
-
#params_valid?(passed_params) ⇒ Boolean
Check whether given parameters match endpoint interface.
Constructor Details
#initialize(uri, method, params = {}) ⇒ Endpoint
Initialize new endpoint.
Interface parameters are described as in example below.
22 23 24 25 26 |
# File 'lib/vt_api/internal/endpoint.rb', line 22 def initialize(uri, method, params = {}) @uri = uri @method = method @params = params end |
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
8 9 10 |
# File 'lib/vt_api/internal/endpoint.rb', line 8 def method @method end |
#uri ⇒ Object
Returns the value of attribute uri.
8 9 10 |
# File 'lib/vt_api/internal/endpoint.rb', line 8 def uri @uri end |
Instance Method Details
#missing_params(passed_params) ⇒ Array
Get a list of missing parameters.
44 45 46 47 48 49 50 51 52 |
# File 'lib/vt_api/internal/endpoint.rb', line 44 def missing_params(passed_params) missing = [] @params.each do |param, required| missing << param if required && passed_params[param].nil? end missing end |
#params_valid?(passed_params) ⇒ Boolean
Check whether given parameters match endpoint interface.
32 33 34 35 36 37 38 |
# File 'lib/vt_api/internal/endpoint.rb', line 32 def params_valid?(passed_params) @params.each do |param, required| return false if required && passed_params[param].nil? end true end |