Class: Tosuto::API
- Inherits:
-
Object
- Object
- Tosuto::API
- Defined in:
- lib/tosuto/api.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULT_HOST =
ENV.fetch("TOAST_HOST", "https://ws-sandbox.eng.toasttab.com")
Instance Method Summary collapse
-
#initialize(host = DEFAULT_HOST) ⇒ API
constructor
A new instance of API.
- #request(method, endpoint, body: nil, params: {}, headers: {}, token: nil, restaurant_id: nil) ⇒ Object
Constructor Details
#initialize(host = DEFAULT_HOST) ⇒ API
Returns a new instance of API.
45 46 47 |
# File 'lib/tosuto/api.rb', line 45 def initialize(host = DEFAULT_HOST) @host = host end |
Instance Method Details
#request(method, endpoint, body: nil, params: {}, headers: {}, token: nil, restaurant_id: nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/tosuto/api.rb', line 49 def request(method, endpoint, body: nil, params: {}, headers: {}, token: nil, restaurant_id: nil) uri = build_uri(endpoint, params) http_start(uri) { |http| http.request( build_request( method, uri, body: body, headers: headers, token: token, restaurant_id: restaurant_id, ) ) } end |