-
Notifications
You must be signed in to change notification settings - Fork 0
/
openapi.yml
347 lines (339 loc) · 9.9 KB
/
openapi.yml
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
openapi: 3.0.1
info:
title: Prepaid Card API
description: |
This is a development exercise for building a prepaid card service written in Go.
The service has RESTful API and does not use any authentication mechanism. It is a fictional and the model is
intentionally simplified.
The service combines functionality to meet requirements of three actors:
- **bank**: this is the entity controlling the service and only authorised personell must have access to these endpoints;
- **user**: this is the cardholder;
- **merchant**: this is a merchant, which accepts card payments via the service.
version: unknown
servers:
-
url: "{protocol}://{host}:{port}/api"
variables:
protocol:
enum:
- http
- https
default: http
host:
default: localhost
port:
default: "8080"
components:
responses:
404:
title: Resource Not Found
description: The requested resource cannot be found.
$ref: "#/components/responses/404"
content:
application/problem+json:
schema:
$ref: "#/components/schemas/error404"
schemas:
authorizationRequest:
title: Authorization Request
type: object
properties:
uuid:
type: string
format: uuid
cardUUID:
type: string
format: uuid
merchantUUID:
type: string
format: uuid
blockedAmount:
type: string
format: uint64
capturedAmount:
type: string
format: uint64
refundedAmount:
type: string
format: uint64
history:
type: array
items:
$ref: "#/components/schemas/authorizationRequestSnapshot"
example:
uuid: DC41D7A5-2D28-4DB9-9122-72FE708D4934
cardUUID: 228A37D0-3DA2-4E9E-AA61-11EFD39E0382
merchantUUID: 1EA91C35-3D61-472D-8080-CE5544DF3C4A
blockedAmount: "2099"
capturedAmount: "0"
refundedAmount: "0"
history:
- uuid: 584D99EC-8160-42B1-87BC-62476CC2045D
blockedAmount: "2099"
capturedAmount: "0"
refundedAmount: "0"
createdAt: "2018-01-20T16:28:43+00:00"
authorizationRequestSnapshot:
title: Authorization Request Snapshot
type: object
properties:
uuid:
type: string
format: uuid
blockedAmount:
type: string
format: uint64
capturedAmount:
type: string
format: uint64
refundedAmount:
type: string
format: uint64
createdAt:
type: string
format: dateTime ISO8601
example:
uuid: 584D99EC-8160-42B1-87BC-62476CC2045D
blockedAmount: "2099"
capturedAmount: "1000"
refundedAmount: "0"
createdAt: "2018-01-20T16:28:43+00:00"
card:
title: Card
type: object
properties:
uuid:
type: string
format: uuid
availableBalance:
type: string
format: uint64
blockedBalance:
type: string
format: uint64
example:
uuid: 68022AD3-7A94-452E-AC9C-A64F14EE5CD1
availableBalance: "0"
blockedBalance: "0"
error:
title: Error
$ref: "#/components/schemas/error"
type: object
description: Problem Details Object. See [RFC7807](https://tools.ietf.org/html/rfc7807#section-3.1).
properties:
type:
type: string
required: false
default: about:blank
title:
type: string
status:
type: integer
detail:
type: string
required: false
instance:
type: string
required: false
example:
type: /doc/error/validation
title: Validation Error
status: 422
invalidParameters:
- name: amount
reason: must be unsigned integer
error404:
title: Error Not Found
$ref: "#/components/schemas/error404"
type: object
description: Problem Details Object. See [RFC7807](https://tools.ietf.org/html/rfc7807#section-4.2).
properties:
type:
type: string
title:
type: string
status:
type: integer
detail:
type: string
required: false
instance:
type: string
required: false
example:
type: about:blank
title: Not Found
status: 404
instance: /card/87656343-74BF-443D-B5F8-C683FD31CFE0
paths:
/card:
post:
summary: Registers a new card
description: |
Registers a new card.
**Actor:** bank
responses:
201:
description: A card is successfully registered and the card details are returned.
content:
application/json:
schema:
$ref: "#/components/schemas/card"
/card/{uuid}:
get:
summary: Returns card details
description: |
Returns the details of card with UUID `{uuid}`.
**Actors**: bank, user
parameters:
- name: uuid
in: path
description: The card UUID.
required: true
schema:
type: string
responses:
200:
description: The card with the requested UUID is found and it's details returned.
content:
application/json:
schema:
$ref: "#/components/schemas/card"
404:
$ref: "#/components/responses/404"
/card/{uuid}/load:
post:
summary: Loads money onto card
description: |
Adds `amount` pence (GBp) to the balance of card with UUID `{uuid}` and returns the transaction UUID.
**Actors**: bank, user
requestBody:
content:
application/json:
schema:
type: object
properties:
amount:
type: string
format: uint64
example:
amount: "1950"
responses:
201:
description: Loads the card and returns the transaction reference.
content:
application/json:
schema:
type: object
properties:
uuid:
type: string
format: uuid
example:
uuid: 373A8AF3-2712-46F3-B7E0-A23FD74E4270
404:
$ref: "#/components/responses/404"
422:
description: The request cannot be processed due to an error.
content:
application/json:
schema:
$ref: "#/components/schemas/error"
/authorization-request:
post:
summary: Creates authorizaton request
description: |
Creates authorizaton request from merchant with UUID `merchantUUID` to block `amount` pence (BPp) from card with UUID `cardUuid`.
**Actor**: merchant
requestBody:
content:
application/json:
schema:
type: object
properties:
merchantUUID:
type: string
format: uuid
cardUUID:
type: string
format: uuid
amount:
type: string
format: uint64
example:
merchantUUID: 1EA91C35-3D61-472D-8080-CE5544DF3C4A
cardUUID: 228A37D0-3DA2-4E9E-AA61-11EFD39E0382
amount: "2099"
responses:
201:
description: The request is authorized and the authorization request details are returned.
content:
application/json:
schema:
$ref: "#/components/schemas/authorizationRequest"
422:
description: The request cannot be processed due to an error.
content:
application/json:
schema:
$ref: "#/components/schemas/error"
/authorization-request/{uuid}/reverse:
post:
summary: Reverses authorizaton request
description: |
Reverses authorizaton request with `uuid`.
**Actor**: merchant
requestBody:
content:
application/json:
schema:
type: object
properties:
amount:
type: string
format: uint64
example:
amount: "1099"
responses:
201:
description: The request is authorized and the authorization request details are returned.
content:
application/json:
schema:
$ref: "#/components/schemas/authorizationRequest"
422:
description: The request cannot be processed due to an error.
content:
application/json:
schema:
$ref: "#/components/schemas/error"
/authorization-request/{uuid}/capture:
post:
summary: Captures transaction
description: |
Captures transaction for authorizaton request with `uuid`.
**Actor**: merchant
requestBody:
content:
application/json:
schema:
type: object
properties:
amount:
type: string
format: uint64
example:
amount: "1099"
responses:
201:
description: The request is authorized and the authorization request details are returned.
content:
application/json:
schema:
$ref: "#/components/schemas/authorizationRequest"
422:
description: The request cannot be processed due to an error.
content:
application/json:
schema:
$ref: "#/components/schemas/error"