-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-specification.yml
162 lines (159 loc) · 4.79 KB
/
api-specification.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
openapi: 3.0.0
info:
title: Account Management API
version: 1.0.0
components:
schemas:
Transaction:
type: object
properties:
account_id:
type: string
format: uuid
amount:
type: integer
required:
- account_id
- amount
AccountBalance:
type: object
properties:
balance:
type: integer
required:
- balance
MaxTransactionVolume:
type: object
properties:
maxVolume:
type: integer
accounts:
type: array
items:
type: string
format: uuid
examples:
TransactionWithPositiveAmount:
value:
account_id: '0afd02d3-6c59-46e7-b7bc-893c5e0b7ac2'
amount: 7
TransactionWithNegativeAmount:
value:
account_id: '5ae0ef78-e902-4c40-9f53-8cf910587312'
amount: -4
PositiveAccountBalance:
value:
balance: 10
NegativeAccountBalance:
value:
balance: -7
MaxTransactionVolumeExample:
value:
maxVolume: 4
accounts: [
"44a92331-a533-4dd3-82e3-3ff75219e33b",
"7c9be9e8-a6df-4f43-9a44-38c10ad0de4a"
]
paths:
/ping:
get:
summary: Healhcheck to make sure the service is responsive.
responses:
'200':
description: The service is up and running.
/amount:
post:
summary: Creates a new transaction which updates the current account balance.
parameters:
- in: header
name: Transaction-Id
schema:
type: string
format: uuid
example: 'cf479136-0a5b-42ad-a16c-26d9eda3b4aa'
required: true
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Transaction'
examples:
TransactionWithPositiveAmount:
$ref: '#/components/examples/TransactionWithPositiveAmount'
TransactionWithNegativeAmount:
$ref: '#/components/examples/TransactionWithNegativeAmount'
responses:
'200':
description: Transaction created.
'400':
description: Mandatory body parameters missing or have incorrect type.
'405':
description: Specified HTTP method not allowed.
'415':
description: Specified content type not allowed.
/transaction/{transaction_id}:
get:
summary: Returns the transaction.
parameters:
- name: transaction_id
in: path
required: true
description: Transaction ID.
schema:
type: string
format: uuid
example: '023d2024-24bc-42c9-ab24-689eef6ea0f9'
responses:
'200':
description: Transaction details.
content:
application/json:
schema:
$ref: '#/components/schemas/Transaction'
examples:
TransactionWithPositiveAmount:
$ref: '#/components/examples/TransactionWithPositiveAmount'
TransactionWithNegativeAmount:
$ref: '#/components/examples/TransactionWithNegativeAmount'
'404':
description: Transaction not found
/balance/{account_id}:
get:
summary: Returns the current account balance.
parameters:
- name: account_id
in: path
required: true
description: Account ID.
schema:
type: string
format: uuid
example: '5ba6e1b0-e3e7-483a-919a-a2fc17629a90'
responses:
'200':
description: Account balance.
content:
application/json:
schema:
$ref: '#/components/schemas/AccountBalance'
examples:
PositiveAccountBalance:
$ref: '#/components/examples/PositiveAccountBalance'
NegativeAccountBalance:
$ref: '#/components/examples/NegativeAccountBalance'
'404':
description: Account not found.
/max_transaction_volume:
get:
summary: Returns accounts with the max number of transactions.
responses:
'200':
description: Accounts with the max number of transactions.
content:
application/json:
schema:
$ref: '#/components/schemas/MaxTransactionVolume'
examples:
MaxTransactionVolumeExample:
$ref: '#/components/examples/MaxTransactionVolumeExample'