moov_ruby 25.1.4 → 25.1.5

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: c2f4602e4712452f039416e8f16ad1ebb0ca1efd06267b15e3e7184bddb934b3
4
- data.tar.gz: cec3572c6e68bff7e265208a53cb53786bc2e2f71dd9ca8442c8396cfa0d90f3
3
+ metadata.gz: 2258514aa37c140df224d325221fd532e04f26cfd690721da879ffc532a86161
4
+ data.tar.gz: 9900dae110c418a72405cb7bb5c180795cf4c864f518a49f2192f44aa4dc036d
5
5
  SHA512:
6
- metadata.gz: 181c1e4d3299e7057ad3a75bb3e58ff9f864349ec95f8e518c99b3f1320149cc9ea40daa6082d663b806e7f71d425047f73a983bdfe9636913f5f39a12464fdb
7
- data.tar.gz: b31c2884e9d8063e2699b7910ac8ab4d3a1f6b3ee13da09352c253020c720d607b69411f155ad4c5cfb39de5b0567174a57981ae738bcaa9f9620fc3a9765d4c
6
+ metadata.gz: 82422624eb364716e75863409836eb5bf194232a63c11d0415e121a071b679548aad4f71cda6270d77b75d1953a3ce0223fef9c34f3ad28047572f32ada48245
7
+ data.tar.gz: 5a27214d632d930f2600eb2f0a999eacd52fc2854266f562d822d54d28b2cbab2c1d8d96e9235304b12812df216d82a845b784c1e41daf8a630f8d6282c437f1
@@ -112,17 +112,21 @@ module Crystalline
112
112
  union_types = Crystalline::Utils.get_union_types(field_type)
113
113
  union_types = union_types.sort_by { |klass| Crystalline.non_nilable_attr_count(klass) }
114
114
 
115
- union_types.each do |union_type|
116
- begin
117
- to_build[key] = Crystalline.unmarshal_json(value, union_type)
118
- rescue TypeError
119
- next
120
- rescue NoMethodError
121
- next
122
- rescue KeyError
123
- next
115
+ if Crystalline.union_strategy == :populated_fields
116
+ to_build[key] = Crystalline.unmarshal_union_populated_fields(value, union_types)
117
+ else
118
+ union_types.each do |union_type|
119
+ begin
120
+ to_build[key] = Crystalline.unmarshal_json(value, union_type)
121
+ rescue TypeError
122
+ next
123
+ rescue NoMethodError
124
+ next
125
+ rescue KeyError
126
+ next
127
+ end
128
+ break
124
129
  end
125
- break
126
130
  end
127
131
  end
128
132
  elsif field_type.instance_of?(Class) && field_type.include?(::Crystalline::MetadataFields)
@@ -4,6 +4,11 @@
4
4
  # frozen_string_literal: true
5
5
 
6
6
  module Crystalline
7
+ @union_strategy = :left_to_right
8
+
9
+ class << self
10
+ attr_accessor :union_strategy
11
+ end
7
12
 
8
13
  def self.to_dict(complex)
9
14
  if complex.is_a? Array
@@ -35,15 +40,10 @@ module Crystalline
35
40
  union_types = Crystalline::Utils.get_union_types(type)
36
41
  union_types = union_types.sort_by { |klass| Crystalline.non_nilable_attr_count(klass) }
37
42
 
38
- union_types.each do |union_type|
39
- unmarshalled_val = Crystalline.unmarshal_json(data, union_type)
40
- return unmarshalled_val
41
- rescue TypeError
42
- next
43
- rescue NoMethodError
44
- next
45
- rescue KeyError
46
- next
43
+ if Crystalline.union_strategy == :populated_fields
44
+ Crystalline.unmarshal_union_populated_fields(data, union_types)
45
+ else
46
+ Crystalline.unmarshal_union_left_to_right(data, union_types)
47
47
  end
48
48
  elsif Crystalline::Utils.arr? type
49
49
  data.map { |v| Crystalline.unmarshal_json(v, Crystalline::Utils.arr_of(type)) }
@@ -76,6 +76,86 @@ module Crystalline
76
76
  end
77
77
  end
78
78
 
79
+ def self.unmarshal_union_left_to_right(data, union_types)
80
+ union_types.each do |union_type|
81
+ return Crystalline.unmarshal_json(data, union_type)
82
+ rescue TypeError
83
+ next
84
+ rescue NoMethodError
85
+ next
86
+ rescue KeyError
87
+ next
88
+ end
89
+ nil
90
+ end
91
+
92
+ def self.unmarshal_union_populated_fields(data, union_types)
93
+ best_value = nil
94
+ best_matched = -1
95
+ best_inexact = 0
96
+ best_unmatched = 0
97
+
98
+ union_types.each do |union_type|
99
+ value = Crystalline.unmarshal_json(data, union_type)
100
+ matched, inexact, unmatched = count_matched_fields(value, data)
101
+
102
+ if best_value.nil? ||
103
+ matched > best_matched ||
104
+ (matched == best_matched && inexact < best_inexact) ||
105
+ (matched == best_matched && inexact == best_inexact && unmatched < best_unmatched)
106
+ best_value = value
107
+ best_matched = matched
108
+ best_inexact = inexact
109
+ best_unmatched = unmatched
110
+ end
111
+ rescue TypeError
112
+ next
113
+ rescue NoMethodError
114
+ next
115
+ rescue KeyError
116
+ next
117
+ end
118
+ best_value
119
+ end
120
+
121
+ def self.count_matched_fields(value, raw_data)
122
+ matched = 0
123
+ inexact = 0
124
+ unmatched = 0
125
+
126
+ if value.class.include?(::Crystalline::MetadataFields)
127
+ value.fields.each do |field|
128
+ format_metadata = field.metadata.fetch(:format_json, {})
129
+ lookup = format_metadata.fetch(:letter_case, nil)&.call
130
+ field_val = value.send(field.name)
131
+
132
+ if raw_data.is_a?(::Hash) && lookup && raw_data.key?(lookup)
133
+ if field_val.class.include?(::Crystalline::MetadataFields) && raw_data[lookup].is_a?(::Hash)
134
+ nested_matched, nested_inexact, nested_unmatched = count_matched_fields(field_val, raw_data[lookup])
135
+ matched += nested_matched
136
+ inexact += nested_inexact
137
+ unmatched += nested_unmatched
138
+ else
139
+ matched += 1
140
+ if field_val.respond_to?(:known?) && !field_val.known?
141
+ inexact += 1
142
+ end
143
+ end
144
+ elsif !::Crystalline::Utils.nilable?(field.type)
145
+ unmatched += 1
146
+ end
147
+ end
148
+ elsif value.is_a?(::Array)
149
+ matched = value.length
150
+ elsif value.is_a?(::Hash)
151
+ matched = value.length
152
+ else
153
+ matched = 1
154
+ end
155
+
156
+ [matched, inexact, unmatched]
157
+ end
158
+
79
159
  def self.non_nilable_attr_count(klass)
80
160
  # somewhat sane sort ordering for Union deserialization.
81
161
  # All Crystalline objects return the number of non-nilable fields
@@ -23,13 +23,16 @@ module Moov
23
23
 
24
24
  field :bank_account_id, Crystalline::Nilable.new(::String), { 'format_json': { 'letter_case': ::Moov::Utils.field_name('bankAccountID') } }
25
25
 
26
- sig { params(transfer_id: T.nilable(::String), card_id: T.nilable(::String), dispute_id: T.nilable(::String), account_id: T.nilable(::String), bank_account_id: T.nilable(::String)).void }
27
- def initialize(transfer_id: nil, card_id: nil, dispute_id: nil, account_id: nil, bank_account_id: nil)
26
+ field :invoice_id, Crystalline::Nilable.new(::String), { 'format_json': { 'letter_case': ::Moov::Utils.field_name('invoiceID') } }
27
+
28
+ sig { params(transfer_id: T.nilable(::String), card_id: T.nilable(::String), dispute_id: T.nilable(::String), account_id: T.nilable(::String), bank_account_id: T.nilable(::String), invoice_id: T.nilable(::String)).void }
29
+ def initialize(transfer_id: nil, card_id: nil, dispute_id: nil, account_id: nil, bank_account_id: nil, invoice_id: nil)
28
30
  @transfer_id = transfer_id
29
31
  @card_id = card_id
30
32
  @dispute_id = dispute_id
31
33
  @account_id = account_id
32
34
  @bank_account_id = bank_account_id
35
+ @invoice_id = invoice_id
33
36
  end
34
37
 
35
38
  sig { params(other: T.untyped).returns(T::Boolean) }
@@ -40,6 +43,7 @@ module Moov
40
43
  return false unless @dispute_id == other.dispute_id
41
44
  return false unless @account_id == other.account_id
42
45
  return false unless @bank_account_id == other.bank_account_id
46
+ return false unless @invoice_id == other.invoice_id
43
47
  true
44
48
  end
45
49
  end
@@ -18,4 +18,6 @@ class Moov::Models::Components::GeneratedBy
18
18
  def account_id=(str_); end
19
19
  def bank_account_id(); end
20
20
  def bank_account_id=(str_); end
21
+ def invoice_id(); end
22
+ def invoice_id=(str_); end
21
23
  end
@@ -95,9 +95,9 @@ module Moov
95
95
  @globals = globals.nil? ? {} : globals
96
96
  @language = 'ruby'
97
97
  @openapi_doc_version = 'v2025.01.00'
98
- @sdk_version = '25.1.4'
99
- @gen_version = '2.818.4'
100
- @user_agent = 'speakeasy-sdk/ruby 25.1.4 2.818.4 v2025.01.00 moov_ruby'
98
+ @sdk_version = '25.1.5'
99
+ @gen_version = '2.821.8'
100
+ @user_agent = 'speakeasy-sdk/ruby 25.1.5 2.821.8 v2025.01.00 moov_ruby'
101
101
  end
102
102
 
103
103
  sig { returns([String, T::Hash[Symbol, String]]) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moov_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 25.1.4
4
+ version: 25.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Speakeasy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-12 00:00:00.000000000 Z
11
+ date: 2026-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: 2.14.1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: 2.14.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: faraday-multipart
49
49
  requirement: !ruby/object:Gem::Requirement