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(cookie_id, ip, headers) ⇒ API
constructor
A new instance of API.
- #request(endpoint, args, method = :post) ⇒ Object
- #request_query(endpoint) ⇒ Object
Constructor Details
#initialize(cookie_id, ip, headers) ⇒ API
Returns a new instance of API.
6 7 8 9 10 11 |
# File 'lib/castle/api.rb', line 6 def initialize(, ip, headers) @config = Castle.config @config_api_endpoint = @config.api_endpoint @http = prepare_http @headers = Castle::Headers.new.prepare(, ip, headers) end |
Instance Method Details
#request(endpoint, args, method = :post) ⇒ Object
18 19 20 21 |
# File 'lib/castle/api.rb', line 18 def request(endpoint, args, method = :post) request = Castle::Request.new(@headers).build(endpoint, args, method) perform_request(request) end |
#request_query(endpoint) ⇒ Object
13 14 15 16 |
# File 'lib/castle/api.rb', line 13 def request_query(endpoint) request = Castle::Request.new(@headers).build_query(endpoint) perform_request(request) end |