laa-fee-calculator-client 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d3882b5345bcdd3d6d939511a330c1edeef6efaff2174fb7cafeaa8183e77fb
4
- data.tar.gz: 0f86f88039aa2d1254d3d763eb6ce28c8ba8085e226faa13c5291b8471788433
3
+ metadata.gz: 3da85f79e91ae96f2fba3ff03befa81ae2341d56559d5de095fadef63af6d118
4
+ data.tar.gz: dd17564a3375b73ea9fc5a8c846f2a41eb27db1ca821df9be10cf2fab9b6e138
5
5
  SHA512:
6
- metadata.gz: 496b6d25799930f471d350092d328e591823448600c607cfbcdcffc7fa20a6522cfdeceb4cb3a765a27c1b481649a214a65dabc950dea00461c5771b9f6a2fda
7
- data.tar.gz: 6571346cf84d19b3ad26c0a7c0202be4fa169cc6ab3c0bf9dab93101d4c7b7e1b72f11559bb9f3d094ccebd4457360c35f326a64538d22461af7c4b4b93f98b5
6
+ metadata.gz: 429ff6ad54a273c293102978e6f041e672ad6b9c883338ae2be5eb0ad0d57023bfa5eb200bd0301f8b8a9f63590b8ee181f014054d353736fb6da76558cfaf0f
7
+ data.tar.gz: b44b780ab5cb138df048aa012d66001d9cf9f7253cef1cfd59d8d4181d73683b5d24e0ff6f23dd08fa7dd0ae59cdafd2a9179757fa29f0d90329844658acb2f3
data/README.md CHANGED
@@ -96,6 +96,7 @@ fee_scheme.offence_classes
96
96
  fee_scheme.fee_types
97
97
  fee_scheme.modifier_types
98
98
  fee_scheme.units
99
+ fee_scheme.prices # defaults to first page (of 100)
99
100
 
100
101
  # filtered
101
102
  # by id
@@ -104,6 +105,11 @@ fee_scheme.modifier_types(1)
104
105
 
105
106
  # by options
106
107
  fee_scheme.modifier_types(fee_type_code: 'AGFS_APPEAL_CON')
108
+ fee_scheme.prices(scenario: 5, advocate_type: 'QC')
109
+
110
+ # searching (as opposed to query parameters filtering above)
111
+ # by attribute values
112
+ fee_scheme.scenarios.find_by(code: 'AS000002')
107
113
  ```
108
114
 
109
115
  ###### Calculate
@@ -164,11 +170,13 @@ Bug reports and pull requests are welcome on GitHub at [ministryofjustice/laa-fe
164
170
 
165
171
  2. Run `bin/ruby_version_test` to test against ruby versions (2.4+ supported at present)
166
172
 
167
- 3. Update the version in `lib/laa/fee_calculator/version` using [semantic versioning](https://guides.rubygems.org/patterns/#semantic-versioning).
173
+ 3. Update the VERSION in `lib/laa/fee_calculator/version` using [semantic versioning](https://guides.rubygems.org/patterns/#semantic-versioning).
174
+
175
+ 4. Update the VERSION_RELEASED in `lib/laa/fee_calculator/version` to the date you intend to publish/release the version.
168
176
 
169
- 4. PR the change, code-review, merge.
177
+ 5. PR the change, code-review, merge.
170
178
 
171
- 5. Pull master and run rake task below to publish
179
+ 6. Pull master and run rake task below to publish
172
180
 
173
181
  ```bash
174
182
  $ rake release
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.version = LAA::FeeCalculator::VERSION
10
10
  spec.authors = ['Joel Sugarman', 'Ministry of Justice']
11
11
  spec.email = ['joel.sugarman@digital.justice.gov.uk', 'tools@digital.justice.gov.uk']
12
- spec.date = '2018-06-29'
12
+ spec.date = LAA::FeeCalculator::VERSION_RELEASED
13
13
  spec.summary = 'Ruby client for the Legal Aid Agency fee calculator API'
14
14
  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
15
  spec.homepage = 'https://github.com/ministryofjustice/laa-fee-calculator-client'
@@ -28,6 +28,7 @@ module LAA
28
28
  fstruct = JSON.parse(json, object_class: FeeScheme)
29
29
  return fstruct unless fstruct.respond_to?(:results)
30
30
  return fstruct.results.first if fstruct.results.size.eql?(1)
31
+
31
32
  fstruct.results
32
33
  end
33
34
  end
@@ -8,6 +8,14 @@ module LAA
8
8
  end
9
9
 
10
10
  module ClassMethods
11
+ module Searchable
12
+ def find_by(**options)
13
+ find do |ostruct|
14
+ options.map { |k, v| ostruct[k].eql?(v) }.all?
15
+ end
16
+ end
17
+ end
18
+
11
19
  def has_many(association)
12
20
  define_method("#{association}_uri".to_sym) do |scheme_pk = nil, id = nil|
13
21
  uri = scheme_pk.nil? ? "#{association.to_s.tr('_', '-')}/" : "fee-schemes/#{scheme_pk}/#{association.to_s.tr('_', '-')}/"
@@ -24,7 +32,8 @@ module LAA
24
32
 
25
33
  ostruct = JSON.parse(json, object_class: OpenStruct)
26
34
  return ostruct unless ostruct.respond_to?(:results)
27
- ostruct.results
35
+
36
+ ostruct.results.extend Searchable
28
37
  end
29
38
  end
30
39
  end
@@ -2,7 +2,8 @@
2
2
 
3
3
  module LAA
4
4
  module FeeCalculator
5
- VERSION = "0.1.3"
5
+ VERSION = "0.2.0"
6
+ VERSION_RELEASED = "2018-09-18"
6
7
  USER_AGENT = "laa-fee-calculator-client/#{VERSION}"
7
8
  end
8
9
  end
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: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Sugarman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-06-29 00:00:00.000000000 Z
12
+ date: 2018-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable