ding_sdk 0.11.45 → 0.11.47

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/{ding_sdk/utils → crystalline}/metadata_fields.rb +32 -19
  3. data/lib/crystalline/utils.rb +65 -0
  4. data/lib/crystalline.rb +12 -0
  5. data/lib/ding_sdk/lookup.rb +2 -2
  6. data/lib/ding_sdk/models/operations/check_response.rb +1 -1
  7. data/lib/ding_sdk/models/operations/create_authentication_response.rb +1 -1
  8. data/lib/ding_sdk/models/operations/feedback_response.rb +1 -1
  9. data/lib/ding_sdk/models/operations/getauthenticationstatus_request.rb +1 -1
  10. data/lib/ding_sdk/models/operations/getauthenticationstatus_response.rb +1 -1
  11. data/lib/ding_sdk/models/operations/lookup_request.rb +1 -1
  12. data/lib/ding_sdk/models/operations/lookup_response.rb +1 -1
  13. data/lib/ding_sdk/models/operations/retry_response.rb +1 -1
  14. data/lib/ding_sdk/models/shared/authenticationstatusresponse.rb +1 -1
  15. data/lib/ding_sdk/models/shared/createauthenticationrequest.rb +1 -1
  16. data/lib/ding_sdk/models/shared/createauthenticationresponse.rb +1 -1
  17. data/lib/ding_sdk/models/shared/createcheckrequest.rb +1 -1
  18. data/lib/ding_sdk/models/shared/createcheckresponse.rb +1 -1
  19. data/lib/ding_sdk/models/shared/errorresponse.rb +1 -1
  20. data/lib/ding_sdk/models/shared/feedbackrequest.rb +1 -1
  21. data/lib/ding_sdk/models/shared/feedbackresponse.rb +1 -1
  22. data/lib/ding_sdk/models/shared/lookupresponse.rb +1 -1
  23. data/lib/ding_sdk/models/shared/retryauthenticationrequest.rb +1 -1
  24. data/lib/ding_sdk/models/shared/retryauthenticationresponse.rb +1 -1
  25. data/lib/ding_sdk/models/shared/security.rb +1 -1
  26. data/lib/ding_sdk/models/shared/signals.rb +1 -1
  27. data/lib/ding_sdk/otp.rb +10 -10
  28. data/lib/ding_sdk/sdkconfiguration.rb +4 -4
  29. data/lib/ding_sdk/utils/utils.rb +12 -55
  30. data/lib/ding_sdk.rb +1 -2
  31. metadata +20 -4
  32. /data/lib/{ding_sdk/utils → crystalline}/t.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff5c1afc652b5d5f65d8bb1f17a7113dbcb87174f19d1aaff923bd51fbe6ea85
4
- data.tar.gz: ba2d35970a04009f02af82684666b7c1ac62bcffb8266720704c5d90859233c7
3
+ metadata.gz: a58a1e9ce45173c98bf8f48b4e16a944f5a42a674285ad28326eaa26cb085d94
4
+ data.tar.gz: 953372e0531c3e75531c8424dd1adba40b0c4f74c03e8f8c956acc538d58f745
5
5
  SHA512:
6
- metadata.gz: c7103900f60699742fa51bf16fdb717569f673b58668f4f1e43d29c443c82597444e36815273c4fe46a468c7fd8116d348a13cb75358ddb8c0fe1cdea7073263
7
- data.tar.gz: c4905c454e9a1837d9e49ae3d0582a6d680ee45259847a4352ae6be30e8f59fd9410971cb639b45d2c416a25027a95067714bf41d0b4c73f5fc1d07801f52cf3
6
+ metadata.gz: ededbd6fd4d566d2523ed8c14f2dacb1a89ef3fd8e573ff21906a43a00e4bd780b50cd0d980414d34fe864ada5fcc20fa505b7e917a97691a496697fe3813d36
7
+ data.tar.gz: 87515fa27b8853c7146ed20cda8d2cd5075c767fbf025e40945b4fbc1a46ec7dcc72188fa276699a142b3596b867c50db699f548a0b213d84653056aefe1f6b7
@@ -3,7 +3,8 @@
3
3
  # typed: true
4
4
  # frozen_string_literal: true
5
5
 
6
- module DingSDK
6
+ module Crystalline
7
+ extend T::Sig
7
8
  module MetadataFields
8
9
  extend T::Sig
9
10
 
@@ -32,9 +33,13 @@ module DingSDK
32
33
  fields << Field.new(field_name, type, metadata)
33
34
  end
34
35
 
36
+ def field_augmented?
37
+ true
38
+ end
39
+
35
40
  def unmarshal_single(field_type, value, decoder = nil)
36
- if field_type.respond_to? :unmarshal_json
37
- unmarshalled = field_type.unmarshal_json(value)
41
+ if field_type.instance_of?(Class) && field_type < ::Crystalline::FieldAugmented
42
+ unmarshalled = field_type.from_dict(value)
38
43
  return unmarshalled
39
44
  elsif field_type.to_s == 'Object'
40
45
  # rubocop:disable Lint/SuppressedException
@@ -52,14 +57,20 @@ module DingSDK
52
57
  end
53
58
  end
54
59
 
55
- sig { params(json_obj: T.any(String, T::Hash[Symbol, String])).returns(Utils::FieldAugmented) }
56
- def unmarshal_json(json_obj)
57
- to_build = new
60
+ sig { params(json_obj: T.any(String, T::Hash[Symbol, String])).returns(::Crystalline::FieldAugmented) }
61
+ def from_json(json_obj)
58
62
  begin
59
63
  d = JSON.parse(json_obj)
60
64
  rescue TypeError, JSON::ParserError
61
65
  d = json_obj
62
66
  end
67
+ from_dict(d)
68
+ end
69
+
70
+ sig { params(d: T::Hash[Symbol, String]).returns(::Crystalline::FieldAugmented) }
71
+ def from_dict(d)
72
+ to_build = new
73
+
63
74
  fields.each do |field|
64
75
  field_type = field.type
65
76
  if T.nilable? field_type
@@ -113,15 +124,15 @@ module DingSDK
113
124
  end
114
125
 
115
126
  def marshal_single(field)
116
- if field.respond_to? :marshal_json
117
- field.marshal_json(encode: false)
127
+ if field.is_a? ::Crystalline::FieldAugmented
128
+ field.to_dict
118
129
  else
119
- Utils.val_to_string(field, primitives: false)
130
+ ::Crystalline.val_to_string(field, primitives: false)
120
131
  end
121
132
  end
122
133
 
123
- def marshal_json(encode: true)
124
- d = {}
134
+ def to_dict
135
+ result = {}
125
136
  fields.sort_by(&:name).each do |field|
126
137
  f = send(field.name)
127
138
  next if f.nil?
@@ -133,18 +144,20 @@ module DingSDK
133
144
  key = field.name
134
145
  end
135
146
  if f.is_a? Array
136
- d[key] = f.map { |o| marshal_single(o) }
147
+ result[key] = f.map { |o| marshal_single(o) }
137
148
  elsif f.is_a? Hash
138
- d[key] = f.map { |k, v| [k, marshal_single(v)] }
149
+ result[key] = f.map { |k, v| [k, marshal_single(v)] }
139
150
  else
140
- d[key] = marshal_single(f)
151
+ result[key] = marshal_single(f)
141
152
  end
142
153
  end
143
- if encode
144
- JSON.dump(d)
145
- else
146
- d
147
- end
154
+ result
155
+ end
156
+
157
+ def to_json(*args)
158
+ JSON.generate(to_dict, *args)
148
159
  end
149
160
  end
161
+
162
+
150
163
  end
@@ -0,0 +1,65 @@
1
+ # Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2
+
3
+ # typed: true
4
+ # frozen_string_literal: true
5
+
6
+ require 'sorbet-runtime'
7
+
8
+ module Crystalline
9
+ extend T::Sig
10
+
11
+ class FieldAugmented
12
+ include MetadataFields
13
+ end
14
+
15
+ sig { params(complex: Object).returns(Object) }
16
+ def self.marshal_dict_complex(complex)
17
+ if complex.is_a? Array
18
+ complex.map { |v| Crystalline.marshal_dict_complex(v) }
19
+ elsif complex.is_a? Hash
20
+ complex.transform_values { |v| Crystalline.marshal_dict_complex(v) }
21
+ elsif complex.is_a? Crystalline::FieldAugmented
22
+ complex.to_dict
23
+ else
24
+ complex
25
+ end
26
+ end
27
+
28
+ def self.marshal_json_complex(complex)
29
+ JSON.dump(marshal_dict_complex(complex))
30
+ end
31
+
32
+ sig { params(data: Object, type: Object).returns(Object) }
33
+ def self.unmarshal_complex(data, type)
34
+ unmarshal_json(data, type)
35
+ end
36
+
37
+ sig { params(data: Object, type: Object).returns(Object) }
38
+ def self.unmarshal_json(data, type)
39
+ if T.simplifiable? type
40
+ type = T.simplify_type type
41
+ end
42
+ if type.instance_of?(Class) && type < ::Crystalline::FieldAugmented
43
+ type.from_dict(data)
44
+ elsif T.arr? type
45
+ data.map { |v| Crystalline.unmarshal_complex(v, T.arr_of(type)) }
46
+ elsif T.hash? type
47
+ data.transform_values { |v| Crystalline.unmarshal_complex(v, T.hash_of(type)) }
48
+ else
49
+ data
50
+ end
51
+ end
52
+
53
+ sig { params(val: Object, primitives: T::Boolean).returns(Object) }
54
+ def self.val_to_string(val, primitives: true)
55
+ if val.is_a? T::Enum
56
+ val.serialize
57
+ elsif val.is_a? DateTime
58
+ val.strftime('%Y-%m-%dT%H:%M:%S.%NZ')
59
+ elsif primitives
60
+ val.to_s
61
+ else
62
+ val
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,12 @@
1
+ # Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2
+
3
+ # typed: true
4
+ # frozen_string_literal: true
5
+
6
+ module Crystalline
7
+ autoload :MetadataFields, 'crystalline/metadata_fields'
8
+ end
9
+
10
+
11
+ require_relative 'crystalline/utils'
12
+ require_relative 'crystalline/t'
@@ -54,12 +54,12 @@ module DingSDK
54
54
  )
55
55
  if r.status == 200
56
56
  if Utils.match_content_type(content_type, 'application/json')
57
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::LookupResponse)
57
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::LookupResponse)
58
58
  res.lookup_response = out
59
59
  end
60
60
  elsif r.status == 400
61
61
  if Utils.match_content_type(content_type, 'application/json')
62
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::ErrorResponse)
62
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
63
63
  res.error_response = out
64
64
  end
65
65
  end
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Operations
9
9
 
10
10
 
11
- class CheckResponse < ::DingSDK::Utils::FieldAugmented
11
+ class CheckResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # HTTP response content type for this operation
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Operations
9
9
 
10
10
 
11
- class CreateAuthenticationResponse < ::DingSDK::Utils::FieldAugmented
11
+ class CreateAuthenticationResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # HTTP response content type for this operation
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Operations
9
9
 
10
10
 
11
- class FeedbackResponse < ::DingSDK::Utils::FieldAugmented
11
+ class FeedbackResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # HTTP response content type for this operation
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Operations
9
9
 
10
10
 
11
- class GetAuthenticationStatusRequest < ::DingSDK::Utils::FieldAugmented
11
+ class GetAuthenticationStatusRequest < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
 
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Operations
9
9
 
10
10
 
11
- class GetAuthenticationStatusResponse < ::DingSDK::Utils::FieldAugmented
11
+ class GetAuthenticationStatusResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # HTTP response content type for this operation
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Operations
9
9
 
10
10
 
11
- class LookupRequest < ::DingSDK::Utils::FieldAugmented
11
+ class LookupRequest < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
 
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Operations
9
9
 
10
10
 
11
- class LookupResponse < ::DingSDK::Utils::FieldAugmented
11
+ class LookupResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # HTTP response content type for this operation
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Operations
9
9
 
10
10
 
11
- class RetryResponse < ::DingSDK::Utils::FieldAugmented
11
+ class RetryResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # HTTP response content type for this operation
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class AuthenticationStatusResponse < ::DingSDK::Utils::FieldAugmented
11
+ class AuthenticationStatusResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # A unique, user-defined identifier that will be included in webhook events.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class CreateAuthenticationRequest < ::DingSDK::Utils::FieldAugmented
11
+ class CreateAuthenticationRequest < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # Your customer UUID, which can be found in the API settings in the dashboard.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
  # A successful response to an authentication creation request.
11
- class CreateAuthenticationResponse < ::DingSDK::Utils::FieldAugmented
11
+ class CreateAuthenticationResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # A unique identifier for the authentication that you can use on the /check and /retry endpoints.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class CreateCheckRequest < ::DingSDK::Utils::FieldAugmented
11
+ class CreateCheckRequest < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # The authentication UUID that was returned when you created the authentication.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class CreateCheckResponse < ::DingSDK::Utils::FieldAugmented
11
+ class CreateCheckResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # The UUID of the corresponding authentication.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class ErrorResponse < ::DingSDK::Utils::FieldAugmented
11
+ class ErrorResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # A machine-readable code that describes the error.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class FeedbackRequest < ::DingSDK::Utils::FieldAugmented
11
+ class FeedbackRequest < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # Your customer UUID, which can be found in the API settings in the dashboard.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class FeedbackResponse < ::DingSDK::Utils::FieldAugmented
11
+ class FeedbackResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # The UUID of the feedback.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class LookupResponse < ::DingSDK::Utils::FieldAugmented
11
+ class LookupResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # The CNAM (Caller ID Name) associated with the phone number. Contact us if you need to use this functionality. Once enabled, put `cnam` option to `type` query parameter.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class RetryAuthenticationRequest < ::DingSDK::Utils::FieldAugmented
11
+ class RetryAuthenticationRequest < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # The authentication UUID that was returned when you created the authentication.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class RetryAuthenticationResponse < ::DingSDK::Utils::FieldAugmented
11
+ class RetryAuthenticationResponse < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # The UUID of the corresponding authentication.
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
 
11
- class Security < ::DingSDK::Utils::FieldAugmented
11
+ class Security < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
 
@@ -8,7 +8,7 @@ module DingSDK
8
8
  module Shared
9
9
 
10
10
  # [Signals](/guides/prevent-fraud#signals) are data points used to distinguish between fraudulent and legitimate users.
11
- class Signals < ::DingSDK::Utils::FieldAugmented
11
+ class Signals < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
14
  # The Android SMS Retriever API hash code that identifies your app. This allows you to automatically retrieve and fill the OTP code on Android devices.
data/lib/ding_sdk/otp.rb CHANGED
@@ -50,12 +50,12 @@ module DingSDK
50
50
  )
51
51
  if r.status == 200
52
52
  if Utils.match_content_type(content_type, 'application/json')
53
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::CreateCheckResponse)
53
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::CreateCheckResponse)
54
54
  res.create_check_response = out
55
55
  end
56
56
  elsif r.status == 400
57
57
  if Utils.match_content_type(content_type, 'application/json')
58
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::ErrorResponse)
58
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
59
59
  res.error_response = out
60
60
  end
61
61
  end
@@ -95,12 +95,12 @@ module DingSDK
95
95
  )
96
96
  if r.status == 200
97
97
  if Utils.match_content_type(content_type, 'application/json')
98
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::CreateAuthenticationResponse)
98
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::CreateAuthenticationResponse)
99
99
  res.create_authentication_response = out
100
100
  end
101
101
  elsif r.status == 400
102
102
  if Utils.match_content_type(content_type, 'application/json')
103
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::ErrorResponse)
103
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
104
104
  res.error_response = out
105
105
  end
106
106
  end
@@ -140,12 +140,12 @@ module DingSDK
140
140
  )
141
141
  if r.status == 200
142
142
  if Utils.match_content_type(content_type, 'application/json')
143
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::FeedbackResponse)
143
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::FeedbackResponse)
144
144
  res.feedback_response = out
145
145
  end
146
146
  elsif r.status == 400
147
147
  if Utils.match_content_type(content_type, 'application/json')
148
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::ErrorResponse)
148
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
149
149
  res.error_response = out
150
150
  end
151
151
  end
@@ -185,12 +185,12 @@ module DingSDK
185
185
  )
186
186
  if r.status == 200
187
187
  if Utils.match_content_type(content_type, 'application/json')
188
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::AuthenticationStatusResponse)
188
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::AuthenticationStatusResponse)
189
189
  res.authentication_status_response = out
190
190
  end
191
191
  elsif r.status == 400
192
192
  if Utils.match_content_type(content_type, 'application/json')
193
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::ErrorResponse)
193
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
194
194
  res.error_response = out
195
195
  end
196
196
  end
@@ -230,12 +230,12 @@ module DingSDK
230
230
  )
231
231
  if r.status == 200
232
232
  if Utils.match_content_type(content_type, 'application/json')
233
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::RetryAuthenticationResponse)
233
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::RetryAuthenticationResponse)
234
234
  res.retry_authentication_response = out
235
235
  end
236
236
  elsif r.status == 400
237
237
  if Utils.match_content_type(content_type, 'application/json')
238
- out = Utils.unmarshal_complex(r.env.response_body, ::DingSDK::Shared::ErrorResponse)
238
+ out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
239
239
  res.error_response = out
240
240
  end
241
241
  end
@@ -15,7 +15,7 @@ module DingSDK
15
15
  ].freeze
16
16
  # Contains the list of servers available to the SDK
17
17
 
18
- class SDKConfiguration < ::DingSDK::Utils::FieldAugmented
18
+ class SDKConfiguration < ::Crystalline::FieldAugmented
19
19
  extend T::Sig
20
20
 
21
21
  field :client, T.nilable(Faraday::Connection)
@@ -38,9 +38,9 @@ module DingSDK
38
38
  @security = security
39
39
  @language = 'ruby'
40
40
  @openapi_doc_version = '1.0.0'
41
- @sdk_version = '0.11.45'
42
- @gen_version = '2.524.1'
43
- @user_agent = 'speakeasy-sdk/ruby 0.11.45 2.524.1 1.0.0 ding_sdk'
41
+ @sdk_version = '0.11.47'
42
+ @gen_version = '2.531.0'
43
+ @user_agent = 'speakeasy-sdk/ruby 0.11.47 2.531.0 1.0.0 ding_sdk'
44
44
  end
45
45
 
46
46
  sig { returns([String, T::Hash[Symbol, String]]) }
@@ -6,16 +6,11 @@
6
6
  require 'date'
7
7
  require 'sorbet-runtime'
8
8
  require 'base64'
9
- require_relative './metadata_fields'
10
9
 
11
10
  module DingSDK
12
11
  module Utils
13
12
  extend T::Sig
14
13
 
15
- class FieldAugmented
16
- include MetadataFields
17
- end
18
-
19
14
  sig { params(val: Object, primitives: T::Boolean).returns(Object) }
20
15
  def self.val_to_string(val, primitives: true)
21
16
  if val.is_a? T::Enum
@@ -29,7 +24,7 @@ module DingSDK
29
24
  end
30
25
  end
31
26
 
32
- sig { params(headers_params: FieldAugmented, gbls: T.nilable(T::Hash[Symbol, T::Hash[Symbol, T::Hash[Symbol, Object]]])).returns(T::Hash[Symbol, String]) }
27
+ sig { params(headers_params: ::Crystalline::FieldAugmented, gbls: T.nilable(T::Hash[Symbol, T::Hash[Symbol, T::Hash[Symbol, Object]]])).returns(T::Hash[Symbol, String]) }
33
28
  def self.get_headers(headers_params, gbls = nil)
34
29
  return {} if headers_params.nil?
35
30
 
@@ -95,7 +90,7 @@ module DingSDK
95
90
 
96
91
  sig do
97
92
  params(field_name: String, explode: T::Boolean, obj: Object, delimiter: String,
98
- get_field_name_lambda: T.proc.params(obj_field: MetadataFields::Field).returns(String))
93
+ get_field_name_lambda: T.proc.params(obj_field: ::Crystalline::MetadataFields::Field).returns(String))
99
94
  .returns(T::Hash[Symbol, T::Array[String]])
100
95
  end
101
96
  def self._populate_form(field_name, explode, obj, delimiter, &get_field_name_lambda)
@@ -215,7 +210,7 @@ module DingSDK
215
210
  params = {}
216
211
 
217
212
  serialization = metadata.fetch(:serialization, '')
218
- params[metadata.fetch(:field_name, field_name)] = obj.marshal_json if serialization == 'json'
213
+ params[metadata.fetch(:field_name, field_name)] = obj.to_json if serialization == 'json'
219
214
 
220
215
  params
221
216
  end
@@ -236,7 +231,7 @@ module DingSDK
236
231
  _populate_form(field_name, metadata.fetch(:explode, true), obj, delimiter, &get_query_param_field_name)
237
232
  end
238
233
 
239
- sig { params(clazz: Class, query_params: FieldAugmented, gbls: T.nilable(T::Hash[Symbol, T::Hash[Symbol, T::Hash[Symbol, Object]]])).returns(T::Hash[Symbol, T::Array[String]]) }
234
+ sig { params(clazz: Class, query_params: ::Crystalline::FieldAugmented, gbls: T.nilable(T::Hash[Symbol, T::Hash[Symbol, T::Hash[Symbol, Object]]])).returns(T::Hash[Symbol, T::Array[String]]) }
240
235
  def self.get_query_params(clazz, query_params, gbls = nil)
241
236
  params = {}
242
237
  param_fields = clazz.fields
@@ -280,7 +275,7 @@ module DingSDK
280
275
  params
281
276
  end
282
277
 
283
- sig { params(clazz: Class, server_url: String, path: String, path_params: FieldAugmented, gbls: T.nilable(T::Hash[Symbol, T::Hash[Symbol, T::Hash[Symbol, Object]]])).returns(String) }
278
+ sig { params(clazz: Class, server_url: String, path: String, path_params: ::Crystalline::FieldAugmented, gbls: T.nilable(T::Hash[Symbol, T::Hash[Symbol, T::Hash[Symbol, Object]]])).returns(String) }
284
279
  def self.generate_url(clazz, server_url, path, path_params, gbls = nil)
285
280
  clazz.fields.each do |f|
286
281
  param_metadata = f.metadata[:path_param]
@@ -463,7 +458,7 @@ module DingSDK
463
458
  end
464
459
  end
465
460
 
466
- sig { params(req: Faraday::Request, scheme: FieldAugmented).void }
461
+ sig { params(req: Faraday::Request, scheme: ::Crystalline::FieldAugmented).void }
467
462
  def self._parse_basic_auth_scheme(req, scheme)
468
463
  username, password = ''
469
464
 
@@ -559,7 +554,7 @@ module DingSDK
559
554
  .returns([String, Object, T.nilable(T::Array[T::Array[Object]])])
560
555
  end
561
556
  def self.serialize_content_type(field_name, media_type, request)
562
- return media_type, marshal_json_complex(request), nil if media_type.match('(application|text)\/.*?\+*json.*')
557
+ return media_type, ::Crystalline.marshal_json_complex(request), nil if media_type.match('(application|text)\/.*?\+*json.*')
563
558
  return serialize_multipart_form(media_type, request) if media_type.match('multipart\/.*')
564
559
  return media_type, serialize_form_data(field_name, request), nil if media_type.match('application\/x-www-form-urlencoded.*')
565
560
  return media_type, request, nil if request.is_a?(String) || request.is_a?(Array)
@@ -567,7 +562,7 @@ module DingSDK
567
562
  raise StandardError, "invalid request body type #{type(request)} for mediaType {metadata['media_type']}"
568
563
  end
569
564
 
570
- sig { params(field: MetadataFields::Field, data_class: FieldAugmented).returns(Object) }
565
+ sig { params(field: ::Crystalline::MetadataFields::Field, data_class: ::Crystalline::FieldAugmented).returns(Object) }
571
566
  def self.parse_field(field, data_class)
572
567
  field_metadata = field.metadata[:metadata_string]
573
568
  return nil if field_metadata.nil?
@@ -578,7 +573,7 @@ module DingSDK
578
573
  field_value
579
574
  end
580
575
 
581
- sig { params(media_type: String, request: FieldAugmented).returns([String, Object, T::Array[T::Array[Object]]]) }
576
+ sig { params(media_type: String, request: ::Crystalline::FieldAugmented).returns([String, Object, T::Array[T::Array[Object]]]) }
582
577
  def self.serialize_multipart_form(media_type, request)
583
578
  form = []
584
579
  request_fields = request.fields
@@ -612,7 +607,7 @@ module DingSDK
612
607
  elsif field_metadata[:json] == true
613
608
  to_append = [
614
609
  field_metadata.fetch(:field_name, field.name), [
615
- nil, marshal_json_complex(val), 'application/json'
610
+ nil, ::Crystalline.marshal_json_complex(val), 'application/json'
616
611
  ]
617
612
  ]
618
613
  form.append(to_append)
@@ -657,7 +652,7 @@ module DingSDK
657
652
  end
658
653
 
659
654
  sig do
660
- params(field_name: Symbol, data: T.any(FieldAugmented, T::Hash[Symbol, String]))
655
+ params(field_name: Symbol, data: T.any(::Crystalline::FieldAugmented, T::Hash[Symbol, String]))
661
656
  .returns(T::Hash[Symbol, Object])
662
657
  end
663
658
  def self.serialize_form_data(field_name, data)
@@ -682,7 +677,7 @@ module DingSDK
682
677
  field_name = metadata.fetch(:field_name, field.name)
683
678
 
684
679
  if metadata[:json]
685
- form[field_name] = marshal_json_complex(val)
680
+ form[field_name] = ::Crystalline.marshal_json_complex(val)
686
681
  else
687
682
  if metadata.fetch(:style, 'form') == 'form'
688
683
  form = form.merge(
@@ -729,43 +724,5 @@ module DingSDK
729
724
  value
730
725
  end
731
726
 
732
- sig { params(complex: Object).returns(Object) }
733
- def self.marshal_json_complex(complex)
734
- if complex.is_a? Array
735
- complex.map { |v| Utils.marshal_json_complex(v) }.to_json
736
- elsif complex.is_a? Hash
737
- complex.transform_values { |v| Utils.marshal_json_complex(v) }.to_json
738
- elsif complex.respond_to? :marshal_json
739
- complex.marshal_json
740
- else
741
- complex.to_json
742
- end
743
- end
744
-
745
- sig { params(data: Object, type: Object).returns(Object) }
746
- def self.unmarshal_complex(data, type)
747
- begin
748
- value = unmarshal_json(JSON.parse(data), type)
749
- rescue TypeError, JSON::ParserError
750
- value = unmarshal_json(data, type)
751
- end
752
- value
753
- end
754
-
755
- sig { params(data: Object, type: Object).returns(Object) }
756
- def self.unmarshal_json(data, type)
757
- if T.simplifiable? type
758
- type = T.simplify_type type
759
- end
760
- if type.respond_to? :unmarshal_json
761
- type.unmarshal_json(data)
762
- elsif T.arr? type
763
- data.map { |v| Utils.unmarshal_complex(v, T.arr_of(type)) }
764
- elsif T.hash? type
765
- data.transform_values { |v| Utils.unmarshal_complex(v, T.hash_of(type)) }
766
- else
767
- data
768
- end
769
- end
770
727
  end
771
728
  end
data/lib/ding_sdk.rb CHANGED
@@ -11,7 +11,6 @@ module DingSDK
11
11
  autoload :Lookup, 'ding_sdk/lookup'
12
12
  end
13
13
 
14
- require_relative 'ding_sdk/utils/t'
15
14
  require_relative 'ding_sdk/utils/utils'
16
- require_relative 'ding_sdk/utils/metadata_fields'
15
+ require_relative 'crystalline'
17
16
  require_relative 'ding_sdk/sdkconfiguration'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ding_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.45
4
+ version: 0.11.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ding
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-25 00:00:00.000000000 Z
11
+ date: 2025-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest-focus
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rubocop
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +156,10 @@ executables: []
142
156
  extensions: []
143
157
  extra_rdoc_files: []
144
158
  files:
159
+ - lib/crystalline.rb
160
+ - lib/crystalline/metadata_fields.rb
161
+ - lib/crystalline/t.rb
162
+ - lib/crystalline/utils.rb
145
163
  - lib/ding_sdk.rb
146
164
  - lib/ding_sdk/ding.rb
147
165
  - lib/ding_sdk/lookup.rb
@@ -179,8 +197,6 @@ files:
179
197
  - lib/ding_sdk/models/shared/status.rb
180
198
  - lib/ding_sdk/otp.rb
181
199
  - lib/ding_sdk/sdkconfiguration.rb
182
- - lib/ding_sdk/utils/metadata_fields.rb
183
- - lib/ding_sdk/utils/t.rb
184
200
  - lib/ding_sdk/utils/utils.rb
185
201
  homepage: https://github.com/ding-live/ding-ruby.git
186
202
  licenses:
File without changes