class BookingSync::Engine::APIClient
Public Class Methods
new(token, options = {})
click to toggle source
Calls superclass method
# File lib/bookingsync/engine/api_client.rb, line 2 def initialize(token, options = {}) super @account = options[:account] end
Public Instance Methods
call(method, path, data = nil, options = nil)
click to toggle source
Calls superclass method
# File lib/bookingsync/engine/api_client.rb, line 7 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 Instance Methods
refresh_token?(error)
click to toggle source
# File lib/bookingsync/engine/api_client.rb, line 21 def refresh_token?(error) error.headers["www-authenticate"].include?("The access token expired") end