Sha256: 6392cfaff47d977532eaf432a0800bff8c231cf1c3d5b03b99a2181472bf3b5f
Contents?: true
Size: 736 Bytes
Versions: 3
Compression:
Stored size: 736 Bytes
Contents
module SurveyGizmo class RateLimitExceededError < RuntimeError; end class BadResponseError < RuntimeError; end class PesterSurveyGizmoMiddleware < Faraday::Middleware Faraday::Response.register_middleware(pester_survey_gizmo: self) def call(environment) Pester.survey_gizmo_ruby.retry do @app.call(environment).on_complete do |response| fail RateLimitExceededError if response.status == 429 fail BadResponseError, "Bad response code #{response.status} in #{response.inspect}" unless response.status == 200 fail BadResponseError, response.body['message'] unless response.body['result_ok'] && response.body['result_ok'].to_s =~ /^true$/i end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems