Class: FizzyApiClient::Request
- Inherits:
-
Object
- Object
- FizzyApiClient::Request
- Defined in:
- lib/fizzy_api_client/request.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#path_params ⇒ Object
readonly
Returns the value of attribute path_params.
Instance Method Summary collapse
- #full_path ⇒ Object
-
#initialize(path:, params: {}, path_params: {}) ⇒ Request
constructor
A new instance of Request.
- #wrap_payload(resource_name, data) ⇒ Object
Constructor Details
#initialize(path:, params: {}, path_params: {}) ⇒ Request
Returns a new instance of Request.
7 8 9 10 11 |
# File 'lib/fizzy_api_client/request.rb', line 7 def initialize(path:, params: {}, path_params: {}) @path = interpolate_path(path, path_params) @params = params @path_params = path_params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/fizzy_api_client/request.rb', line 5 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/fizzy_api_client/request.rb', line 5 def path @path end |
#path_params ⇒ Object (readonly)
Returns the value of attribute path_params.
5 6 7 |
# File 'lib/fizzy_api_client/request.rb', line 5 def path_params @path_params end |
Instance Method Details
#full_path ⇒ Object
13 14 15 16 17 18 |
# File 'lib/fizzy_api_client/request.rb', line 13 def full_path return path if params.empty? query_string = build_query_string(params) "#{path}?#{query_string}" end |
#wrap_payload(resource_name, data) ⇒ Object
20 21 22 |
# File 'lib/fizzy_api_client/request.rb', line 20 def wrap_payload(resource_name, data) { resource_name => data } end |