Class: Yext::Api::Utils::Middleware::ApiRateLimits

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/yext/api/utils/middleware/api_rate_limits.rb

Overview

Faraday Middleware for extracting API limits from call responses.

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/yext/api/utils/middleware/api_rate_limits.rb', line 9

def call(env)
  @app.call(env).on_complete do |environment|
    save_rates(environment, Yext::Api::Utils::ApiFinder.new(env[:url], env[:method]).find_api)

    env.response
  end
end