Class: LightspeedRestaurantClient::Request
- Inherits:
-
Object
- Object
- LightspeedRestaurantClient::Request
- Defined in:
- lib/lightspeed_restaurant/request.rb
Instance Method Summary collapse
-
#initialize(base_uri, path, token, body = {}, query = {}) ⇒ Request
constructor
A new instance of Request.
- #perform(**args) ⇒ Object
Constructor Details
#initialize(base_uri, path, token, body = {}, query = {}) ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 15 16 17 |
# File 'lib/lightspeed_restaurant/request.rb', line 10 def initialize(base_uri, path, token, body = {}, query = {}) @base_uri = base_uri || 'http://stating-integration.posios.com' @headers = { 'Content-Type' => 'application/json', 'X-Auth-Token' => token } @body = body.to_json @query = query @path = '/PosServer' + path @connection = Excon.new(@base_uri) end |
Instance Method Details
#perform(**args) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/lightspeed_restaurant/request.rb', line 19 def perform(**args) response = @connection.request(args.merge(path: @path, headers: @headers, body: @body, query: @query)) if [200, 201].include?(response.status) response.body else handle_error(response) end end |