Sha256: 98afb0357763428efcb06db18c5f72252059cd64354ae2403269ee04154e927d

Contents?: true

Size: 971 Bytes

Versions: 4

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true

module TopsConnect
  class Configuration
    attr_reader :subscription_key, :client_id, :software_key, :zone

    def subscription_key=(key)
      unless key&.match?(/\A\h{32}\z/i)
        raise 'Invalid TOPS Subscription Key. Expected 32 hex characters.'
      end

      @subscription_key = key.downcase
    end

    def client_id=(key)
      unless key&.match?(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/)
        raise 'Invalid TOPS Client ID. Expected a GUID.'
      end

      @client_id = key.upcase
    end

    def software_key=(key)
      unless key&.match?(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/)
        raise 'Invalid TOPS Software Key. Expected a GUID.'
      end

      @software_key = key.upcase
    end

    def zone=(new_zone)
      unless %i[broad limited sandbox].include?(new_zone.to_sym)
        raise 'Invalid TOPS Zone. Accepted values are broad, limited, sandbox.'
      end

      @zone = new_zone.to_sym
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tops_connect-0.6.3 lib/tops_connect/configuration.rb
tops_connect-0.6.2 lib/tops_connect/configuration.rb
tops_connect-0.6.1 lib/tops_connect/configuration.rb
tops_connect-0.6.0 lib/tops_connect/configuration.rb