lib/esendex.rb in esendex-0.2.3 vs lib/esendex.rb in esendex-0.3.0

- old
+ new

@@ -1,33 +1,49 @@ module Esendex require_relative 'esendex/version' + require_relative 'esendex/exceptions' require_relative 'esendex/api_connection' + require_relative 'esendex/hash_serialisation' + require_relative 'esendex/account' + require_relative 'esendex/inbound_message' require_relative 'esendex/message' - require_relative 'esendex/exceptions' require_relative 'esendex/message_batch_submission' + require_relative 'esendex/message_delivered_event' + require_relative 'esendex/message_failed_event' - require_relative 'esendex/railtie' if defined?(Rails) + # Load Rails extensions if Rails present + if defined?(Rails) + require_relative 'esendex/railtie' + require_relative 'esendex/engine' + end API_NAMESPACE = 'http://api.esendex.com/ns/' API_HOST = 'https://api.esendex.com' API_VERSION = 'v1.0' + # Public - used to configure the gem prior to use + # + # Esendex.configure do |config| + # config.username = 'username' + # config.password = 'password' + # config.account_reference = 'account reference' + # end + # def self.configure yield self if block_given? - - unless Esendex.username - raise StandardError.new("username required. Either set Esendex.username or set environment variable ESENDEX_USERNAME") - end - - unless Esendex.password - raise StandardError.new("password required. Either set Esendex.password or set environment variable ESENDEX_PASSWORD") - end end class << self + # credentials for authentication attr_writer :account_reference, :username, :password + # lambdas for handling push notifications + attr_accessor :message_delivered_event_handler, :message_failed_event_handler, :inbound_message_handler + + # behaviour config + attr_accessor :suppress_error_backtrace + def account_reference @account_reference ||= ENV['ESENDEX_ACCOUNT'] end def username \ No newline at end of file