purple-client 0.1.7.5 → 0.1.7.7
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/lib/purple/path.rb +4 -0
- data/lib/purple/responses/body.rb +22 -6
- data/lib/purple/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: d7ca49130cf7c540423e3b62726ca82034f7a7b93e0abcf6a727243be2950ee3
|
4
|
+
data.tar.gz: 5d3650ca03866747031cb9f6da5ebc2c56abb69a26e3a73763b6e40295b98782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6335d77f00653b8f0bd086dc7662c5496fd98910488daed8a9a23f2a6fb7c1134bcdfd9d0c9e7ced41adb06244072bef73e0f230202a6e1b21f77d5539b3d7ee
|
7
|
+
data.tar.gz: b317e1acdb851ac1de738047b9e141ab2aa7a9d79bee1567893bc98e981849d47b7f04757aa3aa813f11f1e265a636eaa0b4bccb7d4b59f27d4ee27a15ca8373
|
data/lib/purple/path.rb
CHANGED
@@ -66,6 +66,10 @@ module Purple
|
|
66
66
|
conn.headers = headers
|
67
67
|
end
|
68
68
|
|
69
|
+
if client.domain.blank?
|
70
|
+
raise ArgumentError, 'Client domain is not set. Please set the domain in the client configuration.'
|
71
|
+
end
|
72
|
+
|
69
73
|
unless client.domain.start_with?('http')
|
70
74
|
raise ArgumentError, "Invalid URL: #{client.domain}. Ensure you have set protocol (http/https) in the client domain."
|
71
75
|
end
|
@@ -81,12 +81,26 @@ class Purple::Responses::Body
|
|
81
81
|
check_structure!(object[key], substructure[key])
|
82
82
|
end
|
83
83
|
elsif value.is_a?(Array)
|
84
|
-
object[key].
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
if object[key].nil?
|
85
|
+
raise BodyStructureMismatchError.new(key, value, nil, object),
|
86
|
+
"Expected a non-nil array for '#{key}' in response body.\n\nExpected response structure: #{substructure}.\n\nUse '#{key}: { type: #{value}, allow_blank: true }' if this field can be nil."
|
87
|
+
end
|
88
|
+
|
89
|
+
type = value.first
|
88
90
|
|
89
|
-
|
91
|
+
if type.is_a?(Symbol)
|
92
|
+
raise "Body structure definition error in key '#{key}' of structure #{substructure}."
|
93
|
+
end
|
94
|
+
|
95
|
+
object[key].each_with_index do |item, index|
|
96
|
+
if type.is_a?(Class)
|
97
|
+
unless item.is_a?(type)
|
98
|
+
raise BodyStructureMismatchError.new(key, type, item, object),
|
99
|
+
"Expected item at #{index} index of '#{key}' to be of type '#{value[index]}', but got '#{item.class}' with value '#{item}'."
|
100
|
+
end
|
101
|
+
else
|
102
|
+
check_structure!(item, type)
|
103
|
+
end
|
90
104
|
end
|
91
105
|
else
|
92
106
|
if object.nil?
|
@@ -100,9 +114,11 @@ class Purple::Responses::Body
|
|
100
114
|
end
|
101
115
|
|
102
116
|
def check_type!(object, key, expected_type)
|
117
|
+
return if key.in?([:optional, :allow_blank])
|
118
|
+
|
103
119
|
unless object.key?(key)
|
104
120
|
raise BodyStructureMismatchError.new(key, expected_type, object[key], object),
|
105
|
-
"Missing field '#{key}' in response body. Body: #{object}"
|
121
|
+
"Missing field '#{key}' in response body. Body: #{object}\n\nUse '#{key}: { type: #{expected_type}, optional: true }' if this field may be absent."
|
106
122
|
end
|
107
123
|
|
108
124
|
return if expected_type == Purple::Boolean && (object[key] == true || object[key] == false)
|
data/lib/purple/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purple-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.7.
|
4
|
+
version: 0.1.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-initializer
|