Sha256: 367a4d882e344680fae642c444a68a471b1c0000d75f2d2c7a9b8055c3f85972

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true
module FinApps
  module REST
    # Represents the client configuration options
    class Configuration # :nodoc:
      using ObjectExtensions
      using HashExtensions

      attr_accessor :host,
                    :tenant_identifier, :tenant_token,
                    :user_identifier, :user_token,
                    :proxy, :timeout, :retry_limit, :log_level

      def initialize(options={})
        FinApps::REST::Defaults::DEFAULTS.merge(options.compact).each {|key, value| public_send("#{key}=", value) }
        raise FinApps::InvalidArgumentsError.new "Invalid argument. {host: #{host}}" unless valid_host?
        raise FinApps::InvalidArgumentsError.new "Invalid argument. {timeout: #{timeout}}" unless timeout.integer?
      end

      private

      def valid_host?
        host.start_with?('http://', 'https://')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
finapps-2.0.10 lib/finapps/rest/configuration.rb