ding_sdk 0.13.2 → 0.14.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: f8f3419a3adeb206df7e90d1c1adbd6fc291ec8ee40baccda555ad8ae1c97bff
4
- data.tar.gz: '0888b5a7f86972967b1387c7aea4af56c7e578c55746de3aa5369f26372b1b72'
3
+ metadata.gz: fad17358d82333ac084fc0d3f9aa113f00237fb8220a3083ffe1fa44a8d68b6d
4
+ data.tar.gz: ac8d0717d3df1f9ee02bd885c845b4c3bf7c86b11e60937b0a496469500b41ce
5
5
  SHA512:
6
- metadata.gz: bfb8cbdf029c38261b602ff3b63096827729f8e2365ec2ed5985c86139ba30efb88d17af0b61119364baef27d16115c5b2cda6f5c3358f326a2c8e8308270fc4
7
- data.tar.gz: 50ac6bed7fc077c0898b27679f54fedbed7f2f95ce95f3b6b5c80b635aed12e4e266782ed543801387827785cb02bbf28b0b9ce80d8567c350d4d8f43a64ec07
6
+ metadata.gz: aa40776373e9c79bbf183daa508b5eff3790f3e8224e8d9fa9ced67485c4abed8096c86f3be5a60e55c8be6529ea0df19019e85da72a4da24f3cad6f14c96bef
7
+ data.tar.gz: fd4e5a1c7a56ae5b0caef8bcb64dd34a3ae6aceeb680f178901a2f39af8e27b46e6a415a2e1d2688d065170650196fb90c8cf4f81fd41e442c685c7612fe1f93
@@ -59,10 +59,11 @@ module DingSDK
59
59
  )
60
60
 
61
61
  error = T.let(nil, T.nilable(StandardError))
62
- r = T.let(nil, T.nilable(Faraday::Response))
62
+ http_response = T.let(nil, T.nilable(Faraday::Response))
63
+
63
64
 
64
65
  begin
65
- r = connection.get(url) do |req|
66
+ http_response = connection.get(url) do |req|
66
67
  req.headers.merge!(headers)
67
68
  req.options.timeout = timeout unless timeout.nil?
68
69
  req.params = query_params
@@ -78,47 +79,73 @@ module DingSDK
78
79
  rescue StandardError => e
79
80
  error = e
80
81
  ensure
81
- if r.nil? || Utils.error_status?(r.status)
82
- r = @sdk_configuration.hooks.after_error(
82
+ if http_response.nil? || Utils.error_status?(http_response.status)
83
+ http_response = @sdk_configuration.hooks.after_error(
83
84
  error: error,
84
85
  hook_ctx: SDKHooks::AfterErrorHookContext.new(
85
86
  hook_ctx: hook_ctx
86
87
  ),
87
- response: r
88
+ response: http_response
88
89
  )
89
90
  else
90
- r = @sdk_configuration.hooks.after_success(
91
+ http_response = @sdk_configuration.hooks.after_success(
91
92
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
92
93
  hook_ctx: hook_ctx
93
94
  ),
94
- response: r
95
+ response: http_response
95
96
  )
96
97
  end
97
98
 
98
- if r.nil?
99
+ if http_response.nil?
99
100
  raise error if !error.nil?
100
101
  raise 'no response'
101
102
  end
102
103
  end
103
-
104
- content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
105
-
106
- res = ::DingSDK::Operations::LookupResponse.new(
107
- status_code: r.status, content_type: content_type, raw_response: r
108
- )
109
- if r.status == 200
104
+
105
+ content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
106
+ if Utils.match_status_code(http_response.status, ['200'])
110
107
  if Utils.match_content_type(content_type, 'application/json')
111
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::LookupResponse)
112
- res.lookup_response = out
108
+ http_response = @sdk_configuration.hooks.after_success(
109
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
110
+ hook_ctx: hook_ctx
111
+ ),
112
+ response: http_response
113
+ )
114
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::LookupResponse)
115
+ response = ::DingSDK::Operations::LookupResponse.new(
116
+ status_code: http_response.status,
117
+ content_type: content_type,
118
+ raw_response: http_response,
119
+ lookup_response: obj
120
+ )
121
+
122
+ return response
123
+ else
124
+ raise StandardError, 'API returned unexpected content type'
113
125
  end
114
- elsif r.status == 400
126
+ elsif Utils.match_status_code(http_response.status, ['400'])
115
127
  if Utils.match_content_type(content_type, 'application/json')
116
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
117
- res.error_response = out
128
+ http_response = @sdk_configuration.hooks.after_success(
129
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
130
+ hook_ctx: hook_ctx
131
+ ),
132
+ response: http_response
133
+ )
134
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::ErrorResponse)
135
+ response = ::DingSDK::Operations::LookupResponse.new(
136
+ status_code: http_response.status,
137
+ content_type: content_type,
138
+ raw_response: http_response,
139
+ error_response: obj
140
+ )
141
+
142
+ return response
143
+ else
144
+ raise StandardError, 'API returned unexpected content type'
118
145
  end
146
+ else
147
+ raise StandardError, 'Unexpected response status code'
119
148
  end
120
-
121
- res
122
149
  end
123
150
  end
124
151
  end
data/lib/ding_sdk/otp.rb CHANGED
@@ -57,10 +57,11 @@ module DingSDK
57
57
  )
58
58
 
59
59
  error = T.let(nil, T.nilable(StandardError))
60
- r = T.let(nil, T.nilable(Faraday::Response))
60
+ http_response = T.let(nil, T.nilable(Faraday::Response))
61
+
61
62
 
62
63
  begin
63
- r = connection.post(url) do |req|
64
+ http_response = connection.post(url) do |req|
64
65
  req.body = body
65
66
  req.headers.merge!(headers)
66
67
  req.options.timeout = timeout unless timeout.nil?
@@ -76,47 +77,73 @@ module DingSDK
76
77
  rescue StandardError => e
77
78
  error = e
78
79
  ensure
79
- if r.nil? || Utils.error_status?(r.status)
80
- r = @sdk_configuration.hooks.after_error(
80
+ if http_response.nil? || Utils.error_status?(http_response.status)
81
+ http_response = @sdk_configuration.hooks.after_error(
81
82
  error: error,
82
83
  hook_ctx: SDKHooks::AfterErrorHookContext.new(
83
84
  hook_ctx: hook_ctx
84
85
  ),
85
- response: r
86
+ response: http_response
86
87
  )
87
88
  else
88
- r = @sdk_configuration.hooks.after_success(
89
+ http_response = @sdk_configuration.hooks.after_success(
89
90
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
90
91
  hook_ctx: hook_ctx
91
92
  ),
92
- response: r
93
+ response: http_response
93
94
  )
94
95
  end
95
96
 
96
- if r.nil?
97
+ if http_response.nil?
97
98
  raise error if !error.nil?
98
99
  raise 'no response'
99
100
  end
100
101
  end
101
-
102
- content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
103
-
104
- res = ::DingSDK::Operations::CheckResponse.new(
105
- status_code: r.status, content_type: content_type, raw_response: r
106
- )
107
- if r.status == 200
102
+
103
+ content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
104
+ if Utils.match_status_code(http_response.status, ['200'])
108
105
  if Utils.match_content_type(content_type, 'application/json')
109
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::CreateCheckResponse)
110
- res.create_check_response = out
106
+ http_response = @sdk_configuration.hooks.after_success(
107
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
108
+ hook_ctx: hook_ctx
109
+ ),
110
+ response: http_response
111
+ )
112
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::CreateCheckResponse)
113
+ response = ::DingSDK::Operations::CheckResponse.new(
114
+ status_code: http_response.status,
115
+ content_type: content_type,
116
+ raw_response: http_response,
117
+ create_check_response: obj
118
+ )
119
+
120
+ return response
121
+ else
122
+ raise StandardError, 'API returned unexpected content type'
111
123
  end
112
- elsif r.status == 400
124
+ elsif Utils.match_status_code(http_response.status, ['400'])
113
125
  if Utils.match_content_type(content_type, 'application/json')
114
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
115
- res.error_response = out
126
+ http_response = @sdk_configuration.hooks.after_success(
127
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
128
+ hook_ctx: hook_ctx
129
+ ),
130
+ response: http_response
131
+ )
132
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::ErrorResponse)
133
+ response = ::DingSDK::Operations::CheckResponse.new(
134
+ status_code: http_response.status,
135
+ content_type: content_type,
136
+ raw_response: http_response,
137
+ error_response: obj
138
+ )
139
+
140
+ return response
141
+ else
142
+ raise StandardError, 'API returned unexpected content type'
116
143
  end
144
+ else
145
+ raise StandardError, 'Unexpected response status code'
117
146
  end
118
-
119
- res
120
147
  end
121
148
 
122
149
 
@@ -155,10 +182,11 @@ module DingSDK
155
182
  )
156
183
 
157
184
  error = T.let(nil, T.nilable(StandardError))
158
- r = T.let(nil, T.nilable(Faraday::Response))
185
+ http_response = T.let(nil, T.nilable(Faraday::Response))
186
+
159
187
 
160
188
  begin
161
- r = connection.post(url) do |req|
189
+ http_response = connection.post(url) do |req|
162
190
  req.body = body
163
191
  req.headers.merge!(headers)
164
192
  req.options.timeout = timeout unless timeout.nil?
@@ -174,47 +202,73 @@ module DingSDK
174
202
  rescue StandardError => e
175
203
  error = e
176
204
  ensure
177
- if r.nil? || Utils.error_status?(r.status)
178
- r = @sdk_configuration.hooks.after_error(
205
+ if http_response.nil? || Utils.error_status?(http_response.status)
206
+ http_response = @sdk_configuration.hooks.after_error(
179
207
  error: error,
180
208
  hook_ctx: SDKHooks::AfterErrorHookContext.new(
181
209
  hook_ctx: hook_ctx
182
210
  ),
183
- response: r
211
+ response: http_response
184
212
  )
185
213
  else
186
- r = @sdk_configuration.hooks.after_success(
214
+ http_response = @sdk_configuration.hooks.after_success(
187
215
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
188
216
  hook_ctx: hook_ctx
189
217
  ),
190
- response: r
218
+ response: http_response
191
219
  )
192
220
  end
193
221
 
194
- if r.nil?
222
+ if http_response.nil?
195
223
  raise error if !error.nil?
196
224
  raise 'no response'
197
225
  end
198
226
  end
199
-
200
- content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
201
-
202
- res = ::DingSDK::Operations::CreateAuthenticationResponse.new(
203
- status_code: r.status, content_type: content_type, raw_response: r
204
- )
205
- if r.status == 200
227
+
228
+ content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
229
+ if Utils.match_status_code(http_response.status, ['200'])
206
230
  if Utils.match_content_type(content_type, 'application/json')
207
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::CreateAuthenticationResponse)
208
- res.create_authentication_response = out
231
+ http_response = @sdk_configuration.hooks.after_success(
232
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
233
+ hook_ctx: hook_ctx
234
+ ),
235
+ response: http_response
236
+ )
237
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::CreateAuthenticationResponse)
238
+ response = ::DingSDK::Operations::CreateAuthenticationResponse.new(
239
+ status_code: http_response.status,
240
+ content_type: content_type,
241
+ raw_response: http_response,
242
+ create_authentication_response: obj
243
+ )
244
+
245
+ return response
246
+ else
247
+ raise StandardError, 'API returned unexpected content type'
209
248
  end
210
- elsif r.status == 400
249
+ elsif Utils.match_status_code(http_response.status, ['400'])
211
250
  if Utils.match_content_type(content_type, 'application/json')
212
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
213
- res.error_response = out
251
+ http_response = @sdk_configuration.hooks.after_success(
252
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
253
+ hook_ctx: hook_ctx
254
+ ),
255
+ response: http_response
256
+ )
257
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::ErrorResponse)
258
+ response = ::DingSDK::Operations::CreateAuthenticationResponse.new(
259
+ status_code: http_response.status,
260
+ content_type: content_type,
261
+ raw_response: http_response,
262
+ error_response: obj
263
+ )
264
+
265
+ return response
266
+ else
267
+ raise StandardError, 'API returned unexpected content type'
214
268
  end
269
+ else
270
+ raise StandardError, 'Unexpected response status code'
215
271
  end
216
-
217
- res
218
272
  end
219
273
 
220
274
 
@@ -253,10 +307,11 @@ module DingSDK
253
307
  )
254
308
 
255
309
  error = T.let(nil, T.nilable(StandardError))
256
- r = T.let(nil, T.nilable(Faraday::Response))
310
+ http_response = T.let(nil, T.nilable(Faraday::Response))
311
+
257
312
 
258
313
  begin
259
- r = connection.post(url) do |req|
314
+ http_response = connection.post(url) do |req|
260
315
  req.body = body
261
316
  req.headers.merge!(headers)
262
317
  req.options.timeout = timeout unless timeout.nil?
@@ -272,47 +327,73 @@ module DingSDK
272
327
  rescue StandardError => e
273
328
  error = e
274
329
  ensure
275
- if r.nil? || Utils.error_status?(r.status)
276
- r = @sdk_configuration.hooks.after_error(
330
+ if http_response.nil? || Utils.error_status?(http_response.status)
331
+ http_response = @sdk_configuration.hooks.after_error(
277
332
  error: error,
278
333
  hook_ctx: SDKHooks::AfterErrorHookContext.new(
279
334
  hook_ctx: hook_ctx
280
335
  ),
281
- response: r
336
+ response: http_response
282
337
  )
283
338
  else
284
- r = @sdk_configuration.hooks.after_success(
339
+ http_response = @sdk_configuration.hooks.after_success(
285
340
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
286
341
  hook_ctx: hook_ctx
287
342
  ),
288
- response: r
343
+ response: http_response
289
344
  )
290
345
  end
291
346
 
292
- if r.nil?
347
+ if http_response.nil?
293
348
  raise error if !error.nil?
294
349
  raise 'no response'
295
350
  end
296
351
  end
297
-
298
- content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
299
-
300
- res = ::DingSDK::Operations::FeedbackResponse.new(
301
- status_code: r.status, content_type: content_type, raw_response: r
302
- )
303
- if r.status == 200
352
+
353
+ content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
354
+ if Utils.match_status_code(http_response.status, ['200'])
304
355
  if Utils.match_content_type(content_type, 'application/json')
305
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::FeedbackResponse)
306
- res.feedback_response = out
356
+ http_response = @sdk_configuration.hooks.after_success(
357
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
358
+ hook_ctx: hook_ctx
359
+ ),
360
+ response: http_response
361
+ )
362
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::FeedbackResponse)
363
+ response = ::DingSDK::Operations::FeedbackResponse.new(
364
+ status_code: http_response.status,
365
+ content_type: content_type,
366
+ raw_response: http_response,
367
+ feedback_response: obj
368
+ )
369
+
370
+ return response
371
+ else
372
+ raise StandardError, 'API returned unexpected content type'
307
373
  end
308
- elsif r.status == 400
374
+ elsif Utils.match_status_code(http_response.status, ['400'])
309
375
  if Utils.match_content_type(content_type, 'application/json')
310
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
311
- res.error_response = out
376
+ http_response = @sdk_configuration.hooks.after_success(
377
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
378
+ hook_ctx: hook_ctx
379
+ ),
380
+ response: http_response
381
+ )
382
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::ErrorResponse)
383
+ response = ::DingSDK::Operations::FeedbackResponse.new(
384
+ status_code: http_response.status,
385
+ content_type: content_type,
386
+ raw_response: http_response,
387
+ error_response: obj
388
+ )
389
+
390
+ return response
391
+ else
392
+ raise StandardError, 'API returned unexpected content type'
312
393
  end
394
+ else
395
+ raise StandardError, 'Unexpected response status code'
313
396
  end
314
-
315
- res
316
397
  end
317
398
 
318
399
 
@@ -350,10 +431,11 @@ module DingSDK
350
431
  )
351
432
 
352
433
  error = T.let(nil, T.nilable(StandardError))
353
- r = T.let(nil, T.nilable(Faraday::Response))
434
+ http_response = T.let(nil, T.nilable(Faraday::Response))
435
+
354
436
 
355
437
  begin
356
- r = connection.get(url) do |req|
438
+ http_response = connection.get(url) do |req|
357
439
  req.headers.merge!(headers)
358
440
  req.options.timeout = timeout unless timeout.nil?
359
441
  Utils.configure_request_security(req, security)
@@ -368,47 +450,73 @@ module DingSDK
368
450
  rescue StandardError => e
369
451
  error = e
370
452
  ensure
371
- if r.nil? || Utils.error_status?(r.status)
372
- r = @sdk_configuration.hooks.after_error(
453
+ if http_response.nil? || Utils.error_status?(http_response.status)
454
+ http_response = @sdk_configuration.hooks.after_error(
373
455
  error: error,
374
456
  hook_ctx: SDKHooks::AfterErrorHookContext.new(
375
457
  hook_ctx: hook_ctx
376
458
  ),
377
- response: r
459
+ response: http_response
378
460
  )
379
461
  else
380
- r = @sdk_configuration.hooks.after_success(
462
+ http_response = @sdk_configuration.hooks.after_success(
381
463
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
382
464
  hook_ctx: hook_ctx
383
465
  ),
384
- response: r
466
+ response: http_response
385
467
  )
386
468
  end
387
469
 
388
- if r.nil?
470
+ if http_response.nil?
389
471
  raise error if !error.nil?
390
472
  raise 'no response'
391
473
  end
392
474
  end
393
-
394
- content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
395
-
396
- res = ::DingSDK::Operations::GetAuthenticationStatusResponse.new(
397
- status_code: r.status, content_type: content_type, raw_response: r
398
- )
399
- if r.status == 200
475
+
476
+ content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
477
+ if Utils.match_status_code(http_response.status, ['200'])
400
478
  if Utils.match_content_type(content_type, 'application/json')
401
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::AuthenticationStatusResponse)
402
- res.authentication_status_response = out
479
+ http_response = @sdk_configuration.hooks.after_success(
480
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
481
+ hook_ctx: hook_ctx
482
+ ),
483
+ response: http_response
484
+ )
485
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::AuthenticationStatusResponse)
486
+ response = ::DingSDK::Operations::GetAuthenticationStatusResponse.new(
487
+ status_code: http_response.status,
488
+ content_type: content_type,
489
+ raw_response: http_response,
490
+ authentication_status_response: obj
491
+ )
492
+
493
+ return response
494
+ else
495
+ raise StandardError, 'API returned unexpected content type'
403
496
  end
404
- elsif r.status == 400
497
+ elsif Utils.match_status_code(http_response.status, ['400'])
405
498
  if Utils.match_content_type(content_type, 'application/json')
406
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
407
- res.error_response = out
499
+ http_response = @sdk_configuration.hooks.after_success(
500
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
501
+ hook_ctx: hook_ctx
502
+ ),
503
+ response: http_response
504
+ )
505
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::ErrorResponse)
506
+ response = ::DingSDK::Operations::GetAuthenticationStatusResponse.new(
507
+ status_code: http_response.status,
508
+ content_type: content_type,
509
+ raw_response: http_response,
510
+ error_response: obj
511
+ )
512
+
513
+ return response
514
+ else
515
+ raise StandardError, 'API returned unexpected content type'
408
516
  end
517
+ else
518
+ raise StandardError, 'Unexpected response status code'
409
519
  end
410
-
411
- res
412
520
  end
413
521
 
414
522
 
@@ -447,10 +555,11 @@ module DingSDK
447
555
  )
448
556
 
449
557
  error = T.let(nil, T.nilable(StandardError))
450
- r = T.let(nil, T.nilable(Faraday::Response))
558
+ http_response = T.let(nil, T.nilable(Faraday::Response))
559
+
451
560
 
452
561
  begin
453
- r = connection.post(url) do |req|
562
+ http_response = connection.post(url) do |req|
454
563
  req.body = body
455
564
  req.headers.merge!(headers)
456
565
  req.options.timeout = timeout unless timeout.nil?
@@ -466,47 +575,73 @@ module DingSDK
466
575
  rescue StandardError => e
467
576
  error = e
468
577
  ensure
469
- if r.nil? || Utils.error_status?(r.status)
470
- r = @sdk_configuration.hooks.after_error(
578
+ if http_response.nil? || Utils.error_status?(http_response.status)
579
+ http_response = @sdk_configuration.hooks.after_error(
471
580
  error: error,
472
581
  hook_ctx: SDKHooks::AfterErrorHookContext.new(
473
582
  hook_ctx: hook_ctx
474
583
  ),
475
- response: r
584
+ response: http_response
476
585
  )
477
586
  else
478
- r = @sdk_configuration.hooks.after_success(
587
+ http_response = @sdk_configuration.hooks.after_success(
479
588
  hook_ctx: SDKHooks::AfterSuccessHookContext.new(
480
589
  hook_ctx: hook_ctx
481
590
  ),
482
- response: r
591
+ response: http_response
483
592
  )
484
593
  end
485
594
 
486
- if r.nil?
595
+ if http_response.nil?
487
596
  raise error if !error.nil?
488
597
  raise 'no response'
489
598
  end
490
599
  end
491
-
492
- content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
493
-
494
- res = ::DingSDK::Operations::RetryResponse.new(
495
- status_code: r.status, content_type: content_type, raw_response: r
496
- )
497
- if r.status == 200
600
+
601
+ content_type = http_response.headers.fetch('Content-Type', 'application/octet-stream')
602
+ if Utils.match_status_code(http_response.status, ['200'])
498
603
  if Utils.match_content_type(content_type, 'application/json')
499
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::RetryAuthenticationResponse)
500
- res.retry_authentication_response = out
604
+ http_response = @sdk_configuration.hooks.after_success(
605
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
606
+ hook_ctx: hook_ctx
607
+ ),
608
+ response: http_response
609
+ )
610
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::RetryAuthenticationResponse)
611
+ response = ::DingSDK::Operations::RetryResponse.new(
612
+ status_code: http_response.status,
613
+ content_type: content_type,
614
+ raw_response: http_response,
615
+ retry_authentication_response: obj
616
+ )
617
+
618
+ return response
619
+ else
620
+ raise StandardError, 'API returned unexpected content type'
501
621
  end
502
- elsif r.status == 400
622
+ elsif Utils.match_status_code(http_response.status, ['400'])
503
623
  if Utils.match_content_type(content_type, 'application/json')
504
- out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::DingSDK::Shared::ErrorResponse)
505
- res.error_response = out
624
+ http_response = @sdk_configuration.hooks.after_success(
625
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
626
+ hook_ctx: hook_ctx
627
+ ),
628
+ response: http_response
629
+ )
630
+ obj = Crystalline.unmarshal_json(JSON.parse(http_response.env.response_body), ::DingSDK::Shared::ErrorResponse)
631
+ response = ::DingSDK::Operations::RetryResponse.new(
632
+ status_code: http_response.status,
633
+ content_type: content_type,
634
+ raw_response: http_response,
635
+ error_response: obj
636
+ )
637
+
638
+ return response
639
+ else
640
+ raise StandardError, 'API returned unexpected content type'
506
641
  end
642
+ else
643
+ raise StandardError, 'Unexpected response status code'
507
644
  end
508
-
509
- res
510
645
  end
511
646
  end
512
647
  end
@@ -61,9 +61,9 @@ module DingSDK
61
61
  end
62
62
  @language = 'ruby'
63
63
  @openapi_doc_version = '1.0.0'
64
- @sdk_version = '0.13.2'
65
- @gen_version = '2.566.5'
66
- @user_agent = 'speakeasy-sdk/ruby 0.13.2 2.566.5 1.0.0 ding_sdk'
64
+ @sdk_version = '0.14.0'
65
+ @gen_version = '2.568.2'
66
+ @user_agent = 'speakeasy-sdk/ruby 0.14.0 2.568.2 1.0.0 ding_sdk'
67
67
  end
68
68
 
69
69
  sig { returns([String, T::Hash[Symbol, String]]) }
@@ -372,6 +372,17 @@ module DingSDK
372
372
  false
373
373
  end
374
374
 
375
+ sig { params(status_code: Integer, status_codes: T::Array[String]).returns(T::Boolean) }
376
+ def self.match_status_code(status_code, status_codes)
377
+ return true if status_codes.include? 'default'
378
+ status_code = status_code.to_s
379
+ status_codes.each do |code|
380
+ return true if code == status_code
381
+ return true if code.end_with?('xx') && status_code[0..1] == code[0..1]
382
+ end
383
+ false
384
+ end
385
+
375
386
  sig { params(req: Faraday::Request, security: Object).void }
376
387
  def self.configure_request_security(req, security)
377
388
  return if security.nil?
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.13.2
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ding
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-07 00:00:00.000000000 Z
11
+ date: 2025-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday