payabli 3.0.6 → 3.0.7

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/.fern/metadata.json +3 -3
  3. data/lib/payabli/case_management/client.rb +662 -0
  4. data/lib/payabli/case_management/types/assign_case_request.rb +15 -0
  5. data/lib/payabli/case_management/types/create_bank_account_change_case_request.rb +31 -0
  6. data/lib/payabli/case_management/types/list_cases_case_management_request.rb +17 -0
  7. data/lib/payabli/case_management/types/list_messages_case_management_request.rb +15 -0
  8. data/lib/payabli/case_management/types/post_case_message_request.rb +13 -0
  9. data/lib/payabli/case_management/types/transition_case_request.rb +17 -0
  10. data/lib/payabli/case_management/types/upload_attachment_case_management_request.rb +11 -0
  11. data/lib/payabli/case_management/types/validate_bank_account_change_request.rb +23 -0
  12. data/lib/payabli/client.rb +6 -1
  13. data/lib/payabli/money_out/client.rb +17 -3
  14. data/lib/payabli/money_out/types/capture_all_out_request.rb +2 -0
  15. data/lib/payabli/money_out/types/capture_out_request.rb +2 -0
  16. data/lib/payabli/money_out/types/request_out_authorize.rb +2 -0
  17. data/lib/payabli/notification/client.rb +2 -2
  18. data/lib/payabli/types/attachment_response.rb +24 -0
  19. data/lib/payabli/types/available_transitions_response.rb +10 -0
  20. data/lib/payabli/types/bank_account_change_parameters.rb +30 -0
  21. data/lib/payabli/types/bank_account_change_parameters_type.rb +11 -0
  22. data/lib/payabli/types/bank_account_services.rb +12 -0
  23. data/lib/payabli/types/bank_review_decision_reason.rb +14 -0
  24. data/lib/payabli/types/bank_verification_metadata.rb +14 -0
  25. data/lib/payabli/types/case_list_response.rb +12 -0
  26. data/lib/payabli/types/case_list_summary.rb +20 -0
  27. data/lib/payabli/types/case_management_bank_account_function.rb +17 -0
  28. data/lib/payabli/types/case_metadata.rb +12 -0
  29. data/lib/payabli/types/case_response.rb +50 -0
  30. data/lib/payabli/types/case_state.rb +22 -0
  31. data/lib/payabli/types/case_trigger.rb +22 -0
  32. data/lib/payabli/types/case_type.rb +11 -0
  33. data/lib/payabli/types/message_page.rb +12 -0
  34. data/lib/payabli/types/money_in_service.rb +17 -0
  35. data/lib/payabli/types/money_out_service.rb +17 -0
  36. data/lib/payabli/types/notification_content.rb +1 -1
  37. data/lib/payabli/types/notification_content_event_type.rb +14 -80
  38. data/lib/payabli/types/notification_standard_request_content_event_type.rb +97 -111
  39. data/lib/payabli/types/org_ref.rb +12 -0
  40. data/lib/payabli/types/paypoint_ref.rb +12 -0
  41. data/lib/payabli/types/posted_message.rb +14 -0
  42. data/lib/payabli/types/pre_creation_validation_result.rb +16 -0
  43. data/lib/payabli/types/review_decision_metadata.rb +12 -0
  44. data/lib/payabli/types/room_message_view.rb +18 -0
  45. data/lib/payabli/types/state_transition_response.rb +26 -0
  46. data/lib/payabli/types/user_ref.rb +12 -0
  47. data/lib/payabli/types/verification_code.rb +14 -0
  48. data/lib/payabli/version.rb +1 -1
  49. data/lib/payabli.rb +36 -0
  50. data/reference.md +1182 -4
  51. data/wiremock/wiremock-mappings.json +418 -1
  52. metadata +38 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4be50a5d248c6bead3079413803be2b8dc5633066dde2d0cf30aeabb022dc22b
4
- data.tar.gz: 0a41703fb012562d9bdc614c4046d32cbe16952bffc4bed7dd94a44cfb97a718
3
+ metadata.gz: c348ce0242faa30e0404200b80d1552188c2a6d953bae3308d44365a45a086e5
4
+ data.tar.gz: 96fd899b2ac2c8bc2ec9193f9ba244ba3b500fd746bd8354a1537f9155887284
5
5
  SHA512:
6
- metadata.gz: cf9edd3022ddf76cb022e634ffb7c90ce56e665ce11bd79ea8649d3d70dc4a01e47ccc2c372e173e9b91e6af0a669006e44b8e35677c6344cea475c141d48556
7
- data.tar.gz: 3a08c3b7d29ae04ec8eadaed4afb2f26aa7d18b940b64c5720d923b9cb2b9d26fc11b629e505bb05dabf5b522ba021045c8c3085e6645bee5f017c1646d35117
6
+ metadata.gz: 8d1832ec5c195aeb5ee8ab8c220a8c02c5dc9886146cfa1c76eca077636e9e83f23c87eb797485734d6b72df6299dec8c93eff9562c645e3098597b731a72081
7
+ data.tar.gz: 4cefd412ad3e15177f5f376e571179c7cbea0ad91ef33b24712a3659262f920eaee66f71150c34b1bcd33c59943ab37a658a5c58307e83d2b3dccc869344f09f
data/.fern/metadata.json CHANGED
@@ -6,10 +6,10 @@
6
6
  "enableWireTests": true,
7
7
  "rubocopVariableNumberStyle": "snake_case"
8
8
  },
9
- "originGitCommit": "bba6b6215757725a8aada77eabcb84166221f24e",
9
+ "originGitCommit": "85dc6dd780991f47e9c2d71ad221647a62bccf93",
10
10
  "originGitCommitIsDirty": true,
11
11
  "invokedBy": "ci",
12
- "requestedVersion": "3.0.6",
12
+ "requestedVersion": "3.0.7",
13
13
  "ciProvider": "github",
14
- "sdkVersion": "3.0.6"
14
+ "sdkVersion": "3.0.7"
15
15
  }
@@ -0,0 +1,662 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Payabli
4
+ module CaseManagement
5
+ class Client
6
+ # @param client [Payabli::Internal::Http::RawClient]
7
+ #
8
+ # @return [void]
9
+ def initialize(client:)
10
+ @client = client
11
+ end
12
+
13
+ # Validates a bank account change for a paypoint without creating a case.
14
+ # Runs the same checks the create endpoint runs, and returns blocking
15
+ # conditions and warnings. Blocking conditions prevent creation; warnings
16
+ # don't.
17
+ #
18
+ # Available to both Platform and Enterprise Partners.
19
+ #
20
+ # @param request_options [Hash]
21
+ # @param params [Payabli::CaseManagement::Types::ValidateBankAccountChangeRequest]
22
+ # @option request_options [String] :base_url
23
+ # @option request_options [Hash{String => Object}] :additional_headers
24
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
25
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
26
+ # @option request_options [Integer] :timeout_in_seconds
27
+ # @option params [Integer] :paypoint_id
28
+ #
29
+ # @example
30
+ # client.case_management.validate_bank_account_change(
31
+ # paypoint_id: 3040,
32
+ # routing_number: "123456789",
33
+ # account_number: "987654321",
34
+ # account_type: "checking",
35
+ # bank_account_holder_type: "business",
36
+ # bank_account_function: "Deposits",
37
+ # services: {
38
+ # money_in: ["Ach"],
39
+ # money_out: ["Ach"]
40
+ # }
41
+ # )
42
+ #
43
+ # @return [Payabli::Types::PreCreationValidationResult]
44
+ def validate_bank_account_change(request_options: {}, **params)
45
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
46
+ request_data = Payabli::CaseManagement::Types::ValidateBankAccountChangeRequest.new(params).to_h
47
+ non_body_param_names = %w[paypointId]
48
+ body = request_data.except(*non_body_param_names)
49
+
50
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
51
+ request = Payabli::Internal::JSON::Request.new(
52
+ base_url: request_options[:base_url],
53
+ method: "POST",
54
+ path: "v2/cases/bank-account/#{URI.encode_uri_component(params[:paypoint_id].to_s)}/validate",
55
+ headers: headers,
56
+ body: body,
57
+ request_options: request_options
58
+ )
59
+ begin
60
+ response = @client.send(request)
61
+ rescue Net::HTTPRequestTimeout
62
+ raise Payabli::Errors::TimeoutError
63
+ end
64
+ code = response.code.to_i
65
+ if code.between?(200, 299)
66
+ Payabli::Types::PreCreationValidationResult.load(response.body)
67
+ else
68
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
69
+ raise error_class.new(response.body, code: code)
70
+ end
71
+ end
72
+
73
+ # Creates a bank-account-change case for a paypoint. The account and
74
+ # routing numbers are validated and tokenized before the case is saved —
75
+ # the raw numbers are never stored or returned. The account holder name is
76
+ # taken from the paypoint's legal name. On success the case is created in
77
+ # `Submitted` and asynchronous verification starts.
78
+ #
79
+ # Available to both Platform and Enterprise Partners.
80
+ #
81
+ # @param request_options [Hash]
82
+ # @param params [Payabli::CaseManagement::Types::CreateBankAccountChangeCaseRequest]
83
+ # @option request_options [String] :base_url
84
+ # @option request_options [Hash{String => Object}] :additional_headers
85
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
86
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
87
+ # @option request_options [Integer] :timeout_in_seconds
88
+ # @option params [Integer] :paypoint_id
89
+ #
90
+ # @example
91
+ # client.case_management.create_bank_account_change(
92
+ # paypoint_id: 3040,
93
+ # nickname: "Main Settlement Account",
94
+ # bank_name: "First National Bank",
95
+ # routing_number: "123456789",
96
+ # account_number: "987654321",
97
+ # account_type: "checking",
98
+ # bank_account_holder_type: "business",
99
+ # bank_account_function: "Deposits",
100
+ # services: {
101
+ # money_in: ["Ach"],
102
+ # money_out: ["Ach"]
103
+ # },
104
+ # default: true
105
+ # )
106
+ #
107
+ # @return [Payabli::Types::CaseResponse]
108
+ def create_bank_account_change(request_options: {}, **params)
109
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
110
+ request_data = Payabli::CaseManagement::Types::CreateBankAccountChangeCaseRequest.new(params).to_h
111
+ non_body_param_names = %w[paypointId]
112
+ body = request_data.except(*non_body_param_names)
113
+
114
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
115
+ request = Payabli::Internal::JSON::Request.new(
116
+ base_url: request_options[:base_url],
117
+ method: "POST",
118
+ path: "v2/cases/bank-account/#{URI.encode_uri_component(params[:paypoint_id].to_s)}",
119
+ headers: headers,
120
+ body: body,
121
+ request_options: request_options
122
+ )
123
+ begin
124
+ response = @client.send(request)
125
+ rescue Net::HTTPRequestTimeout
126
+ raise Payabli::Errors::TimeoutError
127
+ end
128
+ code = response.code.to_i
129
+ if code.between?(200, 299)
130
+ Payabli::Types::CaseResponse.load(response.body)
131
+ else
132
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
133
+ raise error_class.new(response.body, code: code)
134
+ end
135
+ end
136
+
137
+ # Returns a case by its UUID, including its current state, parameters,
138
+ # state history, verification metadata, and attachments.
139
+ #
140
+ # Available to both Platform and Enterprise Partners.
141
+ #
142
+ # @param request_options [Hash]
143
+ # @param params [Hash]
144
+ # @option request_options [String] :base_url
145
+ # @option request_options [Hash{String => Object}] :additional_headers
146
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
147
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
148
+ # @option request_options [Integer] :timeout_in_seconds
149
+ # @option params [String] :uuid
150
+ #
151
+ # @example
152
+ # client.case_management.get_case(uuid: "9c2b7e14-3a5f-4d21-b8e0-1f6a4c9d2e70")
153
+ #
154
+ # @return [Payabli::Types::CaseResponse]
155
+ def get_case(request_options: {}, **params)
156
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
157
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
158
+ request = Payabli::Internal::JSON::Request.new(
159
+ base_url: request_options[:base_url],
160
+ method: "GET",
161
+ path: "v2/cases/#{URI.encode_uri_component(params[:uuid].to_s)}",
162
+ headers: headers,
163
+ request_options: request_options
164
+ )
165
+ begin
166
+ response = @client.send(request)
167
+ rescue Net::HTTPRequestTimeout
168
+ raise Payabli::Errors::TimeoutError
169
+ end
170
+ code = response.code.to_i
171
+ if code.between?(200, 299)
172
+ Payabli::Types::CaseResponse.load(response.body)
173
+ else
174
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
175
+ raise error_class.new(response.body, code: code)
176
+ end
177
+ end
178
+
179
+ # Lists cases for an organization, climbing the platform org hierarchy.
180
+ # Supports pagination and sorting through query parameters, and filtering
181
+ # through repeatable `parameters[field(op)]=value` query parameters (for
182
+ # example `parameters[state(in)]=Assigned|PendingReview`). Filterable
183
+ # fields include `state`, `caseType`, `paypointId`, `createdAt`,
184
+ # `updatedAt`, `scheduleFor`, and `createdBy`.
185
+ #
186
+ # Available to both Platform and Enterprise Partners.
187
+ #
188
+ # @param request_options [Hash]
189
+ # @param params [Hash]
190
+ # @option request_options [String] :base_url
191
+ # @option request_options [Hash{String => Object}] :additional_headers
192
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
193
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
194
+ # @option request_options [Integer] :timeout_in_seconds
195
+ # @option params [Integer] :organization_id
196
+ # @option params [Integer, nil] :from_record
197
+ # @option params [Integer, nil] :limit_record
198
+ # @option params [String, nil] :sort_by
199
+ #
200
+ # @example
201
+ # client.case_management.list_cases(
202
+ # organization_id: 123,
203
+ # from_record: 0,
204
+ # limit_record: 20
205
+ # )
206
+ #
207
+ # @return [Payabli::Types::CaseListResponse]
208
+ def list_cases(request_options: {}, **params)
209
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
210
+ query_params = {}
211
+ query_params["fromRecord"] = params[:from_record] if params.key?(:from_record)
212
+ query_params["limitRecord"] = params[:limit_record] if params.key?(:limit_record)
213
+ query_params["sortBy"] = params[:sort_by] if params.key?(:sort_by)
214
+
215
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
216
+ request = Payabli::Internal::JSON::Request.new(
217
+ base_url: request_options[:base_url],
218
+ method: "GET",
219
+ path: "v2/cases/organization/#{URI.encode_uri_component(params[:organization_id].to_s)}",
220
+ headers: headers,
221
+ query: query_params,
222
+ request_options: request_options
223
+ )
224
+ begin
225
+ response = @client.send(request)
226
+ rescue Net::HTTPRequestTimeout
227
+ raise Payabli::Errors::TimeoutError
228
+ end
229
+ code = response.code.to_i
230
+ if code.between?(200, 299)
231
+ Payabli::Types::CaseListResponse.load(response.body)
232
+ else
233
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
234
+ raise error_class.new(response.body, code: code)
235
+ end
236
+ end
237
+
238
+ # Lists the notes on a case, ordered oldest to newest. Cursor-paginated.
239
+ #
240
+ # Available to both Platform and Enterprise Partners.
241
+ #
242
+ # @param request_options [Hash]
243
+ # @param params [Hash]
244
+ # @option request_options [String] :base_url
245
+ # @option request_options [Hash{String => Object}] :additional_headers
246
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
247
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
248
+ # @option request_options [Integer] :timeout_in_seconds
249
+ # @option params [String] :case_uuid
250
+ # @option params [Integer, nil] :limit
251
+ # @option params [String, nil] :cursor
252
+ #
253
+ # @example
254
+ # client.case_management.list_messages(case_uuid: "9c2b7e14-3a5f-4d21-b8e0-1f6a4c9d2e70")
255
+ #
256
+ # @return [Payabli::Types::MessagePage]
257
+ def list_messages(request_options: {}, **params)
258
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
259
+ query_params = {}
260
+ query_params["limit"] = params[:limit] if params.key?(:limit)
261
+ query_params["cursor"] = params[:cursor] if params.key?(:cursor)
262
+
263
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
264
+ request = Payabli::Internal::JSON::Request.new(
265
+ base_url: request_options[:base_url],
266
+ method: "GET",
267
+ path: "v2/cases/#{URI.encode_uri_component(params[:case_uuid].to_s)}/messages",
268
+ headers: headers,
269
+ query: query_params,
270
+ request_options: request_options
271
+ )
272
+ begin
273
+ response = @client.send(request)
274
+ rescue Net::HTTPRequestTimeout
275
+ raise Payabli::Errors::TimeoutError
276
+ end
277
+ code = response.code.to_i
278
+ if code.between?(200, 299)
279
+ Payabli::Types::MessagePage.load(response.body)
280
+ else
281
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
282
+ raise error_class.new(response.body, code: code)
283
+ end
284
+ end
285
+
286
+ # Adds a note to a case.
287
+ #
288
+ # Available to both Platform and Enterprise Partners.
289
+ #
290
+ # This endpoint is in development and not yet available for API use. To
291
+ # add a note for now, use Case Management in the
292
+ # [Payabli Portal](/guides/pay-ops-portal-bank-account-changes-manage).
293
+ # To read existing notes on a case, use
294
+ # [List case notes](/developers/api-reference/caseManagement/list-case-notes).
295
+ #
296
+ # @param request_options [Hash]
297
+ # @param params [Payabli::CaseManagement::Types::PostCaseMessageRequest]
298
+ # @option request_options [String] :base_url
299
+ # @option request_options [Hash{String => Object}] :additional_headers
300
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
301
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
302
+ # @option request_options [Integer] :timeout_in_seconds
303
+ # @option params [String] :case_uuid
304
+ #
305
+ # @example
306
+ # client.case_management.post_message(
307
+ # case_uuid: "9c2b7e14-3a5f-4d21-b8e0-1f6a4c9d2e70",
308
+ # content: "Reviewed supporting documents; account ownership confirmed."
309
+ # )
310
+ #
311
+ # @return [Payabli::Types::PostedMessage]
312
+ def post_message(request_options: {}, **params)
313
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
314
+ request_data = Payabli::CaseManagement::Types::PostCaseMessageRequest.new(params).to_h
315
+ non_body_param_names = %w[caseUuid]
316
+ body = request_data.except(*non_body_param_names)
317
+
318
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
319
+ request = Payabli::Internal::JSON::Request.new(
320
+ base_url: request_options[:base_url],
321
+ method: "POST",
322
+ path: "v2/cases/#{URI.encode_uri_component(params[:case_uuid].to_s)}/messages",
323
+ headers: headers,
324
+ body: body,
325
+ request_options: request_options
326
+ )
327
+ begin
328
+ response = @client.send(request)
329
+ rescue Net::HTTPRequestTimeout
330
+ raise Payabli::Errors::TimeoutError
331
+ end
332
+ code = response.code.to_i
333
+ if code.between?(200, 299)
334
+ Payabli::Types::PostedMessage.load(response.body)
335
+ else
336
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
337
+ raise error_class.new(response.body, code: code)
338
+ end
339
+ end
340
+
341
+ # Lists the review actions currently available on a case. The list is
342
+ # empty when no user action is available (for example while the case is
343
+ # mid-automation).
344
+ #
345
+ # Available to both Platform and Enterprise Partners, though only
346
+ # Enterprise Partners can fire the returned actions.
347
+ #
348
+ # @param request_options [Hash]
349
+ # @param params [Hash]
350
+ # @option request_options [String] :base_url
351
+ # @option request_options [Hash{String => Object}] :additional_headers
352
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
353
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
354
+ # @option request_options [Integer] :timeout_in_seconds
355
+ # @option params [String] :uuid
356
+ #
357
+ # @example
358
+ # client.case_management.list_transitions(uuid: "9c2b7e14-3a5f-4d21-b8e0-1f6a4c9d2e70")
359
+ #
360
+ # @return [Payabli::Types::AvailableTransitionsResponse]
361
+ def list_transitions(request_options: {}, **params)
362
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
363
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
364
+ request = Payabli::Internal::JSON::Request.new(
365
+ base_url: request_options[:base_url],
366
+ method: "GET",
367
+ path: "v2/cases/#{URI.encode_uri_component(params[:uuid].to_s)}/transitions",
368
+ headers: headers,
369
+ request_options: request_options
370
+ )
371
+ begin
372
+ response = @client.send(request)
373
+ rescue Net::HTTPRequestTimeout
374
+ raise Payabli::Errors::TimeoutError
375
+ end
376
+ code = response.code.to_i
377
+ if code.between?(200, 299)
378
+ Payabli::Types::AvailableTransitionsResponse.load(response.body)
379
+ else
380
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
381
+ raise error_class.new(response.body, code: code)
382
+ end
383
+ end
384
+
385
+ # Fires a review action on a case, such as `Approve`, `Deny`, `Escalate`,
386
+ # or `RequestReview`. Assigning a case uses the dedicated assign endpoint,
387
+ # not this one. Firing an action that isn't valid for the case's current
388
+ # state returns `409`.
389
+ #
390
+ # Available to Enterprise Partners only.
391
+ #
392
+ # @param request_options [Hash]
393
+ # @param params [Payabli::CaseManagement::Types::TransitionCaseRequest]
394
+ # @option request_options [String] :base_url
395
+ # @option request_options [Hash{String => Object}] :additional_headers
396
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
397
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
398
+ # @option request_options [Integer] :timeout_in_seconds
399
+ # @option params [String] :uuid
400
+ #
401
+ # @example
402
+ # client.case_management.transition(
403
+ # uuid: "9c2b7e14-3a5f-4d21-b8e0-1f6a4c9d2e70",
404
+ # trigger: "Approve",
405
+ # reason: "Account ownership confirmed with the merchant by phone."
406
+ # )
407
+ #
408
+ # @return [Payabli::Types::CaseResponse]
409
+ def transition(request_options: {}, **params)
410
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
411
+ request_data = Payabli::CaseManagement::Types::TransitionCaseRequest.new(params).to_h
412
+ non_body_param_names = %w[uuid]
413
+ body = request_data.except(*non_body_param_names)
414
+
415
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
416
+ request = Payabli::Internal::JSON::Request.new(
417
+ base_url: request_options[:base_url],
418
+ method: "POST",
419
+ path: "v2/cases/#{URI.encode_uri_component(params[:uuid].to_s)}/transitions",
420
+ headers: headers,
421
+ body: body,
422
+ request_options: request_options
423
+ )
424
+ begin
425
+ response = @client.send(request)
426
+ rescue Net::HTTPRequestTimeout
427
+ raise Payabli::Errors::TimeoutError
428
+ end
429
+ code = response.code.to_i
430
+ if code.between?(200, 299)
431
+ Payabli::Types::CaseResponse.load(response.body)
432
+ else
433
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
434
+ raise error_class.new(response.body, code: code)
435
+ end
436
+ end
437
+
438
+ # Assigns a case to a reviewer.
439
+ #
440
+ # Available to Enterprise Partners only.
441
+ #
442
+ # @param request_options [Hash]
443
+ # @param params [Payabli::CaseManagement::Types::AssignCaseRequest]
444
+ # @option request_options [String] :base_url
445
+ # @option request_options [Hash{String => Object}] :additional_headers
446
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
447
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
448
+ # @option request_options [Integer] :timeout_in_seconds
449
+ # @option params [String] :uuid
450
+ #
451
+ # @example
452
+ # client.case_management.assign_case(
453
+ # uuid: "9c2b7e14-3a5f-4d21-b8e0-1f6a4c9d2e70",
454
+ # assignee_id: 4238,
455
+ # reason: "Routing to the risk team for review."
456
+ # )
457
+ #
458
+ # @return [Payabli::Types::CaseResponse]
459
+ def assign_case(request_options: {}, **params)
460
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
461
+ request_data = Payabli::CaseManagement::Types::AssignCaseRequest.new(params).to_h
462
+ non_body_param_names = %w[uuid]
463
+ body = request_data.except(*non_body_param_names)
464
+
465
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
466
+ request = Payabli::Internal::JSON::Request.new(
467
+ base_url: request_options[:base_url],
468
+ method: "POST",
469
+ path: "v2/cases/#{URI.encode_uri_component(params[:uuid].to_s)}/assign",
470
+ headers: headers,
471
+ body: body,
472
+ request_options: request_options
473
+ )
474
+ begin
475
+ response = @client.send(request)
476
+ rescue Net::HTTPRequestTimeout
477
+ raise Payabli::Errors::TimeoutError
478
+ end
479
+ code = response.code.to_i
480
+ if code.between?(200, 299)
481
+ Payabli::Types::CaseResponse.load(response.body)
482
+ else
483
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
484
+ raise error_class.new(response.body, code: code)
485
+ end
486
+ end
487
+
488
+ # Lists the files attached to a case.
489
+ #
490
+ # Available to both Platform and Enterprise Partners.
491
+ #
492
+ # @param request_options [Hash]
493
+ # @param params [Hash]
494
+ # @option request_options [String] :base_url
495
+ # @option request_options [Hash{String => Object}] :additional_headers
496
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
497
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
498
+ # @option request_options [Integer] :timeout_in_seconds
499
+ # @option params [String] :case_uuid
500
+ #
501
+ # @example
502
+ # client.case_management.list_attachments(case_uuid: "9c2b7e14-3a5f-4d21-b8e0-1f6a4c9d2e70")
503
+ #
504
+ # @return [Array[Payabli::Types::AttachmentResponse]]
505
+ def list_attachments(request_options: {}, **params)
506
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
507
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
508
+ request = Payabli::Internal::JSON::Request.new(
509
+ base_url: request_options[:base_url],
510
+ method: "GET",
511
+ path: "v2/cases/#{URI.encode_uri_component(params[:case_uuid].to_s)}/attachments",
512
+ headers: headers,
513
+ request_options: request_options
514
+ )
515
+ begin
516
+ response = @client.send(request)
517
+ rescue Net::HTTPRequestTimeout
518
+ raise Payabli::Errors::TimeoutError
519
+ end
520
+ code = response.code.to_i
521
+ return if code.between?(200, 299)
522
+
523
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
524
+ raise error_class.new(response.body, code: code)
525
+ end
526
+
527
+ # Uploads a file to a case as multipart form data. The maximum size is
528
+ # 25 MiB, and the content type must be an allowed type such as PDF, PNG,
529
+ # JPEG, CSV, XLSX, DOCX, or plain text.
530
+ #
531
+ # Available to both Platform and Enterprise Partners.
532
+ #
533
+ # @param request_options [Hash]
534
+ # @param params [void]
535
+ # @option request_options [String] :base_url
536
+ # @option request_options [Hash{String => Object}] :additional_headers
537
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
538
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
539
+ # @option request_options [Integer] :timeout_in_seconds
540
+ # @option params [String] :case_uuid
541
+ #
542
+ # @example
543
+ # client.case_management.upload_attachment(case_uuid: "caseUuid")
544
+ #
545
+ # @return [Payabli::Types::AttachmentResponse]
546
+ def upload_attachment(request_options: {}, **params)
547
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
548
+ body = Internal::Multipart::FormData.new
549
+
550
+ body.add_part(params[:file].to_form_data_part(name: "file")) if params[:file]
551
+
552
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
553
+ request = Payabli::Internal::Multipart::Request.new(
554
+ base_url: request_options[:base_url],
555
+ method: "POST",
556
+ path: "v2/cases/#{URI.encode_uri_component(params[:case_uuid].to_s)}/attachments",
557
+ headers: headers,
558
+ body: body,
559
+ request_options: request_options
560
+ )
561
+ begin
562
+ response = @client.send(request)
563
+ rescue Net::HTTPRequestTimeout
564
+ raise Payabli::Errors::TimeoutError
565
+ end
566
+ code = response.code.to_i
567
+ if code.between?(200, 299)
568
+ Payabli::Types::AttachmentResponse.load(response.body)
569
+ else
570
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
571
+ raise error_class.new(response.body, code: code)
572
+ end
573
+ end
574
+
575
+ # Streams the file content of an attachment.
576
+ #
577
+ # Available to both Platform and Enterprise Partners.
578
+ #
579
+ # @param request_options [Hash]
580
+ # @param params [Hash]
581
+ # @option request_options [String] :base_url
582
+ # @option request_options [Hash{String => Object}] :additional_headers
583
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
584
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
585
+ # @option request_options [Integer] :timeout_in_seconds
586
+ # @option params [String] :case_uuid
587
+ # @option params [String] :attachment_id
588
+ #
589
+ # @example
590
+ # client.case_management.get_attachment(
591
+ # case_uuid: "caseUuid",
592
+ # attachment_id: "attachmentId"
593
+ # )
594
+ #
595
+ # @return [untyped]
596
+ def get_attachment(request_options: {}, **params)
597
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
598
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
599
+ request = Payabli::Internal::JSON::Request.new(
600
+ base_url: request_options[:base_url],
601
+ method: "GET",
602
+ path: "v2/cases/#{URI.encode_uri_component(params[:case_uuid].to_s)}/attachments/#{URI.encode_uri_component(params[:attachment_id].to_s)}",
603
+ headers: headers,
604
+ request_options: request_options
605
+ )
606
+ begin
607
+ response = @client.send(request)
608
+ rescue Net::HTTPRequestTimeout
609
+ raise Payabli::Errors::TimeoutError
610
+ end
611
+ code = response.code.to_i
612
+ return if code.between?(200, 299)
613
+
614
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
615
+ raise error_class.new(response.body, code: code)
616
+ end
617
+
618
+ # Deletes an attachment from a case.
619
+ #
620
+ # Available to both Platform and Enterprise Partners.
621
+ #
622
+ # @param request_options [Hash]
623
+ # @param params [Hash]
624
+ # @option request_options [String] :base_url
625
+ # @option request_options [Hash{String => Object}] :additional_headers
626
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
627
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
628
+ # @option request_options [Integer] :timeout_in_seconds
629
+ # @option params [String] :case_uuid
630
+ # @option params [String] :attachment_id
631
+ #
632
+ # @example
633
+ # client.case_management.delete_attachment(
634
+ # case_uuid: "caseUuid",
635
+ # attachment_id: "attachmentId"
636
+ # )
637
+ #
638
+ # @return [untyped]
639
+ def delete_attachment(request_options: {}, **params)
640
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
641
+ headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }])
642
+ request = Payabli::Internal::JSON::Request.new(
643
+ base_url: request_options[:base_url],
644
+ method: "DELETE",
645
+ path: "v2/cases/#{URI.encode_uri_component(params[:case_uuid].to_s)}/attachments/#{URI.encode_uri_component(params[:attachment_id].to_s)}",
646
+ headers: headers,
647
+ request_options: request_options
648
+ )
649
+ begin
650
+ response = @client.send(request)
651
+ rescue Net::HTTPRequestTimeout
652
+ raise Payabli::Errors::TimeoutError
653
+ end
654
+ code = response.code.to_i
655
+ return if code.between?(200, 299)
656
+
657
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
658
+ raise error_class.new(response.body, code: code)
659
+ end
660
+ end
661
+ end
662
+ end