Sha256: 9aa93958d8076c18b6630f88149c294e14ce7bd61374c1dbacf3b22806ef5cb8

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

module KB
  class ClientResolver
    class << self
      def consultation
        call :petfamily, :consultations, :v1
      end

      def admin
        call :petfamily, :admin
      end

      def pet_parent
        call :petfamily, :petparents
      end

      def pet
        call :petfamily, :pets
      end

      def pet_contract
        call :petfamily, :petcontracts
      end

      def breed
        call :petfamily, :breeds
      end

      def plan
        call :petfamily, :plans
      end

      def product
        call :petfamily, :products
      end

      def hubspot
        call :petfamily, :hubspot
      end

      def call(*args, **kwargs, &block)
        new(*args, **kwargs, &block).call
      end
    end

    attr_reader :template, :bounded_context, :entity, :version

    def initialize(bounded_context, entity, version = 'v1', template: ENV['KB_API_URL_TEMPLATE'])
      @bounded_context = bounded_context
      @entity = entity
      @version = version
      @template = template
    end

    def call
      KB::Client.new base_url
    end

    def base_url
      format(template, bounded_context: bounded_context, entity: entity, version: version).gsub('..', '.')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
barkibu-kb-0.27.0 lib/kb/client_resolver.rb
barkibu-kb-0.26.0 lib/kb/client_resolver.rb
barkibu-kb-0.25.0 lib/kb/client_resolver.rb
barkibu-kb-0.24.1 lib/kb/client_resolver.rb
barkibu-kb-0.24.0 lib/kb/client_resolver.rb
barkibu-kb-0.23.0 lib/kb/client_resolver.rb
barkibu-kb-0.22.0 lib/kb/client_resolver.rb