lib/intercom.rb in intercom-0.0.2 vs lib/intercom.rb in intercom-0.0.3

- old
+ new

@@ -12,39 +12,39 @@ # This library provides ruby bindings for the Intercom API (https://api.intercom.io) # # == Basic Usage # === Configure Intercom with your access credentials # Intercom.app_id = "my_app_id" -# Intercom.secret_key = "my_secret_key" +# Intercom.api_key = "my_api_key" # === Make requests to the API # Intercom::User.find(:email => "bob@example.com") # module Intercom @hostname = "api.intercom.io" @protocol = "https" @app_id = nil - @secret_key = nil + @api_key = nil ## # Set the id of the application you want to interact with. # When logged into your intercom console, the app_id is in the url after /apps (eg https://www.intercom.io/apps/<app-id>) def self.app_id=(app_id) @app_id = app_id end ## - # Set the secret key to gain access to your application data. + # Set the api key to gain access to your application data. # When logged into your intercom console, you can view/create api keys in the settings menu - def self.secret_key=(secret_key) - @secret_key = secret_key + def self.api_key=(api_key) + @api_key = api_key end private def self.url_for_path(path) - raise ArgumentError, "You must set both Intercom.app_id and Intercom.secret_key to use this client. See https://github.com/intercom/intercom for usage examples." if [@app_id, @secret_key].any?(&:nil?) - "#{protocol}://#{@app_id}:#{@secret_key}@#{hostname}/v1/#{path}" + raise ArgumentError, "You must set both Intercom.app_id and Intercom.api_key to use this client. See https://github.com/intercom/intercom for usage examples." if [@app_id, @api_key].any?(&:nil?) + "#{protocol}://#{@app_id}:#{@api_key}@#{hostname}/v1/#{path}" end def self.post(path, payload_hash) execute_request(:post, path, {}, {:content_type => :json, :accept => :json}, payload_hash) end @@ -105,9 +105,12 @@ def self.hostname=(override) @hostname = override end + # + # Raised when the credentials you provide don't match a valid account on Intercom. + # Check that you have set <b>Intercom.app_id=</b> and <b>Intercom.api_key=</b> correctly. class AuthenticationError < StandardError; end class ServerError < StandardError; end \ No newline at end of file