et_fake_ccd 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/et_fake_ccd/command/upload_documents_to_case_command.rb +15 -0
- data/lib/et_fake_ccd/commands.rb +1 -0
- data/lib/et_fake_ccd/data_store_service.rb +17 -4
- data/lib/et_fake_ccd/service/data_store_app.rb +26 -0
- data/lib/et_fake_ccd/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83a716d870b84dcc8039c74488b683e9420ee619b64b9e4a8bbb1f8cdda9c206
|
|
4
|
+
data.tar.gz: 79d6631125e177edb274ba065a6283bf3ac3757741294716d94c25361ff6f2a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98399082f7d8b83f7e5e9f451b3ce1fc5098b2f1123c8081c9df5ce79e2ae57fe6e2da6973d3d4b99c234fd1c852086799b6463c4e469e0909ccec5db3872e8d
|
|
7
|
+
data.tar.gz: 7986d4fc6bc424632948331c17b2db36cb52a139a0af8a2a242bbe5b2bbbace19332289584a00e9f92a280a8920e6afdb8e6ff343e0eac62243a2f88604e5413
|
data/Gemfile.lock
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'active_model'
|
|
2
|
+
module EtFakeCcd
|
|
3
|
+
module Command
|
|
4
|
+
class UploadDocumentsToCaseCommand
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
include ActiveModel::Attributes
|
|
7
|
+
|
|
8
|
+
attribute :data
|
|
9
|
+
|
|
10
|
+
def self.from_json(json)
|
|
11
|
+
new data: json
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/et_fake_ccd/commands.rb
CHANGED
|
@@ -3,3 +3,4 @@ require 'et_fake_ccd/command/login_user_command'
|
|
|
3
3
|
require 'et_fake_ccd/command/create_case_command'
|
|
4
4
|
require 'et_fake_ccd/command/create_bulk_action_case_command'
|
|
5
5
|
require 'et_fake_ccd/command/upload_document_command'
|
|
6
|
+
require 'et_fake_ccd/command/upload_documents_to_case_command'
|
|
@@ -14,12 +14,20 @@ module EtFakeCcd
|
|
|
14
14
|
instance.list(jid: jid, ctid: ctid, filters: filters, page: page, sort_direction: sort_direction, page_size: page_size)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def self.update_case_data(json, jid:, ctid:, cid:)
|
|
18
|
+
instance.update_case_data(json, jid: jid, ctid: ctid, cid: cid)
|
|
19
|
+
end
|
|
20
|
+
|
|
17
21
|
def store_case_data(json, jid:, ctid:)
|
|
18
22
|
adapter.store(json, jid: jid, ctid: ctid)
|
|
19
23
|
end
|
|
20
24
|
|
|
25
|
+
def update_case_data(json, jid:, ctid:, cid:)
|
|
26
|
+
adapter.update_case_data(json, jid: jid, ctid: ctid, cid: cid)
|
|
27
|
+
end
|
|
28
|
+
|
|
21
29
|
def find_case_data_by_id(id, jid:, ctid:)
|
|
22
|
-
adapter.fetch_by_id(id, jid: jid, ctid: ctid)
|
|
30
|
+
adapter.fetch_by_id(id.to_s, jid: jid, ctid: ctid)
|
|
23
31
|
end
|
|
24
32
|
|
|
25
33
|
def list(jid:, ctid:, filters: {}, page: 1, sort_direction: 'asc', page_size: 25)
|
|
@@ -40,12 +48,12 @@ module EtFakeCcd
|
|
|
40
48
|
self.id = id + 1
|
|
41
49
|
data[jid] ||= {}
|
|
42
50
|
data[jid][ctid] ||= {}
|
|
43
|
-
data[jid][ctid][id] = json
|
|
44
|
-
id
|
|
51
|
+
data[jid][ctid][id.to_s] = json
|
|
52
|
+
id.to_s
|
|
45
53
|
end
|
|
46
54
|
|
|
47
55
|
def fetch_by_id(id, jid:, ctid:)
|
|
48
|
-
data.dig(jid, ctid, id)
|
|
56
|
+
data.dig(jid, ctid, id.to_s)
|
|
49
57
|
end
|
|
50
58
|
|
|
51
59
|
def fetch_all(jid:, ctid:, filters: {}, page: 1, sort_direction: 'asc', page_size: 25)
|
|
@@ -57,6 +65,11 @@ module EtFakeCcd
|
|
|
57
65
|
paginate(sorted_list, page_size: page_size, page: page)
|
|
58
66
|
end
|
|
59
67
|
|
|
68
|
+
def update_case_data(json, jid:, ctid:, cid:)
|
|
69
|
+
existing = fetch_by_id(cid.to_s, jid: jid, ctid: ctid)
|
|
70
|
+
existing['data'].merge!(json['data'])
|
|
71
|
+
end
|
|
72
|
+
|
|
60
73
|
private
|
|
61
74
|
|
|
62
75
|
attr_accessor :data, :id
|
|
@@ -36,6 +36,27 @@ module EtFakeCcd
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
|
+
r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "cases", String, "events" do |uid, jid, ctid, cid|
|
|
40
|
+
r.post do
|
|
41
|
+
if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
|
|
42
|
+
r.halt 403, forbidden_error_for(r)
|
|
43
|
+
break
|
|
44
|
+
end
|
|
45
|
+
json = JSON.parse(r.body.read)
|
|
46
|
+
command = case json.dig('event', 'id')
|
|
47
|
+
when 'uploadDocument' then ::EtFakeCcd::Command::UploadDocumentsToCaseCommand.from_json json
|
|
48
|
+
else
|
|
49
|
+
r.halt 400, unknown_event_error_for(r)
|
|
50
|
+
end
|
|
51
|
+
if command.valid?
|
|
52
|
+
::EtFakeCcd::DataStoreService.update_case_data(json, jid: jid, ctid: ctid, cid: cid)
|
|
53
|
+
case_updated_response(cid, uid, jid, ctid)
|
|
54
|
+
else
|
|
55
|
+
r.halt 422, render_error_for(command, r)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|
|
39
60
|
r.is "caseworkers", String, "jurisdictions", String, "case-types", String, "cases" do |uid, jid, ctid|
|
|
40
61
|
r.post do
|
|
41
62
|
if !EtFakeCcd::AuthService.validate_service_token(r.headers['ServiceAuthorization'].gsub(/\ABearer /, '')) || !EtFakeCcd::AuthService.validate_user_token(r.headers['Authorization'].gsub(/\ABearer /, ''))
|
|
@@ -153,6 +174,11 @@ module EtFakeCcd
|
|
|
153
174
|
JSON.generate(j)
|
|
154
175
|
end
|
|
155
176
|
|
|
177
|
+
def case_updated_response(id, uid, jid, ctid)
|
|
178
|
+
j = case_hash(ctid, id, jid)
|
|
179
|
+
JSON.generate(j)
|
|
180
|
+
end
|
|
181
|
+
|
|
156
182
|
def case_hash(ctid, id, jid)
|
|
157
183
|
{
|
|
158
184
|
"id": id,
|
data/lib/et_fake_ccd/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: et_fake_ccd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.20
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gary Taylor
|
|
@@ -177,6 +177,7 @@ files:
|
|
|
177
177
|
- lib/et_fake_ccd/command/lease_command.rb
|
|
178
178
|
- lib/et_fake_ccd/command/login_user_command.rb
|
|
179
179
|
- lib/et_fake_ccd/command/upload_document_command.rb
|
|
180
|
+
- lib/et_fake_ccd/command/upload_documents_to_case_command.rb
|
|
180
181
|
- lib/et_fake_ccd/commands.rb
|
|
181
182
|
- lib/et_fake_ccd/config.rb
|
|
182
183
|
- lib/et_fake_ccd/data_store_service.rb
|