Project

General

Profile

Marketplace » History » Version 24

Ryan Supawarapong, 02/20/2026 08:15 AM

1 1 Ryan Supawarapong
# Marketplace
2
3 13 Ryan Supawarapong
There are the following API:
4
- Get
5
- Sell
6
- Reserve
7
- Update
8
  - Confirm
9
  - Cancel
10 16 karnake ruengchaicharnkij
  - Remove
11 13 Ryan Supawarapong
12 4 Ryan Supawarapong
## Diagram
13 1 Ryan Supawarapong
<img src="market_place.png"><br>
14 16 karnake ruengchaicharnkij
```
15
title Market Place
16 1 Ryan Supawarapong
17 16 karnake ruengchaicharnkij
actor "customer" as c
18
actor "owner" as o
19
actor "admin" as a
20
participant "frontend" as fe
21
participant "admin" as adm
22
participant "backend" as be
23
database "database" as db
24
participant "notification" as n
25
26
o->fe: post sell asset
27
fe->be: verify asset and quantities
28
be<->db: query database
29
be->fe: true/false
30
fe->c: true: dispaly new post
31
c->fe: click "interest" button
32
fe->be: update status and count down 15 minutes
33
be<->db: update database
34
be->fe: true/false
35
fe->c: show status "locked"
36
be->n: update payment notification
37
n->c: email bank account info and payment noti within 15 minutes
38
c->n: click confirm payment
39
c->fe: totp to confirm payment
40
fe->be: update payment
41
fe->fe: update status to "pending payment confirm"
42
be<->db: update database
43
be->n: update payment confirmation
44
n->o: email payment acknowledge confirmation and pay service fees
45
o->n: click confirm service fees
46
o->fe: totp to confirm service fees
47
fe->be: update service fees transaction
48
fe->fe: update status to "pending service fees confirm"
49
be<->db: update database
50
be->n: send service fees notification
51
n->a: get noti for new service fees
52
adm<->be: get new service fees
53
a->adm: verify service fees
54
adm<->be: show service fees
55
a->adm: approved service fees
56
adm->be: update service fees status
57
be<->db: update database
58
be->n: send notification
59
n->o: get noti service fees approved
60
fe->fe: update status to "complete"
61
```
62 1 Ryan Supawarapong
63 17 Ryan Supawarapong
## API route
64 1 Ryan Supawarapong
65 23 Ryan Supawarapong
## 1) Lists
66 8 Ryan Supawarapong
67 23 Ryan Supawarapong
| Type | Value |
68
|---|---|
69
| API Path | `/api/v1/customer/marketplace/lists` |
70 17 Ryan Supawarapong
| Request Type | `GET` |
71 1 Ryan Supawarapong
| Content-Type | `application/json` |
72 24 Ryan Supawarapong
| Authorization | `bearer ...` |
73 17 Ryan Supawarapong
74 13 Ryan Supawarapong
### Request Body
75 17 Ryan Supawarapong
76 3 Ryan Supawarapong
| Key | Type | Example | Required |
77 23 Ryan Supawarapong
|---|---|---|---|
78
| - | - | - | no body |
79 1 Ryan Supawarapong
80 23 Ryan Supawarapong
### Success Response (200)
81 1 Ryan Supawarapong
82
| JSON Path | Type | Example | Required |
83
|---|---|---|---|
84 23 Ryan Supawarapong
| status | string | `"success"` | yes |
85
| data | object | `{"transactions":[...]}` | yes |
86
| data.transactions | array<object> | `[{"id":1,"transactionId":"TXN_123",...}]` | yes |
87
| data.transactions[].id | number | `1` | no (`omitempty`) |
88
| data.transactions[].buyerCode | string | `"90000004"` | no |
89
| data.transactions[].buyerName | string | `"First Last"` | no |
90
| data.transactions[].sellerCode | string | `"90000005"` | no |
91
| data.transactions[].sellerName | string | `"First Last"` | no |
92
| data.transactions[].assetCode | string | `"ASSET001"` | no |
93
| data.transactions[].assetName | string | `"Asset 001"` | no |
94
| data.transactions[].assetShortName | string | `"A001"` | no |
95
| data.transactions[].quantity | number | `10` | no |
96
| data.transactions[].price | number | `10.01` | no |
97
| data.transactions[].totalAmount | number | `100.10` | no |
98
| data.transactions[].transactionId | string | `"TXN_123"` | no |
99
| data.transactions[].currency | string | `"THB"` | no |
100
| data.transactions[].status | number | `1` | no |
101
| data.transactions[].paymentId | string | `"PMT_123"` | no |
102
| data.transactions[].createdAt | string(datetime) | `"2026-02-20T10:00:00Z"` | no |
103
| data.transactions[].deletedAt | object/null | `null` | no |
104 1 Ryan Supawarapong
105 23 Ryan Supawarapong
### Error Response
106 1 Ryan Supawarapong
107 23 Ryan Supawarapong
#### Internal Server Error (500)
108
| JSON Path | Type | Example | Required |
109
|---|---|---|---|
110
| status | string | `"error"` | yes |
111
| message | string | `"database error"` | yes |
112
113
---
114
115
## 2) Posted
116
117
| Type | Value |
118 1 Ryan Supawarapong
|---|---|
119 23 Ryan Supawarapong
| API Path | `/api/v1/customer/marketplace/posted` |
120
| Request Type | `POST` |
121
| Content-Type | `application/json` |
122 24 Ryan Supawarapong
| Authorization | `bearer ...` |
123 1 Ryan Supawarapong
124 23 Ryan Supawarapong
### Request Body
125
126
> `customerCode` and `customerName` are injected from auth token by handler, not required from client body.
127
128
| Key | Type | Example | Required |
129
|---|---|---|---|
130
| assetCode | string | `"ASSET001"` | yes |
131
| assetName | string | `"Asset 001"` | yes |
132
| assetShortName | string | `"A001"` | yes |
133
| quantity | number | `5` | yes (`> 0`) |
134
| price | number | `10` | yes (`> 0`) |
135
| totalAmount | number | `50` | yes (`> 0`) |
136
137
### Success Response (200)
138
139
| JSON Path | Type | Example | Required |
140
|---|---|---|---|
141
| status | string | `"success"` | yes |
142
143
### Error Response
144
145
#### Bad Request (400) - bind error
146
| JSON Path | Type | Example | Required |
147
|---|---|---|---|
148
| status | string | `"failed"` | yes |
149
| data | object | `{"error":"...bind error..."}` | yes |
150
| data.error | string | `"code=400, message=..."` | yes |
151
152
#### Unauthorized (401) - token missing/invalid
153
| JSON Path | Type | Example | Required |
154
|---|---|---|---|
155
| status | string | `"failed"` | yes |
156
| data | object | `{"error":"invalid token claims"}` | yes |
157
| data.error | string | `"invalid token claims"` | yes |
158
159
#### Bad Request (400) - validation error
160
| JSON Path | Type | Example | Required |
161
|---|---|---|---|
162
| status | string | `"failed"` | yes |
163
| data | object | `{"errors":{"assetCode":"required"}}` | yes |
164
| data.errors | object | `{"field":"message"}` | yes |
165
166
#### Internal Server Error (500)
167
| JSON Path | Type | Example | Required |
168
|---|---|---|---|
169
| status | string | `"error"` | yes |
170
| message | string | `"internal error"` | yes |
171
172
---
173
174
## 3) Interested
175
176
| Type | Value |
177
|---|---|
178
| API Path | `/api/v1/customer/marketplace/interested` |
179
| Request Type | `POST` |
180
| Content-Type | `application/json` |
181 24 Ryan Supawarapong
| Authorization | `bearer ...` |
182 23 Ryan Supawarapong
183
### Request Body
184
185
186
| Key | Type | Example | Required |
187
|---|---|---|---|
188
| assetCode | string | `"ASSET001"` | yes |
189
| assetName | string | `"Asset 001"` | yes |
190
| assetShortName | string | `"A001"` | yes |
191
| quantity | number | `5` | yes (`> 0`) |
192
| price | number | `10` | yes (`> 0`) |
193
| totalAmount | number | `50` | yes (`> 0`) |
194
| transactionId | string | `"TXN_123"` | yes |
195
196
### Success Response (200)
197
198
| JSON Path | Type | Example | Required |
199
|---|---|---|---|
200
| status | string | `"success"` | yes |
201
| data | object | `{"emailID":"emailID"}` | yes |
202
| data.emailID | string | `"emailID"` | yes |
203
204
### Error Response
205
206
#### Bad Request (400) - bind error
207
| JSON Path | Type | Example | Required |
208
|---|---|---|---|
209
| status | string | `"failed"` | yes |
210
| data | object | `{"error":"...bind error..."}` | yes |
211
| data.error | string | `"code=400, message=..."` | yes |
212
213
#### Unauthorized (401) - token missing/invalid
214
| JSON Path | Type | Example | Required |
215
|---|---|---|---|
216
| status | string | `"failed"` | yes |
217
| data | object | `{"error":"invalid token claims"}` | yes |
218
| data.error | string | `"invalid token claims"` | yes |
219
220
#### Bad Request (400) - validation error
221
| JSON Path | Type | Example | Required |
222
|---|---|---|---|
223
| status | string | `"failed"` | yes |
224
| data | object | `{"errors":{"transactionId":"required"}}` | yes |
225
| data.errors | object | `{"field":"message"}` | yes |
226
227
#### Internal Server Error (500)
228
| JSON Path | Type | Example | Required |
229
|---|---|---|---|
230
| status | string | `"error"` | yes |
231
| message | string | `"internal error"` | yes |