ledger_sync-domains 1.0.3 → 1.1.0
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/CHANGELOG.md +14 -0
- data/Gemfile.lock +6 -6
- data/lib/ledger_sync/domains/operation/add.rb +12 -6
- data/lib/ledger_sync/domains/operation/remove.rb +5 -5
- data/lib/ledger_sync/domains/operation/resource.rb +6 -0
- data/lib/ledger_sync/domains/operation/update.rb +7 -6
- data/lib/ledger_sync/domains/serializer/relation.rb +2 -0
- data/lib/ledger_sync/domains/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61c31a4c2c548923425e509c754d43c9edfacf8ef8e2b2ce0a0f77c7c67acd74
|
|
4
|
+
data.tar.gz: a305b2db6f2f4a040493c5b9da40662a76d9f9086404a76baa933eda5b0de88d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66974930b8b9a27d57b004765de9562c48d751afe50cc971e0fc416ca52c0e0202d23061eba6bc17533130a7d147977b9e7eed8a0dff24fca9d48e2cced63f0d
|
|
7
|
+
data.tar.gz: c0dbfcd42ecf473460084cf10cbf4b99d5dfbd45e9cac6ad05a107c006fd048712e37ac373dfd44475bc28ad20e804a5e2bf2eb817783170f6fbff13c15946fc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.1.0] - 2022-02-25
|
|
4
|
+
|
|
5
|
+
- Feature: Add and Update operations uses `data` params for setting model attributes
|
|
6
|
+
- Chore: minor indentation cleanup
|
|
7
|
+
- Feature: add method to output validation errors as a string
|
|
8
|
+
|
|
9
|
+
## [1.0.5] - 2022-02-17
|
|
10
|
+
|
|
11
|
+
- Fix: Do not serialize unset reader relational method
|
|
12
|
+
|
|
13
|
+
## [1.0.4] - 2022-02-15
|
|
14
|
+
|
|
15
|
+
- Fix: Do not serialize unset relationships
|
|
16
|
+
|
|
3
17
|
## [1.0.3] - 2022-02-12
|
|
4
18
|
|
|
5
19
|
- Fix: Resource shorthand operations uses limit instead of query
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ledger_sync-domains (1.0
|
|
4
|
+
ledger_sync-domains (1.1.0)
|
|
5
5
|
ledger_sync (~> 2.3.1)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -33,7 +33,7 @@ GEM
|
|
|
33
33
|
dry-logic (1.2.0)
|
|
34
34
|
concurrent-ruby (~> 1.0)
|
|
35
35
|
dry-core (~> 0.5, >= 0.5)
|
|
36
|
-
dry-schema (1.
|
|
36
|
+
dry-schema (1.9.1)
|
|
37
37
|
concurrent-ruby (~> 1.0)
|
|
38
38
|
dry-configurable (~> 0.13, >= 0.13.0)
|
|
39
39
|
dry-core (~> 0.5, >= 0.5)
|
|
@@ -46,15 +46,15 @@ GEM
|
|
|
46
46
|
dry-core (~> 0.5, >= 0.5)
|
|
47
47
|
dry-inflector (~> 0.1, >= 0.1.2)
|
|
48
48
|
dry-logic (~> 1.0, >= 1.0.2)
|
|
49
|
-
dry-validation (1.
|
|
49
|
+
dry-validation (1.8.0)
|
|
50
50
|
concurrent-ruby (~> 1.0)
|
|
51
51
|
dry-container (~> 0.7, >= 0.7.1)
|
|
52
52
|
dry-core (~> 0.5, >= 0.5)
|
|
53
53
|
dry-initializer (~> 3.0)
|
|
54
|
-
dry-schema (~> 1.
|
|
54
|
+
dry-schema (~> 1.9, >= 1.9.1)
|
|
55
55
|
factory_bot (6.2.0)
|
|
56
56
|
activesupport (>= 5.0.0)
|
|
57
|
-
faraday (1.
|
|
57
|
+
faraday (1.10.0)
|
|
58
58
|
faraday-em_http (~> 1.0)
|
|
59
59
|
faraday-em_synchrony (~> 1.0)
|
|
60
60
|
faraday-excon (~> 1.1)
|
|
@@ -103,7 +103,7 @@ GEM
|
|
|
103
103
|
simply_serializable (>= 1.5.1)
|
|
104
104
|
minitest (5.15.0)
|
|
105
105
|
multipart-post (2.1.1)
|
|
106
|
-
nokogiri (1.13.
|
|
106
|
+
nokogiri (1.13.3-x86_64-linux)
|
|
107
107
|
racc (~> 1.4)
|
|
108
108
|
openssl (2.2.1)
|
|
109
109
|
ipaddr
|
|
@@ -7,6 +7,12 @@ module LedgerSync
|
|
|
7
7
|
module Domains
|
|
8
8
|
class Operation
|
|
9
9
|
class Add < Resource
|
|
10
|
+
class Contract < LedgerSync::Ledgers::Contract
|
|
11
|
+
params do
|
|
12
|
+
required(:data).value(:hash)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
10
16
|
private
|
|
11
17
|
|
|
12
18
|
def operate
|
|
@@ -21,7 +27,7 @@ module LedgerSync
|
|
|
21
27
|
end
|
|
22
28
|
|
|
23
29
|
def resource
|
|
24
|
-
@resource ||= resource_class.new(params)
|
|
30
|
+
@resource ||= resource_class.new(params[:data])
|
|
25
31
|
end
|
|
26
32
|
|
|
27
33
|
def success
|
|
@@ -30,11 +36,11 @@ module LedgerSync
|
|
|
30
36
|
|
|
31
37
|
def failure(message, data: nil)
|
|
32
38
|
super(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
LedgerSync::Error::OperationError.new(
|
|
40
|
+
operation: self,
|
|
41
|
+
message: message,
|
|
42
|
+
response: data
|
|
43
|
+
)
|
|
38
44
|
)
|
|
39
45
|
end
|
|
40
46
|
end
|
|
@@ -41,11 +41,11 @@ module LedgerSync
|
|
|
41
41
|
|
|
42
42
|
def failure(message, data: nil)
|
|
43
43
|
super(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
LedgerSync::Error::OperationError.new(
|
|
45
|
+
operation: self,
|
|
46
|
+
message: message,
|
|
47
|
+
response: data
|
|
48
|
+
)
|
|
49
49
|
)
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -10,6 +10,12 @@ module LedgerSync
|
|
|
10
10
|
@resource_class ||= inferred_resource_class
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
def validation_error_message
|
|
14
|
+
errors.messages.map do |e|
|
|
15
|
+
"#{e.path.first.to_s.gsub('_', ' ').capitalize} #{e.text}"
|
|
16
|
+
end.to_sentence
|
|
17
|
+
end
|
|
18
|
+
|
|
13
19
|
private
|
|
14
20
|
|
|
15
21
|
def inferred_resource_class
|
|
@@ -11,6 +11,7 @@ module LedgerSync
|
|
|
11
11
|
params do
|
|
12
12
|
required(:id).filled(:integer)
|
|
13
13
|
required(:limit).value(:hash)
|
|
14
|
+
required(:data).value(:hash)
|
|
14
15
|
end
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -19,7 +20,7 @@ module LedgerSync
|
|
|
19
20
|
def operate
|
|
20
21
|
return failure('Resource not found') unless resource
|
|
21
22
|
|
|
22
|
-
if resource.update(params
|
|
23
|
+
if resource.update(params[:data])
|
|
23
24
|
success
|
|
24
25
|
else
|
|
25
26
|
failure(
|
|
@@ -39,11 +40,11 @@ module LedgerSync
|
|
|
39
40
|
|
|
40
41
|
def failure(message, data: nil)
|
|
41
42
|
super(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
LedgerSync::Error::OperationError.new(
|
|
44
|
+
operation: self,
|
|
45
|
+
message: message,
|
|
46
|
+
response: data
|
|
47
|
+
)
|
|
47
48
|
)
|
|
48
49
|
end
|
|
49
50
|
end
|
|
@@ -41,6 +41,7 @@ module LedgerSync
|
|
|
41
41
|
READER_METHODS.each do |name|
|
|
42
42
|
define_method(name) do |*args, **params, &block|
|
|
43
43
|
item = @query.send(name, *args, **params, &block)
|
|
44
|
+
return nil unless item
|
|
44
45
|
|
|
45
46
|
@serializer.serialize(resource: item)
|
|
46
47
|
end
|
|
@@ -100,6 +101,7 @@ module LedgerSync
|
|
|
100
101
|
class SerializerReferencesOneType
|
|
101
102
|
def proxy(serializer:, resource:, attribute:)
|
|
102
103
|
item = resource.try(attribute)
|
|
104
|
+
return nil unless item
|
|
103
105
|
|
|
104
106
|
serializer.serialize(resource: item)
|
|
105
107
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ledger_sync-domains
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jozef Vaclavik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-02-
|
|
11
|
+
date: 2022-02-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ledger_sync
|