Class: WixAnswers::REST::Request
- Inherits:
-
Object
- Object
- WixAnswers::REST::Request
- Defined in:
- lib/wixanswers/rest/request.rb
Instance Method Summary collapse
- #default_headers ⇒ Object
-
#initialize(client, request_method, path, options: {}, headers: {}) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Constructor Details
#initialize(client, request_method, path, options: {}, headers: {}) ⇒ Request
Returns a new instance of Request.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/wixanswers/rest/request.rb', line 6 def initialize(client, request_method, path, options: {}, headers: {}) @client = client @request_method = request_method.to_sym @uri = Addressable::URI.parse("#{client.base_url}/#{client.version}/#{path}") @path = @uri.path @options = @headers = default_headers.merge(headers) end |
Instance Method Details
#default_headers ⇒ Object
24 25 26 |
# File 'lib/wixanswers/rest/request.rb', line 24 def default_headers {'Content-Type' => 'application/json; charset=utf-8', 'Accept' => 'application/json'} end |
#perform ⇒ Object
18 19 20 21 22 |
# File 'lib/wixanswers/rest/request.rb', line 18 def perform response = self.send(@request_method, @uri.to_s, headers: @headers) response.body end |