Class: Leal::Status::Client
- Inherits:
-
Object
- Object
- Leal::Status::Client
- Defined in:
- lib/leal/status/client.rb
Instance Method Summary collapse
-
#check(request_options: {}, **_params) ⇒ Leal::Status::Types::CheckStatusResponse
Returns the status of the API.
- #initialize(client:) ⇒ void constructor
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/leal/status/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#check(request_options: {}, **_params) ⇒ Leal::Status::Types::CheckStatusResponse
Returns the status of the API. No authentication required.
Every response from this API, including this one, carries RateLimit-Limit,
RateLimit-Remaining, RateLimit-Reset and RateLimit-Policy. Exceeding
the limit returns 429 with Retry-After in seconds.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/leal/status/client.rb', line 31 def check(request_options: {}, **_params) request = Leal::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "api/v1/status", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Leal::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Leal::Status::Types::CheckStatusResponse.load(response.body) else error_class = Leal::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |