Sha256: 066e88712bae4ce295fd17e7db459534e9888203277ab8428f20abf0c9213c48

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 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, &block)
        new(*args, &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.21.0 lib/kb/client_resolver.rb
barkibu-kb-0.20.0 lib/kb/client_resolver.rb
barkibu-kb-0.19.0 lib/kb/client_resolver.rb
barkibu-kb-0.18.0 lib/kb/client_resolver.rb
barkibu-kb-0.17.0 lib/kb/client_resolver.rb
barkibu-kb-0.16.2 lib/kb/client_resolver.rb
barkibu-kb-0.16.1 lib/kb/client_resolver.rb