Sha256: 685e9a02c9fa2170efc4962b211ea8b6913c559af782a8a2a938f95658c28d6c

Contents?: true

Size: 806 Bytes

Versions: 2

Compression:

Stored size: 806 Bytes

Contents

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

    attr_reader :remotes, :remote_str, :verify_ssl

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

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

      remote_client(remote.merge(verify_ssl: verify_ssl))
    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

2 entries across 2 versions & 1 rubygems

Version Path
3scale_toolbox-0.7.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.6.0 lib/3scale_toolbox/3scale_client_factory.rb