purple-client 0.1.7.6 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f57285cc0997c1352f58c090079dc236e52ecf08c040b1a2d68b2e44824b344
4
- data.tar.gz: '094e99048e10af59faabec36d819ec1b075a65bfb47eaebd422ddee9dd216d84'
3
+ metadata.gz: d7ca49130cf7c540423e3b62726ca82034f7a7b93e0abcf6a727243be2950ee3
4
+ data.tar.gz: 5d3650ca03866747031cb9f6da5ebc2c56abb69a26e3a73763b6e40295b98782
5
5
  SHA512:
6
- metadata.gz: e2a8c339a3dfa90dc44444b421b13c819152e3f0c9ce3a0bede32604c9b5bf00ea9068bfff074bc84c8165093167f2c1bb8756ba0fbb059a0e8cb03ebc63705c
7
- data.tar.gz: 8ae3c368e5130486f5c4d466d9232095da167f957134ef2192798fc446b79f69ceb635c8bd1a14f91b745a8f0cdf6bab7384d9e71b46e9bdd17c30868da8bd5a
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].each do |item|
85
- if value[0].is_a?(Symbol)
86
- raise "Body structure definition error in key '#{key}' of structure #{substructure}."
87
- end
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
- check_structure!(item, value[0])
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?
@@ -104,7 +118,7 @@ class Purple::Responses::Body
104
118
 
105
119
  unless object.key?(key)
106
120
  raise BodyStructureMismatchError.new(key, expected_type, object[key], object),
107
- "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."
108
122
  end
109
123
 
110
124
  return if expected_type == Purple::Boolean && (object[key] == true || object[key] == false)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Purple
4
- VERSION = "0.1.7.6"
4
+ VERSION = "0.1.7.7"
5
5
  end
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.6
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-09-01 00:00:00.000000000 Z
11
+ date: 2025-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-initializer