Class: Castle::API
- Inherits:
-
Object
- Object
- Castle::API
- Defined in:
- lib/castle/api.rb
Overview
this class is responsible for making requests to api
Instance Method Summary collapse
-
#initialize(headers = {}) ⇒ API
constructor
A new instance of API.
- #request(command) ⇒ Object
Constructor Details
#initialize(headers = {}) ⇒ API
Returns a new instance of API.
6 7 8 9 10 |
# File 'lib/castle/api.rb', line 6 def initialize(headers = {}) @config = Castle.config @http = prepare_http @headers = headers.merge('Content-Type' => 'application/json') end |
Instance Method Details
#request(command) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/castle/api.rb', line 12 def request(command) request = Castle::Request.new(@headers).build( command.path, command.data, command.method ) perform_request(request) end |