Class: Bitreserve::Request
- Inherits:
-
Object
- Object
- Bitreserve::Request
- Includes:
- HTTParty
- Defined in:
- lib/bitreserve/request.rb
Class Method Summary collapse
- .perform_with_object(http_method, request_data) ⇒ Object
- .perform_with_objects(http_method, request_data) ⇒ Object
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(request_data) ⇒ Request
constructor
A new instance of Request.
- #post ⇒ Object
Constructor Details
#initialize(request_data) ⇒ Request
Returns a new instance of Request.
16 17 18 19 20 |
# File 'lib/bitreserve/request.rb', line 16 def initialize(request_data) @path = request_data.endpoint @data = request_data.payload @headers = request_data.headers end |
Class Method Details
.perform_with_object(http_method, request_data) ⇒ Object
11 12 13 14 |
# File 'lib/bitreserve/request.rb', line 11 def self.perform_with_object(http_method, request_data) response = new(request_data).public_send(http_method) request_data.entity.new(response) end |
.perform_with_objects(http_method, request_data) ⇒ Object
6 7 8 9 |
# File 'lib/bitreserve/request.rb', line 6 def self.perform_with_objects(http_method, request_data) response = new(request_data).public_send(http_method) request_data.entity.from_collection(response) end |
Instance Method Details
#get ⇒ Object
22 23 24 25 26 |
# File 'lib/bitreserve/request.rb', line 22 def get response = self.class.get(path, ) log_request_info(:get, response) response.parsed_response end |
#post ⇒ Object
28 29 30 31 32 |
# File 'lib/bitreserve/request.rb', line 28 def post response = self.class.post(path, ) log_request_info(:post, response) response.parsed_response end |