# Main Qubell module
module Qubell
  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield configuration
  end

  # Store configuration settings
  class Configuration
    attr_accessor :domain, :api_version, :endpoint, :username, :password

    def initialize
      @domain = 'https://express.qubell.com'
      @api_version = '1'
      @endpoint = "#{@domain}/api/#{@api_version}"
    end

    def to_s
      %({"domain": "#{@domain}","api_version": "#{@api_version}",) +
        %("username": "#{@username}","password": "#{@password}"})
    end
  end
end

# Main Qubell module
module Qubell
  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield configuration
  end

  # Store configuration settings
  class Configuration
    attr_accessor :domain, :api_version, :username, :password
    attr_reader :endpoint

    def initialize
      @domain = 'https://express.qubell.com'
      @api_version = '1'
    end

    def endpoint
      "#{@domain}/api/#{@api_version}"
    end

    def to_s
      %({"domain": "#{@domain}","api_version": "#{@api_version}",) +
        %("username": "#{@username}","password": "#{@password}"})
    end
  end
end

Make @endpoint attribute read-only in Qubell::Configuration class
Make @endpoint attribute read-only in Qubell::Configuration class
