Class: LAA::FeeCalculator::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/laa/fee_calculator/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



15
16
17
# File 'lib/laa/fee_calculator/client.rb', line 15

def initialize
  @connection = Connection.instance
end

Instance Attribute Details

#connectionObject (readonly) Also known as: conn

Returns the value of attribute connection.



8
9
10
# File 'lib/laa/fee_calculator/client.rb', line 8

def connection
  @connection
end

#fee_schemeObject

Returns the value of attribute fee_scheme.



11
12
13
# File 'lib/laa/fee_calculator/client.rb', line 11

def fee_scheme
  @fee_scheme
end

Instance Method Details

#fee_schemes(id = nil, **options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/laa/fee_calculator/client.rb', line 19

def fee_schemes(id = nil, **options)
  uri = fee_schemes_uri(id || options[:id])
  filtered_params = options.except(:id)

  json = get(uri, filtered_params).body

  fstruct = JSON.parse(json, object_class: FeeScheme)
  return fstruct unless fstruct.respond_to?(:results)
  return fstruct.results.first if fstruct.results.size.eql?(1)

  fstruct.results
end