Sha256: 3a1221709b819a406f9df5c637840407975ff550060f709a69c8ae7af55537f1

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

module ShipCompliant
  class << self
    attr_accessor :configuration
  end

  def self.configure
    yield(configuration)
  end

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

  # Stores runtime configuration to authenticate user.
  #
  #   ShipCompliant.configure do |c|
  #     c.partner_key = 'XXXX-XX-XXXXX'
  #     c.username = 'bob@example.com'
  #     c.password = 'secret'
  #     c.log = true # savon log
  #   end
  class Configuration
    attr_accessor :partner_key, :username, :password
    attr_accessor :wsdl, :log

    def initialize
      @log = true
      @wsdl = 'https://ws-dev.shipcompliant.com/services/1.2/coreservice.asmx?WSDL'
    end

    # Returns a +Hash+ for authenticating each API request.
    #
    #   {
    #     'PartnerKey' => 'XXXX-XX-XXXXX',
    #     'Username' => 'bob@example.com',
    #     'Password' => 'secret'
    #   }
    def credentials
      {
        'PartnerKey' => partner_key,
        'Username' => username,
        'Password' => password
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ship_compliant-0.2.1 lib/ship_compliant/configuration.rb
ship_compliant-0.2.0 lib/ship_compliant/configuration.rb
ship_compliant-0.1.2 lib/ship_compliant/configuration.rb
ship_compliant-0.1.1 lib/ship_compliant/configuration.rb
ship_compliant-0.1.0 lib/ship_compliant/configuration.rb