cloudpayments-ruby 0.4.1 → 0.4.2

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: aba792aa45d3f0b8069974f43f995be853abefea293de1c8981a8be7cb9cb751
4
- data.tar.gz: b141b78ce8a0de5548f802408adc63e5a0d7f3137df5966ff52bf381693a9ce3
3
+ metadata.gz: 5ecbe8746f84deb89f699aebe23a3bf7452d69c5f357a1dbe649c6133835fdbb
4
+ data.tar.gz: fb2a566cf45c73b11eb9e8fe4ad5c4293507c4b7faf98a8ecaa127fd20153346
5
5
  SHA512:
6
- metadata.gz: 62660f2f4a6a31532adfeabd26beedc8bbbd837e67941775a28cf23cb92a31a042db0ef66310cfc700b68516f8c83c1f6f62e6981de2516600dcef5930dd7182
7
- data.tar.gz: 04c35ea0381c11193d8fdcc3909edf775678fc0692f177da7a17df612c89c097076aeceebe807fdb81899ed3367c942b0a0281746b02921bcc2a0a97a76f5ab1
6
+ metadata.gz: e5b7ab253555833c2b7d3c2b170c11a4ce0513f63ef51a1a28a55b7849bde231d59fcc4bde3e15e5db09cfa9dc4543dfe8c53f6ef57702522aac6dde17ac110d
7
+ data.tar.gz: 85648d5644bf07d2bc930dc8959fdd21014fa3f4198a259e83db54b3ffb6ad8be8e1ccdea4c0476a50034040ba4b7d91b4e57b111767bf67d65e3cf0d1aa4c68
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.2 (2026-04-09)
4
+
5
+ Full Changelog: [v0.4.1...v0.4.2](https://github.com/Hexlet/cloudpayments-ruby/compare/v0.4.1...v0.4.2)
6
+
7
+ ### Bug Fixes
8
+
9
+ * align path encoding with RFC 3986 section 3.3 ([090212b](https://github.com/Hexlet/cloudpayments-ruby/commit/090212b29a6295c575a845adc45b0a5ed8262c81))
10
+ * **internal:** correct multipart form field name encoding ([b4394ee](https://github.com/Hexlet/cloudpayments-ruby/commit/b4394ee4c68e84bd71af191b6deda6a7bb3c3080))
11
+ * multipart encoding for file arrays ([130dd42](https://github.com/Hexlet/cloudpayments-ruby/commit/130dd42926834c23d056df829d7d65c05364f087))
12
+ * properly mock time in ruby ci tests ([7cfd820](https://github.com/Hexlet/cloudpayments-ruby/commit/7cfd8204e2a9d7045d9a05045be6b525768455e0))
13
+ * variable name typo ([74c7bb5](https://github.com/Hexlet/cloudpayments-ruby/commit/74c7bb5ecea0ba1797f0ac837953e94906d7391e))
14
+
15
+
16
+ ### Chores
17
+
18
+ * **ci:** add build step ([9287b3c](https://github.com/Hexlet/cloudpayments-ruby/commit/9287b3cf46dba9228ab6aa4472d7f0cc8a2e437d))
19
+ * **ci:** skip lint on metadata-only changes ([c9de760](https://github.com/Hexlet/cloudpayments-ruby/commit/c9de760a0803d8a04e298009b54508d0f65e44ed))
20
+ * **ci:** skip uploading artifacts on stainless-internal branches ([928a685](https://github.com/Hexlet/cloudpayments-ruby/commit/928a68530d231ae1588a6890280166caf2309831))
21
+ * **ci:** support opting out of skipping builds on metadata-only commits ([0aa99a1](https://github.com/Hexlet/cloudpayments-ruby/commit/0aa99a16822e786207fe0dbf85fc20af0aa4b7b4))
22
+ * **internal:** codegen related update ([2fc9917](https://github.com/Hexlet/cloudpayments-ruby/commit/2fc991731a559b659f2dbe3ae53c130fda957533))
23
+ * **internal:** remove mock server code ([e100d4f](https://github.com/Hexlet/cloudpayments-ruby/commit/e100d4f1eb3433101355817d309ae3008b0faa06))
24
+ * **internal:** tweak CI branches ([85b9aeb](https://github.com/Hexlet/cloudpayments-ruby/commit/85b9aeb70a105aafdfbe6665fc2f5576ca6a0d98))
25
+ * **internal:** update gitignore ([1fb92c3](https://github.com/Hexlet/cloudpayments-ruby/commit/1fb92c3f2453e220bd6c3ea478ad22db68c443b5))
26
+ * update mock server docs ([36a2a37](https://github.com/Hexlet/cloudpayments-ruby/commit/36a2a3788aa8b4638c9d41e2fe54a6cd4a939990))
27
+
3
28
  ## 0.4.1 (2026-02-13)
4
29
 
5
30
  Full Changelog: [v0.4.0...v0.4.1](https://github.com/Hexlet/cloudpayments-ruby/compare/v0.4.0...v0.4.1)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "cloudpayments-ruby", "~> 0.4.1"
18
+ gem "cloudpayments-ruby", "~> 0.4.2"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -157,7 +157,7 @@ module CloudpaymentsRuby
157
157
  in Hash | nil => coerced
158
158
  coerced
159
159
  else
160
- message = "Expected a #{Hash} or #{CloudpaymentsRuby::Internal::Type::BaseModel}, got #{data.inspect}"
160
+ message = "Expected a #{Hash} or #{CloudpaymentsRuby::Internal::Type::BaseModel}, got #{input.inspect}"
161
161
  raise ArgumentError.new(message)
162
162
  end
163
163
  end
@@ -237,6 +237,11 @@ module CloudpaymentsRuby
237
237
  end
238
238
  end
239
239
 
240
+ # @type [Regexp]
241
+ #
242
+ # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
243
+ RFC_3986_NOT_PCHARS = /[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/
244
+
240
245
  class << self
241
246
  # @api private
242
247
  #
@@ -247,6 +252,15 @@ module CloudpaymentsRuby
247
252
  "#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}"
248
253
  end
249
254
 
255
+ # @api private
256
+ #
257
+ # @param path [String, Integer]
258
+ #
259
+ # @return [String]
260
+ def encode_path(path)
261
+ path.to_s.gsub(CloudpaymentsRuby::Internal::Util::RFC_3986_NOT_PCHARS) { ERB::Util.url_encode(_1) }
262
+ end
263
+
250
264
  # @api private
251
265
  #
252
266
  # @param path [String, Array<String>]
@@ -259,7 +273,7 @@ module CloudpaymentsRuby
259
273
  in []
260
274
  ""
261
275
  in [String => p, *interpolations]
262
- encoded = interpolations.map { ERB::Util.url_encode(_1) }
276
+ encoded = interpolations.map { encode_path(_1) }
263
277
  format(p, *encoded)
264
278
  end
265
279
  end
@@ -490,6 +504,37 @@ module CloudpaymentsRuby
490
504
  JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
491
505
 
492
506
  class << self
507
+ # @api private
508
+ #
509
+ # @param query [Hash{Symbol=>Object}]
510
+ #
511
+ # @return [Hash{Symbol=>Object}]
512
+ def encode_query_params(query)
513
+ out = {}
514
+ query.each { write_query_param_element!(out, _1, _2) }
515
+ out
516
+ end
517
+
518
+ # @api private
519
+ #
520
+ # @param collection [Hash{Symbol=>Object}]
521
+ # @param key [String]
522
+ # @param element [Object]
523
+ #
524
+ # @return [nil]
525
+ private def write_query_param_element!(collection, key, element)
526
+ case element
527
+ in Hash
528
+ element.each do |name, value|
529
+ write_query_param_element!(collection, "#{key}[#{name}]", value)
530
+ end
531
+ in Array
532
+ collection[key] = element.map(&:to_s).join(",")
533
+ else
534
+ collection[key] = element.to_s
535
+ end
536
+ end
537
+
493
538
  # @api private
494
539
  #
495
540
  # @param y [Enumerator::Yielder]
@@ -540,16 +585,15 @@ module CloudpaymentsRuby
540
585
  y << "Content-Disposition: form-data"
541
586
 
542
587
  unless key.nil?
543
- name = ERB::Util.url_encode(key.to_s)
544
- y << "; name=\"#{name}\""
588
+ y << "; name=\"#{key}\""
545
589
  end
546
590
 
547
591
  case val
548
592
  in CloudpaymentsRuby::FilePart unless val.filename.nil?
549
- filename = ERB::Util.url_encode(val.filename)
593
+ filename = encode_path(val.filename)
550
594
  y << "; filename=\"#{filename}\""
551
595
  in Pathname | IO
552
- filename = ERB::Util.url_encode(::File.basename(val.to_path))
596
+ filename = encode_path(::File.basename(val.to_path))
553
597
  y << "; filename=\"#{filename}\""
554
598
  else
555
599
  end
@@ -566,6 +610,7 @@ module CloudpaymentsRuby
566
610
  #
567
611
  # @return [Array(String, Enumerable<String>)]
568
612
  private def encode_multipart_streaming(body)
613
+ # rubocop:disable Style/CaseEquality
569
614
  # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
570
615
  boundary = SecureRandom.urlsafe_base64(46)
571
616
 
@@ -575,7 +620,7 @@ module CloudpaymentsRuby
575
620
  in Hash
576
621
  body.each do |key, val|
577
622
  case val
578
- in Array if val.all? { primitive?(_1) }
623
+ in Array if val.all? { primitive?(_1) || CloudpaymentsRuby::Internal::Type::FileInput === _1 }
579
624
  val.each do |v|
580
625
  write_multipart_chunk(y, boundary: boundary, key: key, val: v, closing: closing)
581
626
  end
@@ -591,6 +636,7 @@ module CloudpaymentsRuby
591
636
 
592
637
  fused_io = fused_enum(strio) { closing.each(&:call) }
593
638
  [boundary, fused_io]
639
+ # rubocop:enable Style/CaseEquality
594
640
  end
595
641
 
596
642
  # @api private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudpaymentsRuby
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
@@ -148,12 +148,20 @@ module CloudpaymentsRuby
148
148
  end
149
149
  end
150
150
 
151
+ # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
152
+ RFC_3986_NOT_PCHARS = T.let(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/, Regexp)
153
+
151
154
  class << self
152
155
  # @api private
153
156
  sig { params(uri: URI::Generic).returns(String) }
154
157
  def uri_origin(uri)
155
158
  end
156
159
 
160
+ # @api private
161
+ sig { params(path: T.any(String, Integer)).returns(String) }
162
+ def encode_path(path)
163
+ end
164
+
157
165
  # @api private
158
166
  sig { params(path: T.any(String, T::Array[String])).returns(String) }
159
167
  def interpolate_path(path)
@@ -301,6 +309,26 @@ module CloudpaymentsRuby
301
309
  T.let(%r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}, Regexp)
302
310
 
303
311
  class << self
312
+ # @api private
313
+ sig do
314
+ params(query: CloudpaymentsRuby::Internal::AnyHash).returns(
315
+ CloudpaymentsRuby::Internal::AnyHash
316
+ )
317
+ end
318
+ def encode_query_params(query)
319
+ end
320
+
321
+ # @api private
322
+ sig do
323
+ params(
324
+ collection: CloudpaymentsRuby::Internal::AnyHash,
325
+ key: String,
326
+ element: T.anything
327
+ ).void
328
+ end
329
+ private def write_query_param_element!(collection, key, element)
330
+ end
331
+
304
332
  # @api private
305
333
  sig do
306
334
  params(
@@ -45,8 +45,12 @@ module CloudpaymentsRuby
45
45
  -> top?
46
46
  } -> top?
47
47
 
48
+ RFC_3986_NOT_PCHARS: Regexp
49
+
48
50
  def self?.uri_origin: (URI::Generic uri) -> String
49
51
 
52
+ def self?.encode_path: (String | Integer path) -> String
53
+
50
54
  def self?.interpolate_path: (String | ::Array[String] path) -> String
51
55
 
52
56
  def self?.decode_query: (String? query) -> ::Hash[String, ::Array[String]]
@@ -106,6 +110,16 @@ module CloudpaymentsRuby
106
110
  JSON_CONTENT: Regexp
107
111
  JSONL_CONTENT: Regexp
108
112
 
113
+ def encode_query_params: (
114
+ ::Hash[Symbol, top] query
115
+ ) -> ::Hash[Symbol, top]
116
+
117
+ private def write_query_param_element!: (
118
+ ::Hash[Symbol, top] collection,
119
+ String key,
120
+ top element
121
+ ) -> nil
122
+
109
123
  def self?.write_multipart_content: (
110
124
  Enumerator::Yielder y,
111
125
  val: top,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudpayments-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloudpayments
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-13 00:00:00.000000000 Z
11
+ date: 2026-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cgi