noresponse 10.0.8 → 10.0.10

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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/lib/no_response/events.rb +3946 -0
  3. data/lib/no_response/models/operations/addattendees_request.rb +66 -0
  4. data/lib/no_response/models/operations/addattendees_request.rbi +38 -0
  5. data/lib/no_response/models/operations/addattendees_response.rb +32 -0
  6. data/lib/no_response/models/operations/addattendees_response.rbi +20 -0
  7. data/lib/no_response/models/operations/cancelscreening_request.rb +66 -0
  8. data/lib/no_response/models/operations/cancelscreening_request.rbi +38 -0
  9. data/lib/no_response/models/operations/cancelscreening_response.rb +32 -0
  10. data/lib/no_response/models/operations/cancelscreening_response.rbi +20 -0
  11. data/lib/no_response/models/operations/createevent_request.rb +52 -0
  12. data/lib/no_response/models/operations/createevent_request.rbi +26 -0
  13. data/lib/no_response/models/operations/createevent_response.rb +32 -0
  14. data/lib/no_response/models/operations/createevent_response.rbi +20 -0
  15. data/lib/no_response/models/operations/deleteevent_request.rb +45 -0
  16. data/lib/no_response/models/operations/deleteevent_request.rbi +26 -0
  17. data/lib/no_response/models/operations/deleteevent_response.rb +28 -0
  18. data/lib/no_response/models/operations/deleteevent_response.rbi +14 -0
  19. data/lib/no_response/models/operations/getattendee_request.rb +57 -0
  20. data/lib/no_response/models/operations/getattendee_request.rbi +32 -0
  21. data/lib/no_response/models/operations/getattendee_response.rb +32 -0
  22. data/lib/no_response/models/operations/getattendee_response.rbi +20 -0
  23. data/lib/no_response/models/operations/getevent_request.rb +45 -0
  24. data/lib/no_response/models/operations/getevent_request.rbi +26 -0
  25. data/lib/no_response/models/operations/getevent_response.rb +32 -0
  26. data/lib/no_response/models/operations/getevent_response.rbi +20 -0
  27. data/lib/no_response/models/operations/getscreening_request.rb +61 -0
  28. data/lib/no_response/models/operations/getscreening_request.rbi +32 -0
  29. data/lib/no_response/models/operations/getscreening_response.rb +32 -0
  30. data/lib/no_response/models/operations/getscreening_response.rbi +20 -0
  31. data/lib/no_response/models/operations/listattendees_request.rb +88 -0
  32. data/lib/no_response/models/operations/listattendees_request.rbi +50 -0
  33. data/lib/no_response/models/operations/listattendees_response.rb +32 -0
  34. data/lib/no_response/models/operations/listattendees_response.rbi +20 -0
  35. data/lib/no_response/models/operations/listevents_request.rb +65 -0
  36. data/lib/no_response/models/operations/listevents_request.rbi +32 -0
  37. data/lib/no_response/models/operations/listevents_response.rb +32 -0
  38. data/lib/no_response/models/operations/listevents_response.rbi +20 -0
  39. data/lib/no_response/models/operations/listscreenings_request.rb +70 -0
  40. data/lib/no_response/models/operations/listscreenings_request.rbi +38 -0
  41. data/lib/no_response/models/operations/listscreenings_response.rb +32 -0
  42. data/lib/no_response/models/operations/listscreenings_response.rbi +20 -0
  43. data/lib/no_response/models/operations/reviewattendee_request.rb +62 -0
  44. data/lib/no_response/models/operations/reviewattendee_request.rbi +38 -0
  45. data/lib/no_response/models/operations/reviewattendee_response.rb +32 -0
  46. data/lib/no_response/models/operations/reviewattendee_response.rbi +20 -0
  47. data/lib/no_response/models/operations/startscreening_request.rb +66 -0
  48. data/lib/no_response/models/operations/startscreening_request.rbi +38 -0
  49. data/lib/no_response/models/operations/startscreening_response.rb +32 -0
  50. data/lib/no_response/models/operations/startscreening_response.rbi +20 -0
  51. data/lib/no_response/models/operations/updateevent_request.rb +57 -0
  52. data/lib/no_response/models/operations/updateevent_request.rbi +32 -0
  53. data/lib/no_response/models/operations/updateevent_response.rb +32 -0
  54. data/lib/no_response/models/operations/updateevent_response.rbi +20 -0
  55. data/lib/no_response/models/operations.rb +26 -0
  56. data/lib/no_response/models/shared/attendee.rb +239 -0
  57. data/lib/no_response/models/shared/attendee.rbi +128 -0
  58. data/lib/no_response/models/shared/attendee_coverage.rb +23 -0
  59. data/lib/no_response/models/shared/attendee_coverage.rbi +9 -0
  60. data/lib/no_response/models/shared/attendeebatch.rb +48 -0
  61. data/lib/no_response/models/shared/attendeebatch.rbi +26 -0
  62. data/lib/no_response/models/shared/attendeebatchitem.rb +51 -0
  63. data/lib/no_response/models/shared/attendeebatchitem.rbi +26 -0
  64. data/lib/no_response/models/shared/attendeebatchitemoutcome.rb +20 -0
  65. data/lib/no_response/models/shared/attendeebatchitemoutcome.rbi +9 -0
  66. data/lib/no_response/models/shared/attendeebatchrequest.rb +32 -0
  67. data/lib/no_response/models/shared/attendeebatchrequest.rbi +14 -0
  68. data/lib/no_response/models/shared/attendeedecision.rb +20 -0
  69. data/lib/no_response/models/shared/attendeedecision.rbi +9 -0
  70. data/lib/no_response/models/shared/attendeeidentity.rb +88 -0
  71. data/lib/no_response/models/shared/attendeeidentity.rbi +50 -0
  72. data/lib/no_response/models/shared/attendeelist.rb +40 -0
  73. data/lib/no_response/models/shared/attendeelist.rbi +20 -0
  74. data/lib/no_response/models/shared/attendeereport.rb +65 -0
  75. data/lib/no_response/models/shared/attendeereport.rbi +32 -0
  76. data/lib/no_response/models/shared/attendeereview.rb +75 -0
  77. data/lib/no_response/models/shared/attendeereview.rbi +38 -0
  78. data/lib/no_response/models/shared/attendeereviewrequest.rb +46 -0
  79. data/lib/no_response/models/shared/attendeereviewrequest.rbi +20 -0
  80. data/lib/no_response/models/shared/conflicterrorcode.rb +3 -0
  81. data/lib/no_response/models/shared/event.rb +177 -0
  82. data/lib/no_response/models/shared/event.rbi +98 -0
  83. data/lib/no_response/models/shared/eventlist.rb +40 -0
  84. data/lib/no_response/models/shared/eventlist.rbi +20 -0
  85. data/lib/no_response/models/shared/eventrequest.rb +88 -0
  86. data/lib/no_response/models/shared/eventrequest.rbi +50 -0
  87. data/lib/no_response/models/shared/eventupdate.rb +110 -0
  88. data/lib/no_response/models/shared/eventupdate.rbi +56 -0
  89. data/lib/no_response/models/shared/finding.rb +23 -0
  90. data/lib/no_response/models/shared/finding.rbi +9 -0
  91. data/lib/no_response/models/shared/handle.rb +46 -0
  92. data/lib/no_response/models/shared/handle.rbi +20 -0
  93. data/lib/no_response/models/shared/handleplatform.rb +27 -0
  94. data/lib/no_response/models/shared/handleplatform.rbi +9 -0
  95. data/lib/no_response/models/shared/highestband.rb +22 -0
  96. data/lib/no_response/models/shared/highestband.rbi +9 -0
  97. data/lib/no_response/models/shared/key_scope.rb +1 -0
  98. data/lib/no_response/models/shared/keyrequest_scope.rb +1 -0
  99. data/lib/no_response/models/shared/listattendeesband.rb +20 -0
  100. data/lib/no_response/models/shared/listattendeesband.rbi +9 -0
  101. data/lib/no_response/models/shared/listattendeesdecision.rb +18 -0
  102. data/lib/no_response/models/shared/listattendeesdecision.rbi +9 -0
  103. data/lib/no_response/models/shared/matchstate.rb +23 -0
  104. data/lib/no_response/models/shared/matchstate.rbi +9 -0
  105. data/lib/no_response/models/shared/principal.rb +37 -0
  106. data/lib/no_response/models/shared/principal.rbi +20 -0
  107. data/lib/no_response/models/shared/profile.rb +23 -0
  108. data/lib/no_response/models/shared/profile.rbi +9 -0
  109. data/lib/no_response/models/shared/screening.rb +203 -0
  110. data/lib/no_response/models/shared/screening.rbi +104 -0
  111. data/lib/no_response/models/shared/screening_platform.rb +27 -0
  112. data/lib/no_response/models/shared/screening_platform.rbi +9 -0
  113. data/lib/no_response/models/shared/screeningcancelrequest.rb +23 -0
  114. data/lib/no_response/models/shared/screeningcancelrequest.rbi +9 -0
  115. data/lib/no_response/models/shared/screeningdepth.rb +18 -0
  116. data/lib/no_response/models/shared/screeningdepth.rbi +9 -0
  117. data/lib/no_response/models/shared/screeninglist.rb +40 -0
  118. data/lib/no_response/models/shared/screeninglist.rbi +20 -0
  119. data/lib/no_response/models/shared/screeningrequest.rb +49 -0
  120. data/lib/no_response/models/shared/screeningrequest.rbi +20 -0
  121. data/lib/no_response/models/shared/screeningrequest_platform.rb +24 -0
  122. data/lib/no_response/models/shared/screeningrequest_platform.rbi +9 -0
  123. data/lib/no_response/models/shared/screeningstatus.rb +23 -0
  124. data/lib/no_response/models/shared/screeningstatus.rbi +9 -0
  125. data/lib/no_response/models/shared.rb +33 -0
  126. data/lib/no_response/noresponseclient.rb +3 -1
  127. data/lib/no_response/sdkconfiguration.rb +2 -2
  128. data/lib/noresponse.rb +1 -0
  129. metadata +121 -2
@@ -0,0 +1,3946 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require "faraday"
5
+ require "faraday/multipart"
6
+ require "faraday/retry"
7
+ require "sorbet-runtime"
8
+
9
+ require_relative "sdk_hooks/hooks"
10
+ require_relative "utils/retries"
11
+
12
+ module NoResponse
13
+ extend T::Sig
14
+
15
+ class Events
16
+ extend T::Sig
17
+
18
+ # Events, attendee lists, screenings and reviewer decisions.
19
+
20
+ sig { params(sdk_config: SDKConfiguration).void }
21
+ def initialize(sdk_config)
22
+ @sdk_configuration = sdk_config
23
+ end
24
+
25
+ sig { params(base_url: String, url_variables: T.nilable(T::Hash[Symbol, T.any(String, T::Enum)])).returns(String) }
26
+ def get_url(base_url:, url_variables: nil)
27
+ sd_base_url, sd_options = @sdk_configuration.get_server_details
28
+
29
+ if base_url.nil?
30
+ base_url = sd_base_url
31
+ end
32
+
33
+ if url_variables.nil?
34
+ url_variables = sd_options
35
+ end
36
+
37
+ return Utils.template_url(base_url, url_variables)
38
+ end
39
+
40
+ sig {
41
+ params(
42
+ workspace_id: ::String,
43
+ environment: Models::Shared::KeyEnvironment,
44
+ limit: T.nilable(::Integer),
45
+ before: T.nilable(::String),
46
+ retries: T.nilable(Utils::RetryConfig),
47
+ timeout_ms: T.nilable(Integer),
48
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
49
+ )
50
+ .returns(Models::Operations::ListEventsResponse)
51
+ }
52
+ def list(workspace_id:, environment:, limit: nil, before: nil, retries: nil, timeout_ms: nil, http_headers: nil)
53
+ # list - List an environment's events.
54
+ # List this environment's events, newest first. Pass next_before back as before for the next page. Requires the events scope.
55
+ request = Models::Operations::ListEventsRequest.new(
56
+ workspace_id: workspace_id,
57
+ environment: environment,
58
+ limit: limit,
59
+ before: before
60
+ )
61
+ url, params = @sdk_configuration.get_server_details
62
+ base_url = Utils.template_url(url, params)
63
+ url = Utils.generate_url(
64
+ Models::Operations::ListEventsRequest,
65
+ base_url,
66
+ "/v1/workspaces/{workspace_id}/events/{environment}",
67
+ request
68
+ )
69
+ headers = {}
70
+ headers = T.cast(headers, T::Hash[String, String])
71
+ query_params = Utils.get_query_params(Models::Operations::ListEventsRequest, request, nil)
72
+ headers["Accept"] = "application/json"
73
+ headers["user-agent"] = @sdk_configuration.user_agent
74
+ retries ||= @sdk_configuration.retry_config
75
+ retries ||= Utils::RetryConfig.new(
76
+ backoff: Utils::BackoffStrategy.new(
77
+ exponent: 2.0,
78
+ initial_interval: 500,
79
+ max_elapsed_time: 30_000,
80
+ max_interval: 8000
81
+ ),
82
+ retry_connection_errors: true,
83
+ strategy: "backoff"
84
+ )
85
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
86
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
87
+
88
+ security = @sdk_configuration.security_source&.call
89
+
90
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
91
+ timeout ||= @sdk_configuration.timeout
92
+
93
+ connection = @sdk_configuration.client.dup
94
+ connection.use(Utils::RetryMiddleware, retry_options)
95
+
96
+ hook_ctx = SDKHooks::HookContext.new(
97
+ config: @sdk_configuration,
98
+ base_url: base_url,
99
+ oauth2_scopes: nil,
100
+ operation_id: "listEvents",
101
+ security_source: @sdk_configuration.security_source
102
+ )
103
+
104
+ error = T.let(nil, T.nilable(StandardError))
105
+ http_response = T.let(nil, T.nilable(Faraday::Response))
106
+
107
+ begin
108
+ http_response = T.must(connection).get(url) do |req|
109
+ req.headers.merge!(headers)
110
+ req.options.timeout = timeout unless timeout.nil?
111
+ req.params = query_params
112
+ Utils.configure_request_security(req, security)
113
+ http_headers&.each do |key, value|
114
+ req.headers[key.to_s] = value
115
+ end
116
+
117
+ @sdk_configuration.hooks.before_request(
118
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
119
+ hook_ctx: hook_ctx
120
+ ),
121
+ request: req
122
+ )
123
+ end
124
+
125
+ rescue StandardError => e
126
+ error = e
127
+ ensure
128
+ if http_response.nil? || Utils.error_status?(http_response.status)
129
+ http_response = @sdk_configuration.hooks.after_error(
130
+ error: error,
131
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
132
+ hook_ctx: hook_ctx
133
+ ),
134
+ response: http_response
135
+ )
136
+ else
137
+ http_response = @sdk_configuration.hooks.after_success(
138
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
139
+ hook_ctx: hook_ctx
140
+ ),
141
+ response: http_response
142
+ )
143
+ end
144
+
145
+ if http_response.nil?
146
+ raise error if !error.nil?
147
+ raise "no response"
148
+ end
149
+ end
150
+
151
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
152
+ if Utils.match_status_code(http_response.status, ["200"])
153
+ if Utils.match_content_type(content_type, "application/json")
154
+ @sdk_configuration.hooks.after_success(
155
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
156
+ hook_ctx: hook_ctx
157
+ ),
158
+ response: http_response
159
+ )
160
+ response_data = http_response.env.response_body
161
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::EventList)
162
+ result = obj
163
+ response = Models::Operations::ListEventsResponse.new(
164
+ result: result,
165
+ headers: http_response.headers
166
+ )
167
+
168
+ return response
169
+ else
170
+ raise(
171
+ ::NoResponse::Models::Errors::APIStatusError.new(
172
+ status_code: http_response.status,
173
+ body: http_response.env.response_body,
174
+ raw_response: http_response
175
+ ),
176
+ "Unknown content type received"
177
+ )
178
+ end
179
+ elsif Utils.match_status_code(http_response.status, ["400"])
180
+ if Utils.match_content_type(content_type, "application/problem+json")
181
+ @sdk_configuration.hooks.after_success(
182
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
183
+ hook_ctx: hook_ctx
184
+ ),
185
+ response: http_response
186
+ )
187
+ response_data = http_response.env.response_body
188
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
189
+ raise obj
190
+ else
191
+ raise(
192
+ ::NoResponse::Models::Errors::APIStatusError.new(
193
+ status_code: http_response.status,
194
+ body: http_response.env.response_body,
195
+ raw_response: http_response
196
+ ),
197
+ "Unknown content type received"
198
+ )
199
+ end
200
+ elsif Utils.match_status_code(http_response.status, ["401"])
201
+ if Utils.match_content_type(content_type, "application/problem+json")
202
+ @sdk_configuration.hooks.after_success(
203
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
204
+ hook_ctx: hook_ctx
205
+ ),
206
+ response: http_response
207
+ )
208
+ response_data = http_response.env.response_body
209
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
210
+ raise obj
211
+ else
212
+ raise(
213
+ ::NoResponse::Models::Errors::APIStatusError.new(
214
+ status_code: http_response.status,
215
+ body: http_response.env.response_body,
216
+ raw_response: http_response
217
+ ),
218
+ "Unknown content type received"
219
+ )
220
+ end
221
+ elsif Utils.match_status_code(http_response.status, ["403"])
222
+ if Utils.match_content_type(content_type, "application/problem+json")
223
+ @sdk_configuration.hooks.after_success(
224
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
225
+ hook_ctx: hook_ctx
226
+ ),
227
+ response: http_response
228
+ )
229
+ response_data = http_response.env.response_body
230
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
231
+ raise obj
232
+ else
233
+ raise(
234
+ ::NoResponse::Models::Errors::APIStatusError.new(
235
+ status_code: http_response.status,
236
+ body: http_response.env.response_body,
237
+ raw_response: http_response
238
+ ),
239
+ "Unknown content type received"
240
+ )
241
+ end
242
+ elsif Utils.match_status_code(http_response.status, ["404"])
243
+ if Utils.match_content_type(content_type, "application/problem+json")
244
+ @sdk_configuration.hooks.after_success(
245
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
246
+ hook_ctx: hook_ctx
247
+ ),
248
+ response: http_response
249
+ )
250
+ response_data = http_response.env.response_body
251
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
252
+ raise obj
253
+ else
254
+ raise(
255
+ ::NoResponse::Models::Errors::APIStatusError.new(
256
+ status_code: http_response.status,
257
+ body: http_response.env.response_body,
258
+ raw_response: http_response
259
+ ),
260
+ "Unknown content type received"
261
+ )
262
+ end
263
+ elsif Utils.match_status_code(http_response.status, ["409"])
264
+ if Utils.match_content_type(content_type, "application/problem+json")
265
+ @sdk_configuration.hooks.after_success(
266
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
267
+ hook_ctx: hook_ctx
268
+ ),
269
+ response: http_response
270
+ )
271
+ response_data = http_response.env.response_body
272
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
273
+ raise obj
274
+ else
275
+ raise(
276
+ ::NoResponse::Models::Errors::APIStatusError.new(
277
+ status_code: http_response.status,
278
+ body: http_response.env.response_body,
279
+ raw_response: http_response
280
+ ),
281
+ "Unknown content type received"
282
+ )
283
+ end
284
+ elsif Utils.match_status_code(http_response.status, ["429"])
285
+ if Utils.match_content_type(content_type, "application/problem+json")
286
+ @sdk_configuration.hooks.after_success(
287
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
288
+ hook_ctx: hook_ctx
289
+ ),
290
+ response: http_response
291
+ )
292
+ response_data = http_response.env.response_body
293
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
294
+ raise obj
295
+ else
296
+ raise(
297
+ ::NoResponse::Models::Errors::APIStatusError.new(
298
+ status_code: http_response.status,
299
+ body: http_response.env.response_body,
300
+ raw_response: http_response
301
+ ),
302
+ "Unknown content type received"
303
+ )
304
+ end
305
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
306
+ raise(
307
+ ::NoResponse::Models::Errors::APIStatusError.new(
308
+ status_code: http_response.status,
309
+ body: http_response.env.response_body,
310
+ raw_response: http_response
311
+ ),
312
+ "API error occurred"
313
+ )
314
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
315
+ raise(
316
+ ::NoResponse::Models::Errors::APIStatusError.new(
317
+ status_code: http_response.status,
318
+ body: http_response.env.response_body,
319
+ raw_response: http_response
320
+ ),
321
+ "API error occurred"
322
+ )
323
+ else
324
+ raise(
325
+ ::NoResponse::Models::Errors::APIStatusError.new(
326
+ status_code: http_response.status,
327
+ body: http_response.env.response_body,
328
+ raw_response: http_response
329
+ ),
330
+ "Unknown status code received"
331
+ )
332
+
333
+ end
334
+ end
335
+
336
+ sig {
337
+ params(
338
+ body: Models::Shared::EventRequest,
339
+ workspace_id: ::String,
340
+ environment: Models::Shared::KeyEnvironment,
341
+ timeout_ms: T.nilable(Integer),
342
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
343
+ )
344
+ .returns(Models::Operations::CreateEventResponse)
345
+ }
346
+ def create(body:, workspace_id:, environment:, timeout_ms: nil, http_headers: nil)
347
+ # create - Create an event to screen.
348
+ # Create an event to screen: its name, start, venue, host, the principals it protects and the sensitive topics posts are read against. An environment holds at most 1000 events.
349
+ request = Models::Operations::CreateEventRequest.new(
350
+ workspace_id: workspace_id,
351
+ environment: environment,
352
+ body: body
353
+ )
354
+ url, params = @sdk_configuration.get_server_details
355
+ base_url = Utils.template_url(url, params)
356
+ url = Utils.generate_url(
357
+ Models::Operations::CreateEventRequest,
358
+ base_url,
359
+ "/v1/workspaces/{workspace_id}/events/{environment}",
360
+ request
361
+ )
362
+ headers = {}
363
+ headers = T.cast(headers, T::Hash[String, String])
364
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
365
+ headers["content-type"] = req_content_type
366
+ raise StandardError, "request body is required" if data.nil? && form.nil?
367
+
368
+ if form && !form.empty?
369
+ body = Utils.encode_form(form)
370
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
371
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
372
+ else
373
+ body = data
374
+ end
375
+
376
+ headers["Accept"] = "application/json"
377
+ headers["user-agent"] = @sdk_configuration.user_agent
378
+
379
+ security = @sdk_configuration.security_source&.call
380
+
381
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
382
+ timeout ||= @sdk_configuration.timeout
383
+
384
+ connection = @sdk_configuration.client
385
+
386
+ hook_ctx = SDKHooks::HookContext.new(
387
+ config: @sdk_configuration,
388
+ base_url: base_url,
389
+ oauth2_scopes: nil,
390
+ operation_id: "createEvent",
391
+ security_source: @sdk_configuration.security_source
392
+ )
393
+
394
+ error = T.let(nil, T.nilable(StandardError))
395
+ http_response = T.let(nil, T.nilable(Faraday::Response))
396
+
397
+ begin
398
+ http_response = T.must(connection).post(url) do |req|
399
+ req.body = body
400
+ req.headers.merge!(headers)
401
+ req.options.timeout = timeout unless timeout.nil?
402
+ Utils.configure_request_security(req, security)
403
+ http_headers&.each do |key, value|
404
+ req.headers[key.to_s] = value
405
+ end
406
+
407
+ @sdk_configuration.hooks.before_request(
408
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
409
+ hook_ctx: hook_ctx
410
+ ),
411
+ request: req
412
+ )
413
+ end
414
+
415
+ rescue StandardError => e
416
+ error = e
417
+ ensure
418
+ if http_response.nil? || Utils.error_status?(http_response.status)
419
+ http_response = @sdk_configuration.hooks.after_error(
420
+ error: error,
421
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
422
+ hook_ctx: hook_ctx
423
+ ),
424
+ response: http_response
425
+ )
426
+ else
427
+ http_response = @sdk_configuration.hooks.after_success(
428
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
429
+ hook_ctx: hook_ctx
430
+ ),
431
+ response: http_response
432
+ )
433
+ end
434
+
435
+ if http_response.nil?
436
+ raise error if !error.nil?
437
+ raise "no response"
438
+ end
439
+ end
440
+
441
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
442
+ if Utils.match_status_code(http_response.status, ["201"])
443
+ if Utils.match_content_type(content_type, "application/json")
444
+ @sdk_configuration.hooks.after_success(
445
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
446
+ hook_ctx: hook_ctx
447
+ ),
448
+ response: http_response
449
+ )
450
+ response_data = http_response.env.response_body
451
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Event)
452
+ result = obj
453
+ response = Models::Operations::CreateEventResponse.new(
454
+ result: result,
455
+ headers: http_response.headers
456
+ )
457
+
458
+ return response
459
+ else
460
+ raise(
461
+ ::NoResponse::Models::Errors::APIStatusError.new(
462
+ status_code: http_response.status,
463
+ body: http_response.env.response_body,
464
+ raw_response: http_response
465
+ ),
466
+ "Unknown content type received"
467
+ )
468
+ end
469
+ elsif Utils.match_status_code(http_response.status, ["400"])
470
+ if Utils.match_content_type(content_type, "application/problem+json")
471
+ @sdk_configuration.hooks.after_success(
472
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
473
+ hook_ctx: hook_ctx
474
+ ),
475
+ response: http_response
476
+ )
477
+ response_data = http_response.env.response_body
478
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
479
+ raise obj
480
+ else
481
+ raise(
482
+ ::NoResponse::Models::Errors::APIStatusError.new(
483
+ status_code: http_response.status,
484
+ body: http_response.env.response_body,
485
+ raw_response: http_response
486
+ ),
487
+ "Unknown content type received"
488
+ )
489
+ end
490
+ elsif Utils.match_status_code(http_response.status, ["401"])
491
+ if Utils.match_content_type(content_type, "application/problem+json")
492
+ @sdk_configuration.hooks.after_success(
493
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
494
+ hook_ctx: hook_ctx
495
+ ),
496
+ response: http_response
497
+ )
498
+ response_data = http_response.env.response_body
499
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
500
+ raise obj
501
+ else
502
+ raise(
503
+ ::NoResponse::Models::Errors::APIStatusError.new(
504
+ status_code: http_response.status,
505
+ body: http_response.env.response_body,
506
+ raw_response: http_response
507
+ ),
508
+ "Unknown content type received"
509
+ )
510
+ end
511
+ elsif Utils.match_status_code(http_response.status, ["403"])
512
+ if Utils.match_content_type(content_type, "application/problem+json")
513
+ @sdk_configuration.hooks.after_success(
514
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
515
+ hook_ctx: hook_ctx
516
+ ),
517
+ response: http_response
518
+ )
519
+ response_data = http_response.env.response_body
520
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
521
+ raise obj
522
+ else
523
+ raise(
524
+ ::NoResponse::Models::Errors::APIStatusError.new(
525
+ status_code: http_response.status,
526
+ body: http_response.env.response_body,
527
+ raw_response: http_response
528
+ ),
529
+ "Unknown content type received"
530
+ )
531
+ end
532
+ elsif Utils.match_status_code(http_response.status, ["404"])
533
+ if Utils.match_content_type(content_type, "application/problem+json")
534
+ @sdk_configuration.hooks.after_success(
535
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
536
+ hook_ctx: hook_ctx
537
+ ),
538
+ response: http_response
539
+ )
540
+ response_data = http_response.env.response_body
541
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
542
+ raise obj
543
+ else
544
+ raise(
545
+ ::NoResponse::Models::Errors::APIStatusError.new(
546
+ status_code: http_response.status,
547
+ body: http_response.env.response_body,
548
+ raw_response: http_response
549
+ ),
550
+ "Unknown content type received"
551
+ )
552
+ end
553
+ elsif Utils.match_status_code(http_response.status, ["409"])
554
+ if Utils.match_content_type(content_type, "application/problem+json")
555
+ @sdk_configuration.hooks.after_success(
556
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
557
+ hook_ctx: hook_ctx
558
+ ),
559
+ response: http_response
560
+ )
561
+ response_data = http_response.env.response_body
562
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
563
+ raise obj
564
+ else
565
+ raise(
566
+ ::NoResponse::Models::Errors::APIStatusError.new(
567
+ status_code: http_response.status,
568
+ body: http_response.env.response_body,
569
+ raw_response: http_response
570
+ ),
571
+ "Unknown content type received"
572
+ )
573
+ end
574
+ elsif Utils.match_status_code(http_response.status, ["429"])
575
+ if Utils.match_content_type(content_type, "application/problem+json")
576
+ @sdk_configuration.hooks.after_success(
577
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
578
+ hook_ctx: hook_ctx
579
+ ),
580
+ response: http_response
581
+ )
582
+ response_data = http_response.env.response_body
583
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
584
+ raise obj
585
+ else
586
+ raise(
587
+ ::NoResponse::Models::Errors::APIStatusError.new(
588
+ status_code: http_response.status,
589
+ body: http_response.env.response_body,
590
+ raw_response: http_response
591
+ ),
592
+ "Unknown content type received"
593
+ )
594
+ end
595
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
596
+ raise(
597
+ ::NoResponse::Models::Errors::APIStatusError.new(
598
+ status_code: http_response.status,
599
+ body: http_response.env.response_body,
600
+ raw_response: http_response
601
+ ),
602
+ "API error occurred"
603
+ )
604
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
605
+ raise(
606
+ ::NoResponse::Models::Errors::APIStatusError.new(
607
+ status_code: http_response.status,
608
+ body: http_response.env.response_body,
609
+ raw_response: http_response
610
+ ),
611
+ "API error occurred"
612
+ )
613
+ else
614
+ raise(
615
+ ::NoResponse::Models::Errors::APIStatusError.new(
616
+ status_code: http_response.status,
617
+ body: http_response.env.response_body,
618
+ raw_response: http_response
619
+ ),
620
+ "Unknown status code received"
621
+ )
622
+
623
+ end
624
+ end
625
+
626
+ sig {
627
+ params(
628
+ workspace_id: ::String,
629
+ environment: Models::Shared::KeyEnvironment,
630
+ event_id: ::String,
631
+ retries: T.nilable(Utils::RetryConfig),
632
+ timeout_ms: T.nilable(Integer),
633
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
634
+ )
635
+ .returns(Models::Operations::GetEventResponse)
636
+ }
637
+ def get(workspace_id:, environment:, event_id:, retries: nil, timeout_ms: nil, http_headers: nil)
638
+ # get - Read an event.
639
+ # Read an event and how many attendees it holds.
640
+ request = Models::Operations::GetEventRequest.new(
641
+ workspace_id: workspace_id,
642
+ environment: environment,
643
+ event_id: event_id
644
+ )
645
+ url, params = @sdk_configuration.get_server_details
646
+ base_url = Utils.template_url(url, params)
647
+ url = Utils.generate_url(
648
+ Models::Operations::GetEventRequest,
649
+ base_url,
650
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}",
651
+ request
652
+ )
653
+ headers = {}
654
+ headers = T.cast(headers, T::Hash[String, String])
655
+ headers["Accept"] = "application/json"
656
+ headers["user-agent"] = @sdk_configuration.user_agent
657
+ retries ||= @sdk_configuration.retry_config
658
+ retries ||= Utils::RetryConfig.new(
659
+ backoff: Utils::BackoffStrategy.new(
660
+ exponent: 2.0,
661
+ initial_interval: 500,
662
+ max_elapsed_time: 30_000,
663
+ max_interval: 8000
664
+ ),
665
+ retry_connection_errors: true,
666
+ strategy: "backoff"
667
+ )
668
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
669
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
670
+
671
+ security = @sdk_configuration.security_source&.call
672
+
673
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
674
+ timeout ||= @sdk_configuration.timeout
675
+
676
+ connection = @sdk_configuration.client.dup
677
+ connection.use(Utils::RetryMiddleware, retry_options)
678
+
679
+ hook_ctx = SDKHooks::HookContext.new(
680
+ config: @sdk_configuration,
681
+ base_url: base_url,
682
+ oauth2_scopes: nil,
683
+ operation_id: "getEvent",
684
+ security_source: @sdk_configuration.security_source
685
+ )
686
+
687
+ error = T.let(nil, T.nilable(StandardError))
688
+ http_response = T.let(nil, T.nilable(Faraday::Response))
689
+
690
+ begin
691
+ http_response = T.must(connection).get(url) do |req|
692
+ req.headers.merge!(headers)
693
+ req.options.timeout = timeout unless timeout.nil?
694
+ Utils.configure_request_security(req, security)
695
+ http_headers&.each do |key, value|
696
+ req.headers[key.to_s] = value
697
+ end
698
+
699
+ @sdk_configuration.hooks.before_request(
700
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
701
+ hook_ctx: hook_ctx
702
+ ),
703
+ request: req
704
+ )
705
+ end
706
+
707
+ rescue StandardError => e
708
+ error = e
709
+ ensure
710
+ if http_response.nil? || Utils.error_status?(http_response.status)
711
+ http_response = @sdk_configuration.hooks.after_error(
712
+ error: error,
713
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
714
+ hook_ctx: hook_ctx
715
+ ),
716
+ response: http_response
717
+ )
718
+ else
719
+ http_response = @sdk_configuration.hooks.after_success(
720
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
721
+ hook_ctx: hook_ctx
722
+ ),
723
+ response: http_response
724
+ )
725
+ end
726
+
727
+ if http_response.nil?
728
+ raise error if !error.nil?
729
+ raise "no response"
730
+ end
731
+ end
732
+
733
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
734
+ if Utils.match_status_code(http_response.status, ["200"])
735
+ if Utils.match_content_type(content_type, "application/json")
736
+ @sdk_configuration.hooks.after_success(
737
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
738
+ hook_ctx: hook_ctx
739
+ ),
740
+ response: http_response
741
+ )
742
+ response_data = http_response.env.response_body
743
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Event)
744
+ result = obj
745
+ response = Models::Operations::GetEventResponse.new(
746
+ result: result,
747
+ headers: http_response.headers
748
+ )
749
+
750
+ return response
751
+ else
752
+ raise(
753
+ ::NoResponse::Models::Errors::APIStatusError.new(
754
+ status_code: http_response.status,
755
+ body: http_response.env.response_body,
756
+ raw_response: http_response
757
+ ),
758
+ "Unknown content type received"
759
+ )
760
+ end
761
+ elsif Utils.match_status_code(http_response.status, ["400"])
762
+ if Utils.match_content_type(content_type, "application/problem+json")
763
+ @sdk_configuration.hooks.after_success(
764
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
765
+ hook_ctx: hook_ctx
766
+ ),
767
+ response: http_response
768
+ )
769
+ response_data = http_response.env.response_body
770
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
771
+ raise obj
772
+ else
773
+ raise(
774
+ ::NoResponse::Models::Errors::APIStatusError.new(
775
+ status_code: http_response.status,
776
+ body: http_response.env.response_body,
777
+ raw_response: http_response
778
+ ),
779
+ "Unknown content type received"
780
+ )
781
+ end
782
+ elsif Utils.match_status_code(http_response.status, ["401"])
783
+ if Utils.match_content_type(content_type, "application/problem+json")
784
+ @sdk_configuration.hooks.after_success(
785
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
786
+ hook_ctx: hook_ctx
787
+ ),
788
+ response: http_response
789
+ )
790
+ response_data = http_response.env.response_body
791
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
792
+ raise obj
793
+ else
794
+ raise(
795
+ ::NoResponse::Models::Errors::APIStatusError.new(
796
+ status_code: http_response.status,
797
+ body: http_response.env.response_body,
798
+ raw_response: http_response
799
+ ),
800
+ "Unknown content type received"
801
+ )
802
+ end
803
+ elsif Utils.match_status_code(http_response.status, ["403"])
804
+ if Utils.match_content_type(content_type, "application/problem+json")
805
+ @sdk_configuration.hooks.after_success(
806
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
807
+ hook_ctx: hook_ctx
808
+ ),
809
+ response: http_response
810
+ )
811
+ response_data = http_response.env.response_body
812
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
813
+ raise obj
814
+ else
815
+ raise(
816
+ ::NoResponse::Models::Errors::APIStatusError.new(
817
+ status_code: http_response.status,
818
+ body: http_response.env.response_body,
819
+ raw_response: http_response
820
+ ),
821
+ "Unknown content type received"
822
+ )
823
+ end
824
+ elsif Utils.match_status_code(http_response.status, ["404"])
825
+ if Utils.match_content_type(content_type, "application/problem+json")
826
+ @sdk_configuration.hooks.after_success(
827
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
828
+ hook_ctx: hook_ctx
829
+ ),
830
+ response: http_response
831
+ )
832
+ response_data = http_response.env.response_body
833
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
834
+ raise obj
835
+ else
836
+ raise(
837
+ ::NoResponse::Models::Errors::APIStatusError.new(
838
+ status_code: http_response.status,
839
+ body: http_response.env.response_body,
840
+ raw_response: http_response
841
+ ),
842
+ "Unknown content type received"
843
+ )
844
+ end
845
+ elsif Utils.match_status_code(http_response.status, ["409"])
846
+ if Utils.match_content_type(content_type, "application/problem+json")
847
+ @sdk_configuration.hooks.after_success(
848
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
849
+ hook_ctx: hook_ctx
850
+ ),
851
+ response: http_response
852
+ )
853
+ response_data = http_response.env.response_body
854
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
855
+ raise obj
856
+ else
857
+ raise(
858
+ ::NoResponse::Models::Errors::APIStatusError.new(
859
+ status_code: http_response.status,
860
+ body: http_response.env.response_body,
861
+ raw_response: http_response
862
+ ),
863
+ "Unknown content type received"
864
+ )
865
+ end
866
+ elsif Utils.match_status_code(http_response.status, ["429"])
867
+ if Utils.match_content_type(content_type, "application/problem+json")
868
+ @sdk_configuration.hooks.after_success(
869
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
870
+ hook_ctx: hook_ctx
871
+ ),
872
+ response: http_response
873
+ )
874
+ response_data = http_response.env.response_body
875
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
876
+ raise obj
877
+ else
878
+ raise(
879
+ ::NoResponse::Models::Errors::APIStatusError.new(
880
+ status_code: http_response.status,
881
+ body: http_response.env.response_body,
882
+ raw_response: http_response
883
+ ),
884
+ "Unknown content type received"
885
+ )
886
+ end
887
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
888
+ raise(
889
+ ::NoResponse::Models::Errors::APIStatusError.new(
890
+ status_code: http_response.status,
891
+ body: http_response.env.response_body,
892
+ raw_response: http_response
893
+ ),
894
+ "API error occurred"
895
+ )
896
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
897
+ raise(
898
+ ::NoResponse::Models::Errors::APIStatusError.new(
899
+ status_code: http_response.status,
900
+ body: http_response.env.response_body,
901
+ raw_response: http_response
902
+ ),
903
+ "API error occurred"
904
+ )
905
+ else
906
+ raise(
907
+ ::NoResponse::Models::Errors::APIStatusError.new(
908
+ status_code: http_response.status,
909
+ body: http_response.env.response_body,
910
+ raw_response: http_response
911
+ ),
912
+ "Unknown status code received"
913
+ )
914
+
915
+ end
916
+ end
917
+
918
+ sig {
919
+ params(
920
+ body: Models::Shared::EventUpdate,
921
+ workspace_id: ::String,
922
+ environment: Models::Shared::KeyEnvironment,
923
+ event_id: ::String,
924
+ retries: T.nilable(Utils::RetryConfig),
925
+ timeout_ms: T.nilable(Integer),
926
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
927
+ )
928
+ .returns(Models::Operations::UpdateEventResponse)
929
+ }
930
+ def update(body:, workspace_id:, environment:, event_id:, retries: nil, timeout_ms: nil, http_headers: nil)
931
+ # update - Change an event.
932
+ # Change the fields you name. Send expected_version to apply the change only to that version.
933
+ request = Models::Operations::UpdateEventRequest.new(
934
+ workspace_id: workspace_id,
935
+ environment: environment,
936
+ event_id: event_id,
937
+ body: body
938
+ )
939
+ url, params = @sdk_configuration.get_server_details
940
+ base_url = Utils.template_url(url, params)
941
+ url = Utils.generate_url(
942
+ Models::Operations::UpdateEventRequest,
943
+ base_url,
944
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}",
945
+ request
946
+ )
947
+ headers = {}
948
+ headers = T.cast(headers, T::Hash[String, String])
949
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
950
+ headers["content-type"] = req_content_type
951
+ raise StandardError, "request body is required" if data.nil? && form.nil?
952
+
953
+ if form && !form.empty?
954
+ body = Utils.encode_form(form)
955
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
956
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
957
+ else
958
+ body = data
959
+ end
960
+
961
+ headers["Accept"] = "application/json"
962
+ headers["user-agent"] = @sdk_configuration.user_agent
963
+ retries ||= @sdk_configuration.retry_config
964
+ retries ||= Utils::RetryConfig.new(
965
+ backoff: Utils::BackoffStrategy.new(
966
+ exponent: 2.0,
967
+ initial_interval: 500,
968
+ max_elapsed_time: 30_000,
969
+ max_interval: 8000
970
+ ),
971
+ retry_connection_errors: true,
972
+ strategy: "backoff"
973
+ )
974
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
975
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
976
+
977
+ security = @sdk_configuration.security_source&.call
978
+
979
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
980
+ timeout ||= @sdk_configuration.timeout
981
+
982
+ connection = @sdk_configuration.client.dup
983
+ connection.use(Utils::RetryMiddleware, retry_options)
984
+
985
+ hook_ctx = SDKHooks::HookContext.new(
986
+ config: @sdk_configuration,
987
+ base_url: base_url,
988
+ oauth2_scopes: nil,
989
+ operation_id: "updateEvent",
990
+ security_source: @sdk_configuration.security_source
991
+ )
992
+
993
+ error = T.let(nil, T.nilable(StandardError))
994
+ http_response = T.let(nil, T.nilable(Faraday::Response))
995
+
996
+ begin
997
+ http_response = T.must(connection).patch(url) do |req|
998
+ req.body = body
999
+ req.headers.merge!(headers)
1000
+ req.options.timeout = timeout unless timeout.nil?
1001
+ Utils.configure_request_security(req, security)
1002
+ http_headers&.each do |key, value|
1003
+ req.headers[key.to_s] = value
1004
+ end
1005
+
1006
+ @sdk_configuration.hooks.before_request(
1007
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1008
+ hook_ctx: hook_ctx
1009
+ ),
1010
+ request: req
1011
+ )
1012
+ end
1013
+
1014
+ rescue StandardError => e
1015
+ error = e
1016
+ ensure
1017
+ if http_response.nil? || Utils.error_status?(http_response.status)
1018
+ http_response = @sdk_configuration.hooks.after_error(
1019
+ error: error,
1020
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1021
+ hook_ctx: hook_ctx
1022
+ ),
1023
+ response: http_response
1024
+ )
1025
+ else
1026
+ http_response = @sdk_configuration.hooks.after_success(
1027
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1028
+ hook_ctx: hook_ctx
1029
+ ),
1030
+ response: http_response
1031
+ )
1032
+ end
1033
+
1034
+ if http_response.nil?
1035
+ raise error if !error.nil?
1036
+ raise "no response"
1037
+ end
1038
+ end
1039
+
1040
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1041
+ if Utils.match_status_code(http_response.status, ["200"])
1042
+ if Utils.match_content_type(content_type, "application/json")
1043
+ @sdk_configuration.hooks.after_success(
1044
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1045
+ hook_ctx: hook_ctx
1046
+ ),
1047
+ response: http_response
1048
+ )
1049
+ response_data = http_response.env.response_body
1050
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Event)
1051
+ result = obj
1052
+ response = Models::Operations::UpdateEventResponse.new(
1053
+ result: result,
1054
+ headers: http_response.headers
1055
+ )
1056
+
1057
+ return response
1058
+ else
1059
+ raise(
1060
+ ::NoResponse::Models::Errors::APIStatusError.new(
1061
+ status_code: http_response.status,
1062
+ body: http_response.env.response_body,
1063
+ raw_response: http_response
1064
+ ),
1065
+ "Unknown content type received"
1066
+ )
1067
+ end
1068
+ elsif Utils.match_status_code(http_response.status, ["400"])
1069
+ if Utils.match_content_type(content_type, "application/problem+json")
1070
+ @sdk_configuration.hooks.after_success(
1071
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1072
+ hook_ctx: hook_ctx
1073
+ ),
1074
+ response: http_response
1075
+ )
1076
+ response_data = http_response.env.response_body
1077
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1078
+ raise obj
1079
+ else
1080
+ raise(
1081
+ ::NoResponse::Models::Errors::APIStatusError.new(
1082
+ status_code: http_response.status,
1083
+ body: http_response.env.response_body,
1084
+ raw_response: http_response
1085
+ ),
1086
+ "Unknown content type received"
1087
+ )
1088
+ end
1089
+ elsif Utils.match_status_code(http_response.status, ["401"])
1090
+ if Utils.match_content_type(content_type, "application/problem+json")
1091
+ @sdk_configuration.hooks.after_success(
1092
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1093
+ hook_ctx: hook_ctx
1094
+ ),
1095
+ response: http_response
1096
+ )
1097
+ response_data = http_response.env.response_body
1098
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
1099
+ raise obj
1100
+ else
1101
+ raise(
1102
+ ::NoResponse::Models::Errors::APIStatusError.new(
1103
+ status_code: http_response.status,
1104
+ body: http_response.env.response_body,
1105
+ raw_response: http_response
1106
+ ),
1107
+ "Unknown content type received"
1108
+ )
1109
+ end
1110
+ elsif Utils.match_status_code(http_response.status, ["403"])
1111
+ if Utils.match_content_type(content_type, "application/problem+json")
1112
+ @sdk_configuration.hooks.after_success(
1113
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1114
+ hook_ctx: hook_ctx
1115
+ ),
1116
+ response: http_response
1117
+ )
1118
+ response_data = http_response.env.response_body
1119
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
1120
+ raise obj
1121
+ else
1122
+ raise(
1123
+ ::NoResponse::Models::Errors::APIStatusError.new(
1124
+ status_code: http_response.status,
1125
+ body: http_response.env.response_body,
1126
+ raw_response: http_response
1127
+ ),
1128
+ "Unknown content type received"
1129
+ )
1130
+ end
1131
+ elsif Utils.match_status_code(http_response.status, ["404"])
1132
+ if Utils.match_content_type(content_type, "application/problem+json")
1133
+ @sdk_configuration.hooks.after_success(
1134
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1135
+ hook_ctx: hook_ctx
1136
+ ),
1137
+ response: http_response
1138
+ )
1139
+ response_data = http_response.env.response_body
1140
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
1141
+ raise obj
1142
+ else
1143
+ raise(
1144
+ ::NoResponse::Models::Errors::APIStatusError.new(
1145
+ status_code: http_response.status,
1146
+ body: http_response.env.response_body,
1147
+ raw_response: http_response
1148
+ ),
1149
+ "Unknown content type received"
1150
+ )
1151
+ end
1152
+ elsif Utils.match_status_code(http_response.status, ["409"])
1153
+ if Utils.match_content_type(content_type, "application/problem+json")
1154
+ @sdk_configuration.hooks.after_success(
1155
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1156
+ hook_ctx: hook_ctx
1157
+ ),
1158
+ response: http_response
1159
+ )
1160
+ response_data = http_response.env.response_body
1161
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
1162
+ raise obj
1163
+ else
1164
+ raise(
1165
+ ::NoResponse::Models::Errors::APIStatusError.new(
1166
+ status_code: http_response.status,
1167
+ body: http_response.env.response_body,
1168
+ raw_response: http_response
1169
+ ),
1170
+ "Unknown content type received"
1171
+ )
1172
+ end
1173
+ elsif Utils.match_status_code(http_response.status, ["429"])
1174
+ if Utils.match_content_type(content_type, "application/problem+json")
1175
+ @sdk_configuration.hooks.after_success(
1176
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1177
+ hook_ctx: hook_ctx
1178
+ ),
1179
+ response: http_response
1180
+ )
1181
+ response_data = http_response.env.response_body
1182
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
1183
+ raise obj
1184
+ else
1185
+ raise(
1186
+ ::NoResponse::Models::Errors::APIStatusError.new(
1187
+ status_code: http_response.status,
1188
+ body: http_response.env.response_body,
1189
+ raw_response: http_response
1190
+ ),
1191
+ "Unknown content type received"
1192
+ )
1193
+ end
1194
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1195
+ raise(
1196
+ ::NoResponse::Models::Errors::APIStatusError.new(
1197
+ status_code: http_response.status,
1198
+ body: http_response.env.response_body,
1199
+ raw_response: http_response
1200
+ ),
1201
+ "API error occurred"
1202
+ )
1203
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1204
+ raise(
1205
+ ::NoResponse::Models::Errors::APIStatusError.new(
1206
+ status_code: http_response.status,
1207
+ body: http_response.env.response_body,
1208
+ raw_response: http_response
1209
+ ),
1210
+ "API error occurred"
1211
+ )
1212
+ else
1213
+ raise(
1214
+ ::NoResponse::Models::Errors::APIStatusError.new(
1215
+ status_code: http_response.status,
1216
+ body: http_response.env.response_body,
1217
+ raw_response: http_response
1218
+ ),
1219
+ "Unknown status code received"
1220
+ )
1221
+
1222
+ end
1223
+ end
1224
+
1225
+ sig {
1226
+ params(
1227
+ workspace_id: ::String,
1228
+ environment: Models::Shared::KeyEnvironment,
1229
+ event_id: ::String,
1230
+ retries: T.nilable(Utils::RetryConfig),
1231
+ timeout_ms: T.nilable(Integer),
1232
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1233
+ )
1234
+ .returns(Models::Operations::DeleteEventResponse)
1235
+ }
1236
+ def delete(workspace_id:, environment:, event_id:, retries: nil, timeout_ms: nil, http_headers: nil)
1237
+ # delete - Erase an event.
1238
+ # Erase an event with its attendees, their decisions and its screenings, and stop any screening still running.
1239
+ request = Models::Operations::DeleteEventRequest.new(
1240
+ workspace_id: workspace_id,
1241
+ environment: environment,
1242
+ event_id: event_id
1243
+ )
1244
+ url, params = @sdk_configuration.get_server_details
1245
+ base_url = Utils.template_url(url, params)
1246
+ url = Utils.generate_url(
1247
+ Models::Operations::DeleteEventRequest,
1248
+ base_url,
1249
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}",
1250
+ request
1251
+ )
1252
+ headers = {}
1253
+ headers = T.cast(headers, T::Hash[String, String])
1254
+ headers["Accept"] = "application/problem+json"
1255
+ headers["user-agent"] = @sdk_configuration.user_agent
1256
+ retries ||= @sdk_configuration.retry_config
1257
+ retries ||= Utils::RetryConfig.new(
1258
+ backoff: Utils::BackoffStrategy.new(
1259
+ exponent: 2.0,
1260
+ initial_interval: 500,
1261
+ max_elapsed_time: 30_000,
1262
+ max_interval: 8000
1263
+ ),
1264
+ retry_connection_errors: true,
1265
+ strategy: "backoff"
1266
+ )
1267
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1268
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
1269
+
1270
+ security = @sdk_configuration.security_source&.call
1271
+
1272
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1273
+ timeout ||= @sdk_configuration.timeout
1274
+
1275
+ connection = @sdk_configuration.client.dup
1276
+ connection.use(Utils::RetryMiddleware, retry_options)
1277
+
1278
+ hook_ctx = SDKHooks::HookContext.new(
1279
+ config: @sdk_configuration,
1280
+ base_url: base_url,
1281
+ oauth2_scopes: nil,
1282
+ operation_id: "deleteEvent",
1283
+ security_source: @sdk_configuration.security_source
1284
+ )
1285
+
1286
+ error = T.let(nil, T.nilable(StandardError))
1287
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1288
+
1289
+ begin
1290
+ http_response = T.must(connection).delete(url) do |req|
1291
+ req.headers.merge!(headers)
1292
+ req.options.timeout = timeout unless timeout.nil?
1293
+ Utils.configure_request_security(req, security)
1294
+ http_headers&.each do |key, value|
1295
+ req.headers[key.to_s] = value
1296
+ end
1297
+
1298
+ @sdk_configuration.hooks.before_request(
1299
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1300
+ hook_ctx: hook_ctx
1301
+ ),
1302
+ request: req
1303
+ )
1304
+ end
1305
+
1306
+ rescue StandardError => e
1307
+ error = e
1308
+ ensure
1309
+ if http_response.nil? || Utils.error_status?(http_response.status)
1310
+ http_response = @sdk_configuration.hooks.after_error(
1311
+ error: error,
1312
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1313
+ hook_ctx: hook_ctx
1314
+ ),
1315
+ response: http_response
1316
+ )
1317
+ else
1318
+ http_response = @sdk_configuration.hooks.after_success(
1319
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1320
+ hook_ctx: hook_ctx
1321
+ ),
1322
+ response: http_response
1323
+ )
1324
+ end
1325
+
1326
+ if http_response.nil?
1327
+ raise error if !error.nil?
1328
+ raise "no response"
1329
+ end
1330
+ end
1331
+
1332
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1333
+ if Utils.match_status_code(http_response.status, ["204"])
1334
+ @sdk_configuration.hooks.after_success(
1335
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1336
+ hook_ctx: hook_ctx
1337
+ ),
1338
+ response: http_response
1339
+ )
1340
+ return Models::Operations::DeleteEventResponse.new(
1341
+ headers: http_response.headers
1342
+ )
1343
+ elsif Utils.match_status_code(http_response.status, ["400"])
1344
+ if Utils.match_content_type(content_type, "application/problem+json")
1345
+ @sdk_configuration.hooks.after_success(
1346
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1347
+ hook_ctx: hook_ctx
1348
+ ),
1349
+ response: http_response
1350
+ )
1351
+ response_data = http_response.env.response_body
1352
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1353
+ raise obj
1354
+ else
1355
+ raise(
1356
+ ::NoResponse::Models::Errors::APIStatusError.new(
1357
+ status_code: http_response.status,
1358
+ body: http_response.env.response_body,
1359
+ raw_response: http_response
1360
+ ),
1361
+ "Unknown content type received"
1362
+ )
1363
+ end
1364
+ elsif Utils.match_status_code(http_response.status, ["401"])
1365
+ if Utils.match_content_type(content_type, "application/problem+json")
1366
+ @sdk_configuration.hooks.after_success(
1367
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1368
+ hook_ctx: hook_ctx
1369
+ ),
1370
+ response: http_response
1371
+ )
1372
+ response_data = http_response.env.response_body
1373
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
1374
+ raise obj
1375
+ else
1376
+ raise(
1377
+ ::NoResponse::Models::Errors::APIStatusError.new(
1378
+ status_code: http_response.status,
1379
+ body: http_response.env.response_body,
1380
+ raw_response: http_response
1381
+ ),
1382
+ "Unknown content type received"
1383
+ )
1384
+ end
1385
+ elsif Utils.match_status_code(http_response.status, ["403"])
1386
+ if Utils.match_content_type(content_type, "application/problem+json")
1387
+ @sdk_configuration.hooks.after_success(
1388
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1389
+ hook_ctx: hook_ctx
1390
+ ),
1391
+ response: http_response
1392
+ )
1393
+ response_data = http_response.env.response_body
1394
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
1395
+ raise obj
1396
+ else
1397
+ raise(
1398
+ ::NoResponse::Models::Errors::APIStatusError.new(
1399
+ status_code: http_response.status,
1400
+ body: http_response.env.response_body,
1401
+ raw_response: http_response
1402
+ ),
1403
+ "Unknown content type received"
1404
+ )
1405
+ end
1406
+ elsif Utils.match_status_code(http_response.status, ["404"])
1407
+ if Utils.match_content_type(content_type, "application/problem+json")
1408
+ @sdk_configuration.hooks.after_success(
1409
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1410
+ hook_ctx: hook_ctx
1411
+ ),
1412
+ response: http_response
1413
+ )
1414
+ response_data = http_response.env.response_body
1415
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
1416
+ raise obj
1417
+ else
1418
+ raise(
1419
+ ::NoResponse::Models::Errors::APIStatusError.new(
1420
+ status_code: http_response.status,
1421
+ body: http_response.env.response_body,
1422
+ raw_response: http_response
1423
+ ),
1424
+ "Unknown content type received"
1425
+ )
1426
+ end
1427
+ elsif Utils.match_status_code(http_response.status, ["409"])
1428
+ if Utils.match_content_type(content_type, "application/problem+json")
1429
+ @sdk_configuration.hooks.after_success(
1430
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1431
+ hook_ctx: hook_ctx
1432
+ ),
1433
+ response: http_response
1434
+ )
1435
+ response_data = http_response.env.response_body
1436
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
1437
+ raise obj
1438
+ else
1439
+ raise(
1440
+ ::NoResponse::Models::Errors::APIStatusError.new(
1441
+ status_code: http_response.status,
1442
+ body: http_response.env.response_body,
1443
+ raw_response: http_response
1444
+ ),
1445
+ "Unknown content type received"
1446
+ )
1447
+ end
1448
+ elsif Utils.match_status_code(http_response.status, ["429"])
1449
+ if Utils.match_content_type(content_type, "application/problem+json")
1450
+ @sdk_configuration.hooks.after_success(
1451
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1452
+ hook_ctx: hook_ctx
1453
+ ),
1454
+ response: http_response
1455
+ )
1456
+ response_data = http_response.env.response_body
1457
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
1458
+ raise obj
1459
+ else
1460
+ raise(
1461
+ ::NoResponse::Models::Errors::APIStatusError.new(
1462
+ status_code: http_response.status,
1463
+ body: http_response.env.response_body,
1464
+ raw_response: http_response
1465
+ ),
1466
+ "Unknown content type received"
1467
+ )
1468
+ end
1469
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1470
+ raise(
1471
+ ::NoResponse::Models::Errors::APIStatusError.new(
1472
+ status_code: http_response.status,
1473
+ body: http_response.env.response_body,
1474
+ raw_response: http_response
1475
+ ),
1476
+ "API error occurred"
1477
+ )
1478
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1479
+ raise(
1480
+ ::NoResponse::Models::Errors::APIStatusError.new(
1481
+ status_code: http_response.status,
1482
+ body: http_response.env.response_body,
1483
+ raw_response: http_response
1484
+ ),
1485
+ "API error occurred"
1486
+ )
1487
+ else
1488
+ raise(
1489
+ ::NoResponse::Models::Errors::APIStatusError.new(
1490
+ status_code: http_response.status,
1491
+ body: http_response.env.response_body,
1492
+ raw_response: http_response
1493
+ ),
1494
+ "Unknown status code received"
1495
+ )
1496
+
1497
+ end
1498
+ end
1499
+
1500
+ sig {
1501
+ params(
1502
+ request: Models::Operations::ListAttendeesRequest,
1503
+ retries: T.nilable(Utils::RetryConfig),
1504
+ timeout_ms: T.nilable(Integer),
1505
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1506
+ )
1507
+ .returns(Models::Operations::ListAttendeesResponse)
1508
+ }
1509
+ def list_attendees(request:, retries: nil, timeout_ms: nil, http_headers: nil)
1510
+ # list_attendees - List an event's attendees.
1511
+ # Read an event's roster in upload order, with each attendee's match state, highest finding band and decision. Filter by band or decision; pass next_after back as after.
1512
+ url, params = @sdk_configuration.get_server_details
1513
+ base_url = Utils.template_url(url, params)
1514
+ url = Utils.generate_url(
1515
+ Models::Operations::ListAttendeesRequest,
1516
+ base_url,
1517
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}/attendees",
1518
+ request
1519
+ )
1520
+ headers = {}
1521
+ headers = T.cast(headers, T::Hash[String, String])
1522
+ query_params = Utils.get_query_params(Models::Operations::ListAttendeesRequest, request, nil)
1523
+ headers["Accept"] = "application/json"
1524
+ headers["user-agent"] = @sdk_configuration.user_agent
1525
+ retries ||= @sdk_configuration.retry_config
1526
+ retries ||= Utils::RetryConfig.new(
1527
+ backoff: Utils::BackoffStrategy.new(
1528
+ exponent: 2.0,
1529
+ initial_interval: 500,
1530
+ max_elapsed_time: 30_000,
1531
+ max_interval: 8000
1532
+ ),
1533
+ retry_connection_errors: true,
1534
+ strategy: "backoff"
1535
+ )
1536
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1537
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
1538
+
1539
+ security = @sdk_configuration.security_source&.call
1540
+
1541
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1542
+ timeout ||= @sdk_configuration.timeout
1543
+
1544
+ connection = @sdk_configuration.client.dup
1545
+ connection.use(Utils::RetryMiddleware, retry_options)
1546
+
1547
+ hook_ctx = SDKHooks::HookContext.new(
1548
+ config: @sdk_configuration,
1549
+ base_url: base_url,
1550
+ oauth2_scopes: nil,
1551
+ operation_id: "listAttendees",
1552
+ security_source: @sdk_configuration.security_source
1553
+ )
1554
+
1555
+ error = T.let(nil, T.nilable(StandardError))
1556
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1557
+
1558
+ begin
1559
+ http_response = T.must(connection).get(url) do |req|
1560
+ req.headers.merge!(headers)
1561
+ req.options.timeout = timeout unless timeout.nil?
1562
+ req.params = query_params
1563
+ Utils.configure_request_security(req, security)
1564
+ http_headers&.each do |key, value|
1565
+ req.headers[key.to_s] = value
1566
+ end
1567
+
1568
+ @sdk_configuration.hooks.before_request(
1569
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1570
+ hook_ctx: hook_ctx
1571
+ ),
1572
+ request: req
1573
+ )
1574
+ end
1575
+
1576
+ rescue StandardError => e
1577
+ error = e
1578
+ ensure
1579
+ if http_response.nil? || Utils.error_status?(http_response.status)
1580
+ http_response = @sdk_configuration.hooks.after_error(
1581
+ error: error,
1582
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1583
+ hook_ctx: hook_ctx
1584
+ ),
1585
+ response: http_response
1586
+ )
1587
+ else
1588
+ http_response = @sdk_configuration.hooks.after_success(
1589
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1590
+ hook_ctx: hook_ctx
1591
+ ),
1592
+ response: http_response
1593
+ )
1594
+ end
1595
+
1596
+ if http_response.nil?
1597
+ raise error if !error.nil?
1598
+ raise "no response"
1599
+ end
1600
+ end
1601
+
1602
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1603
+ if Utils.match_status_code(http_response.status, ["200"])
1604
+ if Utils.match_content_type(content_type, "application/json")
1605
+ @sdk_configuration.hooks.after_success(
1606
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1607
+ hook_ctx: hook_ctx
1608
+ ),
1609
+ response: http_response
1610
+ )
1611
+ response_data = http_response.env.response_body
1612
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AttendeeList)
1613
+ result = obj
1614
+ response = Models::Operations::ListAttendeesResponse.new(
1615
+ result: result,
1616
+ headers: http_response.headers
1617
+ )
1618
+
1619
+ return response
1620
+ else
1621
+ raise(
1622
+ ::NoResponse::Models::Errors::APIStatusError.new(
1623
+ status_code: http_response.status,
1624
+ body: http_response.env.response_body,
1625
+ raw_response: http_response
1626
+ ),
1627
+ "Unknown content type received"
1628
+ )
1629
+ end
1630
+ elsif Utils.match_status_code(http_response.status, ["400"])
1631
+ if Utils.match_content_type(content_type, "application/problem+json")
1632
+ @sdk_configuration.hooks.after_success(
1633
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1634
+ hook_ctx: hook_ctx
1635
+ ),
1636
+ response: http_response
1637
+ )
1638
+ response_data = http_response.env.response_body
1639
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1640
+ raise obj
1641
+ else
1642
+ raise(
1643
+ ::NoResponse::Models::Errors::APIStatusError.new(
1644
+ status_code: http_response.status,
1645
+ body: http_response.env.response_body,
1646
+ raw_response: http_response
1647
+ ),
1648
+ "Unknown content type received"
1649
+ )
1650
+ end
1651
+ elsif Utils.match_status_code(http_response.status, ["401"])
1652
+ if Utils.match_content_type(content_type, "application/problem+json")
1653
+ @sdk_configuration.hooks.after_success(
1654
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1655
+ hook_ctx: hook_ctx
1656
+ ),
1657
+ response: http_response
1658
+ )
1659
+ response_data = http_response.env.response_body
1660
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
1661
+ raise obj
1662
+ else
1663
+ raise(
1664
+ ::NoResponse::Models::Errors::APIStatusError.new(
1665
+ status_code: http_response.status,
1666
+ body: http_response.env.response_body,
1667
+ raw_response: http_response
1668
+ ),
1669
+ "Unknown content type received"
1670
+ )
1671
+ end
1672
+ elsif Utils.match_status_code(http_response.status, ["403"])
1673
+ if Utils.match_content_type(content_type, "application/problem+json")
1674
+ @sdk_configuration.hooks.after_success(
1675
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1676
+ hook_ctx: hook_ctx
1677
+ ),
1678
+ response: http_response
1679
+ )
1680
+ response_data = http_response.env.response_body
1681
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
1682
+ raise obj
1683
+ else
1684
+ raise(
1685
+ ::NoResponse::Models::Errors::APIStatusError.new(
1686
+ status_code: http_response.status,
1687
+ body: http_response.env.response_body,
1688
+ raw_response: http_response
1689
+ ),
1690
+ "Unknown content type received"
1691
+ )
1692
+ end
1693
+ elsif Utils.match_status_code(http_response.status, ["404"])
1694
+ if Utils.match_content_type(content_type, "application/problem+json")
1695
+ @sdk_configuration.hooks.after_success(
1696
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1697
+ hook_ctx: hook_ctx
1698
+ ),
1699
+ response: http_response
1700
+ )
1701
+ response_data = http_response.env.response_body
1702
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
1703
+ raise obj
1704
+ else
1705
+ raise(
1706
+ ::NoResponse::Models::Errors::APIStatusError.new(
1707
+ status_code: http_response.status,
1708
+ body: http_response.env.response_body,
1709
+ raw_response: http_response
1710
+ ),
1711
+ "Unknown content type received"
1712
+ )
1713
+ end
1714
+ elsif Utils.match_status_code(http_response.status, ["409"])
1715
+ if Utils.match_content_type(content_type, "application/problem+json")
1716
+ @sdk_configuration.hooks.after_success(
1717
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1718
+ hook_ctx: hook_ctx
1719
+ ),
1720
+ response: http_response
1721
+ )
1722
+ response_data = http_response.env.response_body
1723
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
1724
+ raise obj
1725
+ else
1726
+ raise(
1727
+ ::NoResponse::Models::Errors::APIStatusError.new(
1728
+ status_code: http_response.status,
1729
+ body: http_response.env.response_body,
1730
+ raw_response: http_response
1731
+ ),
1732
+ "Unknown content type received"
1733
+ )
1734
+ end
1735
+ elsif Utils.match_status_code(http_response.status, ["429"])
1736
+ if Utils.match_content_type(content_type, "application/problem+json")
1737
+ @sdk_configuration.hooks.after_success(
1738
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1739
+ hook_ctx: hook_ctx
1740
+ ),
1741
+ response: http_response
1742
+ )
1743
+ response_data = http_response.env.response_body
1744
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
1745
+ raise obj
1746
+ else
1747
+ raise(
1748
+ ::NoResponse::Models::Errors::APIStatusError.new(
1749
+ status_code: http_response.status,
1750
+ body: http_response.env.response_body,
1751
+ raw_response: http_response
1752
+ ),
1753
+ "Unknown content type received"
1754
+ )
1755
+ end
1756
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1757
+ raise(
1758
+ ::NoResponse::Models::Errors::APIStatusError.new(
1759
+ status_code: http_response.status,
1760
+ body: http_response.env.response_body,
1761
+ raw_response: http_response
1762
+ ),
1763
+ "API error occurred"
1764
+ )
1765
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1766
+ raise(
1767
+ ::NoResponse::Models::Errors::APIStatusError.new(
1768
+ status_code: http_response.status,
1769
+ body: http_response.env.response_body,
1770
+ raw_response: http_response
1771
+ ),
1772
+ "API error occurred"
1773
+ )
1774
+ else
1775
+ raise(
1776
+ ::NoResponse::Models::Errors::APIStatusError.new(
1777
+ status_code: http_response.status,
1778
+ body: http_response.env.response_body,
1779
+ raw_response: http_response
1780
+ ),
1781
+ "Unknown status code received"
1782
+ )
1783
+
1784
+ end
1785
+ end
1786
+
1787
+ sig {
1788
+ params(
1789
+ body: Models::Shared::AttendeeBatchRequest,
1790
+ workspace_id: ::String,
1791
+ environment: Models::Shared::KeyEnvironment,
1792
+ event_id: ::String,
1793
+ idempotency_key: T.nilable(::String),
1794
+ retries: T.nilable(Utils::RetryConfig),
1795
+ timeout_ms: T.nilable(Integer),
1796
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1797
+ )
1798
+ .returns(Models::Operations::AddAttendeesResponse)
1799
+ }
1800
+ def add_attendees(
1801
+ body:,
1802
+ workspace_id:,
1803
+ environment:,
1804
+ event_id:,
1805
+ idempotency_key: nil,
1806
+ retries: nil,
1807
+ timeout_ms: nil,
1808
+ http_headers: nil
1809
+ )
1810
+ # add_attendees - Add or update a batch of attendees.
1811
+ # Add or update 1 to 500 attendees with an Idempotency-Key. A row with the same external_id, else email, else phone as an existing attendee updates it. Identities are stored encrypted.
1812
+ request = Models::Operations::AddAttendeesRequest.new(
1813
+ workspace_id: workspace_id,
1814
+ environment: environment,
1815
+ event_id: event_id,
1816
+ body: body,
1817
+ idempotency_key: idempotency_key
1818
+ )
1819
+ url, params = @sdk_configuration.get_server_details
1820
+ base_url = Utils.template_url(url, params)
1821
+ url = Utils.generate_url(
1822
+ Models::Operations::AddAttendeesRequest,
1823
+ base_url,
1824
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}/attendees",
1825
+ request
1826
+ )
1827
+ headers = Utils.get_headers(request)
1828
+ headers = T.cast(headers, T::Hash[String, String])
1829
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
1830
+ headers["content-type"] = req_content_type
1831
+ raise StandardError, "request body is required" if data.nil? && form.nil?
1832
+
1833
+ if form && !form.empty?
1834
+ body = Utils.encode_form(form)
1835
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
1836
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1837
+ else
1838
+ body = data
1839
+ end
1840
+
1841
+ headers["Accept"] = "application/json"
1842
+ headers["user-agent"] = @sdk_configuration.user_agent
1843
+ retries ||= @sdk_configuration.retry_config
1844
+ retries ||= Utils::RetryConfig.new(
1845
+ backoff: Utils::BackoffStrategy.new(
1846
+ exponent: 2.0,
1847
+ initial_interval: 500,
1848
+ max_elapsed_time: 30_000,
1849
+ max_interval: 8000
1850
+ ),
1851
+ retry_connection_errors: true,
1852
+ strategy: "backoff"
1853
+ )
1854
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1855
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
1856
+
1857
+ security = @sdk_configuration.security_source&.call
1858
+
1859
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1860
+ timeout ||= @sdk_configuration.timeout
1861
+
1862
+ connection = @sdk_configuration.client.dup
1863
+ connection.use(Utils::RetryMiddleware, retry_options)
1864
+
1865
+ hook_ctx = SDKHooks::HookContext.new(
1866
+ config: @sdk_configuration,
1867
+ base_url: base_url,
1868
+ oauth2_scopes: nil,
1869
+ operation_id: "addAttendees",
1870
+ security_source: @sdk_configuration.security_source
1871
+ )
1872
+
1873
+ error = T.let(nil, T.nilable(StandardError))
1874
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1875
+
1876
+ begin
1877
+ http_response = T.must(connection).post(url) do |req|
1878
+ req.body = body
1879
+ req.headers.merge!(headers)
1880
+ req.options.timeout = timeout unless timeout.nil?
1881
+ Utils.configure_request_security(req, security)
1882
+ http_headers&.each do |key, value|
1883
+ req.headers[key.to_s] = value
1884
+ end
1885
+
1886
+ @sdk_configuration.hooks.before_request(
1887
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1888
+ hook_ctx: hook_ctx
1889
+ ),
1890
+ request: req
1891
+ )
1892
+ end
1893
+
1894
+ rescue StandardError => e
1895
+ error = e
1896
+ ensure
1897
+ if http_response.nil? || Utils.error_status?(http_response.status)
1898
+ http_response = @sdk_configuration.hooks.after_error(
1899
+ error: error,
1900
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1901
+ hook_ctx: hook_ctx
1902
+ ),
1903
+ response: http_response
1904
+ )
1905
+ else
1906
+ http_response = @sdk_configuration.hooks.after_success(
1907
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1908
+ hook_ctx: hook_ctx
1909
+ ),
1910
+ response: http_response
1911
+ )
1912
+ end
1913
+
1914
+ if http_response.nil?
1915
+ raise error if !error.nil?
1916
+ raise "no response"
1917
+ end
1918
+ end
1919
+
1920
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1921
+ if Utils.match_status_code(http_response.status, ["200"])
1922
+ if Utils.match_content_type(content_type, "application/json")
1923
+ @sdk_configuration.hooks.after_success(
1924
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1925
+ hook_ctx: hook_ctx
1926
+ ),
1927
+ response: http_response
1928
+ )
1929
+ response_data = http_response.env.response_body
1930
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AttendeeBatch)
1931
+ result = obj
1932
+ response = Models::Operations::AddAttendeesResponse.new(
1933
+ result: result,
1934
+ headers: http_response.headers
1935
+ )
1936
+
1937
+ return response
1938
+ else
1939
+ raise(
1940
+ ::NoResponse::Models::Errors::APIStatusError.new(
1941
+ status_code: http_response.status,
1942
+ body: http_response.env.response_body,
1943
+ raw_response: http_response
1944
+ ),
1945
+ "Unknown content type received"
1946
+ )
1947
+ end
1948
+ elsif Utils.match_status_code(http_response.status, ["400"])
1949
+ if Utils.match_content_type(content_type, "application/problem+json")
1950
+ @sdk_configuration.hooks.after_success(
1951
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1952
+ hook_ctx: hook_ctx
1953
+ ),
1954
+ response: http_response
1955
+ )
1956
+ response_data = http_response.env.response_body
1957
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1958
+ raise obj
1959
+ else
1960
+ raise(
1961
+ ::NoResponse::Models::Errors::APIStatusError.new(
1962
+ status_code: http_response.status,
1963
+ body: http_response.env.response_body,
1964
+ raw_response: http_response
1965
+ ),
1966
+ "Unknown content type received"
1967
+ )
1968
+ end
1969
+ elsif Utils.match_status_code(http_response.status, ["401"])
1970
+ if Utils.match_content_type(content_type, "application/problem+json")
1971
+ @sdk_configuration.hooks.after_success(
1972
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1973
+ hook_ctx: hook_ctx
1974
+ ),
1975
+ response: http_response
1976
+ )
1977
+ response_data = http_response.env.response_body
1978
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
1979
+ raise obj
1980
+ else
1981
+ raise(
1982
+ ::NoResponse::Models::Errors::APIStatusError.new(
1983
+ status_code: http_response.status,
1984
+ body: http_response.env.response_body,
1985
+ raw_response: http_response
1986
+ ),
1987
+ "Unknown content type received"
1988
+ )
1989
+ end
1990
+ elsif Utils.match_status_code(http_response.status, ["403"])
1991
+ if Utils.match_content_type(content_type, "application/problem+json")
1992
+ @sdk_configuration.hooks.after_success(
1993
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1994
+ hook_ctx: hook_ctx
1995
+ ),
1996
+ response: http_response
1997
+ )
1998
+ response_data = http_response.env.response_body
1999
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2000
+ raise obj
2001
+ else
2002
+ raise(
2003
+ ::NoResponse::Models::Errors::APIStatusError.new(
2004
+ status_code: http_response.status,
2005
+ body: http_response.env.response_body,
2006
+ raw_response: http_response
2007
+ ),
2008
+ "Unknown content type received"
2009
+ )
2010
+ end
2011
+ elsif Utils.match_status_code(http_response.status, ["404"])
2012
+ if Utils.match_content_type(content_type, "application/problem+json")
2013
+ @sdk_configuration.hooks.after_success(
2014
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2015
+ hook_ctx: hook_ctx
2016
+ ),
2017
+ response: http_response
2018
+ )
2019
+ response_data = http_response.env.response_body
2020
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2021
+ raise obj
2022
+ else
2023
+ raise(
2024
+ ::NoResponse::Models::Errors::APIStatusError.new(
2025
+ status_code: http_response.status,
2026
+ body: http_response.env.response_body,
2027
+ raw_response: http_response
2028
+ ),
2029
+ "Unknown content type received"
2030
+ )
2031
+ end
2032
+ elsif Utils.match_status_code(http_response.status, ["409"])
2033
+ if Utils.match_content_type(content_type, "application/problem+json")
2034
+ @sdk_configuration.hooks.after_success(
2035
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2036
+ hook_ctx: hook_ctx
2037
+ ),
2038
+ response: http_response
2039
+ )
2040
+ response_data = http_response.env.response_body
2041
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2042
+ raise obj
2043
+ else
2044
+ raise(
2045
+ ::NoResponse::Models::Errors::APIStatusError.new(
2046
+ status_code: http_response.status,
2047
+ body: http_response.env.response_body,
2048
+ raw_response: http_response
2049
+ ),
2050
+ "Unknown content type received"
2051
+ )
2052
+ end
2053
+ elsif Utils.match_status_code(http_response.status, ["429"])
2054
+ if Utils.match_content_type(content_type, "application/problem+json")
2055
+ @sdk_configuration.hooks.after_success(
2056
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2057
+ hook_ctx: hook_ctx
2058
+ ),
2059
+ response: http_response
2060
+ )
2061
+ response_data = http_response.env.response_body
2062
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2063
+ raise obj
2064
+ else
2065
+ raise(
2066
+ ::NoResponse::Models::Errors::APIStatusError.new(
2067
+ status_code: http_response.status,
2068
+ body: http_response.env.response_body,
2069
+ raw_response: http_response
2070
+ ),
2071
+ "Unknown content type received"
2072
+ )
2073
+ end
2074
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2075
+ raise(
2076
+ ::NoResponse::Models::Errors::APIStatusError.new(
2077
+ status_code: http_response.status,
2078
+ body: http_response.env.response_body,
2079
+ raw_response: http_response
2080
+ ),
2081
+ "API error occurred"
2082
+ )
2083
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2084
+ raise(
2085
+ ::NoResponse::Models::Errors::APIStatusError.new(
2086
+ status_code: http_response.status,
2087
+ body: http_response.env.response_body,
2088
+ raw_response: http_response
2089
+ ),
2090
+ "API error occurred"
2091
+ )
2092
+ else
2093
+ raise(
2094
+ ::NoResponse::Models::Errors::APIStatusError.new(
2095
+ status_code: http_response.status,
2096
+ body: http_response.env.response_body,
2097
+ raw_response: http_response
2098
+ ),
2099
+ "Unknown status code received"
2100
+ )
2101
+
2102
+ end
2103
+ end
2104
+
2105
+ sig {
2106
+ params(
2107
+ workspace_id: ::String,
2108
+ environment: Models::Shared::KeyEnvironment,
2109
+ event_id: ::String,
2110
+ attendee_id: ::String,
2111
+ retries: T.nilable(Utils::RetryConfig),
2112
+ timeout_ms: T.nilable(Integer),
2113
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
2114
+ )
2115
+ .returns(Models::Operations::GetAttendeeResponse)
2116
+ }
2117
+ def get_attendee(
2118
+ workspace_id:,
2119
+ environment:,
2120
+ event_id:,
2121
+ attendee_id:,
2122
+ retries: nil,
2123
+ timeout_ms: nil,
2124
+ http_headers: nil
2125
+ )
2126
+ # get_attendee - Read an attendee's report.
2127
+ # Read an attendee's report: matched profiles, findings with their evidence and every recorded decision.
2128
+ request = Models::Operations::GetAttendeeRequest.new(
2129
+ workspace_id: workspace_id,
2130
+ environment: environment,
2131
+ event_id: event_id,
2132
+ attendee_id: attendee_id
2133
+ )
2134
+ url, params = @sdk_configuration.get_server_details
2135
+ base_url = Utils.template_url(url, params)
2136
+ url = Utils.generate_url(
2137
+ Models::Operations::GetAttendeeRequest,
2138
+ base_url,
2139
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}/attendees/{attendee_id}",
2140
+ request
2141
+ )
2142
+ headers = {}
2143
+ headers = T.cast(headers, T::Hash[String, String])
2144
+ headers["Accept"] = "application/json"
2145
+ headers["user-agent"] = @sdk_configuration.user_agent
2146
+ retries ||= @sdk_configuration.retry_config
2147
+ retries ||= Utils::RetryConfig.new(
2148
+ backoff: Utils::BackoffStrategy.new(
2149
+ exponent: 2.0,
2150
+ initial_interval: 500,
2151
+ max_elapsed_time: 30_000,
2152
+ max_interval: 8000
2153
+ ),
2154
+ retry_connection_errors: true,
2155
+ strategy: "backoff"
2156
+ )
2157
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
2158
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
2159
+
2160
+ security = @sdk_configuration.security_source&.call
2161
+
2162
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
2163
+ timeout ||= @sdk_configuration.timeout
2164
+
2165
+ connection = @sdk_configuration.client.dup
2166
+ connection.use(Utils::RetryMiddleware, retry_options)
2167
+
2168
+ hook_ctx = SDKHooks::HookContext.new(
2169
+ config: @sdk_configuration,
2170
+ base_url: base_url,
2171
+ oauth2_scopes: nil,
2172
+ operation_id: "getAttendee",
2173
+ security_source: @sdk_configuration.security_source
2174
+ )
2175
+
2176
+ error = T.let(nil, T.nilable(StandardError))
2177
+ http_response = T.let(nil, T.nilable(Faraday::Response))
2178
+
2179
+ begin
2180
+ http_response = T.must(connection).get(url) do |req|
2181
+ req.headers.merge!(headers)
2182
+ req.options.timeout = timeout unless timeout.nil?
2183
+ Utils.configure_request_security(req, security)
2184
+ http_headers&.each do |key, value|
2185
+ req.headers[key.to_s] = value
2186
+ end
2187
+
2188
+ @sdk_configuration.hooks.before_request(
2189
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
2190
+ hook_ctx: hook_ctx
2191
+ ),
2192
+ request: req
2193
+ )
2194
+ end
2195
+
2196
+ rescue StandardError => e
2197
+ error = e
2198
+ ensure
2199
+ if http_response.nil? || Utils.error_status?(http_response.status)
2200
+ http_response = @sdk_configuration.hooks.after_error(
2201
+ error: error,
2202
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
2203
+ hook_ctx: hook_ctx
2204
+ ),
2205
+ response: http_response
2206
+ )
2207
+ else
2208
+ http_response = @sdk_configuration.hooks.after_success(
2209
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2210
+ hook_ctx: hook_ctx
2211
+ ),
2212
+ response: http_response
2213
+ )
2214
+ end
2215
+
2216
+ if http_response.nil?
2217
+ raise error if !error.nil?
2218
+ raise "no response"
2219
+ end
2220
+ end
2221
+
2222
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
2223
+ if Utils.match_status_code(http_response.status, ["200"])
2224
+ if Utils.match_content_type(content_type, "application/json")
2225
+ @sdk_configuration.hooks.after_success(
2226
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2227
+ hook_ctx: hook_ctx
2228
+ ),
2229
+ response: http_response
2230
+ )
2231
+ response_data = http_response.env.response_body
2232
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AttendeeReport)
2233
+ result = obj
2234
+ response = Models::Operations::GetAttendeeResponse.new(
2235
+ result: result,
2236
+ headers: http_response.headers
2237
+ )
2238
+
2239
+ return response
2240
+ else
2241
+ raise(
2242
+ ::NoResponse::Models::Errors::APIStatusError.new(
2243
+ status_code: http_response.status,
2244
+ body: http_response.env.response_body,
2245
+ raw_response: http_response
2246
+ ),
2247
+ "Unknown content type received"
2248
+ )
2249
+ end
2250
+ elsif Utils.match_status_code(http_response.status, ["400"])
2251
+ if Utils.match_content_type(content_type, "application/problem+json")
2252
+ @sdk_configuration.hooks.after_success(
2253
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2254
+ hook_ctx: hook_ctx
2255
+ ),
2256
+ response: http_response
2257
+ )
2258
+ response_data = http_response.env.response_body
2259
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
2260
+ raise obj
2261
+ else
2262
+ raise(
2263
+ ::NoResponse::Models::Errors::APIStatusError.new(
2264
+ status_code: http_response.status,
2265
+ body: http_response.env.response_body,
2266
+ raw_response: http_response
2267
+ ),
2268
+ "Unknown content type received"
2269
+ )
2270
+ end
2271
+ elsif Utils.match_status_code(http_response.status, ["401"])
2272
+ if Utils.match_content_type(content_type, "application/problem+json")
2273
+ @sdk_configuration.hooks.after_success(
2274
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2275
+ hook_ctx: hook_ctx
2276
+ ),
2277
+ response: http_response
2278
+ )
2279
+ response_data = http_response.env.response_body
2280
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2281
+ raise obj
2282
+ else
2283
+ raise(
2284
+ ::NoResponse::Models::Errors::APIStatusError.new(
2285
+ status_code: http_response.status,
2286
+ body: http_response.env.response_body,
2287
+ raw_response: http_response
2288
+ ),
2289
+ "Unknown content type received"
2290
+ )
2291
+ end
2292
+ elsif Utils.match_status_code(http_response.status, ["403"])
2293
+ if Utils.match_content_type(content_type, "application/problem+json")
2294
+ @sdk_configuration.hooks.after_success(
2295
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2296
+ hook_ctx: hook_ctx
2297
+ ),
2298
+ response: http_response
2299
+ )
2300
+ response_data = http_response.env.response_body
2301
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2302
+ raise obj
2303
+ else
2304
+ raise(
2305
+ ::NoResponse::Models::Errors::APIStatusError.new(
2306
+ status_code: http_response.status,
2307
+ body: http_response.env.response_body,
2308
+ raw_response: http_response
2309
+ ),
2310
+ "Unknown content type received"
2311
+ )
2312
+ end
2313
+ elsif Utils.match_status_code(http_response.status, ["404"])
2314
+ if Utils.match_content_type(content_type, "application/problem+json")
2315
+ @sdk_configuration.hooks.after_success(
2316
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2317
+ hook_ctx: hook_ctx
2318
+ ),
2319
+ response: http_response
2320
+ )
2321
+ response_data = http_response.env.response_body
2322
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2323
+ raise obj
2324
+ else
2325
+ raise(
2326
+ ::NoResponse::Models::Errors::APIStatusError.new(
2327
+ status_code: http_response.status,
2328
+ body: http_response.env.response_body,
2329
+ raw_response: http_response
2330
+ ),
2331
+ "Unknown content type received"
2332
+ )
2333
+ end
2334
+ elsif Utils.match_status_code(http_response.status, ["409"])
2335
+ if Utils.match_content_type(content_type, "application/problem+json")
2336
+ @sdk_configuration.hooks.after_success(
2337
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2338
+ hook_ctx: hook_ctx
2339
+ ),
2340
+ response: http_response
2341
+ )
2342
+ response_data = http_response.env.response_body
2343
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2344
+ raise obj
2345
+ else
2346
+ raise(
2347
+ ::NoResponse::Models::Errors::APIStatusError.new(
2348
+ status_code: http_response.status,
2349
+ body: http_response.env.response_body,
2350
+ raw_response: http_response
2351
+ ),
2352
+ "Unknown content type received"
2353
+ )
2354
+ end
2355
+ elsif Utils.match_status_code(http_response.status, ["429"])
2356
+ if Utils.match_content_type(content_type, "application/problem+json")
2357
+ @sdk_configuration.hooks.after_success(
2358
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2359
+ hook_ctx: hook_ctx
2360
+ ),
2361
+ response: http_response
2362
+ )
2363
+ response_data = http_response.env.response_body
2364
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2365
+ raise obj
2366
+ else
2367
+ raise(
2368
+ ::NoResponse::Models::Errors::APIStatusError.new(
2369
+ status_code: http_response.status,
2370
+ body: http_response.env.response_body,
2371
+ raw_response: http_response
2372
+ ),
2373
+ "Unknown content type received"
2374
+ )
2375
+ end
2376
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2377
+ raise(
2378
+ ::NoResponse::Models::Errors::APIStatusError.new(
2379
+ status_code: http_response.status,
2380
+ body: http_response.env.response_body,
2381
+ raw_response: http_response
2382
+ ),
2383
+ "API error occurred"
2384
+ )
2385
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2386
+ raise(
2387
+ ::NoResponse::Models::Errors::APIStatusError.new(
2388
+ status_code: http_response.status,
2389
+ body: http_response.env.response_body,
2390
+ raw_response: http_response
2391
+ ),
2392
+ "API error occurred"
2393
+ )
2394
+ else
2395
+ raise(
2396
+ ::NoResponse::Models::Errors::APIStatusError.new(
2397
+ status_code: http_response.status,
2398
+ body: http_response.env.response_body,
2399
+ raw_response: http_response
2400
+ ),
2401
+ "Unknown status code received"
2402
+ )
2403
+
2404
+ end
2405
+ end
2406
+
2407
+ sig {
2408
+ params(
2409
+ body: Models::Shared::AttendeeReviewRequest,
2410
+ workspace_id: ::String,
2411
+ environment: Models::Shared::KeyEnvironment,
2412
+ event_id: ::String,
2413
+ attendee_id: ::String,
2414
+ timeout_ms: T.nilable(Integer),
2415
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
2416
+ )
2417
+ .returns(Models::Operations::ReviewAttendeeResponse)
2418
+ }
2419
+ def review_attendee(body:, workspace_id:, environment:, event_id:, attendee_id:, timeout_ms: nil, http_headers: nil)
2420
+ # review_attendee - Record a decision on an attendee.
2421
+ # Record a cleared, watch or escalated decision with a note. The latest decision is the attendee's; the next screening refreshes everyone on watch or escalated.
2422
+ request = Models::Operations::ReviewAttendeeRequest.new(
2423
+ workspace_id: workspace_id,
2424
+ environment: environment,
2425
+ event_id: event_id,
2426
+ attendee_id: attendee_id,
2427
+ body: body
2428
+ )
2429
+ url, params = @sdk_configuration.get_server_details
2430
+ base_url = Utils.template_url(url, params)
2431
+ url = Utils.generate_url(
2432
+ Models::Operations::ReviewAttendeeRequest,
2433
+ base_url,
2434
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}/attendees/{attendee_id}/review",
2435
+ request
2436
+ )
2437
+ headers = {}
2438
+ headers = T.cast(headers, T::Hash[String, String])
2439
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
2440
+ headers["content-type"] = req_content_type
2441
+ raise StandardError, "request body is required" if data.nil? && form.nil?
2442
+
2443
+ if form && !form.empty?
2444
+ body = Utils.encode_form(form)
2445
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
2446
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
2447
+ else
2448
+ body = data
2449
+ end
2450
+
2451
+ headers["Accept"] = "application/json"
2452
+ headers["user-agent"] = @sdk_configuration.user_agent
2453
+
2454
+ security = @sdk_configuration.security_source&.call
2455
+
2456
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
2457
+ timeout ||= @sdk_configuration.timeout
2458
+
2459
+ connection = @sdk_configuration.client
2460
+
2461
+ hook_ctx = SDKHooks::HookContext.new(
2462
+ config: @sdk_configuration,
2463
+ base_url: base_url,
2464
+ oauth2_scopes: nil,
2465
+ operation_id: "reviewAttendee",
2466
+ security_source: @sdk_configuration.security_source
2467
+ )
2468
+
2469
+ error = T.let(nil, T.nilable(StandardError))
2470
+ http_response = T.let(nil, T.nilable(Faraday::Response))
2471
+
2472
+ begin
2473
+ http_response = T.must(connection).post(url) do |req|
2474
+ req.body = body
2475
+ req.headers.merge!(headers)
2476
+ req.options.timeout = timeout unless timeout.nil?
2477
+ Utils.configure_request_security(req, security)
2478
+ http_headers&.each do |key, value|
2479
+ req.headers[key.to_s] = value
2480
+ end
2481
+
2482
+ @sdk_configuration.hooks.before_request(
2483
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
2484
+ hook_ctx: hook_ctx
2485
+ ),
2486
+ request: req
2487
+ )
2488
+ end
2489
+
2490
+ rescue StandardError => e
2491
+ error = e
2492
+ ensure
2493
+ if http_response.nil? || Utils.error_status?(http_response.status)
2494
+ http_response = @sdk_configuration.hooks.after_error(
2495
+ error: error,
2496
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
2497
+ hook_ctx: hook_ctx
2498
+ ),
2499
+ response: http_response
2500
+ )
2501
+ else
2502
+ http_response = @sdk_configuration.hooks.after_success(
2503
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2504
+ hook_ctx: hook_ctx
2505
+ ),
2506
+ response: http_response
2507
+ )
2508
+ end
2509
+
2510
+ if http_response.nil?
2511
+ raise error if !error.nil?
2512
+ raise "no response"
2513
+ end
2514
+ end
2515
+
2516
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
2517
+ if Utils.match_status_code(http_response.status, ["200"])
2518
+ if Utils.match_content_type(content_type, "application/json")
2519
+ @sdk_configuration.hooks.after_success(
2520
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2521
+ hook_ctx: hook_ctx
2522
+ ),
2523
+ response: http_response
2524
+ )
2525
+ response_data = http_response.env.response_body
2526
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Attendee)
2527
+ result = obj
2528
+ response = Models::Operations::ReviewAttendeeResponse.new(
2529
+ result: result,
2530
+ headers: http_response.headers
2531
+ )
2532
+
2533
+ return response
2534
+ else
2535
+ raise(
2536
+ ::NoResponse::Models::Errors::APIStatusError.new(
2537
+ status_code: http_response.status,
2538
+ body: http_response.env.response_body,
2539
+ raw_response: http_response
2540
+ ),
2541
+ "Unknown content type received"
2542
+ )
2543
+ end
2544
+ elsif Utils.match_status_code(http_response.status, ["400"])
2545
+ if Utils.match_content_type(content_type, "application/problem+json")
2546
+ @sdk_configuration.hooks.after_success(
2547
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2548
+ hook_ctx: hook_ctx
2549
+ ),
2550
+ response: http_response
2551
+ )
2552
+ response_data = http_response.env.response_body
2553
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
2554
+ raise obj
2555
+ else
2556
+ raise(
2557
+ ::NoResponse::Models::Errors::APIStatusError.new(
2558
+ status_code: http_response.status,
2559
+ body: http_response.env.response_body,
2560
+ raw_response: http_response
2561
+ ),
2562
+ "Unknown content type received"
2563
+ )
2564
+ end
2565
+ elsif Utils.match_status_code(http_response.status, ["401"])
2566
+ if Utils.match_content_type(content_type, "application/problem+json")
2567
+ @sdk_configuration.hooks.after_success(
2568
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2569
+ hook_ctx: hook_ctx
2570
+ ),
2571
+ response: http_response
2572
+ )
2573
+ response_data = http_response.env.response_body
2574
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2575
+ raise obj
2576
+ else
2577
+ raise(
2578
+ ::NoResponse::Models::Errors::APIStatusError.new(
2579
+ status_code: http_response.status,
2580
+ body: http_response.env.response_body,
2581
+ raw_response: http_response
2582
+ ),
2583
+ "Unknown content type received"
2584
+ )
2585
+ end
2586
+ elsif Utils.match_status_code(http_response.status, ["403"])
2587
+ if Utils.match_content_type(content_type, "application/problem+json")
2588
+ @sdk_configuration.hooks.after_success(
2589
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2590
+ hook_ctx: hook_ctx
2591
+ ),
2592
+ response: http_response
2593
+ )
2594
+ response_data = http_response.env.response_body
2595
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2596
+ raise obj
2597
+ else
2598
+ raise(
2599
+ ::NoResponse::Models::Errors::APIStatusError.new(
2600
+ status_code: http_response.status,
2601
+ body: http_response.env.response_body,
2602
+ raw_response: http_response
2603
+ ),
2604
+ "Unknown content type received"
2605
+ )
2606
+ end
2607
+ elsif Utils.match_status_code(http_response.status, ["404"])
2608
+ if Utils.match_content_type(content_type, "application/problem+json")
2609
+ @sdk_configuration.hooks.after_success(
2610
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2611
+ hook_ctx: hook_ctx
2612
+ ),
2613
+ response: http_response
2614
+ )
2615
+ response_data = http_response.env.response_body
2616
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2617
+ raise obj
2618
+ else
2619
+ raise(
2620
+ ::NoResponse::Models::Errors::APIStatusError.new(
2621
+ status_code: http_response.status,
2622
+ body: http_response.env.response_body,
2623
+ raw_response: http_response
2624
+ ),
2625
+ "Unknown content type received"
2626
+ )
2627
+ end
2628
+ elsif Utils.match_status_code(http_response.status, ["409"])
2629
+ if Utils.match_content_type(content_type, "application/problem+json")
2630
+ @sdk_configuration.hooks.after_success(
2631
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2632
+ hook_ctx: hook_ctx
2633
+ ),
2634
+ response: http_response
2635
+ )
2636
+ response_data = http_response.env.response_body
2637
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2638
+ raise obj
2639
+ else
2640
+ raise(
2641
+ ::NoResponse::Models::Errors::APIStatusError.new(
2642
+ status_code: http_response.status,
2643
+ body: http_response.env.response_body,
2644
+ raw_response: http_response
2645
+ ),
2646
+ "Unknown content type received"
2647
+ )
2648
+ end
2649
+ elsif Utils.match_status_code(http_response.status, ["429"])
2650
+ if Utils.match_content_type(content_type, "application/problem+json")
2651
+ @sdk_configuration.hooks.after_success(
2652
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2653
+ hook_ctx: hook_ctx
2654
+ ),
2655
+ response: http_response
2656
+ )
2657
+ response_data = http_response.env.response_body
2658
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2659
+ raise obj
2660
+ else
2661
+ raise(
2662
+ ::NoResponse::Models::Errors::APIStatusError.new(
2663
+ status_code: http_response.status,
2664
+ body: http_response.env.response_body,
2665
+ raw_response: http_response
2666
+ ),
2667
+ "Unknown content type received"
2668
+ )
2669
+ end
2670
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2671
+ raise(
2672
+ ::NoResponse::Models::Errors::APIStatusError.new(
2673
+ status_code: http_response.status,
2674
+ body: http_response.env.response_body,
2675
+ raw_response: http_response
2676
+ ),
2677
+ "API error occurred"
2678
+ )
2679
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2680
+ raise(
2681
+ ::NoResponse::Models::Errors::APIStatusError.new(
2682
+ status_code: http_response.status,
2683
+ body: http_response.env.response_body,
2684
+ raw_response: http_response
2685
+ ),
2686
+ "API error occurred"
2687
+ )
2688
+ else
2689
+ raise(
2690
+ ::NoResponse::Models::Errors::APIStatusError.new(
2691
+ status_code: http_response.status,
2692
+ body: http_response.env.response_body,
2693
+ raw_response: http_response
2694
+ ),
2695
+ "Unknown status code received"
2696
+ )
2697
+
2698
+ end
2699
+ end
2700
+
2701
+ sig {
2702
+ params(
2703
+ workspace_id: ::String,
2704
+ environment: Models::Shared::KeyEnvironment,
2705
+ event_id: ::String,
2706
+ limit: T.nilable(::Integer),
2707
+ before: T.nilable(::String),
2708
+ retries: T.nilable(Utils::RetryConfig),
2709
+ timeout_ms: T.nilable(Integer),
2710
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
2711
+ )
2712
+ .returns(Models::Operations::ListScreeningsResponse)
2713
+ }
2714
+ def list_screenings(
2715
+ workspace_id:,
2716
+ environment:,
2717
+ event_id:,
2718
+ limit: nil,
2719
+ before: nil,
2720
+ retries: nil,
2721
+ timeout_ms: nil,
2722
+ http_headers: nil
2723
+ )
2724
+ # list_screenings - List an event's screenings.
2725
+ # List an event's screenings, newest first.
2726
+ request = Models::Operations::ListScreeningsRequest.new(
2727
+ workspace_id: workspace_id,
2728
+ environment: environment,
2729
+ event_id: event_id,
2730
+ limit: limit,
2731
+ before: before
2732
+ )
2733
+ url, params = @sdk_configuration.get_server_details
2734
+ base_url = Utils.template_url(url, params)
2735
+ url = Utils.generate_url(
2736
+ Models::Operations::ListScreeningsRequest,
2737
+ base_url,
2738
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}/screenings",
2739
+ request
2740
+ )
2741
+ headers = {}
2742
+ headers = T.cast(headers, T::Hash[String, String])
2743
+ query_params = Utils.get_query_params(Models::Operations::ListScreeningsRequest, request, nil)
2744
+ headers["Accept"] = "application/json"
2745
+ headers["user-agent"] = @sdk_configuration.user_agent
2746
+ retries ||= @sdk_configuration.retry_config
2747
+ retries ||= Utils::RetryConfig.new(
2748
+ backoff: Utils::BackoffStrategy.new(
2749
+ exponent: 2.0,
2750
+ initial_interval: 500,
2751
+ max_elapsed_time: 30_000,
2752
+ max_interval: 8000
2753
+ ),
2754
+ retry_connection_errors: true,
2755
+ strategy: "backoff"
2756
+ )
2757
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
2758
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
2759
+
2760
+ security = @sdk_configuration.security_source&.call
2761
+
2762
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
2763
+ timeout ||= @sdk_configuration.timeout
2764
+
2765
+ connection = @sdk_configuration.client.dup
2766
+ connection.use(Utils::RetryMiddleware, retry_options)
2767
+
2768
+ hook_ctx = SDKHooks::HookContext.new(
2769
+ config: @sdk_configuration,
2770
+ base_url: base_url,
2771
+ oauth2_scopes: nil,
2772
+ operation_id: "listScreenings",
2773
+ security_source: @sdk_configuration.security_source
2774
+ )
2775
+
2776
+ error = T.let(nil, T.nilable(StandardError))
2777
+ http_response = T.let(nil, T.nilable(Faraday::Response))
2778
+
2779
+ begin
2780
+ http_response = T.must(connection).get(url) do |req|
2781
+ req.headers.merge!(headers)
2782
+ req.options.timeout = timeout unless timeout.nil?
2783
+ req.params = query_params
2784
+ Utils.configure_request_security(req, security)
2785
+ http_headers&.each do |key, value|
2786
+ req.headers[key.to_s] = value
2787
+ end
2788
+
2789
+ @sdk_configuration.hooks.before_request(
2790
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
2791
+ hook_ctx: hook_ctx
2792
+ ),
2793
+ request: req
2794
+ )
2795
+ end
2796
+
2797
+ rescue StandardError => e
2798
+ error = e
2799
+ ensure
2800
+ if http_response.nil? || Utils.error_status?(http_response.status)
2801
+ http_response = @sdk_configuration.hooks.after_error(
2802
+ error: error,
2803
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
2804
+ hook_ctx: hook_ctx
2805
+ ),
2806
+ response: http_response
2807
+ )
2808
+ else
2809
+ http_response = @sdk_configuration.hooks.after_success(
2810
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2811
+ hook_ctx: hook_ctx
2812
+ ),
2813
+ response: http_response
2814
+ )
2815
+ end
2816
+
2817
+ if http_response.nil?
2818
+ raise error if !error.nil?
2819
+ raise "no response"
2820
+ end
2821
+ end
2822
+
2823
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
2824
+ if Utils.match_status_code(http_response.status, ["200"])
2825
+ if Utils.match_content_type(content_type, "application/json")
2826
+ @sdk_configuration.hooks.after_success(
2827
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2828
+ hook_ctx: hook_ctx
2829
+ ),
2830
+ response: http_response
2831
+ )
2832
+ response_data = http_response.env.response_body
2833
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::ScreeningList)
2834
+ result = obj
2835
+ response = Models::Operations::ListScreeningsResponse.new(
2836
+ result: result,
2837
+ headers: http_response.headers
2838
+ )
2839
+
2840
+ return response
2841
+ else
2842
+ raise(
2843
+ ::NoResponse::Models::Errors::APIStatusError.new(
2844
+ status_code: http_response.status,
2845
+ body: http_response.env.response_body,
2846
+ raw_response: http_response
2847
+ ),
2848
+ "Unknown content type received"
2849
+ )
2850
+ end
2851
+ elsif Utils.match_status_code(http_response.status, ["400"])
2852
+ if Utils.match_content_type(content_type, "application/problem+json")
2853
+ @sdk_configuration.hooks.after_success(
2854
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2855
+ hook_ctx: hook_ctx
2856
+ ),
2857
+ response: http_response
2858
+ )
2859
+ response_data = http_response.env.response_body
2860
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
2861
+ raise obj
2862
+ else
2863
+ raise(
2864
+ ::NoResponse::Models::Errors::APIStatusError.new(
2865
+ status_code: http_response.status,
2866
+ body: http_response.env.response_body,
2867
+ raw_response: http_response
2868
+ ),
2869
+ "Unknown content type received"
2870
+ )
2871
+ end
2872
+ elsif Utils.match_status_code(http_response.status, ["401"])
2873
+ if Utils.match_content_type(content_type, "application/problem+json")
2874
+ @sdk_configuration.hooks.after_success(
2875
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2876
+ hook_ctx: hook_ctx
2877
+ ),
2878
+ response: http_response
2879
+ )
2880
+ response_data = http_response.env.response_body
2881
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2882
+ raise obj
2883
+ else
2884
+ raise(
2885
+ ::NoResponse::Models::Errors::APIStatusError.new(
2886
+ status_code: http_response.status,
2887
+ body: http_response.env.response_body,
2888
+ raw_response: http_response
2889
+ ),
2890
+ "Unknown content type received"
2891
+ )
2892
+ end
2893
+ elsif Utils.match_status_code(http_response.status, ["403"])
2894
+ if Utils.match_content_type(content_type, "application/problem+json")
2895
+ @sdk_configuration.hooks.after_success(
2896
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2897
+ hook_ctx: hook_ctx
2898
+ ),
2899
+ response: http_response
2900
+ )
2901
+ response_data = http_response.env.response_body
2902
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2903
+ raise obj
2904
+ else
2905
+ raise(
2906
+ ::NoResponse::Models::Errors::APIStatusError.new(
2907
+ status_code: http_response.status,
2908
+ body: http_response.env.response_body,
2909
+ raw_response: http_response
2910
+ ),
2911
+ "Unknown content type received"
2912
+ )
2913
+ end
2914
+ elsif Utils.match_status_code(http_response.status, ["404"])
2915
+ if Utils.match_content_type(content_type, "application/problem+json")
2916
+ @sdk_configuration.hooks.after_success(
2917
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2918
+ hook_ctx: hook_ctx
2919
+ ),
2920
+ response: http_response
2921
+ )
2922
+ response_data = http_response.env.response_body
2923
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2924
+ raise obj
2925
+ else
2926
+ raise(
2927
+ ::NoResponse::Models::Errors::APIStatusError.new(
2928
+ status_code: http_response.status,
2929
+ body: http_response.env.response_body,
2930
+ raw_response: http_response
2931
+ ),
2932
+ "Unknown content type received"
2933
+ )
2934
+ end
2935
+ elsif Utils.match_status_code(http_response.status, ["409"])
2936
+ if Utils.match_content_type(content_type, "application/problem+json")
2937
+ @sdk_configuration.hooks.after_success(
2938
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2939
+ hook_ctx: hook_ctx
2940
+ ),
2941
+ response: http_response
2942
+ )
2943
+ response_data = http_response.env.response_body
2944
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2945
+ raise obj
2946
+ else
2947
+ raise(
2948
+ ::NoResponse::Models::Errors::APIStatusError.new(
2949
+ status_code: http_response.status,
2950
+ body: http_response.env.response_body,
2951
+ raw_response: http_response
2952
+ ),
2953
+ "Unknown content type received"
2954
+ )
2955
+ end
2956
+ elsif Utils.match_status_code(http_response.status, ["429"])
2957
+ if Utils.match_content_type(content_type, "application/problem+json")
2958
+ @sdk_configuration.hooks.after_success(
2959
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2960
+ hook_ctx: hook_ctx
2961
+ ),
2962
+ response: http_response
2963
+ )
2964
+ response_data = http_response.env.response_body
2965
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2966
+ raise obj
2967
+ else
2968
+ raise(
2969
+ ::NoResponse::Models::Errors::APIStatusError.new(
2970
+ status_code: http_response.status,
2971
+ body: http_response.env.response_body,
2972
+ raw_response: http_response
2973
+ ),
2974
+ "Unknown content type received"
2975
+ )
2976
+ end
2977
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2978
+ raise(
2979
+ ::NoResponse::Models::Errors::APIStatusError.new(
2980
+ status_code: http_response.status,
2981
+ body: http_response.env.response_body,
2982
+ raw_response: http_response
2983
+ ),
2984
+ "API error occurred"
2985
+ )
2986
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2987
+ raise(
2988
+ ::NoResponse::Models::Errors::APIStatusError.new(
2989
+ status_code: http_response.status,
2990
+ body: http_response.env.response_body,
2991
+ raw_response: http_response
2992
+ ),
2993
+ "API error occurred"
2994
+ )
2995
+ else
2996
+ raise(
2997
+ ::NoResponse::Models::Errors::APIStatusError.new(
2998
+ status_code: http_response.status,
2999
+ body: http_response.env.response_body,
3000
+ raw_response: http_response
3001
+ ),
3002
+ "Unknown status code received"
3003
+ )
3004
+
3005
+ end
3006
+ end
3007
+
3008
+ sig {
3009
+ params(
3010
+ body: Models::Shared::ScreeningRequest,
3011
+ workspace_id: ::String,
3012
+ environment: Models::Shared::KeyEnvironment,
3013
+ event_id: ::String,
3014
+ idempotency_key: T.nilable(::String),
3015
+ retries: T.nilable(Utils::RetryConfig),
3016
+ timeout_ms: T.nilable(Integer),
3017
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
3018
+ )
3019
+ .returns(Models::Operations::StartScreeningResponse)
3020
+ }
3021
+ def start_screening(
3022
+ body:,
3023
+ workspace_id:,
3024
+ environment:,
3025
+ event_id:,
3026
+ idempotency_key: nil,
3027
+ retries: nil,
3028
+ timeout_ms: nil,
3029
+ http_headers: nil
3030
+ )
3031
+ # start_screening - Start a screening.
3032
+ # Start a screening of new attendees and everyone on watch or escalated, with an Idempotency-Key. It finishes completed, partial or failed minutes to hours later; poll it. The test environment screens with stand-ins that find no accounts.
3033
+ request = Models::Operations::StartScreeningRequest.new(
3034
+ workspace_id: workspace_id,
3035
+ environment: environment,
3036
+ event_id: event_id,
3037
+ body: body,
3038
+ idempotency_key: idempotency_key
3039
+ )
3040
+ url, params = @sdk_configuration.get_server_details
3041
+ base_url = Utils.template_url(url, params)
3042
+ url = Utils.generate_url(
3043
+ Models::Operations::StartScreeningRequest,
3044
+ base_url,
3045
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}/screenings",
3046
+ request
3047
+ )
3048
+ headers = Utils.get_headers(request)
3049
+ headers = T.cast(headers, T::Hash[String, String])
3050
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
3051
+ headers["content-type"] = req_content_type
3052
+ raise StandardError, "request body is required" if data.nil? && form.nil?
3053
+
3054
+ if form && !form.empty?
3055
+ body = Utils.encode_form(form)
3056
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
3057
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
3058
+ else
3059
+ body = data
3060
+ end
3061
+
3062
+ headers["Accept"] = "application/json"
3063
+ headers["user-agent"] = @sdk_configuration.user_agent
3064
+ retries ||= @sdk_configuration.retry_config
3065
+ retries ||= Utils::RetryConfig.new(
3066
+ backoff: Utils::BackoffStrategy.new(
3067
+ exponent: 2.0,
3068
+ initial_interval: 500,
3069
+ max_elapsed_time: 30_000,
3070
+ max_interval: 8000
3071
+ ),
3072
+ retry_connection_errors: true,
3073
+ strategy: "backoff"
3074
+ )
3075
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
3076
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
3077
+
3078
+ security = @sdk_configuration.security_source&.call
3079
+
3080
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
3081
+ timeout ||= @sdk_configuration.timeout
3082
+
3083
+ connection = @sdk_configuration.client.dup
3084
+ connection.use(Utils::RetryMiddleware, retry_options)
3085
+
3086
+ hook_ctx = SDKHooks::HookContext.new(
3087
+ config: @sdk_configuration,
3088
+ base_url: base_url,
3089
+ oauth2_scopes: nil,
3090
+ operation_id: "startScreening",
3091
+ security_source: @sdk_configuration.security_source
3092
+ )
3093
+
3094
+ error = T.let(nil, T.nilable(StandardError))
3095
+ http_response = T.let(nil, T.nilable(Faraday::Response))
3096
+
3097
+ begin
3098
+ http_response = T.must(connection).post(url) do |req|
3099
+ req.body = body
3100
+ req.headers.merge!(headers)
3101
+ req.options.timeout = timeout unless timeout.nil?
3102
+ Utils.configure_request_security(req, security)
3103
+ http_headers&.each do |key, value|
3104
+ req.headers[key.to_s] = value
3105
+ end
3106
+
3107
+ @sdk_configuration.hooks.before_request(
3108
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
3109
+ hook_ctx: hook_ctx
3110
+ ),
3111
+ request: req
3112
+ )
3113
+ end
3114
+
3115
+ rescue StandardError => e
3116
+ error = e
3117
+ ensure
3118
+ if http_response.nil? || Utils.error_status?(http_response.status)
3119
+ http_response = @sdk_configuration.hooks.after_error(
3120
+ error: error,
3121
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
3122
+ hook_ctx: hook_ctx
3123
+ ),
3124
+ response: http_response
3125
+ )
3126
+ else
3127
+ http_response = @sdk_configuration.hooks.after_success(
3128
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3129
+ hook_ctx: hook_ctx
3130
+ ),
3131
+ response: http_response
3132
+ )
3133
+ end
3134
+
3135
+ if http_response.nil?
3136
+ raise error if !error.nil?
3137
+ raise "no response"
3138
+ end
3139
+ end
3140
+
3141
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
3142
+ if Utils.match_status_code(http_response.status, ["202"])
3143
+ if Utils.match_content_type(content_type, "application/json")
3144
+ @sdk_configuration.hooks.after_success(
3145
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3146
+ hook_ctx: hook_ctx
3147
+ ),
3148
+ response: http_response
3149
+ )
3150
+ response_data = http_response.env.response_body
3151
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Screening)
3152
+ result = obj
3153
+ response = Models::Operations::StartScreeningResponse.new(
3154
+ result: result,
3155
+ headers: http_response.headers
3156
+ )
3157
+
3158
+ return response
3159
+ else
3160
+ raise(
3161
+ ::NoResponse::Models::Errors::APIStatusError.new(
3162
+ status_code: http_response.status,
3163
+ body: http_response.env.response_body,
3164
+ raw_response: http_response
3165
+ ),
3166
+ "Unknown content type received"
3167
+ )
3168
+ end
3169
+ elsif Utils.match_status_code(http_response.status, ["400"])
3170
+ if Utils.match_content_type(content_type, "application/problem+json")
3171
+ @sdk_configuration.hooks.after_success(
3172
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3173
+ hook_ctx: hook_ctx
3174
+ ),
3175
+ response: http_response
3176
+ )
3177
+ response_data = http_response.env.response_body
3178
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
3179
+ raise obj
3180
+ else
3181
+ raise(
3182
+ ::NoResponse::Models::Errors::APIStatusError.new(
3183
+ status_code: http_response.status,
3184
+ body: http_response.env.response_body,
3185
+ raw_response: http_response
3186
+ ),
3187
+ "Unknown content type received"
3188
+ )
3189
+ end
3190
+ elsif Utils.match_status_code(http_response.status, ["401"])
3191
+ if Utils.match_content_type(content_type, "application/problem+json")
3192
+ @sdk_configuration.hooks.after_success(
3193
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3194
+ hook_ctx: hook_ctx
3195
+ ),
3196
+ response: http_response
3197
+ )
3198
+ response_data = http_response.env.response_body
3199
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
3200
+ raise obj
3201
+ else
3202
+ raise(
3203
+ ::NoResponse::Models::Errors::APIStatusError.new(
3204
+ status_code: http_response.status,
3205
+ body: http_response.env.response_body,
3206
+ raw_response: http_response
3207
+ ),
3208
+ "Unknown content type received"
3209
+ )
3210
+ end
3211
+ elsif Utils.match_status_code(http_response.status, ["403"])
3212
+ if Utils.match_content_type(content_type, "application/problem+json")
3213
+ @sdk_configuration.hooks.after_success(
3214
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3215
+ hook_ctx: hook_ctx
3216
+ ),
3217
+ response: http_response
3218
+ )
3219
+ response_data = http_response.env.response_body
3220
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
3221
+ raise obj
3222
+ else
3223
+ raise(
3224
+ ::NoResponse::Models::Errors::APIStatusError.new(
3225
+ status_code: http_response.status,
3226
+ body: http_response.env.response_body,
3227
+ raw_response: http_response
3228
+ ),
3229
+ "Unknown content type received"
3230
+ )
3231
+ end
3232
+ elsif Utils.match_status_code(http_response.status, ["404"])
3233
+ if Utils.match_content_type(content_type, "application/problem+json")
3234
+ @sdk_configuration.hooks.after_success(
3235
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3236
+ hook_ctx: hook_ctx
3237
+ ),
3238
+ response: http_response
3239
+ )
3240
+ response_data = http_response.env.response_body
3241
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
3242
+ raise obj
3243
+ else
3244
+ raise(
3245
+ ::NoResponse::Models::Errors::APIStatusError.new(
3246
+ status_code: http_response.status,
3247
+ body: http_response.env.response_body,
3248
+ raw_response: http_response
3249
+ ),
3250
+ "Unknown content type received"
3251
+ )
3252
+ end
3253
+ elsif Utils.match_status_code(http_response.status, ["409"])
3254
+ if Utils.match_content_type(content_type, "application/problem+json")
3255
+ @sdk_configuration.hooks.after_success(
3256
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3257
+ hook_ctx: hook_ctx
3258
+ ),
3259
+ response: http_response
3260
+ )
3261
+ response_data = http_response.env.response_body
3262
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
3263
+ raise obj
3264
+ else
3265
+ raise(
3266
+ ::NoResponse::Models::Errors::APIStatusError.new(
3267
+ status_code: http_response.status,
3268
+ body: http_response.env.response_body,
3269
+ raw_response: http_response
3270
+ ),
3271
+ "Unknown content type received"
3272
+ )
3273
+ end
3274
+ elsif Utils.match_status_code(http_response.status, ["429"])
3275
+ if Utils.match_content_type(content_type, "application/problem+json")
3276
+ @sdk_configuration.hooks.after_success(
3277
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3278
+ hook_ctx: hook_ctx
3279
+ ),
3280
+ response: http_response
3281
+ )
3282
+ response_data = http_response.env.response_body
3283
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
3284
+ raise obj
3285
+ else
3286
+ raise(
3287
+ ::NoResponse::Models::Errors::APIStatusError.new(
3288
+ status_code: http_response.status,
3289
+ body: http_response.env.response_body,
3290
+ raw_response: http_response
3291
+ ),
3292
+ "Unknown content type received"
3293
+ )
3294
+ end
3295
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
3296
+ raise(
3297
+ ::NoResponse::Models::Errors::APIStatusError.new(
3298
+ status_code: http_response.status,
3299
+ body: http_response.env.response_body,
3300
+ raw_response: http_response
3301
+ ),
3302
+ "API error occurred"
3303
+ )
3304
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
3305
+ raise(
3306
+ ::NoResponse::Models::Errors::APIStatusError.new(
3307
+ status_code: http_response.status,
3308
+ body: http_response.env.response_body,
3309
+ raw_response: http_response
3310
+ ),
3311
+ "API error occurred"
3312
+ )
3313
+ else
3314
+ raise(
3315
+ ::NoResponse::Models::Errors::APIStatusError.new(
3316
+ status_code: http_response.status,
3317
+ body: http_response.env.response_body,
3318
+ raw_response: http_response
3319
+ ),
3320
+ "Unknown status code received"
3321
+ )
3322
+
3323
+ end
3324
+ end
3325
+
3326
+ sig {
3327
+ params(
3328
+ workspace_id: ::String,
3329
+ environment: Models::Shared::KeyEnvironment,
3330
+ event_id: ::String,
3331
+ screening_id: ::String,
3332
+ retries: T.nilable(Utils::RetryConfig),
3333
+ timeout_ms: T.nilable(Integer),
3334
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
3335
+ )
3336
+ .returns(Models::Operations::GetScreeningResponse)
3337
+ }
3338
+ def get_screening(
3339
+ workspace_id:,
3340
+ environment:,
3341
+ event_id:,
3342
+ screening_id:,
3343
+ retries: nil,
3344
+ timeout_ms: nil,
3345
+ http_headers: nil
3346
+ )
3347
+ # get_screening - Read a screening.
3348
+ # Read a screening's status and progress.
3349
+ request = Models::Operations::GetScreeningRequest.new(
3350
+ workspace_id: workspace_id,
3351
+ environment: environment,
3352
+ event_id: event_id,
3353
+ screening_id: screening_id
3354
+ )
3355
+ url, params = @sdk_configuration.get_server_details
3356
+ base_url = Utils.template_url(url, params)
3357
+ url = Utils.generate_url(
3358
+ Models::Operations::GetScreeningRequest,
3359
+ base_url,
3360
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}/screenings/{screening_id}",
3361
+ request
3362
+ )
3363
+ headers = {}
3364
+ headers = T.cast(headers, T::Hash[String, String])
3365
+ headers["Accept"] = "application/json"
3366
+ headers["user-agent"] = @sdk_configuration.user_agent
3367
+ retries ||= @sdk_configuration.retry_config
3368
+ retries ||= Utils::RetryConfig.new(
3369
+ backoff: Utils::BackoffStrategy.new(
3370
+ exponent: 2.0,
3371
+ initial_interval: 500,
3372
+ max_elapsed_time: 30_000,
3373
+ max_interval: 8000
3374
+ ),
3375
+ retry_connection_errors: true,
3376
+ strategy: "backoff"
3377
+ )
3378
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
3379
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
3380
+
3381
+ security = @sdk_configuration.security_source&.call
3382
+
3383
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
3384
+ timeout ||= @sdk_configuration.timeout
3385
+
3386
+ connection = @sdk_configuration.client.dup
3387
+ connection.use(Utils::RetryMiddleware, retry_options)
3388
+
3389
+ hook_ctx = SDKHooks::HookContext.new(
3390
+ config: @sdk_configuration,
3391
+ base_url: base_url,
3392
+ oauth2_scopes: nil,
3393
+ operation_id: "getScreening",
3394
+ security_source: @sdk_configuration.security_source
3395
+ )
3396
+
3397
+ error = T.let(nil, T.nilable(StandardError))
3398
+ http_response = T.let(nil, T.nilable(Faraday::Response))
3399
+
3400
+ begin
3401
+ http_response = T.must(connection).get(url) do |req|
3402
+ req.headers.merge!(headers)
3403
+ req.options.timeout = timeout unless timeout.nil?
3404
+ Utils.configure_request_security(req, security)
3405
+ http_headers&.each do |key, value|
3406
+ req.headers[key.to_s] = value
3407
+ end
3408
+
3409
+ @sdk_configuration.hooks.before_request(
3410
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
3411
+ hook_ctx: hook_ctx
3412
+ ),
3413
+ request: req
3414
+ )
3415
+ end
3416
+
3417
+ rescue StandardError => e
3418
+ error = e
3419
+ ensure
3420
+ if http_response.nil? || Utils.error_status?(http_response.status)
3421
+ http_response = @sdk_configuration.hooks.after_error(
3422
+ error: error,
3423
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
3424
+ hook_ctx: hook_ctx
3425
+ ),
3426
+ response: http_response
3427
+ )
3428
+ else
3429
+ http_response = @sdk_configuration.hooks.after_success(
3430
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3431
+ hook_ctx: hook_ctx
3432
+ ),
3433
+ response: http_response
3434
+ )
3435
+ end
3436
+
3437
+ if http_response.nil?
3438
+ raise error if !error.nil?
3439
+ raise "no response"
3440
+ end
3441
+ end
3442
+
3443
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
3444
+ if Utils.match_status_code(http_response.status, ["200"])
3445
+ if Utils.match_content_type(content_type, "application/json")
3446
+ @sdk_configuration.hooks.after_success(
3447
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3448
+ hook_ctx: hook_ctx
3449
+ ),
3450
+ response: http_response
3451
+ )
3452
+ response_data = http_response.env.response_body
3453
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Screening)
3454
+ result = obj
3455
+ response = Models::Operations::GetScreeningResponse.new(
3456
+ result: result,
3457
+ headers: http_response.headers
3458
+ )
3459
+
3460
+ return response
3461
+ else
3462
+ raise(
3463
+ ::NoResponse::Models::Errors::APIStatusError.new(
3464
+ status_code: http_response.status,
3465
+ body: http_response.env.response_body,
3466
+ raw_response: http_response
3467
+ ),
3468
+ "Unknown content type received"
3469
+ )
3470
+ end
3471
+ elsif Utils.match_status_code(http_response.status, ["400"])
3472
+ if Utils.match_content_type(content_type, "application/problem+json")
3473
+ @sdk_configuration.hooks.after_success(
3474
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3475
+ hook_ctx: hook_ctx
3476
+ ),
3477
+ response: http_response
3478
+ )
3479
+ response_data = http_response.env.response_body
3480
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
3481
+ raise obj
3482
+ else
3483
+ raise(
3484
+ ::NoResponse::Models::Errors::APIStatusError.new(
3485
+ status_code: http_response.status,
3486
+ body: http_response.env.response_body,
3487
+ raw_response: http_response
3488
+ ),
3489
+ "Unknown content type received"
3490
+ )
3491
+ end
3492
+ elsif Utils.match_status_code(http_response.status, ["401"])
3493
+ if Utils.match_content_type(content_type, "application/problem+json")
3494
+ @sdk_configuration.hooks.after_success(
3495
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3496
+ hook_ctx: hook_ctx
3497
+ ),
3498
+ response: http_response
3499
+ )
3500
+ response_data = http_response.env.response_body
3501
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
3502
+ raise obj
3503
+ else
3504
+ raise(
3505
+ ::NoResponse::Models::Errors::APIStatusError.new(
3506
+ status_code: http_response.status,
3507
+ body: http_response.env.response_body,
3508
+ raw_response: http_response
3509
+ ),
3510
+ "Unknown content type received"
3511
+ )
3512
+ end
3513
+ elsif Utils.match_status_code(http_response.status, ["403"])
3514
+ if Utils.match_content_type(content_type, "application/problem+json")
3515
+ @sdk_configuration.hooks.after_success(
3516
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3517
+ hook_ctx: hook_ctx
3518
+ ),
3519
+ response: http_response
3520
+ )
3521
+ response_data = http_response.env.response_body
3522
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
3523
+ raise obj
3524
+ else
3525
+ raise(
3526
+ ::NoResponse::Models::Errors::APIStatusError.new(
3527
+ status_code: http_response.status,
3528
+ body: http_response.env.response_body,
3529
+ raw_response: http_response
3530
+ ),
3531
+ "Unknown content type received"
3532
+ )
3533
+ end
3534
+ elsif Utils.match_status_code(http_response.status, ["404"])
3535
+ if Utils.match_content_type(content_type, "application/problem+json")
3536
+ @sdk_configuration.hooks.after_success(
3537
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3538
+ hook_ctx: hook_ctx
3539
+ ),
3540
+ response: http_response
3541
+ )
3542
+ response_data = http_response.env.response_body
3543
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
3544
+ raise obj
3545
+ else
3546
+ raise(
3547
+ ::NoResponse::Models::Errors::APIStatusError.new(
3548
+ status_code: http_response.status,
3549
+ body: http_response.env.response_body,
3550
+ raw_response: http_response
3551
+ ),
3552
+ "Unknown content type received"
3553
+ )
3554
+ end
3555
+ elsif Utils.match_status_code(http_response.status, ["409"])
3556
+ if Utils.match_content_type(content_type, "application/problem+json")
3557
+ @sdk_configuration.hooks.after_success(
3558
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3559
+ hook_ctx: hook_ctx
3560
+ ),
3561
+ response: http_response
3562
+ )
3563
+ response_data = http_response.env.response_body
3564
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
3565
+ raise obj
3566
+ else
3567
+ raise(
3568
+ ::NoResponse::Models::Errors::APIStatusError.new(
3569
+ status_code: http_response.status,
3570
+ body: http_response.env.response_body,
3571
+ raw_response: http_response
3572
+ ),
3573
+ "Unknown content type received"
3574
+ )
3575
+ end
3576
+ elsif Utils.match_status_code(http_response.status, ["429"])
3577
+ if Utils.match_content_type(content_type, "application/problem+json")
3578
+ @sdk_configuration.hooks.after_success(
3579
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3580
+ hook_ctx: hook_ctx
3581
+ ),
3582
+ response: http_response
3583
+ )
3584
+ response_data = http_response.env.response_body
3585
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
3586
+ raise obj
3587
+ else
3588
+ raise(
3589
+ ::NoResponse::Models::Errors::APIStatusError.new(
3590
+ status_code: http_response.status,
3591
+ body: http_response.env.response_body,
3592
+ raw_response: http_response
3593
+ ),
3594
+ "Unknown content type received"
3595
+ )
3596
+ end
3597
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
3598
+ raise(
3599
+ ::NoResponse::Models::Errors::APIStatusError.new(
3600
+ status_code: http_response.status,
3601
+ body: http_response.env.response_body,
3602
+ raw_response: http_response
3603
+ ),
3604
+ "API error occurred"
3605
+ )
3606
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
3607
+ raise(
3608
+ ::NoResponse::Models::Errors::APIStatusError.new(
3609
+ status_code: http_response.status,
3610
+ body: http_response.env.response_body,
3611
+ raw_response: http_response
3612
+ ),
3613
+ "API error occurred"
3614
+ )
3615
+ else
3616
+ raise(
3617
+ ::NoResponse::Models::Errors::APIStatusError.new(
3618
+ status_code: http_response.status,
3619
+ body: http_response.env.response_body,
3620
+ raw_response: http_response
3621
+ ),
3622
+ "Unknown status code received"
3623
+ )
3624
+
3625
+ end
3626
+ end
3627
+
3628
+ sig {
3629
+ params(
3630
+ body: Models::Shared::ScreeningCancelRequest,
3631
+ workspace_id: ::String,
3632
+ environment: Models::Shared::KeyEnvironment,
3633
+ event_id: ::String,
3634
+ screening_id: ::String,
3635
+ retries: T.nilable(Utils::RetryConfig),
3636
+ timeout_ms: T.nilable(Integer),
3637
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
3638
+ )
3639
+ .returns(Models::Operations::CancelScreeningResponse)
3640
+ }
3641
+ def cancel_screening(
3642
+ body:,
3643
+ workspace_id:,
3644
+ environment:,
3645
+ event_id:,
3646
+ screening_id:,
3647
+ retries: nil,
3648
+ timeout_ms: nil,
3649
+ http_headers: nil
3650
+ )
3651
+ # cancel_screening - Cancel a screening.
3652
+ # Stop a queued or running screening. Attendees already screened keep their results.
3653
+ request = Models::Operations::CancelScreeningRequest.new(
3654
+ workspace_id: workspace_id,
3655
+ environment: environment,
3656
+ event_id: event_id,
3657
+ screening_id: screening_id,
3658
+ body: body
3659
+ )
3660
+ url, params = @sdk_configuration.get_server_details
3661
+ base_url = Utils.template_url(url, params)
3662
+ url = Utils.generate_url(
3663
+ Models::Operations::CancelScreeningRequest,
3664
+ base_url,
3665
+ "/v1/workspaces/{workspace_id}/events/{environment}/{event_id}/screenings/{screening_id}/cancel",
3666
+ request
3667
+ )
3668
+ headers = {}
3669
+ headers = T.cast(headers, T::Hash[String, String])
3670
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
3671
+ headers["content-type"] = req_content_type
3672
+ raise StandardError, "request body is required" if data.nil? && form.nil?
3673
+
3674
+ if form && !form.empty?
3675
+ body = Utils.encode_form(form)
3676
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
3677
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
3678
+ else
3679
+ body = data
3680
+ end
3681
+
3682
+ headers["Accept"] = "application/json"
3683
+ headers["user-agent"] = @sdk_configuration.user_agent
3684
+ retries ||= @sdk_configuration.retry_config
3685
+ retries ||= Utils::RetryConfig.new(
3686
+ backoff: Utils::BackoffStrategy.new(
3687
+ exponent: 2.0,
3688
+ initial_interval: 500,
3689
+ max_elapsed_time: 30_000,
3690
+ max_interval: 8000
3691
+ ),
3692
+ retry_connection_errors: true,
3693
+ strategy: "backoff"
3694
+ )
3695
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
3696
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
3697
+
3698
+ security = @sdk_configuration.security_source&.call
3699
+
3700
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
3701
+ timeout ||= @sdk_configuration.timeout
3702
+
3703
+ connection = @sdk_configuration.client.dup
3704
+ connection.use(Utils::RetryMiddleware, retry_options)
3705
+
3706
+ hook_ctx = SDKHooks::HookContext.new(
3707
+ config: @sdk_configuration,
3708
+ base_url: base_url,
3709
+ oauth2_scopes: nil,
3710
+ operation_id: "cancelScreening",
3711
+ security_source: @sdk_configuration.security_source
3712
+ )
3713
+
3714
+ error = T.let(nil, T.nilable(StandardError))
3715
+ http_response = T.let(nil, T.nilable(Faraday::Response))
3716
+
3717
+ begin
3718
+ http_response = T.must(connection).post(url) do |req|
3719
+ req.body = body
3720
+ req.headers.merge!(headers)
3721
+ req.options.timeout = timeout unless timeout.nil?
3722
+ Utils.configure_request_security(req, security)
3723
+ http_headers&.each do |key, value|
3724
+ req.headers[key.to_s] = value
3725
+ end
3726
+
3727
+ @sdk_configuration.hooks.before_request(
3728
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
3729
+ hook_ctx: hook_ctx
3730
+ ),
3731
+ request: req
3732
+ )
3733
+ end
3734
+
3735
+ rescue StandardError => e
3736
+ error = e
3737
+ ensure
3738
+ if http_response.nil? || Utils.error_status?(http_response.status)
3739
+ http_response = @sdk_configuration.hooks.after_error(
3740
+ error: error,
3741
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
3742
+ hook_ctx: hook_ctx
3743
+ ),
3744
+ response: http_response
3745
+ )
3746
+ else
3747
+ http_response = @sdk_configuration.hooks.after_success(
3748
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3749
+ hook_ctx: hook_ctx
3750
+ ),
3751
+ response: http_response
3752
+ )
3753
+ end
3754
+
3755
+ if http_response.nil?
3756
+ raise error if !error.nil?
3757
+ raise "no response"
3758
+ end
3759
+ end
3760
+
3761
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
3762
+ if Utils.match_status_code(http_response.status, ["200"])
3763
+ if Utils.match_content_type(content_type, "application/json")
3764
+ @sdk_configuration.hooks.after_success(
3765
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3766
+ hook_ctx: hook_ctx
3767
+ ),
3768
+ response: http_response
3769
+ )
3770
+ response_data = http_response.env.response_body
3771
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Screening)
3772
+ result = obj
3773
+ response = Models::Operations::CancelScreeningResponse.new(
3774
+ result: result,
3775
+ headers: http_response.headers
3776
+ )
3777
+
3778
+ return response
3779
+ else
3780
+ raise(
3781
+ ::NoResponse::Models::Errors::APIStatusError.new(
3782
+ status_code: http_response.status,
3783
+ body: http_response.env.response_body,
3784
+ raw_response: http_response
3785
+ ),
3786
+ "Unknown content type received"
3787
+ )
3788
+ end
3789
+ elsif Utils.match_status_code(http_response.status, ["400"])
3790
+ if Utils.match_content_type(content_type, "application/problem+json")
3791
+ @sdk_configuration.hooks.after_success(
3792
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3793
+ hook_ctx: hook_ctx
3794
+ ),
3795
+ response: http_response
3796
+ )
3797
+ response_data = http_response.env.response_body
3798
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
3799
+ raise obj
3800
+ else
3801
+ raise(
3802
+ ::NoResponse::Models::Errors::APIStatusError.new(
3803
+ status_code: http_response.status,
3804
+ body: http_response.env.response_body,
3805
+ raw_response: http_response
3806
+ ),
3807
+ "Unknown content type received"
3808
+ )
3809
+ end
3810
+ elsif Utils.match_status_code(http_response.status, ["401"])
3811
+ if Utils.match_content_type(content_type, "application/problem+json")
3812
+ @sdk_configuration.hooks.after_success(
3813
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3814
+ hook_ctx: hook_ctx
3815
+ ),
3816
+ response: http_response
3817
+ )
3818
+ response_data = http_response.env.response_body
3819
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
3820
+ raise obj
3821
+ else
3822
+ raise(
3823
+ ::NoResponse::Models::Errors::APIStatusError.new(
3824
+ status_code: http_response.status,
3825
+ body: http_response.env.response_body,
3826
+ raw_response: http_response
3827
+ ),
3828
+ "Unknown content type received"
3829
+ )
3830
+ end
3831
+ elsif Utils.match_status_code(http_response.status, ["403"])
3832
+ if Utils.match_content_type(content_type, "application/problem+json")
3833
+ @sdk_configuration.hooks.after_success(
3834
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3835
+ hook_ctx: hook_ctx
3836
+ ),
3837
+ response: http_response
3838
+ )
3839
+ response_data = http_response.env.response_body
3840
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
3841
+ raise obj
3842
+ else
3843
+ raise(
3844
+ ::NoResponse::Models::Errors::APIStatusError.new(
3845
+ status_code: http_response.status,
3846
+ body: http_response.env.response_body,
3847
+ raw_response: http_response
3848
+ ),
3849
+ "Unknown content type received"
3850
+ )
3851
+ end
3852
+ elsif Utils.match_status_code(http_response.status, ["404"])
3853
+ if Utils.match_content_type(content_type, "application/problem+json")
3854
+ @sdk_configuration.hooks.after_success(
3855
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3856
+ hook_ctx: hook_ctx
3857
+ ),
3858
+ response: http_response
3859
+ )
3860
+ response_data = http_response.env.response_body
3861
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
3862
+ raise obj
3863
+ else
3864
+ raise(
3865
+ ::NoResponse::Models::Errors::APIStatusError.new(
3866
+ status_code: http_response.status,
3867
+ body: http_response.env.response_body,
3868
+ raw_response: http_response
3869
+ ),
3870
+ "Unknown content type received"
3871
+ )
3872
+ end
3873
+ elsif Utils.match_status_code(http_response.status, ["409"])
3874
+ if Utils.match_content_type(content_type, "application/problem+json")
3875
+ @sdk_configuration.hooks.after_success(
3876
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3877
+ hook_ctx: hook_ctx
3878
+ ),
3879
+ response: http_response
3880
+ )
3881
+ response_data = http_response.env.response_body
3882
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
3883
+ raise obj
3884
+ else
3885
+ raise(
3886
+ ::NoResponse::Models::Errors::APIStatusError.new(
3887
+ status_code: http_response.status,
3888
+ body: http_response.env.response_body,
3889
+ raw_response: http_response
3890
+ ),
3891
+ "Unknown content type received"
3892
+ )
3893
+ end
3894
+ elsif Utils.match_status_code(http_response.status, ["429"])
3895
+ if Utils.match_content_type(content_type, "application/problem+json")
3896
+ @sdk_configuration.hooks.after_success(
3897
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3898
+ hook_ctx: hook_ctx
3899
+ ),
3900
+ response: http_response
3901
+ )
3902
+ response_data = http_response.env.response_body
3903
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
3904
+ raise obj
3905
+ else
3906
+ raise(
3907
+ ::NoResponse::Models::Errors::APIStatusError.new(
3908
+ status_code: http_response.status,
3909
+ body: http_response.env.response_body,
3910
+ raw_response: http_response
3911
+ ),
3912
+ "Unknown content type received"
3913
+ )
3914
+ end
3915
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
3916
+ raise(
3917
+ ::NoResponse::Models::Errors::APIStatusError.new(
3918
+ status_code: http_response.status,
3919
+ body: http_response.env.response_body,
3920
+ raw_response: http_response
3921
+ ),
3922
+ "API error occurred"
3923
+ )
3924
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
3925
+ raise(
3926
+ ::NoResponse::Models::Errors::APIStatusError.new(
3927
+ status_code: http_response.status,
3928
+ body: http_response.env.response_body,
3929
+ raw_response: http_response
3930
+ ),
3931
+ "API error occurred"
3932
+ )
3933
+ else
3934
+ raise(
3935
+ ::NoResponse::Models::Errors::APIStatusError.new(
3936
+ status_code: http_response.status,
3937
+ body: http_response.env.response_body,
3938
+ raw_response: http_response
3939
+ ),
3940
+ "Unknown status code received"
3941
+ )
3942
+
3943
+ end
3944
+ end
3945
+ end
3946
+ end