Class: LAA::FeeCalculator::Client
- Inherits:
-
Object
- Object
- LAA::FeeCalculator::Client
- Extended by:
- Forwardable
- Defined in:
- lib/laa/fee_calculator/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
(also: #conn)
readonly
Returns the value of attribute connection.
-
#fee_scheme ⇒ Object
Returns the value of attribute fee_scheme.
Instance Method Summary collapse
- #fee_schemes(id = nil, **options) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
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
#connection ⇒ Object (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_scheme ⇒ Object
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 31 32 |
# File 'lib/laa/fee_calculator/client.rb', line 19 def fee_schemes(id = nil, **) uri = 'fee-schemes/' id ||= .fetch(:id, nil) uri.concat(id.to_s, "/") if id uri = Addressable::URI.parse(uri) uri.query_values = .reject { |k, _v| k.eql?(:id) } json = get(uri).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 |