Marketplace » History » Version 23
Ryan Supawarapong, 02/20/2026 08:10 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 | 17 | Ryan Supawarapong | |
| 73 | 13 | Ryan Supawarapong | ### Request Body |
| 74 | 17 | Ryan Supawarapong | |
| 75 | 3 | Ryan Supawarapong | | Key | Type | Example | Required | |
| 76 | 23 | Ryan Supawarapong | |---|---|---|---| |
| 77 | | - | - | - | no body | |
||
| 78 | 1 | Ryan Supawarapong | |
| 79 | 23 | Ryan Supawarapong | ### Success Response (200) |
| 80 | 1 | Ryan Supawarapong | |
| 81 | | JSON Path | Type | Example | Required | |
||
| 82 | |---|---|---|---| |
||
| 83 | 23 | Ryan Supawarapong | | status | string | `"success"` | yes | |
| 84 | | data | object | `{"transactions":[...]}` | yes | |
||
| 85 | | data.transactions | array<object> | `[{"id":1,"transactionId":"TXN_123",...}]` | yes | |
||
| 86 | | data.transactions[].id | number | `1` | no (`omitempty`) | |
||
| 87 | | data.transactions[].buyerCode | string | `"90000004"` | no | |
||
| 88 | | data.transactions[].buyerName | string | `"First Last"` | no | |
||
| 89 | | data.transactions[].sellerCode | string | `"90000005"` | no | |
||
| 90 | | data.transactions[].sellerName | string | `"First Last"` | no | |
||
| 91 | | data.transactions[].assetCode | string | `"ASSET001"` | no | |
||
| 92 | | data.transactions[].assetName | string | `"Asset 001"` | no | |
||
| 93 | | data.transactions[].assetShortName | string | `"A001"` | no | |
||
| 94 | | data.transactions[].quantity | number | `10` | no | |
||
| 95 | | data.transactions[].price | number | `10.01` | no | |
||
| 96 | | data.transactions[].totalAmount | number | `100.10` | no | |
||
| 97 | | data.transactions[].transactionId | string | `"TXN_123"` | no | |
||
| 98 | | data.transactions[].currency | string | `"THB"` | no | |
||
| 99 | | data.transactions[].status | number | `1` | no | |
||
| 100 | | data.transactions[].paymentId | string | `"PMT_123"` | no | |
||
| 101 | | data.transactions[].createdAt | string(datetime) | `"2026-02-20T10:00:00Z"` | no | |
||
| 102 | | data.transactions[].deletedAt | object/null | `null` | no | |
||
| 103 | 1 | Ryan Supawarapong | |
| 104 | 23 | Ryan Supawarapong | ### Error Response |
| 105 | 1 | Ryan Supawarapong | |
| 106 | 23 | Ryan Supawarapong | #### Internal Server Error (500) |
| 107 | | JSON Path | Type | Example | Required | |
||
| 108 | |---|---|---|---| |
||
| 109 | | status | string | `"error"` | yes | |
||
| 110 | | message | string | `"database error"` | yes | |
||
| 111 | |||
| 112 | --- |
||
| 113 | |||
| 114 | ## 2) Posted |
||
| 115 | |||
| 116 | | Type | Value | |
||
| 117 | 1 | Ryan Supawarapong | |---|---| |
| 118 | 23 | Ryan Supawarapong | | API Path | `/api/v1/customer/marketplace/posted` | |
| 119 | | Request Type | `POST` | |
||
| 120 | | Content-Type | `application/json` | |
||
| 121 | 1 | Ryan Supawarapong | |
| 122 | 23 | Ryan Supawarapong | ### Request Body |
| 123 | |||
| 124 | > `customerCode` and `customerName` are injected from auth token by handler, not required from client body. |
||
| 125 | |||
| 126 | | Key | Type | Example | Required | |
||
| 127 | |---|---|---|---| |
||
| 128 | | assetCode | string | `"ASSET001"` | yes | |
||
| 129 | | assetName | string | `"Asset 001"` | yes | |
||
| 130 | | assetShortName | string | `"A001"` | yes | |
||
| 131 | | quantity | number | `5` | yes (`> 0`) | |
||
| 132 | | price | number | `10` | yes (`> 0`) | |
||
| 133 | | totalAmount | number | `50` | yes (`> 0`) | |
||
| 134 | |||
| 135 | ### Success Response (200) |
||
| 136 | |||
| 137 | | JSON Path | Type | Example | Required | |
||
| 138 | |---|---|---|---| |
||
| 139 | | status | string | `"success"` | yes | |
||
| 140 | |||
| 141 | ### Error Response |
||
| 142 | |||
| 143 | #### Bad Request (400) - bind error |
||
| 144 | | JSON Path | Type | Example | Required | |
||
| 145 | |---|---|---|---| |
||
| 146 | | status | string | `"failed"` | yes | |
||
| 147 | | data | object | `{"error":"...bind error..."}` | yes | |
||
| 148 | | data.error | string | `"code=400, message=..."` | yes | |
||
| 149 | |||
| 150 | #### Unauthorized (401) - token missing/invalid |
||
| 151 | | JSON Path | Type | Example | Required | |
||
| 152 | |---|---|---|---| |
||
| 153 | | status | string | `"failed"` | yes | |
||
| 154 | | data | object | `{"error":"invalid token claims"}` | yes | |
||
| 155 | | data.error | string | `"invalid token claims"` | yes | |
||
| 156 | |||
| 157 | #### Bad Request (400) - validation error |
||
| 158 | | JSON Path | Type | Example | Required | |
||
| 159 | |---|---|---|---| |
||
| 160 | | status | string | `"failed"` | yes | |
||
| 161 | | data | object | `{"errors":{"assetCode":"required"}}` | yes | |
||
| 162 | | data.errors | object | `{"field":"message"}` | yes | |
||
| 163 | |||
| 164 | #### Internal Server Error (500) |
||
| 165 | | JSON Path | Type | Example | Required | |
||
| 166 | |---|---|---|---| |
||
| 167 | | status | string | `"error"` | yes | |
||
| 168 | | message | string | `"internal error"` | yes | |
||
| 169 | |||
| 170 | --- |
||
| 171 | |||
| 172 | ## 3) Interested |
||
| 173 | |||
| 174 | | Type | Value | |
||
| 175 | |---|---| |
||
| 176 | | API Path | `/api/v1/customer/marketplace/interested` | |
||
| 177 | | Request Type | `POST` | |
||
| 178 | | Content-Type | `application/json` | |
||
| 179 | |||
| 180 | ### Request Body |
||
| 181 | |||
| 182 | |||
| 183 | | Key | Type | Example | Required | |
||
| 184 | |---|---|---|---| |
||
| 185 | | assetCode | string | `"ASSET001"` | yes | |
||
| 186 | | assetName | string | `"Asset 001"` | yes | |
||
| 187 | | assetShortName | string | `"A001"` | yes | |
||
| 188 | | quantity | number | `5` | yes (`> 0`) | |
||
| 189 | | price | number | `10` | yes (`> 0`) | |
||
| 190 | | totalAmount | number | `50` | yes (`> 0`) | |
||
| 191 | | transactionId | string | `"TXN_123"` | yes | |
||
| 192 | |||
| 193 | ### Success Response (200) |
||
| 194 | |||
| 195 | | JSON Path | Type | Example | Required | |
||
| 196 | |---|---|---|---| |
||
| 197 | | status | string | `"success"` | yes | |
||
| 198 | | data | object | `{"emailID":"emailID"}` | yes | |
||
| 199 | | data.emailID | string | `"emailID"` | yes | |
||
| 200 | |||
| 201 | ### Error Response |
||
| 202 | |||
| 203 | #### Bad Request (400) - bind error |
||
| 204 | | JSON Path | Type | Example | Required | |
||
| 205 | |---|---|---|---| |
||
| 206 | | status | string | `"failed"` | yes | |
||
| 207 | | data | object | `{"error":"...bind error..."}` | yes | |
||
| 208 | | data.error | string | `"code=400, message=..."` | yes | |
||
| 209 | |||
| 210 | #### Unauthorized (401) - token missing/invalid |
||
| 211 | | JSON Path | Type | Example | Required | |
||
| 212 | |---|---|---|---| |
||
| 213 | | status | string | `"failed"` | yes | |
||
| 214 | | data | object | `{"error":"invalid token claims"}` | yes | |
||
| 215 | | data.error | string | `"invalid token claims"` | yes | |
||
| 216 | |||
| 217 | #### Bad Request (400) - validation error |
||
| 218 | | JSON Path | Type | Example | Required | |
||
| 219 | |---|---|---|---| |
||
| 220 | | status | string | `"failed"` | yes | |
||
| 221 | | data | object | `{"errors":{"transactionId":"required"}}` | yes | |
||
| 222 | | data.errors | object | `{"field":"message"}` | yes | |
||
| 223 | |||
| 224 | #### Internal Server Error (500) |
||
| 225 | | JSON Path | Type | Example | Required | |
||
| 226 | |---|---|---|---| |
||
| 227 | | status | string | `"error"` | yes | |
||
| 228 | | message | string | `"internal error"` | yes | |