laa-fee-calculator-client 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile +1 -1
- data/README.md +3 -5
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/laa-fee-calculator-client.gemspec +6 -5
- data/lib/laa/fee_calculator/calculator.rb +3 -10
- data/lib/laa/fee_calculator/client.rb +13 -7
- data/lib/laa/fee_calculator/has_manyable.rb +15 -10
- data/lib/laa/fee_calculator/version.rb +1 -2
- data/lib/laa/fee_calculator.rb +1 -1
- metadata +47 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 846930f03ac36c9166dcba3a25cc3b2b552f32b31861043fa1908741912da754
|
4
|
+
data.tar.gz: 3b5ec2435a93a7584eff62facedf12a8ab3c754f6f83bcabc625b1ef8fc96c07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 953bba0d471745c2502a7dc9b0d7cc21c1a58fae009ce09777d419b4a9cc7177b25593d90476ed3536b2f17092b2f124336090dd6c600b7567021dc0f2d26113
|
7
|
+
data.tar.gz: 44e1ca22ff932959a6ddfab3046120b8d619647178e9e37957b23539176cee281916e24f23cc6b4fb409b0c58862c0650bf460eb2ee92032c0dbd0a0472e4e25
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -177,13 +177,11 @@ Bug reports and pull requests are welcome on GitHub at [ministryofjustice/laa-fe
|
|
177
177
|
|
178
178
|
3. Update the VERSION in `lib/laa/fee_calculator/version` using [semantic versioning](https://guides.rubygems.org/patterns/#semantic-versioning).
|
179
179
|
|
180
|
-
4. Update the
|
180
|
+
4. Update the `CHANGELOG.md` - format/documentation standards specified at top of file.
|
181
181
|
|
182
|
-
5.
|
182
|
+
5. PR the change, code-review, merge.
|
183
183
|
|
184
|
-
6.
|
185
|
-
|
186
|
-
7. Pull master and run rake task below to publish. Note, you will need a [rubygems](https://rubygems.org/) account with gem owner privileges and have configured your `~/.gem/credentials` in order for this task to complete successfully.
|
184
|
+
6. Pull master and run rake task below to publish. Note, you will need a [rubygems](https://rubygems.org/) account with gem owner privileges and have configured your `~/.gem/credentials` in order for this task to complete successfully.
|
187
185
|
|
188
186
|
```bash
|
189
187
|
$ rake release
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'laa/fee_calculator'
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -16,5 +16,5 @@ LAA::FeeCalculator.configure do |config|
|
|
16
16
|
config.host = 'http://localhost:8000/api/v1'
|
17
17
|
end
|
18
18
|
|
19
|
-
require
|
19
|
+
require 'irb'
|
20
20
|
IRB.start(__FILE__)
|
@@ -9,12 +9,11 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = LAA::FeeCalculator::VERSION
|
10
10
|
spec.authors = ['Katharine Ahern', 'Ministry of Justice']
|
11
11
|
spec.email = ['katharine.ahern@digital.justice.gov.uk', 'joel.sugarman@digital.justice.gov.uk', 'tools@digital.justice.gov.uk']
|
12
|
-
spec.date = LAA::FeeCalculator::VERSION_RELEASED
|
13
12
|
spec.summary = 'Ruby client for the Legal Aid Agency fee calculator API'
|
14
|
-
spec.description =
|
13
|
+
spec.description = 'Ruby client for the Ministry of Justices LAA fee calculator API. A simple interface for transparent calling of the API endpoints to query data and return calculated fee amounts.'
|
15
14
|
spec.homepage = 'https://github.com/ministryofjustice/laa-fee-calculator-client'
|
16
15
|
spec.license = 'MIT'
|
17
|
-
spec.extra_rdoc_files = [
|
16
|
+
spec.extra_rdoc_files = ['LICENSE', 'README.md']
|
18
17
|
|
19
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
19
|
f.match(%r{^(test/|spec/|features/|\..*)})
|
@@ -26,14 +25,16 @@ Gem::Specification.new do |spec|
|
|
26
25
|
# see bin/ruby_version_test
|
27
26
|
spec.required_ruby_version = '>= 2.6.0'
|
28
27
|
|
29
|
-
spec.add_runtime_dependency 'addressable', '~> 2.3', '>= 2.3.7'
|
30
28
|
spec.add_runtime_dependency 'faraday', '~> 1.0'
|
31
29
|
|
32
30
|
spec.add_development_dependency 'awesome_print'
|
33
31
|
spec.add_development_dependency 'rake', '~> 13.0'
|
34
32
|
spec.add_development_dependency 'rb-readline'
|
35
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
|
-
spec.add_development_dependency 'rubocop', '~>
|
34
|
+
spec.add_development_dependency 'rubocop', '~> 1.28'
|
35
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.13'
|
36
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6'
|
37
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
|
37
38
|
spec.add_development_dependency 'vcr'
|
38
39
|
spec.add_development_dependency 'webmock'
|
39
40
|
end
|
@@ -6,25 +6,18 @@ module LAA
|
|
6
6
|
extend Forwardable
|
7
7
|
def_delegators :connection, :get
|
8
8
|
|
9
|
-
attr_reader :scheme_pk, :options
|
10
|
-
|
11
9
|
def initialize(scheme_pk, options)
|
12
|
-
@
|
13
|
-
@
|
10
|
+
@uri = "fee-schemes/#{scheme_pk}/calculate/"
|
11
|
+
@filtered_params = options.reject { |k, _v| k.eql?(:id) }
|
14
12
|
end
|
15
13
|
|
16
14
|
def call
|
17
|
-
|
18
|
-
json = get(uri).body
|
15
|
+
json = get(@uri, @filtered_params).body
|
19
16
|
JSON.parse(json)['amount']
|
20
17
|
end
|
21
18
|
|
22
19
|
private
|
23
20
|
|
24
|
-
def uri
|
25
|
-
@uri ||= Addressable::URI.parse("fee-schemes/#{scheme_pk}/calculate/")
|
26
|
-
end
|
27
|
-
|
28
21
|
def connection
|
29
22
|
@connection ||= Connection.instance
|
30
23
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module LAA
|
4
4
|
module FeeCalculator
|
@@ -17,13 +17,11 @@ module LAA
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def fee_schemes(id = nil, **options)
|
20
|
-
uri =
|
21
|
-
|
22
|
-
|
23
|
-
uri = Addressable::URI.parse(uri)
|
24
|
-
uri.query_values = options.reject { |k, _v| k.eql?(:id) }
|
20
|
+
uri = fee_schemes_uri(id || options[:id])
|
21
|
+
filtered_params = options.reject { |k, _| k.eql?(:id) }
|
22
|
+
# Ruby 3.0+; filtered_params = options.except(:id)
|
25
23
|
|
26
|
-
json = get(uri).body
|
24
|
+
json = get(uri, filtered_params).body
|
27
25
|
|
28
26
|
fstruct = JSON.parse(json, object_class: FeeScheme)
|
29
27
|
return fstruct unless fstruct.respond_to?(:results)
|
@@ -31,6 +29,14 @@ module LAA
|
|
31
29
|
|
32
30
|
fstruct.results
|
33
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def fee_schemes_uri(id)
|
36
|
+
return "fee-schemes/#{id}/" if id
|
37
|
+
|
38
|
+
'fee-schemes/'
|
39
|
+
end
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
module LAA
|
@@ -17,18 +19,11 @@ module LAA
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def has_many(association)
|
20
|
-
define_method("#{association}_uri".to_sym) do |scheme_pk = nil, id = nil|
|
21
|
-
uri = scheme_pk.nil? ? "#{association.to_s.tr('_', '-')}/" : "fee-schemes/#{scheme_pk}/#{association.to_s.tr('_', '-')}/"
|
22
|
-
uri = uri.concat(id.to_s, '/') unless id.nil?
|
23
|
-
Addressable::URI.parse(uri)
|
24
|
-
end
|
25
|
-
|
26
22
|
define_method(association) do |id = nil, **options|
|
27
|
-
id
|
28
|
-
|
29
|
-
uri.query_values = options.reject { |k, _v| k.eql?(:id) }
|
23
|
+
uri = uri_for(association, id: id || options[:id])
|
24
|
+
filtered_params = options.reject { |k, _v| k.eql?(:id) }
|
30
25
|
|
31
|
-
json = get(uri).body
|
26
|
+
json = get(uri, filtered_params).body
|
32
27
|
|
33
28
|
ostruct = JSON.parse(json, object_class: OpenStruct)
|
34
29
|
return ostruct unless ostruct.respond_to?(:results)
|
@@ -37,6 +32,16 @@ module LAA
|
|
37
32
|
end
|
38
33
|
end
|
39
34
|
end
|
35
|
+
|
36
|
+
def uri_for(association, id: nil)
|
37
|
+
return "#{base_fee_scheme_uri}#{association.to_s.tr('_', '-')}/" if id.nil?
|
38
|
+
|
39
|
+
"#{base_fee_scheme_uri}#{association.to_s.tr('_', '-')}/#{id}/"
|
40
|
+
end
|
41
|
+
|
42
|
+
def base_fee_scheme_uri
|
43
|
+
id ? "fee-schemes/#{id}/" : ''
|
44
|
+
end
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
data/lib/laa/fee_calculator.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: laa-fee-calculator-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katharine Ahern
|
@@ -9,28 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-04-
|
12
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: addressable
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '2.3'
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 2.3.7
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
requirements:
|
28
|
-
- - "~>"
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '2.3'
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.3.7
|
34
14
|
- !ruby/object:Gem::Dependency
|
35
15
|
name: faraday
|
36
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,14 +87,56 @@ dependencies:
|
|
107
87
|
requirements:
|
108
88
|
- - "~>"
|
109
89
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
90
|
+
version: '1.28'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.28'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rubocop-performance
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.13'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.13'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rubocop-rake
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0.6'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0.6'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rubocop-rspec
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '2.10'
|
111
133
|
type: :development
|
112
134
|
prerelease: false
|
113
135
|
version_requirements: !ruby/object:Gem::Requirement
|
114
136
|
requirements:
|
115
137
|
- - "~>"
|
116
138
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
139
|
+
version: '2.10'
|
118
140
|
- !ruby/object:Gem::Dependency
|
119
141
|
name: vcr
|
120
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
217
|
- !ruby/object:Gem::Version
|
196
218
|
version: '0'
|
197
219
|
requirements: []
|
198
|
-
rubygems_version: 3.1.
|
220
|
+
rubygems_version: 3.1.6
|
199
221
|
signing_key:
|
200
222
|
specification_version: 4
|
201
223
|
summary: Ruby client for the Legal Aid Agency fee calculator API
|