├── README.md ├── .gitignore ├── LICENSE └── point-of-sale.yaml /README.md: -------------------------------------------------------------------------------- 1 | # point-of-sale -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # If you prefer the allow list template instead of the deny list, see community template: 2 | # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore 3 | # 4 | # Binaries for programs and plugins 5 | *.exe 6 | *.exe~ 7 | *.dll 8 | *.so 9 | *.dylib 10 | 11 | # Code Editor 12 | *.idea 13 | 14 | # Test binary, built with `go test -c` 15 | *.test 16 | 17 | # Output of the go coverage tool, specifically when used with LiteIDE 18 | *.out 19 | 20 | # Dependency directories (remove the comment below to include it) 21 | # vendor/ 22 | 23 | # Go workspace file 24 | go.work 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 EkoEdyPurwanto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /point-of-sale.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Point Of Sale 4 | description: This is API Specification for point of sale 5 | termsOfService: https://example.com/terms-of-service 6 | contact: 7 | name: Echo Edy P 8 | email: mailto:eep@gmail.com 9 | license: 10 | name: MIT 11 | url: https://github.com/EkoEdyPurwanto/point-of-sale/blob/main/LICENSE 12 | x-custom-filed: https://www.buymeacoffee.com/ekoedypurwanto 13 | version: 1.0.0 14 | externalDocs: 15 | description: source code 16 | url: https://github.com/EkoEdyPurwanto/point-of-sale 17 | servers: 18 | - url: 'https://{environment}.localhost:{port}/api/{basePath}' 19 | description: point of sale RESTfulAPi servers 20 | variables: 21 | environment: 22 | description: Server Environment 23 | default: development 24 | enum: 25 | - development 26 | - staging 27 | - production 28 | port: 29 | description: Port Number 30 | default: '1323' 31 | enum: 32 | - '1323' 33 | - '8443' 34 | - '443' 35 | basePath: 36 | description: Base Path 37 | default: v1 38 | components: 39 | securitySchemes: 40 | PointOfSaleAuth: 41 | type: http 42 | scheme: bearer 43 | bearerFormat: JWT 44 | description: JWT authorization 45 | schemas: 46 | userAccount: 47 | type: object 48 | properties: 49 | id: 50 | type: string 51 | username: 52 | type: string 53 | password: 54 | type: string 55 | email: 56 | type: string 57 | format: email 58 | phoneNumber: 59 | type: string 60 | accountStatus: 61 | type: string 62 | enum: 63 | - active 64 | - inactive 65 | - blocked 66 | - other 67 | default: aktif 68 | role: 69 | type: string 70 | enum: 71 | - admin 72 | - cashier 73 | createdAt: 74 | type: string 75 | format: date-time 76 | updatedAt: 77 | type: string 78 | format: date-time 79 | # REGISTER USER ACCOUNT jadikan identifier harus di isi salah satu: email or phone number 80 | registerUserAccount: 81 | type: object 82 | properties: 83 | identifier: 84 | type: object 85 | properties: 86 | email: 87 | type: string 88 | format: email 89 | phoneNumber: 90 | type: string 91 | role: 92 | type: string 93 | username: 94 | type: string 95 | password: 96 | type: string 97 | passwordConfirm: 98 | type: string 99 | required: 100 | - identifier 101 | - role 102 | - username 103 | - password 104 | - passwordConfirm 105 | # LOGIN USER ACCOUNT jadikan identifier harus di isi salah satu: username or email or phone number 106 | loginUserAccount: 107 | type: object 108 | properties: 109 | identifier: 110 | type: object 111 | properties: 112 | username: 113 | type: string 114 | email: 115 | type: string 116 | format: email 117 | phoneNumber: 118 | type: string 119 | password: 120 | type: string 121 | paths: 122 | # REGISTER ADMIN 123 | /auth/register/admin: 124 | post: 125 | tags: 126 | - Auth 127 | - Admin 128 | summary: register admin 129 | description: create new user admin 130 | requestBody: 131 | required: true 132 | content: 133 | application/json: 134 | schema: 135 | $ref: '#/components/schemas/registerUserAccount' 136 | examples: 137 | email: 138 | description: example register use email 139 | value: 140 | identifier: user@example.com 141 | username: user 142 | role: admin 143 | password: password123 144 | passwordConfirm: password123 145 | phoneNumber: 146 | description: example register use email 147 | value: 148 | identifier: 089653168345 149 | username: user 150 | role: admin 151 | password: password123 152 | passwordConfirm: password123 153 | responses: 154 | 201: 155 | description: you have successfully registered as admin 156 | 400: 157 | description: bad request 158 | # REGISTER CASHIER 159 | /auth/register: 160 | post: 161 | tags: 162 | - Auth 163 | - Cashier 164 | summary: register cashier 165 | description: create new user cashier 166 | requestBody: 167 | required: true 168 | content: 169 | application/json: 170 | schema: 171 | $ref: '#/components/schemas/registerUserAccount' 172 | examples: 173 | email: 174 | description: example register use email 175 | value: 176 | identifier: user@mail.com 177 | username: user 178 | role: cashier 179 | password: password123 180 | passwordConfirm: password123 181 | phoneNumber: 182 | description: example register use email 183 | value: 184 | identifier: 089653168345 185 | username: user 186 | role: cashier 187 | password: password123 188 | passwordConfirm: password123 189 | responses: 190 | 201: 191 | description: you have successfully registered as cashier 192 | 400: 193 | description: bad request 194 | # LOGIN ADMIN jadikan ketika admin berhasil login generate token 195 | /auth/login/admin: 196 | post: 197 | tags: 198 | - Auth 199 | - Admin 200 | summary: login admin 201 | description: login as admin 202 | requestBody: 203 | required: true 204 | content: 205 | application/json: 206 | schema: 207 | $ref: '#/components/schemas/loginUserAccount' 208 | responses: 209 | 200: 210 | description: you have successfully login as admin 211 | content: 212 | application/json: 213 | schema: 214 | type: object 215 | properties: 216 | token: 217 | type: string 218 | description: JWT token for authentication 219 | example: 220 | token: your_generated_jwt_token_here 221 | 401: 222 | description: unauthorized - invalid credential 223 | 406: 224 | description: your account is inactive 225 | # LOGIN CASHIER 226 | /auth/login: 227 | post: 228 | tags: 229 | - Auth 230 | - Cashier 231 | summary: login cashier 232 | description: login as cashier 233 | requestBody: 234 | required: true 235 | content: 236 | application/json: 237 | schema: 238 | $ref: '#/components/schemas/loginUserAccount' 239 | responses: 240 | 200: 241 | description: you have successfully login as admin 242 | 401: 243 | description: unauthorized - invalid credential 244 | 406: 245 | description: your account is inactive 246 | # GET ALL USER CASHIER 247 | /user-management/cashier: 248 | get: 249 | security: 250 | - PointOfSaleAuth: [ ] 251 | tags: 252 | - Admin 253 | summary: get all user cashier 254 | description: retrieve all user cashier information 255 | responses: 256 | 200: 257 | description: success retrieving all user cashier information 258 | content: 259 | application/json: 260 | schema: 261 | type: array 262 | items: 263 | $ref: '#/components/schemas/userAccount' 264 | examples: 265 | success: 266 | description: example success get all user cashier 267 | value: 268 | - id: randomstringbecauseuuid 269 | username: user1 270 | email: user1@example.com 271 | phoneNumber: 08971641117 272 | accountStatus: active 273 | role: cashier 274 | createdAt: 2022-02-20T10:00:00Z 275 | updatedAt: 2022-02-20T10:00:00Z 276 | - id: randomstringbecauseuuid 277 | username: user2 278 | email: user2@example.com 279 | phoneNumber: 08971642217 280 | accountStatus: blocked 281 | role: cashier 282 | createdAt: 2022-02-20T10:00:00Z 283 | updatedAt: 2022-02-20T10:00:00Z 284 | # GET USER ACCOUNT BY SOMETHING, like id, username, role, email, phone number. 285 | # GET ALL USER ACCOUNT BY IDENTIFIER 286 | /user-management/user-account/{identifier}: 287 | get: 288 | security: 289 | - PointOfSaleAuth: [ ] 290 | tags: 291 | - Admin 292 | summary: Get user account by identifier 293 | description: Retrieve user account information based on the provided identifier (id, username, role, email, or phone number) 294 | parameters: 295 | - in: path 296 | name: identifier 297 | required: true 298 | description: Identifier of the user account (id, username, role, email, or phone number) 299 | schema: 300 | type: string 301 | responses: 302 | 200: 303 | description: Success retrieving user user account information 304 | content: 305 | application/json: 306 | schema: 307 | oneOf: 308 | - type: array 309 | items: 310 | $ref: '#/components/schemas/userAccount' 311 | - $ref: '#/components/schemas/userAccount' 312 | examples: 313 | successIdentifierByRole: 314 | description: Example success retrieving user account information by role 315 | value: 316 | - id: randomstringbecauseuuid 317 | username: user1 318 | email: user1@example.com 319 | phoneNumber: "08971641117" 320 | accountStatus: active 321 | role: cashier 322 | createdAt: "2022-02-20T10:00:00Z" 323 | updatedAt: "2022-02-20T10:00:00Z" 324 | - id: randomstringbecauseuuid 325 | username: user2 326 | email: user2@example.com 327 | phoneNumber: "08971642217" 328 | accountStatus: active 329 | role: cashier 330 | createdAt: "2022-02-20T10:00:00Z" 331 | updatedAt: "2022-02-20T10:00:00Z" 332 | successIdentifierByEmail: 333 | description: Example success retrieving user account information by email 334 | value: 335 | id: randomstringbecauseuuid 336 | username: user1 337 | email: user1@example.com 338 | phoneNumber: "08971641117" 339 | accountStatus: active 340 | role: cashier 341 | createdAt: "2022-02-20T10:00:00Z" 342 | updatedAt: "2022-02-20T10:00:00Z" 343 | 404: 344 | description: User account with the provided identifier not found 345 | # CHANGE PASSWORD USER ADMIN 346 | /user-management/admin/{id}/password: 347 | put: 348 | security: 349 | - PointOfSaleAuth: [ ] 350 | tags: 351 | - Admin 352 | summary: change pass admin 353 | description: change password user admin 354 | parameters: 355 | - in: path 356 | name: id 357 | required: true 358 | schema: 359 | type: string 360 | description: ID of the user admin to change password for 361 | requestBody: 362 | required: true 363 | content: 364 | application/json: 365 | schema: 366 | type: object 367 | properties: 368 | currentPassword: 369 | type: string 370 | newPassword: 371 | type: string 372 | confirmPassword: 373 | type: string 374 | required: 375 | - currentPassword 376 | - newPassword 377 | - confirmPassword 378 | responses: 379 | 200: 380 | description: Password changed successfully 381 | 400: 382 | description: Bad request, invalid input 383 | 401: 384 | description: Unauthorized, authentication failure 385 | 404: 386 | description: User account not found 387 | 500: 388 | description: Internal server error 389 | # CHANGE PASSWORD USER CASHIER 390 | /user-management/cashier/{id}/password: 391 | put: 392 | tags: 393 | - Cashier 394 | summary: change pass cashier 395 | description: change password user cashier 396 | parameters: 397 | - in: path 398 | name: id 399 | required: true 400 | schema: 401 | type: string 402 | description: ID of the user cashier to change password for 403 | requestBody: 404 | required: true 405 | content: 406 | application/json: 407 | schema: 408 | type: object 409 | properties: 410 | currentPassword: 411 | type: string 412 | newPassword: 413 | type: string 414 | confirmPassword: 415 | type: string 416 | required: 417 | - currentPassword 418 | - newPassword 419 | - confirmPassword 420 | responses: 421 | 200: 422 | description: Password changed successfully 423 | 400: 424 | description: Bad request, invalid input 425 | 401: 426 | description: Unauthorized, authentication failure 427 | 404: 428 | description: User account not found 429 | 500: 430 | description: Internal server error 431 | --------------------------------------------------------------------------------