moov_ruby 26.4.0.pre.dev.3 → 26.4.0.pre.dev.4
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5725710c938e291d9ab5a5839ac1057e603b8e24f4d7c213236db4be6e948dac
|
|
4
|
+
data.tar.gz: 4cbad0abfa1dd67895486fabc60503d0126f92fc2c062307eed34f26be55ab0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc28dec6087c82dd5376da8a4dc80505c4bf926790b627c9923d7c75b3ed7704485b9c1c9224f0885945fac750ccdd13bda60db6c7f6941d6c77e09ddd28cbae
|
|
7
|
+
data.tar.gz: ee87c35fe605529af348cf796d14af02cb40ebbfc02ae79dda39f328c69640bbaf4088f56838e0f296e2c9d8d6eaa2a8906a4c3baa1b8694e78eb3b1f5019390
|
|
@@ -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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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)
|
data/lib/crystalline/module.rb
CHANGED
|
@@ -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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
|
@@ -95,9 +95,9 @@ module Moov
|
|
|
95
95
|
@globals = globals.nil? ? {} : globals
|
|
96
96
|
@language = 'ruby'
|
|
97
97
|
@openapi_doc_version = 'v2026.04.00'
|
|
98
|
-
@sdk_version = '26.4.0-dev.
|
|
99
|
-
@gen_version = '2.
|
|
100
|
-
@user_agent = 'speakeasy-sdk/ruby 26.4.0-dev.
|
|
98
|
+
@sdk_version = '26.4.0-dev.4'
|
|
99
|
+
@gen_version = '2.821.8'
|
|
100
|
+
@user_agent = 'speakeasy-sdk/ruby 26.4.0-dev.4 2.821.8 v2026.04.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: 26.4.0.pre.dev.
|
|
4
|
+
version: 26.4.0.pre.dev.4
|
|
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-
|
|
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:
|
|
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:
|
|
46
|
+
version: 2.14.1
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: faraday-multipart
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|