boldsign 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32abdfa0ebbbb1803c298cc8055169d7330f7cc43a62b15838f9ae39594c146e
4
- data.tar.gz: 4dd1f27abb3fb5209d5fe9a570db74336b6babc7300692f82cfa992544700263
3
+ metadata.gz: 9fc2965681164f6e721c5d7a18b9370d1ddfd7570916cde257078b29d3be34d5
4
+ data.tar.gz: 9210a75137622829403d8b6ae47dfa1f51e3f71462313b12ef076e6b240391a9
5
5
  SHA512:
6
- metadata.gz: a92371ad102e288e429f7bcb3d2d535d64572dcf1208de7459bfe41dde8f3b52b72eb895af05fd0ee9dfe3dad9f38bae86bd3d678ebf03ac13c986df0b6312c0
7
- data.tar.gz: 4fc0bf95e332d59d2a170225bf6d75173951d03594b2017fddc82d28cec38bccbe308bc826a5894fe5cb426b0880b5c2f1d962b195569852b68dacee90021816
6
+ metadata.gz: 00ab26917b2ad3ab3af835ec58842b1fa75ba19d61254447466a5eee7b5db388f9c5800ec7807806fd737526772516f43277520ba1005d18539a8e54356f0ee8
7
+ data.tar.gz: '038338c9aca83500340f85e0d6d2e6247466701739ff3606ae8bf59905f930541514e9e3130ac5296b9ee658085993c601126d84ee5e6527451b4ba1d75df1ab'
data/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.0] — 2026-05-22
11
+
12
+ ### Changed
13
+ - Request bodies (JSON and multipart) now have their Hash keys recursively
14
+ converted to PascalCase before being sent to BoldSign. Callers can pass
15
+ idiomatic snake_case (or camelCase) Ruby symbols/strings and the gem will
16
+ emit the casing the API expects. Already-PascalCase keys pass through
17
+ unchanged. Non-Hash/Array values (including IO objects and
18
+ `Faraday::Multipart::FilePart` instances) are not touched.
19
+
20
+ ### Added
21
+ - `Boldsign::CaseConvert` module with `pascalize` / `pascalize_key` helpers
22
+ for callers that need to PascalCase keys outside of the HTTP path.
23
+
10
24
  ## [0.2.0] — 2026-05-22
11
25
 
12
26
  ### Added
@@ -0,0 +1,43 @@
1
+ module Boldsign
2
+ # Converts arbitrary Ruby hash keys (snake_case or camelCase, Symbol or
3
+ # String) to PascalCase string keys recursively, matching the casing the
4
+ # BoldSign REST API expects in request bodies. Non-Hash and non-Array values
5
+ # — including binary IO objects, FilePart instances, scalars, dates, etc. —
6
+ # pass through untouched.
7
+ module CaseConvert
8
+ module_function
9
+
10
+ # Recursively PascalCase every Hash key reachable from `obj`.
11
+ # @param obj [Object]
12
+ # @return [Object] new object with the same shape and PascalCase keys
13
+ def pascalize(obj)
14
+ case obj
15
+ when Hash
16
+ obj.each_with_object({}) { |(k, v), acc| acc[pascalize_key(k)] = pascalize(v) }
17
+ when Array
18
+ obj.map { |v| pascalize(v) }
19
+ else
20
+ obj
21
+ end
22
+ end
23
+
24
+ # @param key [String, Symbol]
25
+ # @return [String] PascalCase string
26
+ def pascalize_key(key)
27
+ str = key.to_s
28
+ return str if str.empty?
29
+
30
+ if str.include?("_")
31
+ str.split("_").map { |part| capitalize_word(part) }.join
32
+ else
33
+ capitalize_word(str)
34
+ end
35
+ end
36
+
37
+ def capitalize_word(str)
38
+ return str if str.empty?
39
+
40
+ str[0].upcase + str[1..]
41
+ end
42
+ end
43
+ end
@@ -125,7 +125,7 @@ module Boldsign
125
125
  req.body = body
126
126
  else
127
127
  req.headers["Content-Type"] = "application/json"
128
- req.body = body.is_a?(String) ? body : JSON.generate(body)
128
+ req.body = body.is_a?(String) ? body : JSON.generate(CaseConvert.pascalize(body))
129
129
  end
130
130
  end
131
131
  end
@@ -77,7 +77,12 @@ module Boldsign
77
77
  parts = body.each_with_object({}) do |(key, value), acc|
78
78
  next if value.nil?
79
79
 
80
- acc[key.to_s] = scalar?(value) ? value.to_s : JSON.generate(value)
80
+ pascal_key = Boldsign::CaseConvert.pascalize_key(key)
81
+ acc[pascal_key] = if scalar?(value)
82
+ value.to_s
83
+ else
84
+ JSON.generate(Boldsign::CaseConvert.pascalize(value))
85
+ end
81
86
  end
82
87
  parts["Files"] = Array(files).map { |f| file_part(f) }
83
88
  parts
@@ -1,3 +1,3 @@
1
1
  module Boldsign
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/boldsign.rb CHANGED
@@ -4,6 +4,7 @@ require "json"
4
4
 
5
5
  require_relative "boldsign/version"
6
6
  require_relative "boldsign/error"
7
+ require_relative "boldsign/case_convert"
7
8
  require_relative "boldsign/client"
8
9
  require_relative "boldsign/resource"
9
10
  require_relative "boldsign/resources/brand"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boldsign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Klein
@@ -92,6 +92,7 @@ files:
92
92
  - README.md
93
93
  - boldsign.gemspec
94
94
  - lib/boldsign.rb
95
+ - lib/boldsign/case_convert.rb
95
96
  - lib/boldsign/client.rb
96
97
  - lib/boldsign/error.rb
97
98
  - lib/boldsign/resource.rb