Class: KB::ClientResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/kb/client_resolver.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bounded_context, entity, version = 'v1', template: ENV['KB_API_URL_TEMPLATE']) ⇒ ClientResolver

Returns a new instance of ClientResolver.



47
48
49
50
51
52
# File 'lib/kb/client_resolver.rb', line 47

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

Instance Attribute Details

#bounded_contextObject (readonly)

Returns the value of attribute bounded_context.



45
46
47
# File 'lib/kb/client_resolver.rb', line 45

def bounded_context
  @bounded_context
end

#entityObject (readonly)

Returns the value of attribute entity.



45
46
47
# File 'lib/kb/client_resolver.rb', line 45

def entity
  @entity
end

#templateObject (readonly)

Returns the value of attribute template.



45
46
47
# File 'lib/kb/client_resolver.rb', line 45

def template
  @template
end

#versionObject (readonly)

Returns the value of attribute version.



45
46
47
# File 'lib/kb/client_resolver.rb', line 45

def version
  @version
end

Class Method Details

.adminObject



8
9
10
# File 'lib/kb/client_resolver.rb', line 8

def admin
  call :petfamily, :admin
end

.breedObject



24
25
26
# File 'lib/kb/client_resolver.rb', line 24

def breed
  call :petfamily, :breeds
end

.call(*args, **kwargs, &block) ⇒ Object



40
41
42
# File 'lib/kb/client_resolver.rb', line 40

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

.consultationObject



4
5
6
# File 'lib/kb/client_resolver.rb', line 4

def consultation
  call :petfamily, :consultations, :v1
end

.hubspotObject



36
37
38
# File 'lib/kb/client_resolver.rb', line 36

def hubspot
  call :petfamily, :hubspot
end

.petObject



16
17
18
# File 'lib/kb/client_resolver.rb', line 16

def pet
  call :petfamily, :pets
end

.pet_contractObject



20
21
22
# File 'lib/kb/client_resolver.rb', line 20

def pet_contract
  call :petfamily, :petcontracts
end

.pet_parentObject



12
13
14
# File 'lib/kb/client_resolver.rb', line 12

def pet_parent
  call :petfamily, :petparents
end

.planObject



28
29
30
# File 'lib/kb/client_resolver.rb', line 28

def plan
  call :petfamily, :plans
end

.productObject



32
33
34
# File 'lib/kb/client_resolver.rb', line 32

def product
  call :petfamily, :products
end

Instance Method Details

#base_urlObject



58
59
60
# File 'lib/kb/client_resolver.rb', line 58

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

#callObject



54
55
56
# File 'lib/kb/client_resolver.rb', line 54

def call
  KB::Client.new base_url
end