-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapiary.apib
499 lines (334 loc) · 12.1 KB
/
apiary.apib
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
FORMAT: 1A
HOST: https://ticketchain-backend.herokuapp.com/api/v1
# TicketChain MVP v.1
TicketChain is an application that's making ticket market decentralized.
## Backend server address
**https://ticketchain-backend.herokuapp.com/api/v1**
## API currently lacks these features
1) Authentication
2) Async methods
3) Pagination
## Basic Info [/api/v1/info]
### Get Basic Info [GET /api/v1/info]
Returns basic info for the project that can be used to inform service clients.
+ Response 201 (application/json)
+ Body
{
"eth_is_enabled": true,
"eth_node": "http://ethnode.chain.cloud:8545",
"eth_main_address": "0x0605bf0970025A6DD604f5fE481Cc307E9d5450e",
"eth_main_address_link": "https://kovan.etherscan.io/address/0x0605bf0970025A6DD604f5fE481Cc307E9d5450e",
"eth_main_account": "0xb9af8aa42c97f5a1f73c6e1a683c4bf6353b83e7",
"eth_main_account_link": "https://kovan.etherscan.io/address/0xb9af8aa42c97f5a1f73c6e1a683c4bf6353b83e7",
"eth_balance_wei": "123112"
}
## Organizers [/organizers]
### Get all Organizers [GET /organizers]
Returns array of all organizers INN's.
+ Response 201 (application/json)
+ Body
[
123456789012
]
## Batches [/organizers/{INN}/batches]
### Create new Batch [POST /organizers/{INN}/batches]
Create multiple new blank tickets to reserve them. This method is blocking. It can take long time to deploy all tickets to Ethereum network.
Will create Organizer if it doesn't exist. Returns batch ID.
Postcondition:
1) Organizer has been created
2) Blank tickets have been created and deployed (can take some time)
3) Batch has been created.
+ Parameters
+ INN - Organizer's INN
+ Request (application/json)
{
start_series: "АА",
start_number: "123456",
end_series: "ББ",
end_number: "123456"
}
+ Response 201 (application/json)
+ Body
{
batch_id: 12313434,
count: 16
}
### Create new Batch with ticket count only [POST /organizers/{INN}/batches_with_count]
Create multiple new blank tickets to reserve them. This method is blocking. It can take long time to deploy all tickets to Ethereum network.
Will create Organizer if it doesn't exist. Returns batch ID.
Postcondition:
1) Organizer has been created
2) Blank tickets have been created and deployed (can take some time)
3) Batch has been created.
+ Parameters
+ INN - Organizer's INN
+ Request (application/json)
{
start_series: "АА",
start_number: "123456",
count: 12
}
+ Response 201 (application/json)
+ Body
{
batch_id: 12313434,
count: 12
}
### Get batch [GET /organizers/{INN}/batches/{BATCH_ID}]
Will return all tickets that have been created in a single batch.
+ Parameters
+ INN - Organizer's INN
+ BATCH_ID - Current batch ID you want to read
+ Response 201 (application/json)
+ Body
[
12313123112311,
12314144576546,
89089403889898,
]
+ Response 409 (application/json)
If ticket with this serial number already exists.
+ Body
{
collision: "АБ123456"
}
### Calculate Ticket count for batch [POST /organizers/{INN}/calculate_ticket_count]
Before you create all tickets in batch -> calculate count.
+ Parameters
+ INN - Organizer's INN
+ Request (application/json)
{
start_series: "АА",
start_number: "123456",
end_series: "ББ",
end_number: "123456"
}
+ Response 201 (application/json)
+ Body
{
"count": 16
}
## Tickets [/organizers/{INN}/tickets]
### Get Ticket Count [GET /organizers/{INN}/ticket_count{?state}]
Get the count of all tickets for that organizer.
+ Parameters
+ INN - Organizer's INN
+ state (string, optional) - State of tickets to search ("created", "sold", "cancelled")
+ Response 201 (application/json)
+ Body
{
count: 134034
}
### Get all Ticket issued by Organizer [GET /organizers/{INN}/tickets{?page}{?limit}{?state}]
Get all issued by particular company tickets. Returns array of ticket IDs.
This method supports paging. Please use ?page=1&limit=100 format. Default limit is 50.
+ Parameters
+ page (number, optional) - Current page for paging
+ Default: 1
+ limit (number, optional) - Limit for paging
+ Default: 50
+ state (string, optional) - State of tickets to search ("created","sold", "cancelled")
+ Response 201 (application/json)
+ Body
[
12313123112311,
12314144576546,
89089403889898,
]
### Create a New Ticket [POST /organizers/{INN}/tickets]
Create new blank ticket to reserve it. This method is blocking.
Will create Organizer if it doesn't exist.
**Postcondition**:
1) Blank ticket has been created and deployed to network
2) Organizer has been created.
+ Parameters
+ INN - Organizer's INN
+ Request (application/json)
{
"serial_number": "АБ123456"
}
+ Response 201 (application/json)
+ Body
{
"id": "123123123123123123123123123123",
// 2 letters + 6 numbers
"serial_number": "АБ123456"
}
+ Response 409 (application/json)
If ticket with this serial number already exists.
+ Body
{
"collision": "АБ123456"
}
### Get a Ticket [GET /organizers/{INN}/tickets/{ID_OR_SERIAL_NUMBER}]
Get a ticket by ID or SERIAL_NUMBER.
This method is blocking.
+ Parameters
+ INN - Organizer's INN
+ ID_OR_SERIAL_NUMBER - Ticket's ID or Serial Number
+ Response 201 (application/json)
+ Body
{
"serial_number": "AB123456",
"id": "4782397489173954872839457",
// 0 - created
// 1 - sold
// 2 - cancelled
"state": "sold",
"created_date":"1486740328",
// optional fields:
"price_kop": 120,
"is_paper_ticket": false,
"issuer": "TicketChain",
"issuer_inn": "111111111145",
"issuer_ogrn": "7811111111123",
"issuer_ogrnip": "221111111112345",
"issuer_address": "",
"event_title": "",
"event_place_title": "",
"event_date": "1486740328",
"event_place_address": "",
"row": "17",
"seat": "9",
"ticket_category": "1",
"seller": "TicketLand company",
"seller_inn": "1234567812",
"seller_ogrn": "1234567812123",
"seller_ogrnip": "123456781212345",
"seller_address": "",
"buyer_name": "Alexey Key",
"buying_date":"1486740328",
"cancelled_date": "",
// ticket contract is at this address
"contract_address: "0xe7962464741983eB4620DD0e2Aa6d572145bab0E"
}
### Edit a Ticket [PUT /organizers/{INN}/tickets/{ID}]
Update/edit ticket data.
**Postcondition**:
1) Ticket data has been updated.
This method is blocking.
+ Parameters
+ INN - Organizer's INN
+ ID - Ticket's ID
+ Request (application/json)
{
// all these fields are optional:
"price_kop": 120,
"is_paper_ticket": false,
"issuer": "TicketChain",
"issuer_inn": "111111111145",
"issuer_ogrn": "7811111111123",
"issuer_ogrnip": "221111111112345",
"issuer_address": "",
"event_title": "",
"event_place_title": "",
"event_date": "1486740328",
"event_place_address": "",
"row": "17",
"seat": "9",
"ticket_category": "1",
"seller": "TicketLand company",
"seller_inn": "1234567812",
"seller_ogrn": "1234567812123",
"seller_ogrnip": "123456781212345",
"seller_address": "",
"buyer_name": "Alexey Key",
"buying_date": "1486740328",
"cancelled_date": ""
}
+ Response 201
+ Response 400
### Sell a Ticket [POST /organizers/{INN}/tickets/{ID}/sell]
Sell ticket.
**Postcondition**:
1) Ticket has changed state from 'created' to 'sold'.
+ Parameters
+ INN - Organizer's INN
+ ID - Ticket's ID
+ Request (application/json)
{
// all these fields are optional:
"price_kop": 120,
"is_paper_ticket": false,
"issuer": "TicketChain",
"issuer_inn": "111111111145",
"issuer_ogrn": "7811111111123",
"issuer_ogrnip": "221111111112345",
"issuer_address": "",
"event_title": "",
"event_place_title": "",
"event_date": "1486740328",
"event_place_address": "",
"row": "17",
"seat": "9",
"ticket_category": "1",
"seller": "TicketLand company",
"seller_inn": "1234567812",
"seller_ogrn": "1234567812123",
"seller_ogrnip": "123456781212345",
"seller_address": "",
"buyer_name": "Alexey Key",
"buying_date":"1486740328",
"cancelled_date": ""
}
+ Response 201
+ Response 400
### Cancel a Ticket [POST /organizers/{INN}/tickets/{ID}/cancel]
Cancel ticket.
**Postcondition**:
1) Ticket has changed state to 'cancelled'.
+ Parameters
+ INN - Organizer's INN
+ ID - Ticket's ID
+ Response 201
+ Response 400
## CSV File Processing Jobs [/organizers/{INN}/cvs_jobs]
### Create new CVS File Processing Job [POST /organizers/{INN}/csv_jobs]
Add new CSV file processing job. Will process it asynchronously.
CSV file format: https://docs.google.com/spreadsheets/d/1g3YEMokRK8HAEyPKNjAZQWnt2xvBH4jMsJhHmBtWTYU/edit?usp=sharing
**Postcondition**:
1) New job added to queue.
+ Parameters
+ INN - Organizer's INN
+ Request (application/json)
{
}
+ Response 201 (application/json)
+ Body
{
"job_id": 12313434
}
### Get CSV File Processing Job info [GET /organizers/{INN}/csv_jobs/{JOB_ID}]
Will return status of the job.
+ Parameters
+ INN - Organizer's INN
+ JOB_ID - Current job ID you want to read
+ Response 201 (application/json)
+ Body
{
// 0 - created
// 1 - processing
// 2 - ready
//
status: "ready",
// if status is 'ready' -> get tickets through the /batch API method
batch_id: 1234124124,
file_name: "one.csv",
processed_items: 15000,
// each item is serial number
collisions: [],
// each item a line index (CSV file)
errors: []
}
## Ticket Stats [/organizers/{INN}/stats]
### Get all Ticket Stats for Organizer [GET /organizers/{INN}/stats]
+ Parameters
+ INN - Organizer's INN
+ Response 201 (application/json)
+ Body
{
totalTickets: 12,
blank: 5,
sold: 6,
cancelled: 1
}