require 'httparty'
require 'campi/version'
require 'active_support/dependencies/autoload'
require 'active_support/cache'
require 'dalli'

module Campi
  extend ActiveSupport::Autoload
  autoload :Client

  class << self
    attr_accessor :configuration, :cache
  end

  def self.configure
    self.configuration ||= Configuration.new
    yield(configuration)
  end

  def self.configure_cache
    self.cache ||= Cache.new
    yield(cache)
  end

  class Configuration
    attr_accessor :basecamp_id, :username, :password, :application_name, :application_contact

    def initialize
      @basecamp_id = nil
      @username = nil
      @password = nil
      @application_name = nil
      @application_contact = nil
    end
  end

  class Cache
    attr_accessor :store_option, :parameters
    attr_reader :store

    def initialize
      @store_option = nil
      @parameters = nil
      @store = nil
    end

    def store
      @store ||= ActiveSupport::Cache.lookup_store(@store_option, @parameters)
    end
  end
end
