salestation 4.0.3 → 4.1.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: a16ccdf085040d1bb82a78c416621b0d5b6fcf691a3b568b80cc6b54a4d9e61e
4
- data.tar.gz: b53ae89dd854e7694e90d9b090bb4a96f082b7c8c1f42a3f0be57781260b0698
3
+ metadata.gz: 68e2a18e5e9afcefd5ebec1ff8ed6fce053049fc71dbc04ef863662810fbcc69
4
+ data.tar.gz: 935756c02ffb2d60138c3be7b8506215ed0b9a720e85c6e606751eb71b13ebd9
5
5
  SHA512:
6
- metadata.gz: 468261b62a6493fabdd47cf3737dce28f306c1ccc6eaa84d76267cb62625bcf7a98e934d099977d2c2dc92273e512cf0d95249834b29ec0e18826fdcd20e9677
7
- data.tar.gz: d8cb168a96c15f6448febb8a24f43be4194b9bdffc83090a102a0fbd28cdc6f192ad3867c18d860f92cf972bfc3ba78b8efe1231d0196667ad3ad8daf9c5b702
6
+ metadata.gz: 2cb946c7702e75dc9c00f4bbf80f758a7ec5cde1501d6e7b36e6093a500a854ba5a209a1d62973c113aa7534cb7d620be82ad27f0cccad32b6adb774d8e5d26a
7
+ data.tar.gz: 9aaf105fa50b0e82e3fcd613e53d2dba9023930ada4281edcf53cc1be5ee6cdb44966c02bedb5a0f6a6cb3bd306d9dd40dd56dcc2a6891679a23b2f139d0f9f7
@@ -12,44 +12,44 @@ module Salestation
12
12
  end
13
13
 
14
14
  class InvalidInput < Error
15
- attribute :errors, Types::Strict::Hash
16
- attribute :hints, Types::Coercible::Hash.default({}.freeze)
15
+ attribute? :errors, Types::Strict::Hash
16
+ attribute? :hints, Types::Coercible::Hash.default({}.freeze)
17
17
  attribute? :debug_message, Types::Strict::String
18
18
  attribute? :form_errors, Types::Strict::Bool.default(false)
19
19
  end
20
20
 
21
21
  class DependencyCurrentlyUnavailable < Error
22
- attribute :message, Types::Strict::String
22
+ attribute? :message, Types::Strict::String
23
23
  attribute? :debug_message, Types::Strict::String
24
24
  end
25
25
 
26
26
  class RequestedResourceNotFound < Error
27
- attribute :message, Types::Strict::String
27
+ attribute? :message, Types::Strict::String
28
28
  attribute? :debug_message, Types::Strict::String
29
29
  end
30
30
 
31
31
  class Forbidden < Error
32
- attribute :message, Types::Strict::String
32
+ attribute? :message, Types::Strict::String
33
33
  attribute? :debug_message, Types::Strict::String
34
34
  end
35
35
 
36
36
  class Conflict < Error
37
- attribute :message, Types::Strict::String
38
- attribute :debug_message, Types::Strict::String
37
+ attribute? :message, Types::Strict::String
38
+ attribute? :debug_message, Types::Strict::String
39
39
  end
40
40
 
41
41
  class NotAcceptable < Error
42
- attribute :message, Types::Strict::String
43
- attribute :debug_message, Types::Strict::String
42
+ attribute? :message, Types::Strict::String
43
+ attribute? :debug_message, Types::Strict::String
44
44
  end
45
45
 
46
46
  class UnsupportedMediaType < Error
47
- attribute :message, Types::Strict::String
48
- attribute :debug_message, Types::Strict::String
47
+ attribute? :message, Types::Strict::String
48
+ attribute? :debug_message, Types::Strict::String
49
49
  end
50
50
 
51
51
  class RequestEntityTooLarge < Error
52
- attribute :message, Types::Strict::String
52
+ attribute? :message, Types::Strict::String
53
53
  attribute? :debug_message, Types::Strict::String
54
54
  end
55
55
  end
@@ -31,15 +31,23 @@ module Salestation
31
31
 
32
32
  class Error < Response
33
33
  attribute :status, Types::Strict::Integer
34
- attribute :message, Types::Strict::String
35
- attribute :debug_message, Types::Coercible::String.default('')
34
+ attribute? :message, Types::String.optional
35
+ attribute? :debug_message, Types::Coercible::String.default('')
36
36
  attribute :context, Types::Hash.default({}.freeze)
37
37
  attribute :headers, Types::Hash.default({}.freeze)
38
38
  attribute? :base_error, Types::Coercible::Hash
39
39
 
40
40
  def body
41
41
  # Merge into `base_error` to ensure standard fields are not overriden
42
- (base_error || {}).merge(message: message, debug_message: debug_message)
42
+ merge_not_nil(base_error || {}, :message, message)
43
+ .merge(debug_message: debug_message)
44
+ end
45
+
46
+ private
47
+
48
+ def merge_not_nil(map, key, value)
49
+ map[key] = value if value
50
+ map
43
51
  end
44
52
  end
45
53
 
@@ -59,8 +67,8 @@ module Salestation
59
67
 
60
68
  class UnprocessableEntityFromSchemaErrors
61
69
  def self.create(errors:, hints:, base_error: nil, form_errors: false)
62
- message = parse_errors(errors)
63
- debug_message = parse_hints(hints)
70
+ message = errors ? parse_errors(errors) : nil
71
+ debug_message = hints ? parse_hints(hints) : nil
64
72
 
65
73
  UnprocessableEntity.new(
66
74
  message: message,
data/salestation.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "salestation"
7
- spec.version = "4.0.3"
7
+ spec.version = "4.1.0"
8
8
  spec.authors = ["Glia TechMovers"]
9
9
  spec.email = ["techmovers@glia.com"]
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salestation
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glia TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-26 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler