forked from sngular/scs-multiapi-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-rest.yaml
More file actions
591 lines (591 loc) · 16.4 KB
/
Copy pathapi-rest.yaml
File metadata and controls
591 lines (591 loc) · 16.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
openapi: 3.0.0
info:
title: Operation Authorization Service
description: |
This service provides the set of operations needed to make a decision on whether a certain operation should be financed.
It will rely on a number of providers, but initially we will only be using Allianz Trade (AZT).
contact:
name: BNPL Support Team
email: payments.m3a.1@gmail.com
version: 0.1.0
servers:
- url: http://localhost:8087
description: Localhost
tags:
- name: Company
description: Gather info about a company
- name: Insurance
description: Run insurance operations
paths:
/v1/company/{companyId}/info:
get:
tags:
- Company
summary: Retrieve info from a company
description: |
Gather info about a company of a certain country, provided its VAT code, countryCode and database identifier.
operationId: getCompanyInfo
parameters:
- name: countryCode
in: query
description: Country code according to ISO 3166
required: true
schema:
type: string
- name: vatCode
in: query
description: The unique VAT code that identifies the company
required: true
schema:
type: string
- name: companyId
in: path
description: The company database identifier
required: true
schema:
type: integer
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Company'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/v1/company/{companyId}/creditLimit:
post:
tags:
- Company
summary: Compute the credit limits for a company
description: Gather info about the credit limits that certain providers allow for a specific company.
operationId: getCompanyCreditLimit
parameters:
- name: companyId
in: path
description: Company database identifier
required: true
schema:
type: integer
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CreditLimit'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/v1/insurance:
post:
tags:
- Insurance
summary: Request a quote to insure an invoice
description: Request a quote for the insurance of an invoice from a number of insurance providers
operationId: obtainInsuranceQuote
requestBody:
$ref: '#/components/requestBodies/QuoteRequest'
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/QuoteResponse'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/v1/insurance/update/{quoteId}:
put:
tags:
- Insurance
summary: Update the invoice number and invoice date for a certain quote
description:
Normally, at the time of sale, there is not an invoice number as the invoice has not yet been issued.
Therefore, we need to update the invoice number and date for a certain quote before activating it.
operationId: updateInvoiceNumberAndDateForInsurance
parameters:
- name: quoteId
in: path
required: true
schema:
type: integer
requestBody:
$ref: '#/components/requestBodies/UpdateQuote'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/QuoteUpdateResponse'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/v1/insurance/activate/{quoteId}:
post:
tags:
- Insurance
summary: Activate a quote to insure an invoice
description: We activate a policy that has already the correct invoice number and date, for an
accepted sale (for which we have the dispatch info and invoice on file)
operationId: activate
parameters:
- name: quoteId
in: path
required: true
schema:
type: integer
requestBody:
$ref: '#/components/requestBodies/ActivatePolicy'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/PolicyActivation'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/v1/insurance/settle/{policyId}:
post:
tags:
- Insurance
summary: Settle a policy that was previously activated
description: Once the debtor has paid for the insurance, we settle it using this endpoint.
operationId: settle
requestBody:
$ref: '#/components/requestBodies/PolicySettlement'
parameters:
- name: policyIdInProvider
in: path
description: ID of the policy for the specific insurance provider
required: true
schema:
type: string
example: 1
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PolicySettlement'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/v1/insurance/claim/{policyId}:
post:
tags:
- Insurance
summary: Claim a policy that was unpaid
description: If the policy was unpaid, we make a claim to the insurance company.
operationId: claim
parameters:
- name: operationId
in: query
description: ID of the operation in our own records, for reconciliation purposes
required: true
style: form
explode: true
schema:
type: integer
example: 12345678
- name: provider
in: query
description: Name of the insurance provider
required: false
style: form
explode: true
schema:
type: string
example: AZT
- name: policyId
in: path
description: ID of the policy for the specific insurance provider
required: true
schema:
type: string
example: 1
- name: claimDate
in: query
description: Date that we start the claim
required: true
style: form
explode: true
schema:
type: string
format: datetime
example: 2023-11-06T14:00:00Z
requestBody:
$ref: '#/components/requestBodies/ClaimRequest'
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PolicySettlement'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
ErrorResponse:
type: object
properties:
status:
type: string
description: Error status
message:
type: string
description: Error message
Company:
type: object
properties:
name:
type: string
example: Sngular
isActive:
type: boolean
example: true
isInsurable:
type: boolean
example: true
fiscalAddress:
$ref: '#/components/schemas/Address'
Address:
type: object
properties:
street:
type: string
example: Calle Sor Joaquina
number:
type: integer
example: 6
postcode:
type: integer
example: 15002
city:
type: string
example: A Coruña
country:
type: string
example: ES
Contact:
type: object
required:
- lastName
- officePhoneNumber
- phoneNumber
- email
properties:
firstName:
type: string
example: John
lastName:
type: integer
officePhoneNumber:
type: integer
example: 34600111222
phoneNumber:
type: integer
example: 34600111222
email:
type: string
example: john@doe.com
CreditLimit:
type: object
properties:
isFundable:
type: boolean
example: true
insuredCreditLimit:
$ref: '#/components/schemas/InsuredCreditObject'
InsuredCreditObject:
type: object
properties:
providerName:
type: string
example: AZT
creditLimitInCents:
type: integer
example: 1000000
creditAvailableInCents:
type: integer
example: 800000
QuoteRequest:
type: object
properties:
totalAmountInCents:
type: integer
format: int64
example: 10000
currency:
type: string
example: EUR
saleDate:
type: string
description:
Is the date the sale is made.
Initially, we assume the date of invoice will be the date of sale.
format: datetime
example: 2023-10-31T14:00:00Z
paymentDueDate:
type: string
description:
Is the date the invoice must be paid. As of now, 60 days from saleDate.
format: datetime
example: 2023-12-30T14:00:00Z
debtorId:
type: integer
example: 1
merchantId:
type: integer
example: 2
QuoteResponse:
type: object
properties:
isInsurable:
type: boolean
example: true
quoteId:
type: string
example: 1
description: Quote adapter database identifier
estimatedCostInCents:
type: integer
example: 242
currency:
type: string
example: EUR
activateBeforeDate:
type: string
format: datetime
example: 2023-11-06T14:00:00Z
claimBeforeDate:
type: string
format: datetime
example: 2024-03-10T14:00:00Z
QuoteUpdateResponse:
type: object
properties:
isInsurable:
type: boolean
example: true
estimatedCostInCents:
type: integer
example: 242
activateBeforeDate:
type: string
format: datetime
example: 2023-11-06T14:00:00Z
claimBeforeDate:
type: string
format: datetime
example: 2024-03-10T14:00:00Z
PolicyActivation:
type: object
properties:
isActive:
type: boolean
example: true
insuranceProvider:
type: string
example: AZT
policyId:
type: string
example: 1
description: Policy identifier in adapter database
netCostInCents:
type: integer
example: 200
totalCostInCents:
type: integer
example: 242
currency:
type: string
example: EUR
claimBeforeDate:
type: string
format: datetime
example: 2024-03-10T14:00:00Z
coveredAmountInCents:
type: integer
example: 10000
PolicySettlement:
type: object
properties:
provider:
type: string
example: AZT
settlementDate:
type: string
format: datetime
example: 2023-11-06T14:00:00Z
PolicyClaim:
type: object
properties:
claimKind:
type: string
example: Dispute
claimDocument:
$ref: '#/components/schemas/Document'
invoiceDocument:
$ref: '#/components/schemas/Document'
proofOfDeliveryDocument:
$ref: '#/components/schemas/Document'
debtorContactDetails:
$ref: '#/components/schemas/Contact'
merchantContactDetails:
$ref: '#/components/schemas/Contact'
Document:
type: object
properties:
document:
type: string
format: binary
example: invoice01234.pdf
attachments:
type: array
items:
type: string
format: binary
description:
type: string
example: Invoice for the sale 01234
UpdateQuote:
type: object
required:
- invoiceNumber
- invoiceDate
properties:
provider:
type: string
example: AZT
invoiceNumber:
type: string
description: Invoice number
example: INV/2023/00234
invoiceDate:
type: string
format: datetime
example: 2024-03-10T14:00:00Z
ActivatePolicy:
type: object
properties:
provider:
type: string
example: AZT
requestBodies:
PolicySettlement:
description: Data needed to settle a policy
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PolicySettlement'
ActivatePolicy:
description: Data needed to activate a policy
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/ActivatePolicy'
UpdateQuote:
description: Data needed to update the invoice number and date for a certain quote
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateQuote'
QuoteRequest:
description: Data needed to obtain a quote
content:
application/json:
schema:
$ref: '#/components/schemas/QuoteRequest'
required: true
ClaimRequest:
description: Data needed to make a claim
content:
application/json:
schema:
$ref: '#/components/schemas/PolicyClaim'
required: true