Class: GustoApi::Request
- Inherits:
-
Object
- Object
- GustoApi::Request
- Defined in:
- lib/gusto_api/request.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(endpoint:, method:, params: {}, auth_token:, auth_type: 'Token') ⇒ Request
constructor
A new instance of Request.
- #submit ⇒ Object
Constructor Details
#initialize(endpoint:, method:, params: {}, auth_token:, auth_type: 'Token') ⇒ Request
Returns a new instance of Request.
5 6 7 8 9 10 11 12 13 |
# File 'lib/gusto_api/request.rb', line 5 def initialize(endpoint:, method:, params: {}, auth_token:, auth_type: 'Token') raise Error.new("Invalid method: #{method}. Must be :get or :post") unless %i[get post].include?(method) self.endpoint = endpoint self.method = method self.params = params self.auth_token = auth_token self.auth_type = auth_type end |
Instance Method Details
#submit ⇒ Object
15 16 17 18 19 |
# File 'lib/gusto_api/request.rb', line 15 def submit HTTParty.send(method, url, ).tap do |response| raise InvalidAuthError.new("Invalid or expired auth token") if response.code == 401 end end |