{
    "info": {
        "name": "Cipher Network API",
        "description": "Production-grade REST API for Cipher Network.",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "item": [
        {
            "name": "Authentication & Accounts",
            "item": [
                {
                    "name": "1. Admin/User Login",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"email\": \"ahmadrizalalfian@gmail.com\",\n  \"password\": \"asdASD1$\"\n}"
                        },
                        "url": {
                            "raw": "{{BASE_URL}}/auth/login",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "auth",
                                "login"
                            ]
                        }
                    }
                },
                {
                    "name": "2. Register User",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"email\": \"newuser@example.com\",\n  \"password\": \"SecurePass123!\"\n}"
                        },
                        "url": {
                            "raw": "{{BASE_URL}}/auth/register",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "auth",
                                "register"
                            ]
                        }
                    }
                },
                {
                    "name": "3. Get My Profile",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Authorization",
                                "value": "Bearer {{JWT_TOKEN}}"
                            }
                        ],
                        "url": {
                            "raw": "{{BASE_URL}}/auth/me",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "auth",
                                "me"
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "CMS & Public Pages",
            "item": [
                {
                    "name": "Get Page by Slug (Public)",
                    "request": {
                        "method": "GET",
                        "header": [],
                        "url": {
                            "raw": "{{BASE_URL}}/cms/pages/about",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "cms",
                                "pages",
                                "about"
                            ]
                        }
                    }
                },
                {
                    "name": "Admin: List All Pages",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Authorization",
                                "value": "Bearer {{JWT_TOKEN}}"
                            }
                        ],
                        "url": {
                            "raw": "{{BASE_URL}}/cms/admin/pages",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "cms",
                                "admin",
                                "pages"
                            ]
                        }
                    }
                },
                {
                    "name": "Admin: Create Page",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Authorization",
                                "value": "Bearer {{JWT_TOKEN}}"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"slug\": \"fees\",\n  \"title\": \"Trading Fees\",\n  \"content\": \"<h1>Exposed Fees</h1>\",\n  \"is_published\": true\n}"
                        },
                        "url": {
                            "raw": "{{BASE_URL}}/cms/admin/pages",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "cms",
                                "admin",
                                "pages"
                            ]
                        }
                    }
                },
                {
                    "name": "Admin: Update Page",
                    "request": {
                        "method": "PUT",
                        "header": [
                            {
                                "key": "Authorization",
                                "value": "Bearer {{JWT_TOKEN}}"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"content\": \"Updated content via admin.\"\n}"
                        },
                        "url": {
                            "raw": "{{BASE_URL}}/cms/admin/pages/REPLACE_WITH_UUID",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "cms",
                                "admin",
                                "pages",
                                "REPLACE_WITH_UUID"
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Wallet Operations",
            "item": [
                {
                    "name": "Deposit (Simulation)",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Authorization",
                                "value": "Bearer {{JWT_TOKEN}}"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"currency\": \"USDT\",\n  \"amount\": \"10000.00\",\n  \"txHash\": \"0x123abcfakehash456\"\n}"
                        },
                        "url": {
                            "raw": "{{BASE_URL}}/wallet/deposit-simulate",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "wallet",
                                "deposit-simulate"
                            ]
                        }
                    }
                },
                {
                    "name": "Withdraw (Idempotency Protected)",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Authorization",
                                "value": "Bearer {{JWT_TOKEN}}"
                            },
                            {
                                "key": "x-idempotency-key",
                                "value": "unique_tx_uuid_12345"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"currency\": \"USDT\",\n  \"amount\": \"500.00\",\n  \"address\": \"0xDestinationTrc20Address\"\n}"
                        },
                        "url": {
                            "raw": "{{BASE_URL}}/wallet/withdraw",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "wallet",
                                "withdraw"
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Trading Engine",
            "item": [
                {
                    "name": "Place Limit Order",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "x-api-key",
                                "value": "{{API_KEY}}"
                            },
                            {
                                "key": "x-timestamp",
                                "value": "{{$timestamp}}000"
                            },
                            {
                                "key": "x-nonce",
                                "value": "{{$guid}}"
                            },
                            {
                                "key": "x-signature",
                                "value": "{{AUTO_GENERATED_SIGNATURE}}"
                            },
                            {
                                "key": "x-idempotency-key",
                                "value": "{{$guid}}"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"symbol\": \"BTC_USDT\",\n  \"side\": \"BUY\",\n  \"type\": \"LIMIT\",\n  \"price\": \"68000.00\",\n  \"amount\": \"0.1\"\n}"
                        },
                        "url": {
                            "raw": "{{BASE_URL}}/trade/order",
                            "host": [
                                "{{BASE_URL}}"
                            ],
                            "path": [
                                "trade",
                                "order"
                            ]
                        }
                    }
                }
            ]
        }
    ],
    "event": [
        {
            "listen": "prerequest",
            "script": {
                "type": "text/javascript",
                "exec": [
                    "if(pm.request.url.path.includes('trade')) {",
                    "    var secret = pm.environment.get('API_SECRET') || 'super_secret_hmac_secret_key';",
                    "    var timestamp = Date.now().toString();",
                    "    var nonce = require('uuid').v4();",
                    "    pm.request.headers.upsert({key: 'x-timestamp', value: timestamp});",
                    "    pm.request.headers.upsert({key: 'x-nonce', value: nonce});",
                    "    var payload = pm.request.body ? pm.request.body.raw : '';",
                    "    var method = pm.request.method;",
                    "    var url = '/' + pm.request.url.path.join('/');",
                    "    var signString = timestamp + nonce + method + url + payload;",
                    "    var signature = CryptoJS.HmacSHA256(signString, secret).toString(CryptoJS.enc.Hex);",
                    "    pm.request.headers.upsert({key: 'x-signature', value: signature});",
                    "}"
                ]
            }
        }
    ],
    "variable": [
        {
            "key": "BASE_URL",
            "value": "http://localhost:3000"
        },
        {
            "key": "JWT_TOKEN",
            "value": "paste_your_token_here"
        },
        {
            "key": "API_KEY",
            "value": "paste_your_api_key_here"
        },
        {
            "key": "API_SECRET",
            "value": "super_secret_hmac_secret_key"
        }
    ]
}