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