{
  "info": {
    "name": "Liqi CaaS API",
    "description": "Collection completa da API Liqi CaaS com autenticacao automatica.\n\nPre-requisitos:\n1. Variavel global 'jsrsasign-js' com conteudo de http://kjur.github.io/jsrsasign/jsrsasign-latest-all-min.js\n2. Ambiente com variaveis: caas_operational_url, JWT_SUB, JWT_PRIVATE_KEY, profile",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{operational_authorization}}",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    },
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "variable": [
    {
      "key": "prs_authorization",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Auth",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "exec": [
              "var navigator = {};",
              "var window = {};",
              "eval(pm.globals.get(\"jsrsasign-js\"));",
              "",
              "var date = new Date();",
              "var now_utc = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(),",
              "                date.getUTCDate(), date.getUTCHours(),",
              "                date.getUTCMinutes(), date.getUTCSeconds());",
              "var issuedAtTimeSeconds = Math.floor(now_utc / 1000);",
              "var expirationTimeSeconds = issuedAtTimeSeconds + 60;",
              "",
              "var header = { \"alg\": \"RS256\", \"typ\": \"JWT\" };",
              "var payload = {",
              "  \"exp\": Math.ceil(expirationTimeSeconds),",
              "  \"iat\": Math.ceil(issuedAtTimeSeconds),",
              "  \"sub\": pm.environment.get(\"JWT_SUB\")",
              "};",
              "",
              "var jwt = pm.environment.get(\"JWT_PRIVATE_KEY\");",
              "var prvKey = KEYUTIL.getKey(\"-----BEGIN RSA PRIVATE KEY-----\" + jwt + \"-----END RSA PRIVATE KEY-----\");",
              "var sJWT = KJUR.jws.JWS.sign(header.alg, JSON.stringify(header), JSON.stringify(payload), prvKey);",
              "",
              "pm.collectionVariables.set(\"prs_authorization\", sJWT);"
            ],
            "type": "text/javascript"
          }
        },
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test(\"Status test\", function () {",
              "    pm.response.to.have.status(200);",
              "    let response = pm.response.json();",
              "    var token = response[\"token\"];",
              "    pm.environment.set(\"operational_authorization\", token);",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{prs_authorization}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [],
        "url": {
          "raw": "{{caas_operational_url}}/auth/signin",
          "host": [
            "{{caas_operational_url}}"
          ],
          "path": [
            "auth",
            "signin"
          ]
        }
      },
      "response": []
    },
    {
      "name": "Client",
      "item": [
        {
          "name": "createProfile",
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"profile\": \"{{profile}}\",\n    \"activeBuy\": true,\n    \"activeSell\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{caas_operational_url}}/account/createProfile",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "account",
                "createProfile"
              ]
            }
          },
          "response": []
        },
        {
          "name": "enableDisabledProfile",
          "request": {
            "method": "PUT",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"profile\": \"{{profile}}\",\n    \"activeBuy\": true,\n    \"activeSell\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{caas_operational_url}}/account/enableDisabledProfile",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "account",
                "enableDisabledProfile"
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchProfile",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/account/fetchProfile?profile={{profile}}",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "account",
                "fetchProfile"
              ],
              "query": [
                {
                  "key": "profile",
                  "value": "{{profile}}"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchProfiles",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/account/fetchProfiles",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "account",
                "fetchProfiles"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Wallet",
      "item": [
        {
          "name": "fetchBalance",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/wallet/fetchBalance?profile={{profile}}",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "wallet",
                "fetchBalance"
              ],
              "query": [
                {
                  "key": "profile",
                  "value": "{{profile}}"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchBalances",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/wallet/fetchBalances",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "wallet",
                "fetchBalances"
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchStatement",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/wallet/fetchStatement?profile={{profile}}",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "wallet",
                "fetchStatement"
              ],
              "query": [
                {
                  "key": "profile",
                  "value": "{{profile}}"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchStatementCategory",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/wallet/fetchStatementCategory",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "wallet",
                "fetchStatementCategory"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Markets",
      "item": [
        {
          "name": "fetchExchanges",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/market/fetchExchanges",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "market",
                "fetchExchanges"
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchMarkets",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/market/fetchMarkets",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "market",
                "fetchMarkets"
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchTickers",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/market/fetchTickers?onlyPriority=true",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "market",
                "fetchTickers"
              ],
              "query": [
                {
                  "key": "onlyPriority",
                  "value": "true"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchTicker",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/market/fetchTicker?symbol=btc/brl&exchange=foxbitsimulated",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "market",
                "fetchTicker"
              ],
              "query": [
                {
                  "key": "symbol",
                  "value": "btc/brl"
                },
                {
                  "key": "exchange",
                  "value": "foxbitsimulated"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchHistoricalPrices",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/market/fetchHistoricalPrices?symbol=BTC/BRL&exchange=cainvest2&range=1h",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "market",
                "fetchHistoricalPrices"
              ],
              "query": [
                {
                  "key": "symbol",
                  "value": "BTC/BRL"
                },
                {
                  "key": "exchange",
                  "value": "cainvest2"
                },
                {
                  "key": "range",
                  "value": "1h"
                }
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Orders",
      "item": [
        {
          "name": "createOrder - Buy",
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"profile\": \"{{profile}}\",\n    \"id\": \"{{$guid}}\",\n    \"symbol\": \"btc/brl\",\n    \"side\": \"buy\",\n    \"quoteAmount\": 100\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{caas_operational_url}}/orders/createOrder",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "orders",
                "createOrder"
              ]
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test(\"Status test\", function () {",
                  "    pm.response.to.have.status(200);",
                  "    const response = pm.response.json();",
                  "    const orderId = response[\"id\"];",
                  "    pm.environment.set(\"order_id\", orderId);",
                  "});"
                ],
                "type": "text/javascript"
              }
            }
          ]
        },
        {
          "name": "createOrder - Sell",
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"profile\": \"{{profile}}\",\n    \"id\": \"{{$guid}}\",\n    \"symbol\": \"btc/brl\",\n    \"side\": \"sell\",\n    \"amount\": 0.00006945\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{caas_operational_url}}/orders/createOrder",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "orders",
                "createOrder"
              ]
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test(\"Status test\", function () {",
                  "    pm.response.to.have.status(200);",
                  "    const response = pm.response.json();",
                  "    const orderId = response[\"id\"];",
                  "    pm.environment.set(\"order_id\", orderId);",
                  "});"
                ],
                "type": "text/javascript"
              }
            }
          ]
        },
        {
          "name": "fetchOrder",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/orders/fetchOrder?profile={{profile}}&id={{order_id}}",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "orders",
                "fetchOrder"
              ],
              "query": [
                {
                  "key": "profile",
                  "value": "{{profile}}"
                },
                {
                  "key": "id",
                  "value": "{{order_id}}"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "fetchOrders",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/orders/fetchOrders?symbol=btc/brl&profile={{profile}}",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "orders",
                "fetchOrders"
              ],
              "query": [
                {
                  "key": "symbol",
                  "value": "btc/brl"
                },
                {
                  "key": "profile",
                  "value": "{{profile}}"
                }
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Orders RFQ",
      "item": [
        {
          "name": "createQuote",
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"profile\": \"{{profile}}\",\n    \"symbol\": \"btc/brl\",\n    \"side\": \"buy\",\n    \"quoteAmount\": 100\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{caas_operational_url}}/orders/rfq/createQuote",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "orders",
                "rfq",
                "createQuote"
              ]
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test(\"Status test\", function () {",
                  "    pm.response.to.have.status(200);",
                  "    const response = pm.response.json();",
                  "    const quoteId = response[\"id\"];",
                  "    pm.environment.set(\"quote_id\", quoteId);",
                  "});"
                ],
                "type": "text/javascript"
              }
            }
          ]
        },
        {
          "name": "fetchQuote",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/orders/rfq/fetchQuote?id={{quote_id}}&symbol=btc/brl",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "orders",
                "rfq",
                "fetchQuote"
              ],
              "query": [
                {
                  "key": "id",
                  "value": "{{quote_id}}"
                },
                {
                  "key": "symbol",
                  "value": "btc/brl"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "createOrder RFQ",
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"profile\": \"{{profile}}\",\n    \"id\": \"{{$guid}}\",\n    \"symbol\": \"btc/brl\",\n    \"side\": \"buy\",\n    \"quoteAmount\": 100,\n    \"quoteId\": \"{{quote_id}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{caas_operational_url}}/orders/rfq/createOrder",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "orders",
                "rfq",
                "createOrder"
              ]
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test(\"Status test\", function () {",
                  "    pm.response.to.have.status(200);",
                  "    const response = pm.response.json();",
                  "    const orderId = response[\"id\"];",
                  "    pm.environment.set(\"order_id\", orderId);",
                  "});"
                ],
                "type": "text/javascript"
              }
            }
          ]
        },
        {
          "name": "fetchOrder",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/orders/fetchOrder?profile={{profile}}&id={{order_id}}",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "orders",
                "fetchOrder"
              ],
              "query": [
                {
                  "key": "profile",
                  "value": "{{profile}}"
                },
                {
                  "key": "id",
                  "value": "{{order_id}}"
                }
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Analytics",
      "item": [
        {
          "name": "poolsBalances",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{caas_operational_url}}/analytics/poolsBalances",
              "host": [
                "{{caas_operational_url}}"
              ],
              "path": [
                "analytics",
                "poolsBalances"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Transactions",
      "item": [
        {
          "name": "transfers",
          "item": [
            {
              "name": "createTransfer",
              "request": {
                "method": "POST",
                "header": [],
                "body": {
                  "mode": "raw",
                  "raw": "{\n    \"fromProfile\": \"{{profile}}\",\n    \"toProfile\": \"profile-destino\",\n    \"asset\": \"BTC\",\n    \"amount\": \"0.001\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{caas_operational_url}}/transactions/transfer",
                  "host": [
                    "{{caas_operational_url}}"
                  ],
                  "path": [
                    "transactions",
                    "transfer"
                  ]
                }
              },
              "response": [],
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "pm.test(\"Status test\", function () {",
                      "    pm.response.to.have.status(200);",
                      "    const response = pm.response.json();",
                      "    pm.environment.set(\"transfer_id\", response[\"id\"]);",
                      "});"
                    ],
                    "type": "text/javascript"
                  }
                }
              ]
            },
            {
              "name": "fetchTransfers",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{caas_operational_url}}/transactions/transfers",
                  "host": [
                    "{{caas_operational_url}}"
                  ],
                  "path": [
                    "transactions",
                    "transfers"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "fetchTransfer",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{caas_operational_url}}/transactions/transfer?id={{transfer_id}}",
                  "host": [
                    "{{caas_operational_url}}"
                  ],
                  "path": [
                    "transactions",
                    "transfer"
                  ],
                  "query": [
                    {
                      "key": "id",
                      "value": "{{transfer_id}}"
                    }
                  ]
                }
              },
              "response": []
            }
          ]
        },
        {
          "name": "balances",
          "item": [
            {
              "name": "createTransactionBalance",
              "request": {
                "method": "POST",
                "header": [],
                "body": {
                  "mode": "raw",
                  "raw": "{\n    \"profile\": \"{{profile}}\",\n    \"asset\": \"BTC\",\n    \"amount\": \"0.001\",\n    \"type\": \"credit\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{caas_operational_url}}/transactions/balance",
                  "host": [
                    "{{caas_operational_url}}"
                  ],
                  "path": [
                    "transactions",
                    "balance"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "fetchTransactionsBalances",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{caas_operational_url}}/transactions/balances",
                  "host": [
                    "{{caas_operational_url}}"
                  ],
                  "path": [
                    "transactions",
                    "balances"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "fetchTransactionBalance",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{caas_operational_url}}/transactions/balance?id={{balance_id}}",
                  "host": [
                    "{{caas_operational_url}}"
                  ],
                  "path": [
                    "transactions",
                    "balance"
                  ],
                  "query": [
                    {
                      "key": "id",
                      "value": "{{balance_id}}"
                    }
                  ]
                }
              },
              "response": []
            }
          ]
        },
        {
          "name": "deposit",
          "item": [
            {
              "name": "createDeposit",
              "request": {
                "method": "POST",
                "header": [],
                "body": {
                  "mode": "raw",
                  "raw": "{\n    \"profile\": \"{{profile}}\",\n    \"asset\": \"BTC\",\n    \"amount\": \"0.001\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{caas_operational_url}}/transactions/createDeposit",
                  "host": [
                    "{{caas_operational_url}}"
                  ],
                  "path": [
                    "transactions",
                    "createDeposit"
                  ]
                }
              },
              "response": [],
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "pm.test(\"Status test\", function () {",
                      "    pm.response.to.have.status(200);",
                      "    const response = pm.response.json();",
                      "    pm.environment.set(\"deposit_id\", response[\"id\"]);",
                      "});"
                    ],
                    "type": "text/javascript"
                  }
                }
              ]
            },
            {
              "name": "fetchDeposit",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{caas_operational_url}}/transactions/fetchDeposit?id={{deposit_id}}",
                  "host": [
                    "{{caas_operational_url}}"
                  ],
                  "path": [
                    "transactions",
                    "fetchDeposit"
                  ],
                  "query": [
                    {
                      "key": "id",
                      "value": "{{deposit_id}}"
                    }
                  ]
                }
              },
              "response": []
            }
          ]
        }
      ]
    }
  ]
}