dub 0.2.2.pre.alpha.78 → 0.2.2.pre.alpha.80

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.
@@ -7,6 +7,7 @@ require 'faraday'
7
7
  require 'faraday/multipart'
8
8
  require 'faraday/retry'
9
9
  require 'sorbet-runtime'
10
+ require_relative 'sdk_hooks/hooks'
10
11
  require_relative 'utils/retries'
11
12
 
12
13
  module OpenApiSDK
@@ -21,8 +22,8 @@ module OpenApiSDK
21
22
  end
22
23
 
23
24
 
24
- sig { params(request: T.nilable(::OpenApiSDK::Operations::GetMetatagsRequest)).returns(::OpenApiSDK::Operations::GetMetatagsResponse) }
25
- def get(request)
25
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::GetMetatagsRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::GetMetatagsResponse) }
26
+ def get(request, timeout_ms = nil)
26
27
  # get - Retrieve the metatags for a URL
27
28
  # Retrieve the metatags for a URL.
28
29
  url, params = @sdk_configuration.get_server_details
@@ -33,13 +34,61 @@ module OpenApiSDK
33
34
  headers['Accept'] = 'application/json'
34
35
  headers['user-agent'] = @sdk_configuration.user_agent
35
36
 
37
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
38
+
39
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
40
+ timeout ||= @sdk_configuration.timeout
41
+
36
42
  connection = @sdk_configuration.client
37
43
 
38
- r = connection.get(url) do |req|
39
- req.headers = headers
40
- req.params = query_params
41
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
42
- Utils.configure_request_security(req, security) if !security.nil?
44
+ hook_ctx = SDKHooks::HookContext.new(
45
+ base_url: base_url,
46
+ oauth2_scopes: [],
47
+ operation_id: 'getMetatags',
48
+ security_source: @sdk_configuration.security_source
49
+ )
50
+
51
+ error = T.let(nil, T.nilable(StandardError))
52
+ r = T.let(nil, T.nilable(Faraday::Response))
53
+
54
+ begin
55
+ r = connection.get(url) do |req|
56
+ req.headers.merge!(headers)
57
+ req.options.timeout = timeout unless timeout.nil?
58
+ req.params = query_params
59
+ Utils.configure_request_security(req, security)
60
+
61
+ @sdk_configuration.hooks.before_request(
62
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
63
+ hook_ctx: hook_ctx
64
+ ),
65
+ request: req
66
+ )
67
+ end
68
+ rescue StandardError => e
69
+ error = e
70
+ ensure
71
+ if r.nil? || Utils.error_status?(r.status)
72
+ r = @sdk_configuration.hooks.after_error(
73
+ error: error,
74
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
75
+ hook_ctx: hook_ctx
76
+ ),
77
+ response: r
78
+ )
79
+ else
80
+ r = @sdk_configuration.hooks.after_success(
81
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
82
+ hook_ctx: hook_ctx
83
+ ),
84
+ response: r
85
+ )
86
+ end
87
+
88
+ if r.nil?
89
+ raise error if !error.nil?
90
+ raise 'no response'
91
+ end
43
92
  end
44
93
 
45
94
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -10,11 +10,12 @@ module OpenApiSDK
10
10
 
11
11
  class Status < T::Enum
12
12
  enums do
13
- INVITED = new('invited')
13
+ PENDING = new('pending')
14
14
  APPROVED = new('approved')
15
15
  REJECTED = new('rejected')
16
+ INVITED = new('invited')
16
17
  DECLINED = new('declined')
17
- PENDING = new('pending')
18
+ BANNED = new('banned')
18
19
  end
19
20
  end
20
21
  end
@@ -16,6 +16,7 @@ module OpenApiSDK
16
16
  REFUNDED = new('refunded')
17
17
  DUPLICATE = new('duplicate')
18
18
  FRAUD = new('fraud')
19
+ CANCELED = new('canceled')
19
20
  end
20
21
  end
21
22
  end
@@ -16,6 +16,7 @@ module OpenApiSDK
16
16
  BUSINESS_PLUS = new('business plus')
17
17
  BUSINESS_EXTRA = new('business extra')
18
18
  BUSINESS_MAX = new('business max')
19
+ ADVANCED = new('advanced')
19
20
  ENTERPRISE = new('enterprise')
20
21
  end
21
22
  end
@@ -11,12 +11,15 @@ module OpenApiSDK
11
11
  class Users < ::Crystalline::FieldAugmented
12
12
  extend T::Sig
13
13
 
14
+ # The ID of the default folder for the user in the workspace.
15
+ field :default_folder_id, ::String, { 'format_json': { 'letter_case': ::OpenApiSDK::Utils.field_name('defaultFolderId') } }
14
16
  # The role of the authenticated user in the workspace.
15
17
  field :role, ::OpenApiSDK::Shared::Role, { 'format_json': { 'letter_case': ::OpenApiSDK::Utils.field_name('role'), 'decoder': Utils.enum_from_string(::OpenApiSDK::Shared::Role, false) } }
16
18
 
17
19
 
18
- sig { params(role: ::OpenApiSDK::Shared::Role).void }
19
- def initialize(role: nil)
20
+ sig { params(default_folder_id: ::String, role: ::OpenApiSDK::Shared::Role).void }
21
+ def initialize(default_folder_id: nil, role: nil)
22
+ @default_folder_id = default_folder_id
20
23
  @role = role
21
24
  end
22
25
  end
@@ -7,6 +7,7 @@ require 'faraday'
7
7
  require 'faraday/multipart'
8
8
  require 'faraday/retry'
9
9
  require 'sorbet-runtime'
10
+ require_relative 'sdk_hooks/hooks'
10
11
  require_relative 'utils/retries'
11
12
 
12
13
  module OpenApiSDK
@@ -21,8 +22,8 @@ module OpenApiSDK
21
22
  end
22
23
 
23
24
 
24
- sig { params(request: T.nilable(::OpenApiSDK::Operations::CreatePartnerRequestBody)).returns(::OpenApiSDK::Operations::CreatePartnerResponse) }
25
- def create(request)
25
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::CreatePartnerRequestBody), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::CreatePartnerResponse) }
26
+ def create(request, timeout_ms = nil)
26
27
  # create - Create a new partner
27
28
  # Create a new partner for a program. If partner exists, automatically enrolls them.
28
29
  url, params = @sdk_configuration.get_server_details
@@ -31,21 +32,71 @@ module OpenApiSDK
31
32
  headers = {}
32
33
  req_content_type, data, form = Utils.serialize_request_body(request, :request, :json)
33
34
  headers['content-type'] = req_content_type
35
+
36
+ if form
37
+ body = Utils.encode_form(form)
38
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
39
+ body = URI.encode_www_form(data)
40
+ else
41
+ body = data
42
+ end
34
43
  headers['Accept'] = 'application/json'
35
44
  headers['user-agent'] = @sdk_configuration.user_agent
36
45
 
46
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
47
+
48
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
49
+ timeout ||= @sdk_configuration.timeout
50
+
37
51
  connection = @sdk_configuration.client
38
52
 
39
- r = connection.post(url) do |req|
40
- req.headers = headers
41
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
42
- Utils.configure_request_security(req, security) if !security.nil?
43
- if form
44
- req.body = Utils.encode_form(form)
45
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
46
- req.body = URI.encode_www_form(data)
53
+ hook_ctx = SDKHooks::HookContext.new(
54
+ base_url: base_url,
55
+ oauth2_scopes: [],
56
+ operation_id: 'createPartner',
57
+ security_source: @sdk_configuration.security_source
58
+ )
59
+
60
+ error = T.let(nil, T.nilable(StandardError))
61
+ r = T.let(nil, T.nilable(Faraday::Response))
62
+
63
+ begin
64
+ r = connection.post(url) do |req|
65
+ req.body = body
66
+ req.headers.merge!(headers)
67
+ req.options.timeout = timeout unless timeout.nil?
68
+ Utils.configure_request_security(req, security)
69
+
70
+ @sdk_configuration.hooks.before_request(
71
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
72
+ hook_ctx: hook_ctx
73
+ ),
74
+ request: req
75
+ )
76
+ end
77
+ rescue StandardError => e
78
+ error = e
79
+ ensure
80
+ if r.nil? || Utils.error_status?(r.status)
81
+ r = @sdk_configuration.hooks.after_error(
82
+ error: error,
83
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
84
+ hook_ctx: hook_ctx
85
+ ),
86
+ response: r
87
+ )
47
88
  else
48
- req.body = data
89
+ r = @sdk_configuration.hooks.after_success(
90
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
91
+ hook_ctx: hook_ctx
92
+ ),
93
+ response: r
94
+ )
95
+ end
96
+
97
+ if r.nil?
98
+ raise error if !error.nil?
99
+ raise 'no response'
49
100
  end
50
101
  end
51
102
 
@@ -110,8 +161,8 @@ module OpenApiSDK
110
161
  end
111
162
 
112
163
 
113
- sig { params(request: T.nilable(::OpenApiSDK::Operations::CreatePartnerLinkRequestBody)).returns(::OpenApiSDK::Operations::CreatePartnerLinkResponse) }
114
- def create_link(request)
164
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::CreatePartnerLinkRequestBody), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::CreatePartnerLinkResponse) }
165
+ def create_link(request, timeout_ms = nil)
115
166
  # create_link - Create a link for a partner
116
167
  # Create a new link for a partner that is enrolled in your program.
117
168
  url, params = @sdk_configuration.get_server_details
@@ -120,21 +171,71 @@ module OpenApiSDK
120
171
  headers = {}
121
172
  req_content_type, data, form = Utils.serialize_request_body(request, :request, :json)
122
173
  headers['content-type'] = req_content_type
174
+
175
+ if form
176
+ body = Utils.encode_form(form)
177
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
178
+ body = URI.encode_www_form(data)
179
+ else
180
+ body = data
181
+ end
123
182
  headers['Accept'] = 'application/json'
124
183
  headers['user-agent'] = @sdk_configuration.user_agent
125
184
 
185
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
186
+
187
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
188
+ timeout ||= @sdk_configuration.timeout
189
+
126
190
  connection = @sdk_configuration.client
127
191
 
128
- r = connection.post(url) do |req|
129
- req.headers = headers
130
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
131
- Utils.configure_request_security(req, security) if !security.nil?
132
- if form
133
- req.body = Utils.encode_form(form)
134
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
135
- req.body = URI.encode_www_form(data)
192
+ hook_ctx = SDKHooks::HookContext.new(
193
+ base_url: base_url,
194
+ oauth2_scopes: [],
195
+ operation_id: 'createPartnerLink',
196
+ security_source: @sdk_configuration.security_source
197
+ )
198
+
199
+ error = T.let(nil, T.nilable(StandardError))
200
+ r = T.let(nil, T.nilable(Faraday::Response))
201
+
202
+ begin
203
+ r = connection.post(url) do |req|
204
+ req.body = body
205
+ req.headers.merge!(headers)
206
+ req.options.timeout = timeout unless timeout.nil?
207
+ Utils.configure_request_security(req, security)
208
+
209
+ @sdk_configuration.hooks.before_request(
210
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
211
+ hook_ctx: hook_ctx
212
+ ),
213
+ request: req
214
+ )
215
+ end
216
+ rescue StandardError => e
217
+ error = e
218
+ ensure
219
+ if r.nil? || Utils.error_status?(r.status)
220
+ r = @sdk_configuration.hooks.after_error(
221
+ error: error,
222
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
223
+ hook_ctx: hook_ctx
224
+ ),
225
+ response: r
226
+ )
136
227
  else
137
- req.body = data
228
+ r = @sdk_configuration.hooks.after_success(
229
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
230
+ hook_ctx: hook_ctx
231
+ ),
232
+ response: r
233
+ )
234
+ end
235
+
236
+ if r.nil?
237
+ raise error if !error.nil?
238
+ raise 'no response'
138
239
  end
139
240
  end
140
241
 
@@ -199,8 +300,8 @@ module OpenApiSDK
199
300
  end
200
301
 
201
302
 
202
- sig { params(request: T.nilable(::OpenApiSDK::Operations::UpsertPartnerLinkRequestBody)).returns(::OpenApiSDK::Operations::UpsertPartnerLinkResponse) }
203
- def upsert_link(request)
303
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::UpsertPartnerLinkRequestBody), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::UpsertPartnerLinkResponse) }
304
+ def upsert_link(request, timeout_ms = nil)
204
305
  # upsert_link - Upsert a link for a partner
205
306
  # Upsert a link for a partner that is enrolled in your program. If a link with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new link will be created.
206
307
  url, params = @sdk_configuration.get_server_details
@@ -209,21 +310,71 @@ module OpenApiSDK
209
310
  headers = {}
210
311
  req_content_type, data, form = Utils.serialize_request_body(request, :request, :json)
211
312
  headers['content-type'] = req_content_type
313
+
314
+ if form
315
+ body = Utils.encode_form(form)
316
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
317
+ body = URI.encode_www_form(data)
318
+ else
319
+ body = data
320
+ end
212
321
  headers['Accept'] = 'application/json'
213
322
  headers['user-agent'] = @sdk_configuration.user_agent
214
323
 
324
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
325
+
326
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
327
+ timeout ||= @sdk_configuration.timeout
328
+
215
329
  connection = @sdk_configuration.client
216
330
 
217
- r = connection.put(url) do |req|
218
- req.headers = headers
219
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
220
- Utils.configure_request_security(req, security) if !security.nil?
221
- if form
222
- req.body = Utils.encode_form(form)
223
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
224
- req.body = URI.encode_www_form(data)
331
+ hook_ctx = SDKHooks::HookContext.new(
332
+ base_url: base_url,
333
+ oauth2_scopes: [],
334
+ operation_id: 'upsertPartnerLink',
335
+ security_source: @sdk_configuration.security_source
336
+ )
337
+
338
+ error = T.let(nil, T.nilable(StandardError))
339
+ r = T.let(nil, T.nilable(Faraday::Response))
340
+
341
+ begin
342
+ r = connection.put(url) do |req|
343
+ req.body = body
344
+ req.headers.merge!(headers)
345
+ req.options.timeout = timeout unless timeout.nil?
346
+ Utils.configure_request_security(req, security)
347
+
348
+ @sdk_configuration.hooks.before_request(
349
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
350
+ hook_ctx: hook_ctx
351
+ ),
352
+ request: req
353
+ )
354
+ end
355
+ rescue StandardError => e
356
+ error = e
357
+ ensure
358
+ if r.nil? || Utils.error_status?(r.status)
359
+ r = @sdk_configuration.hooks.after_error(
360
+ error: error,
361
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
362
+ hook_ctx: hook_ctx
363
+ ),
364
+ response: r
365
+ )
225
366
  else
226
- req.body = data
367
+ r = @sdk_configuration.hooks.after_success(
368
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
369
+ hook_ctx: hook_ctx
370
+ ),
371
+ response: r
372
+ )
373
+ end
374
+
375
+ if r.nil?
376
+ raise error if !error.nil?
377
+ raise 'no response'
227
378
  end
228
379
  end
229
380
 
@@ -288,8 +439,8 @@ module OpenApiSDK
288
439
  end
289
440
 
290
441
 
291
- sig { params(request: T.nilable(::OpenApiSDK::Operations::RetrievePartnerAnalyticsRequest)).returns(::OpenApiSDK::Operations::RetrievePartnerAnalyticsResponse) }
292
- def analytics(request)
442
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::RetrievePartnerAnalyticsRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::RetrievePartnerAnalyticsResponse) }
443
+ def analytics(request, timeout_ms = nil)
293
444
  # analytics - Retrieve analytics for a partner
294
445
  # Retrieve analytics for a partner within a program. The response type vary based on the `groupBy` query parameter.
295
446
  url, params = @sdk_configuration.get_server_details
@@ -300,13 +451,61 @@ module OpenApiSDK
300
451
  headers['Accept'] = 'application/json'
301
452
  headers['user-agent'] = @sdk_configuration.user_agent
302
453
 
454
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
455
+
456
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
457
+ timeout ||= @sdk_configuration.timeout
458
+
303
459
  connection = @sdk_configuration.client
304
460
 
305
- r = connection.get(url) do |req|
306
- req.headers = headers
307
- req.params = query_params
308
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
309
- Utils.configure_request_security(req, security) if !security.nil?
461
+ hook_ctx = SDKHooks::HookContext.new(
462
+ base_url: base_url,
463
+ oauth2_scopes: [],
464
+ operation_id: 'retrievePartnerAnalytics',
465
+ security_source: @sdk_configuration.security_source
466
+ )
467
+
468
+ error = T.let(nil, T.nilable(StandardError))
469
+ r = T.let(nil, T.nilable(Faraday::Response))
470
+
471
+ begin
472
+ r = connection.get(url) do |req|
473
+ req.headers.merge!(headers)
474
+ req.options.timeout = timeout unless timeout.nil?
475
+ req.params = query_params
476
+ Utils.configure_request_security(req, security)
477
+
478
+ @sdk_configuration.hooks.before_request(
479
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
480
+ hook_ctx: hook_ctx
481
+ ),
482
+ request: req
483
+ )
484
+ end
485
+ rescue StandardError => e
486
+ error = e
487
+ ensure
488
+ if r.nil? || Utils.error_status?(r.status)
489
+ r = @sdk_configuration.hooks.after_error(
490
+ error: error,
491
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
492
+ hook_ctx: hook_ctx
493
+ ),
494
+ response: r
495
+ )
496
+ else
497
+ r = @sdk_configuration.hooks.after_success(
498
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
499
+ hook_ctx: hook_ctx
500
+ ),
501
+ response: r
502
+ )
503
+ end
504
+
505
+ if r.nil?
506
+ raise error if !error.nil?
507
+ raise 'no response'
508
+ end
310
509
  end
311
510
 
312
511
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -370,8 +569,8 @@ module OpenApiSDK
370
569
  end
371
570
 
372
571
 
373
- sig { params(request: T.nilable(::OpenApiSDK::Operations::UpdatePartnerSaleRequestBody)).returns(::OpenApiSDK::Operations::UpdatePartnerSaleResponse) }
374
- def update_sale(request)
572
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::UpdatePartnerSaleRequestBody), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::UpdatePartnerSaleResponse) }
573
+ def update_sale(request, timeout_ms = nil)
375
574
  # update_sale - Update a sale for a partner.
376
575
  # Update an existing sale amount. This is useful for handling refunds (partial or full) or fraudulent sales.
377
576
  url, params = @sdk_configuration.get_server_details
@@ -380,21 +579,71 @@ module OpenApiSDK
380
579
  headers = {}
381
580
  req_content_type, data, form = Utils.serialize_request_body(request, :request, :json)
382
581
  headers['content-type'] = req_content_type
582
+
583
+ if form
584
+ body = Utils.encode_form(form)
585
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
586
+ body = URI.encode_www_form(data)
587
+ else
588
+ body = data
589
+ end
383
590
  headers['Accept'] = 'application/json'
384
591
  headers['user-agent'] = @sdk_configuration.user_agent
385
592
 
593
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
594
+
595
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
596
+ timeout ||= @sdk_configuration.timeout
597
+
386
598
  connection = @sdk_configuration.client
387
599
 
388
- r = connection.patch(url) do |req|
389
- req.headers = headers
390
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
391
- Utils.configure_request_security(req, security) if !security.nil?
392
- if form
393
- req.body = Utils.encode_form(form)
394
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
395
- req.body = URI.encode_www_form(data)
600
+ hook_ctx = SDKHooks::HookContext.new(
601
+ base_url: base_url,
602
+ oauth2_scopes: [],
603
+ operation_id: 'updatePartnerSale',
604
+ security_source: @sdk_configuration.security_source
605
+ )
606
+
607
+ error = T.let(nil, T.nilable(StandardError))
608
+ r = T.let(nil, T.nilable(Faraday::Response))
609
+
610
+ begin
611
+ r = connection.patch(url) do |req|
612
+ req.body = body
613
+ req.headers.merge!(headers)
614
+ req.options.timeout = timeout unless timeout.nil?
615
+ Utils.configure_request_security(req, security)
616
+
617
+ @sdk_configuration.hooks.before_request(
618
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
619
+ hook_ctx: hook_ctx
620
+ ),
621
+ request: req
622
+ )
623
+ end
624
+ rescue StandardError => e
625
+ error = e
626
+ ensure
627
+ if r.nil? || Utils.error_status?(r.status)
628
+ r = @sdk_configuration.hooks.after_error(
629
+ error: error,
630
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
631
+ hook_ctx: hook_ctx
632
+ ),
633
+ response: r
634
+ )
396
635
  else
397
- req.body = data
636
+ r = @sdk_configuration.hooks.after_success(
637
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
638
+ hook_ctx: hook_ctx
639
+ ),
640
+ response: r
641
+ )
642
+ end
643
+
644
+ if r.nil?
645
+ raise error if !error.nil?
646
+ raise 'no response'
398
647
  end
399
648
  end
400
649
 
@@ -7,6 +7,7 @@ require 'faraday'
7
7
  require 'faraday/multipart'
8
8
  require 'faraday/retry'
9
9
  require 'sorbet-runtime'
10
+ require_relative 'sdk_hooks/hooks'
10
11
  require_relative 'utils/retries'
11
12
 
12
13
  module OpenApiSDK
@@ -21,8 +22,8 @@ module OpenApiSDK
21
22
  end
22
23
 
23
24
 
24
- sig { params(request: T.nilable(::OpenApiSDK::Operations::GetQRCodeRequest)).returns(::OpenApiSDK::Operations::GetQRCodeResponse) }
25
- def get(request)
25
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::GetQRCodeRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::GetQRCodeResponse) }
26
+ def get(request, timeout_ms = nil)
26
27
  # get - Retrieve a QR code
27
28
  # Retrieve a QR code for a link.
28
29
  url, params = @sdk_configuration.get_server_details
@@ -33,13 +34,61 @@ module OpenApiSDK
33
34
  headers['Accept'] = 'application/json;q=1, image/png;q=0'
34
35
  headers['user-agent'] = @sdk_configuration.user_agent
35
36
 
37
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
38
+
39
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
40
+ timeout ||= @sdk_configuration.timeout
41
+
36
42
  connection = @sdk_configuration.client
37
43
 
38
- r = connection.get(url) do |req|
39
- req.headers = headers
40
- req.params = query_params
41
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
42
- Utils.configure_request_security(req, security) if !security.nil?
44
+ hook_ctx = SDKHooks::HookContext.new(
45
+ base_url: base_url,
46
+ oauth2_scopes: [],
47
+ operation_id: 'getQRCode',
48
+ security_source: @sdk_configuration.security_source
49
+ )
50
+
51
+ error = T.let(nil, T.nilable(StandardError))
52
+ r = T.let(nil, T.nilable(Faraday::Response))
53
+
54
+ begin
55
+ r = connection.get(url) do |req|
56
+ req.headers.merge!(headers)
57
+ req.options.timeout = timeout unless timeout.nil?
58
+ req.params = query_params
59
+ Utils.configure_request_security(req, security)
60
+
61
+ @sdk_configuration.hooks.before_request(
62
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
63
+ hook_ctx: hook_ctx
64
+ ),
65
+ request: req
66
+ )
67
+ end
68
+ rescue StandardError => e
69
+ error = e
70
+ ensure
71
+ if r.nil? || Utils.error_status?(r.status)
72
+ r = @sdk_configuration.hooks.after_error(
73
+ error: error,
74
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
75
+ hook_ctx: hook_ctx
76
+ ),
77
+ response: r
78
+ )
79
+ else
80
+ r = @sdk_configuration.hooks.after_success(
81
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
82
+ hook_ctx: hook_ctx
83
+ ),
84
+ response: r
85
+ )
86
+ end
87
+
88
+ if r.nil?
89
+ raise error if !error.nil?
90
+ raise 'no response'
91
+ end
43
92
  end
44
93
 
45
94
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')