Sha256: b2d0b4346123a0959e048729605201f499233a4e0a0447a7a96f33829df3b3be
Contents?: true
Size: 546 Bytes
Versions: 12
Compression:
Stored size: 546 Bytes
Contents
class BookingSync::Engine::APIClient < BookingSync::API::Client def initialize(token, options = {}) super @account = options[:account] end def call(method, path, data = nil, options = nil) tries ||= 1 super rescue BookingSync::API::Unauthorized => error if refresh_token?(error) && (tries -= 1) >= 0 @token = @account.refresh_token!.token retry else raise end end private def refresh_token?(error) error.headers["www-authenticate"].include?("The access token expired") end end
Version data entries
12 entries across 12 versions & 1 rubygems