Sha256: 331a882db804c86c111ba68b71589144dad33107d6770784e5b5bb2f18310ff1

Contents?: true

Size: 500 Bytes

Versions: 11

Compression:

Stored size: 500 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 => e
    token_expired = e.headers["www-authenticate"].include?("The access token expired")
    if token_expired && (tries -= 1) >= 0
      @token = @account.refresh_token!.token
      retry
    else
      raise
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bookingsync-engine-2.0.1 lib/bookingsync/engine/api_client.rb
bookingsync-engine-2.0.0 lib/bookingsync/engine/api_client.rb
bookingsync-engine-1.1.0 lib/bookingsync/engine/api_client.rb
bookingsync-engine-1.0.2 lib/bookingsync/engine/api_client.rb
bookingsync-engine-1.0.1 lib/bookingsync/engine/api_client.rb
bookingsync-engine-1.0.0 lib/bookingsync/engine/api_client.rb
bookingsync-engine-0.5.0 lib/bookingsync/engine/api_client.rb
bookingsync-engine-0.4.6 lib/bookingsync/engine/api_client.rb
bookingsync-engine-0.4.5 lib/bookingsync/engine/api_client.rb
bookingsync-engine-0.4.4 lib/bookingsync/engine/api_client.rb
bookingsync-engine-0.4.3 lib/bookingsync/engine/api_client.rb