Class: Bitreserve::Request

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/bitreserve/request.rb

Class Method Summary collapse

Instance Method Summary collapse

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

#getObject



22
23
24
25
26
# File 'lib/bitreserve/request.rb', line 22

def get
  response = self.class.get(path, options)
  log_request_info(:get, response)
  response.parsed_response
end

#postObject



28
29
30
31
32
# File 'lib/bitreserve/request.rb', line 28

def post
  response = self.class.post(path, options)
  log_request_info(:post, response)
  response.parsed_response
end