Sha256: 685d8d9665183ca3d34351c819e0c86bd75112f764f5e0505578ea6b45c3c7de

Contents?: true

Size: 967 Bytes

Versions: 7

Compression:

Stored size: 967 Bytes

Contents

module ThreeScaleToolbox
  class ThreeScaleClientFactory
    class << self
      def get(remotes, remote_str, verify_ssl, verbose = false)
        new(remotes, remote_str, verify_ssl, verbose).call
      end
    end

    attr_reader :remotes, :remote_str, :verify_ssl, :verbose

    def initialize(remotes, remote_str, verify_ssl, verbose)
      @remotes = remotes
      @remote_str = remote_str
      @verify_ssl = verify_ssl
      @verbose = verbose
    end

    def call
      begin
        remote = Remotes.from_uri(remote_str)
      rescue InvalidUrlError
        remote = remotes.fetch(remote_str)
      end

      client = remote_client(**remote.merge(verify_ssl: verify_ssl))
      client = ProxyLogger.new(client) if verbose
      RemoteCache.new(client)
    end

    private

    def remote_client(endpoint:, authentication:, verify_ssl:)
      ThreeScale::API.new(endpoint: endpoint, provider_key: authentication, verify_ssl: verify_ssl)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
3scale_toolbox-0.19.3 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/3scale_client_factory.rb