lib/zoho_hub/connection.rb in zoho_hub-0.1.5 vs lib/zoho_hub/connection.rb in zoho_hub-0.1.6

- old
+ new

@@ -8,10 +8,13 @@ require 'zoho_hub/response' module ZohoHub class Connection attr_accessor :debug, :access_token, :expires_in, :api_domain, :refresh_token + + # This is a block to be run when the token is refreshed. This way you can do whatever you want + # with the new parameters returned by the refresh method. attr_accessor :on_refresh_cb DEFAULT_DOMAIN = 'https://www.zohoapis.eu' BASE_PATH = '/crm/v2/' @@ -73,9 +76,11 @@ @on_refresh_cb.call(params) if @on_refresh_cb.present? @access_token = params[:access_token] http_response = yield + elsif response.authentication_failure? + raise ZohoAPIError, response.msg end http_response end