Class: Vng::Request Private
- Inherits:
-
Object
- Object
- Vng::Request
- Defined in:
- lib/vng/http_request.rb,
lib/vng/mock_request.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A mock version of HTTPRequest which returns pre-built responses.
Constant Summary collapse
- AVAILABLE_ROUTE_ID =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1630
- @@logged_out =
This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.
false
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
private
Initializes an MockRequest object.
-
#run ⇒ Hash
private
Sends the request and returns the body parsed from the JSON response.
Constructor Details
#initialize(options = {}) ⇒ Request
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes an MockRequest object.
27 28 29 30 31 32 |
# File 'lib/vng/http_request.rb', line 27 def initialize( = {}) @host = [:host] @path = [:path] @body = [:body] @query = .fetch :query, {} end |
Instance Method Details
#run ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sends the request and returns the body parsed from the JSON response.
38 39 40 41 42 43 |
# File 'lib/vng/http_request.rb', line 38 def run return {} if response.body.empty? JSON(response.body).tap do |data| raise Error, "#{data['errMsg']} #{data['Errors']}" unless data['errNo'].zero? end end |