Sha256: 81d8ffa14b9a0af169600cc0e93078361ccdbe02fe4f8fbc7d6f5ebe8609579d

Contents?: true

Size: 1.83 KB

Versions: 13

Compression:

Stored size: 1.83 KB

Contents

module NetSuite
  module Configuration
    extend self

    def reset!
      attributes.clear
    end

    def attributes
      @attributes ||= {}
    end

    def connection
      attributes[:connection] ||= Savon::Client.new(self.wsdl)
    end

    def wsdl=(wsdl)
      attributes[:wsdl] = wsdl
    end

    def wsdl(wsdl = nil)
      if wsdl
        self.wsdl = wsdl
      else
        attributes[:wsdl] ||= File.expand_path('../../../wsdl/2011_02.wsdl', __FILE__)
      end
    end

    def auth_header
      attributes[:auth_header] ||= {
        'platformMsgs:passport' => {
          'platformCore:email'    => email,
          'platformCore:password' => password,
          'platformCore:account'  => account.to_s
        }
      }
    end

    def email=(email)
      attributes[:email] = email
    end

    def email(email = nil)
      if email
        self.email = email
      else
        attributes[:email] ||
        raise(ConfigurationError,
          '#email is a required configuration value. Please set it by calling NetSuite::Configuration.email = "me@example.com"')
      end
    end

    def password=(password)
      attributes[:password] = password
    end

    def password(password = nil)
      if password
        self.password = password
      else
        attributes[:password] ||
        raise(ConfigurationError,
          '#password is a required configuration value. Please set it by calling NetSuite::Configuration.password = "my_pass"')
      end
    end

    def account=(account)
      attributes[:account] = account
    end

    def account(account = nil)
      if account
        self.account = account
      else
        attributes[:account] ||
        raise(ConfigurationError,
          '#account is a required configuration value. Please set it by calling NetSuite::Configuration.account = 1234')
      end
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
netsuite-0.0.17 lib/netsuite/configuration.rb
netsuite-0.0.16 lib/netsuite/configuration.rb
netsuite-0.0.15 lib/netsuite/configuration.rb
netsuite-0.0.14 lib/netsuite/configuration.rb
netsuite-0.0.13 lib/netsuite/configuration.rb
netsuite-0.0.12 lib/netsuite/configuration.rb
netsuite-0.0.11 lib/netsuite/configuration.rb
netsuite-0.0.10 lib/netsuite/configuration.rb
netsuite-0.0.9 lib/netsuite/configuration.rb
netsuite-0.0.8 lib/netsuite/configuration.rb
netsuite-0.0.7 lib/netsuite/configuration.rb
netsuite-0.0.6 lib/netsuite/configuration.rb
netsuite-0.0.5 lib/netsuite/configuration.rb