diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 1692977..0000000 --- a/.editorconfig +++ /dev/null @@ -1,18 +0,0 @@ -# EditorConfig is awesome: https://EditorConfig.org - -# Top-most EditorConfig file -root = true - -# Unix-style newlines with a newline ending every file -[*] -end_of_line = lf -insert_final_newline = true -indent_style = space -indent_size = 2 -trim_trailing_whitespace = true - -[*.rb] -charset = utf-8 - -[*.md] -trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 3069c43..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -source/javascripts/lib/* linguist-vendored diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dc27f6e..5a00c91 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,42 +1,33 @@ -name: Deploy +name: Deploy Docusaurus on: push: - branches: [ 'master' ] + branches: [ 'main/open-api' ] jobs: deploy: runs-on: ubuntu-latest - env: - ruby-version: 3.3.8 steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + - name: Set up Node.js + uses: actions/setup-node@v4 with: - ruby-version: ${{ env.ruby-version }} + node-version: 18 + cache: yarn + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Clean old docs + run: yarn clean:docs - - uses: actions/cache@v4 - with: - path: vendor/bundle - key: gems-${{ runner.os }}-${{ env.ruby-version }}-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - gems-${{ runner.os }}-${{ env.ruby-version }}- - gems-${{ runner.os }}- - - - run: bundle config set deployment 'true' - - name: bundle install - run: | - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 + - name: Generate API docs + run: yarn genapi - - run: bundle exec middleman build + - name: Build site + run: yarn build - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build - keep_files: true + - name: Deploy to GitHub Pages + run: yarn deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 357bd56..f817c8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,26 @@ -*.gem -*.rbc -.bundle -.config -coverage -InstalledFiles -vendor/bundle -lib/bundler/man -pkg -rdoc -spec/reports -test/tmp -test/version_tmp -tmp +# Dependencies +node_modules + +# Production +build + +# Generated files +.docusaurus +.cache-loader + +# Misc *.DS_STORE -build/ -.cache -.vagrant -.sass-cache +*.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* -# YARD artifacts -.yardoc -_yardoc -doc/ -.idea/ -.vscode +docs/* +yarn.lock -# Vagrant artifacts -ubuntu-*-console.log +.idea diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6f0f42..c024f9b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,100 @@ -# Contributing +
-## Development -To install dependencies, after installing `ruby`, install bundle with `gem install bundler` and then -use `bundle install` to install dependencies. +### راهنمای اضافه کردن سکشن جدید به OpenAPI و مستندات Docusaurus -Now you can start editing files in `source` directory. Launch a server with `make serve` to view the -resulting HTML in your browser. +#### I. افزودن اندپوینت جدید به فایل OpenAPI -To build the site run `make build`. This will generate site's static files in `build` folder. +1. در فایل OpenAPI مربوطه، اندپوینت جدید را در بخش `paths` و بر اساس متد مورد نظر (`post`, `get`, `delete`, …) اضافه کنید. +2. برای قابل‌مشاهده بودن اندپوینت در سایدبار، مقدار `tag` آن را مطابق با تگ تعریف‌شده برای همان فایل OpenAPI تنظیم کنید. +3. در صورت نیاز: + - `summary` و `description` اندپوینت را کامل بنویسید. + - اگر اندپوینت خصوصی است، در بخش `security` برای آن `TokenAuth` اضافه کنید. + - اگر به هدرها یا بدنهٔ درخواست نیاز است، `requestBody` را تعریف کنید. + - در نهایت، پارامترها (`parameters`) و انواع ریسپانس‌های (`responses`) مربوط به اندپوینت را اضافه کنید. -# References -* https://github.com/lord/slate/wiki/ -* https://developer.tradegecko.com/docs.html -* https://github.com/rouge-ruby/rouge/wiki/List-of-supported-languages-and-lexers +> اگر فایل جدیدی اضافه نمی‌کنید و فقط روی فایل‌های موجود ویرایش انجام می‌دهید، می‌توانید مرحلهٔ II و III را نادیده بگیرید و مستقیم به مرحله IV بروید. + +#### II. افزودن فایل OpenAPI جدید به تنظیمات `docusaurus-plugin-openapi-docs` + +اگر فایل OpenAPI جدیدی اضافه می‌کنید: + +1. فایل جدید را در تنظیمات پلاگین `docusaurus-plugin-openapi-docs` در فایل `docusaurus.config.ts` ثبت کنید. +2. برای هر ورودی جدید، مقادیر زیر را تنظیم کنید: + - `specPath`: مسیر فایل OpenAPI در پوشهٔ `openapi` + - `outputDir`: مسیر پوشهٔ خروجی که طبق کنوانسیون باید به صورت `docs/` باشد + - `sidebarOptions`: تنظیمات نحوهٔ نمایش در سایدبار. با توجه به این‌که در مرحلهٔ قبل تگ اندپوینت‌ها را مشخص کرده‌ایم، این بخش معمولاً به صورت زیر تنظیم می‌شود: + +
+ +```ts +sidebarOptions: { + groupPathsBy: "tag", + categoryLinkSource: "tag", +} +``` + +
+ + +خروجی این بخش باید بصورت زیر باشد: +
+ +```ts +: { + specPath: "openapi/.yaml", + outputDir: "docs/", + sidebarOptions: { + groupPathsBy: "tag", + categoryLinkSource: "tag", + }, +} satisfies OpenApiPlugin.Options, +``` + +
+ +3. با توجه به ساختار TypeScript، بهتر است نوع تنظیمات پلاگین را نیز با `OpenApiPlugin.Options` مشخص کنید. + +در این مرحله امکان جنریت کردن مستندات مربوط به فایل جدید توسط Docusaurus فراهم می‌شود. برای این کار می‌توانید دستور زیر را اجرا کنید: + +
+ +```bash + yarn genapi +``` + +
+ +#### III. بررسی خروجی جنریت‌شده + +1. اگر فایل‌ها بدون خطا جنریت شدند، بسته به مقداری که برای `outputDir` تنظیم کرده‌اید، می‌توانید دایرکتوری متناظر را در مسیر `./docs` مشاهده کنید. +2. پلاگین `docusaurus-plugin-openapi-docs` برای هر پوشهٔ خروجی، یک فایل `sidebar` نیز تولید می‌کند: + - این فایل سایدبار را ابتدا در روت پروژه به تنظیمات سایدبارها اضافه کنید. + - سپس مانند سایر سایدبارها، آیتم‌های آن را (از ایندکس دوم به بعد) به لیست `items` اضافه کنید. + - با تغییر ترتیب آیتم‌ها در لیست `items`، ترتیب نمایش در سایدبار نیز تغییر خواهد کرد. + +#### IV. به‌روزرسانی تغییرات و اجرای پروژه + +1. تغییرات مربوط به این کار را در فایل زیر ثبت کنید: + + [`src/pages/changelog.md`](src/pages/changelog.md) + +2. برای مشاهدهٔ بیلد لوکال، دستور زیر را اجرا کنید: + +
+ +```bash + yarn dev +``` + +
+ +3. پس از تأیید نهایی تغییرات، آن‌ها را با برنچ زیر مرج کنید. +
+ +```text + main/open-api +``` + +
+ +
diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 504da65..0000000 --- a/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM ruby:2.6-slim - -WORKDIR /srv/slate - -VOLUME /srv/slate/build -VOLUME /srv/slate/source - -EXPOSE 4567 - -COPY Gemfile . -COPY Gemfile.lock . - -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - build-essential \ - git \ - nodejs \ - && gem install bundler \ - && bundle install \ - && apt-get remove -y build-essential git \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* - -COPY . /srv/slate - -RUN chmod +x /srv/slate/slate.sh - -ENTRYPOINT ["/srv/slate/slate.sh"] -CMD ["build"] diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 89f29bc..0000000 --- a/Gemfile +++ /dev/null @@ -1,15 +0,0 @@ -ruby '>= 2.5' -source 'https://rubygems.org' - - -gem "rack", ">= 2.2.13", "< 3.0" -# Middleman -gem 'middleman', '~> 4.4' -gem 'middleman-syntax', '~> 3.2' -gem 'middleman-autoprefixer', '~> 3.0' -gem 'middleman-sprockets', '~> 4.1' -gem 'rouge', '~> 3.21' -gem 'redcarpet', '~> 3.5.0' -gem "nokogiri", ">= 1.18.8" -gem 'sass' -gem 'webrick' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 7a6c5de..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,148 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activesupport (6.1.7.3) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - autoprefixer-rails (10.2.5.0) - execjs (< 2.8.0) - backports (3.21.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.12.2) - concurrent-ruby (1.2.2) - contracts (0.13.0) - dotenv (2.7.6) - erubis (2.7.0) - execjs (2.7.0) - fast_blank (1.0.0) - fastimage (2.2.4) - ffi (1.15.0) - haml (5.2.1) - temple (>= 0.8.0) - tilt - hamster (3.0.0) - concurrent-ruby (~> 1.0) - hashie (3.6.0) - i18n (1.6.0) - concurrent-ruby (~> 1.0) - kramdown (2.3.1) - rexml - listen (3.0.8) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - memoist (0.16.2) - middleman (4.4.0) - coffee-script (~> 2.2) - haml (>= 4.0.5) - kramdown (>= 2.3.0) - middleman-cli (= 4.4.0) - middleman-core (= 4.4.0) - middleman-autoprefixer (3.0.0) - autoprefixer-rails (~> 10.0) - middleman-core (>= 4.0.0) - middleman-cli (4.4.0) - thor (>= 0.17.0, < 2.0) - middleman-core (4.4.0) - activesupport (>= 6.1, < 7.0) - addressable (~> 2.4) - backports (~> 3.6) - bundler (~> 2.0) - contracts (~> 0.13.0) - dotenv - erubis - execjs (~> 2.0) - fast_blank - fastimage (~> 2.0) - hamster (~> 3.0) - hashie (~> 3.4) - i18n (~> 1.6.0) - listen (~> 3.0.0) - memoist (~> 0.14) - padrino-helpers (~> 0.15.0) - parallel - rack (>= 1.4.5, < 3) - sassc (~> 2.0) - servolux - tilt (~> 2.0.9) - toml - uglifier (~> 3.0) - webrick - middleman-sprockets (4.1.1) - middleman-core (~> 4.0) - sprockets (>= 3.0) - middleman-syntax (3.2.0) - middleman-core (>= 3.2) - rouge (~> 3.2) - mini_portile2 (2.8.7) - minitest (5.18.0) - nokogiri (1.18.8) - mini_portile2 (~> 2.8.2) - racc (~> 1.4) - padrino-helpers (0.15.1) - i18n (>= 0.6.7, < 2) - padrino-support (= 0.15.1) - tilt (>= 1.4.1, < 3) - padrino-support (0.15.1) - parallel (1.20.1) - parslet (2.0.0) - public_suffix (4.0.6) - racc (1.8.1) - rack (2.2.13) - rb-fsevent (0.11.0) - rb-inotify (0.10.1) - ffi (~> 1.0) - redcarpet (3.5.1) - rexml (3.3.6) - strscan - rouge (3.26.0) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sassc (2.4.0) - ffi (~> 1.9) - servolux (0.13.0) - sprockets (3.7.2) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - strscan (3.1.0) - temple (0.8.2) - thor (1.1.0) - tilt (2.0.10) - toml (0.3.0) - parslet (>= 1.8.0, < 3.0.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uglifier (3.2.0) - execjs (>= 0.3.0, < 3) - webrick (1.8.2) - zeitwerk (2.6.7) - -PLATFORMS - ruby - -DEPENDENCIES - middleman (~> 4.4) - middleman-autoprefixer (~> 3.0) - middleman-sprockets (~> 4.1) - middleman-syntax (~> 3.2) - nokogiri (>= 1.18.8) - rack (>= 2.2.13, < 3.0) - redcarpet (~> 3.5.0) - rouge (~> 3.21) - sass - webrick - -RUBY VERSION - ruby 3.1.0 - -BUNDLED WITH - 2.6.8 diff --git a/Makefile b/Makefile deleted file mode 100644 index 010e98b..0000000 --- a/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -.PHONY: clean build serve - -all: build - -build: - bundle exec middleman build - -serve: - bundle exec middleman server - -clean: - rm -rf build diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 200839d..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,47 +0,0 @@ -Vagrant.configure(2) do |config| - config.vm.box = "ubuntu/bionic64" - config.vm.network :forwarded_port, guest: 4567, host: 4567 - config.vm.provider "virtualbox" do |vb| - vb.memory = "2048" - end - - config.vm.provision "bootstrap", - type: "shell", - inline: <<-SHELL - # add nodejs v12 repository - curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - - - sudo apt-get update - sudo apt-get install -yq ruby ruby-dev - sudo apt-get install -yq pkg-config build-essential nodejs git libxml2-dev libxslt-dev - sudo apt-get autoremove -yq - gem install --no-ri --no-rdoc bundler - SHELL - - # add the local user git config to the vm - config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig" - - config.vm.provision "install", - type: "shell", - privileged: false, - inline: <<-SHELL - echo "==============================================" - echo "Installing app dependencies" - cd /vagrant - sudo gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)" - bundle config build.nokogiri --use-system-libraries - bundle install - SHELL - - config.vm.provision "run", - type: "shell", - privileged: false, - run: "always", - inline: <<-SHELL - echo "==============================================" - echo "Starting up middleman at http://localhost:4567" - echo "If it does not come up, check the ~/middleman.log file for any error messages" - cd /vagrant - bundle exec middleman server --watcher-force-polling --watcher-latency=1 &> ~/middleman.log & - SHELL -end diff --git a/config.rb b/config.rb deleted file mode 100644 index 6f8b677..0000000 --- a/config.rb +++ /dev/null @@ -1,63 +0,0 @@ -# Unique header generation -require './lib/unique_head.rb' - -# Markdown -set :markdown_engine, :redcarpet -set :markdown, - fenced_code_blocks: true, - smartypants: true, - disable_indented_code_blocks: true, - prettify: true, - strikethrough: true, - tables: true, - with_toc_data: true, - no_intra_emphasis: true, - renderer: UniqueHeadCounter - -# Assets -set :css_dir, 'stylesheets' -set :js_dir, 'javascripts' -set :images_dir, 'images' -set :fonts_dir, 'fonts' - -# Activate the syntax highlighter -activate :syntax -ready do - require './lib/monokai_sublime_slate.rb' - require './lib/multilang.rb' -end - -activate :sprockets - -activate :autoprefixer do |config| - config.browsers = ['last 2 version', 'Firefox ESR'] - config.cascade = false - config.inline = true -end - -# Github pages require relative links -activate :relative_assets -set :relative_links, true - -# Build Configuration -configure :build do - # We do want to hash woff and woff2 as there's a bug where woff2 will use - # woff asset hash which breaks things. Trying to use a combination of ignore and - # rewrite_ignore does not work as it conflicts weirdly with relative_assets. Disabling - # the .woff2 extension only does not work as .woff will still activate it so have to - # have both. See https://github.com/slatedocs/slate/issues/1171 for more details. - activate :asset_hash, :exts => app.config[:asset_extensions] - %w[.woff .woff2] - # If you're having trouble with Middleman hanging, commenting - # out the following two lines has been known to help - activate :minify_css - activate :minify_javascript - # activate :gzip -end - -# Deploy Configuration -# If you want Middleman to listen on a different port, you can set that below -set :port, 4567 - -helpers do - require './lib/toc_data.rb' -end diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 9dbd7db..0000000 --- a/deploy.sh +++ /dev/null @@ -1,226 +0,0 @@ -#!/usr/bin/env bash -set -o errexit #abort if any command fails -me=$(basename "$0") - -help_message="\ -Usage: $me [-c FILE] [] -Deploy generated files to a git branch. - -Options: - - -h, --help Show this help information. - -v, --verbose Increase verbosity. Useful for debugging. - -e, --allow-empty Allow deployment of an empty directory. - -m, --message MESSAGE Specify the message used when committing on the - deploy branch. - -n, --no-hash Don't append the source commit's hash to the deploy - commit's message. - --source-only Only build but not push - --push-only Only push but not build -" - - -run_build() { - bundle exec middleman build --clean -} - -parse_args() { - # Set args from a local environment file. - if [ -e ".env" ]; then - source .env - fi - - # Parse arg flags - # If something is exposed as an environment variable, set/overwrite it - # here. Otherwise, set/overwrite the internal variable instead. - while : ; do - if [[ $1 = "-h" || $1 = "--help" ]]; then - echo "$help_message" - exit 0 - elif [[ $1 = "-v" || $1 = "--verbose" ]]; then - verbose=true - shift - elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then - allow_empty=true - shift - elif [[ ( $1 = "-m" || $1 = "--message" ) && -n $2 ]]; then - commit_message=$2 - shift 2 - elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then - GIT_DEPLOY_APPEND_HASH=false - shift - elif [[ $1 = "--source-only" ]]; then - source_only=true - shift - elif [[ $1 = "--push-only" ]]; then - push_only=true - shift - else - break - fi - done - - if [ ${source_only} ] && [ ${push_only} ]; then - >&2 echo "You can only specify one of --source-only or --push-only" - exit 1 - fi - - # Set internal option vars from the environment and arg flags. All internal - # vars should be declared here, with sane defaults if applicable. - - # Source directory & target branch. - deploy_directory=build - deploy_branch=gh-pages - - #if no user identity is already set in the current git environment, use this: - default_username=${GIT_DEPLOY_USERNAME:-deploy.sh} - default_email=${GIT_DEPLOY_EMAIL:-} - - #repository to deploy to. must be readable and writable. - repo=origin - - #append commit hash to the end of message by default - append_hash=${GIT_DEPLOY_APPEND_HASH:-true} -} - -main() { - enable_expanded_output - - if ! git diff --exit-code --quiet --cached; then - echo Aborting due to uncommitted changes in the index >&2 - return 1 - fi - - commit_title=`git log -n 1 --format="%s" HEAD` - commit_hash=` git log -n 1 --format="%H" HEAD` - - #default commit message uses last title if a custom one is not supplied - if [[ -z $commit_message ]]; then - commit_message="publish: $commit_title" - fi - - #append hash to commit message unless no hash flag was found - if [ $append_hash = true ]; then - commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash" - fi - - previous_branch=`git rev-parse --abbrev-ref HEAD` - - if [ ! -d "$deploy_directory" ]; then - echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2 - return 1 - fi - - # must use short form of flag in ls for compatibility with macOS and BSD - if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then - echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2 - return 1 - fi - - if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then - # deploy_branch exists in $repo; make sure we have the latest version - - disable_expanded_output - git fetch --force $repo $deploy_branch:$deploy_branch - enable_expanded_output - fi - - # check if deploy_branch exists locally - if git show-ref --verify --quiet "refs/heads/$deploy_branch" - then incremental_deploy - else initial_deploy - fi - - restore_head -} - -initial_deploy() { - git --work-tree "$deploy_directory" checkout --orphan $deploy_branch - git --work-tree "$deploy_directory" add --all - commit+push -} - -incremental_deploy() { - #make deploy_branch the current branch - git symbolic-ref HEAD refs/heads/$deploy_branch - #put the previously committed contents of deploy_branch into the index - git --work-tree "$deploy_directory" reset --mixed --quiet - git --work-tree "$deploy_directory" add --all - - set +o errexit - diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$? - set -o errexit - case $diff in - 0) echo No changes to files in $deploy_directory. Skipping commit.;; - 1) commit+push;; - *) - echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to main, use: git symbolic-ref HEAD refs/heads/main && git reset --mixed >&2 - return $diff - ;; - esac -} - -commit+push() { - set_user_id - git --work-tree "$deploy_directory" commit -m "$commit_message" - - disable_expanded_output - #--quiet is important here to avoid outputting the repo URL, which may contain a secret token - git push --quiet $repo $deploy_branch - enable_expanded_output -} - -#echo expanded commands as they are executed (for debugging) -enable_expanded_output() { - if [ $verbose ]; then - set -o xtrace - set +o verbose - fi -} - -#this is used to avoid outputting the repo URL, which may contain a secret token -disable_expanded_output() { - if [ $verbose ]; then - set +o xtrace - set -o verbose - fi -} - -set_user_id() { - if [[ -z `git config user.name` ]]; then - git config user.name "$default_username" - fi - if [[ -z `git config user.email` ]]; then - git config user.email "$default_email" - fi -} - -restore_head() { - if [[ $previous_branch = "HEAD" ]]; then - #we weren't on any branch before, so just set HEAD back to the commit it was on - git update-ref --no-deref HEAD $commit_hash $deploy_branch - else - git symbolic-ref HEAD refs/heads/$previous_branch - fi - - git reset --mixed -} - -filter() { - sed -e "s|$repo|\$repo|g" -} - -sanitize() { - "$@" 2> >(filter 1>&2) | filter -} - -parse_args "$@" - -if [[ ${source_only} ]]; then - run_build -elif [[ ${push_only} ]]; then - main "$@" -else - run_build - main "$@" -fi diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..abed2a5 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +.gitignore + +# Except this file +!.gitignore diff --git a/docusaurus.config.ts b/docusaurus.config.ts new file mode 100644 index 0000000..1cbf057 --- /dev/null +++ b/docusaurus.config.ts @@ -0,0 +1,160 @@ +import {themes as prismThemes} from 'prism-react-renderer' +import type {Config} from '@docusaurus/types' +import type * as Preset from '@docusaurus/preset-classic' +import type * as Plugin from '@docusaurus/types/src/plugin' +import type * as OpenApiPlugin from 'docusaurus-plugin-openapi-docs' + +const API_SPECS = [ + {id: 'market_data', hideSendButton: false}, + {id: 'user_data', hideSendButton: false}, + {id: 'spot_trade', hideSendButton: false}, + {id: 'margin_trade', hideSendButton: false}, + {id: 'withdraw', hideSendButton: false}, + {id: 'address_book', hideSendButton: false}, + {id: 'security', hideSendButton: false}, + {id: 'referral', hideSendButton: false}, + {id: 'auth', hideSendButton: false}, + {id: 'portfolio', hideSendButton: false}, + {id: 'options', hideSendButton: false}, + {id: 'websocket', hideSendButton: true}, +] as const + +const docsPluginConfigs = () => { + const DEFAULT_SIDEBAR_OPTIONS: OpenApiPlugin.Options['sidebarOptions'] = { + groupPathsBy: 'tag', + categoryLinkSource: 'tag', + } + + const createApiConfig = (item: { id: string, hideSendButton: boolean }): OpenApiPlugin.Options => ({ + specPath: `openapi/${item.id}.yaml`, + outputDir: `docs/${item.id}`, + sidebarOptions: DEFAULT_SIDEBAR_OPTIONS, + hideSendButton: true, + }) + + return Object.fromEntries( + API_SPECS.map((item) => [item.id, createApiConfig(item)]) + ) +} + +const config: Config = { + title: 'مستندات API نوبیتکس', + tagline: 'Nobitex API Documentation', + favicon: 'img/favicon.ico', + + future: { + v4: true, + }, + + url: 'https://apidocs.nobitex.ir', + baseUrl: '/', + organizationName: 'nobitex', + projectName: 'nobitex-docs-api', + + onBrokenLinks: 'throw', + onBrokenMarkdownLinks: 'warn', + + i18n: { + defaultLocale: 'fa', + locales: ['fa'], + localeConfigs: { + fa: { + direction: 'rtl', + htmlLang: 'fa-IR', + }, + }, + }, + + presets: [ + [ + 'classic', + { + docs: { + sidebarPath: './sidebars.ts', + docItemComponent: "@theme/ApiItem", + routeBasePath: '/', + editUrl: + 'https://github.com/nobitex/docs-api/', + }, + blog: false, + } satisfies Preset.Options, + ], + ], + + themeConfig: { + image: 'img/nobitex-social.jpg', + colorMode: { + respectPrefersColorScheme: true, + }, + prism: { + theme: prismThemes.vsLight, + darkTheme: prismThemes.vsDark, + }, + navbar: { + logo: { + alt: 'Nobitex Logo', + src: 'img/logo-light.svg', + srcDark: 'img/logo-dark.svg', + }, + items: [ + { href: 'https://github.com/nobitex/docs-api', label: 'GitHub', position: 'right' }, + { + type: 'custom-searchNavbarItem', + position: 'right', + }, + { to: '/', label: 'مستندات', position: 'left', activeBaseRegex: '^(?!/(ws|websocket|changelog|faq|general_notes|download)(/|$)).*' }, + { to: '/websocket/websocket-connection', label: 'وبسوکت', position: 'left', activeBaseRegex: 'websocket/*' }, + { to: '/changelog', label: 'سابقه‌ی تغییرات', position: 'left' }, + { to: '/faq', label: 'سوالات متداول', position: 'left' }, + { to: '/general_notes', label: 'ملاحظات عمومی', position: 'left' }, + ], + }, + api: { + theme: { + codeSamplesLanguages: ['curl', 'python', 'go', 'javascript'], + }, + }, + languageTabs: [ + { + highlight: "python", + language: "python", + logoClass: "python", + }, + { + highlight: "javascript", + language: "nodejs", + logoClass: "nodejs", + }, + { + highlight: "go", + language: "go", + logoClass: "go", + }, + { + highlight: "java", + language: "java", + logoClass: "java", + }, + { + highlight: "bash", + language: "curl", + logoClass: "curl", + }, + ] + } satisfies Preset.ThemeConfig, + + plugins: [ + './plugins/docusaurus-plugin-custom-search', + [ + 'docusaurus-plugin-openapi-docs', + { + id: "api", + docsPluginId: "classic", + config: docsPluginConfigs() + }, + ] + ], + themes: ["docusaurus-theme-openapi-docs"], +} + +export default config diff --git a/font-selection.json b/font-selection.json deleted file mode 100755 index 5e78f5d..0000000 --- a/font-selection.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "IcoMoonType": "selection", - "icons": [ - { - "icon": { - "paths": [ - "M438.857 73.143q119.429 0 220.286 58.857t159.714 159.714 58.857 220.286-58.857 220.286-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857zM512 785.714v-108.571q0-8-5.143-13.429t-12.571-5.429h-109.714q-7.429 0-13.143 5.714t-5.714 13.143v108.571q0 7.429 5.714 13.143t13.143 5.714h109.714q7.429 0 12.571-5.429t5.143-13.429zM510.857 589.143l10.286-354.857q0-6.857-5.714-10.286-5.714-4.571-13.714-4.571h-125.714q-8 0-13.714 4.571-5.714 3.429-5.714 10.286l9.714 354.857q0 5.714 5.714 10t13.714 4.286h105.714q8 0 13.429-4.286t6-10z" - ], - "attrs": [], - "isMulticolor": false, - "tags": [ - "exclamation-circle" - ], - "defaultCode": 61546, - "grid": 14 - }, - "attrs": [], - "properties": { - "id": 100, - "order": 4, - "prevSize": 28, - "code": 58880, - "name": "exclamation-sign", - "ligatures": "" - }, - "setIdx": 0, - "iconIdx": 0 - }, - { - "icon": { - "paths": [ - "M585.143 786.286v-91.429q0-8-5.143-13.143t-13.143-5.143h-54.857v-292.571q0-8-5.143-13.143t-13.143-5.143h-182.857q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h54.857v182.857h-54.857q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h256q8 0 13.143-5.143t5.143-13.143zM512 274.286v-91.429q0-8-5.143-13.143t-13.143-5.143h-109.714q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h109.714q8 0 13.143-5.143t5.143-13.143zM877.714 512q0 119.429-58.857 220.286t-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857 220.286 58.857 159.714 159.714 58.857 220.286z" - ], - "attrs": [], - "isMulticolor": false, - "tags": [ - "info-circle" - ], - "defaultCode": 61530, - "grid": 14 - }, - "attrs": [], - "properties": { - "id": 85, - "order": 3, - "name": "info-sign", - "prevSize": 28, - "code": 58882 - }, - "setIdx": 0, - "iconIdx": 2 - }, - { - "icon": { - "paths": [ - "M733.714 419.429q0-16-10.286-26.286l-52-51.429q-10.857-10.857-25.714-10.857t-25.714 10.857l-233.143 232.571-129.143-129.143q-10.857-10.857-25.714-10.857t-25.714 10.857l-52 51.429q-10.286 10.286-10.286 26.286 0 15.429 10.286 25.714l206.857 206.857q10.857 10.857 25.714 10.857 15.429 0 26.286-10.857l310.286-310.286q10.286-10.286 10.286-25.714zM877.714 512q0 119.429-58.857 220.286t-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857 220.286 58.857 159.714 159.714 58.857 220.286z" - ], - "attrs": [], - "isMulticolor": false, - "tags": [ - "check-circle" - ], - "defaultCode": 61528, - "grid": 14 - }, - "attrs": [], - "properties": { - "id": 83, - "order": 9, - "prevSize": 28, - "code": 58886, - "name": "ok-sign" - }, - "setIdx": 0, - "iconIdx": 6 - }, - { - "icon": { - "paths": [ - "M658.286 475.429q0-105.714-75.143-180.857t-180.857-75.143-180.857 75.143-75.143 180.857 75.143 180.857 180.857 75.143 180.857-75.143 75.143-180.857zM950.857 950.857q0 29.714-21.714 51.429t-51.429 21.714q-30.857 0-51.429-21.714l-196-195.429q-102.286 70.857-228 70.857-81.714 0-156.286-31.714t-128.571-85.714-85.714-128.571-31.714-156.286 31.714-156.286 85.714-128.571 128.571-85.714 156.286-31.714 156.286 31.714 128.571 85.714 85.714 128.571 31.714 156.286q0 125.714-70.857 228l196 196q21.143 21.143 21.143 51.429z" - ], - "width": 951, - "attrs": [], - "isMulticolor": false, - "tags": [ - "search" - ], - "defaultCode": 61442, - "grid": 14 - }, - "attrs": [], - "properties": { - "id": 2, - "order": 1, - "prevSize": 28, - "code": 58887, - "name": "icon-search" - }, - "setIdx": 0, - "iconIdx": 7 - } - ], - "height": 1024, - "metadata": { - "name": "slate", - "license": "SIL OFL 1.1" - }, - "preferences": { - "showGlyphs": true, - "showQuickUse": true, - "showQuickUse2": true, - "showSVGs": true, - "fontPref": { - "prefix": "icon-", - "metadata": { - "fontFamily": "slate", - "majorVersion": 1, - "minorVersion": 0, - "description": "Based on FontAwesome", - "license": "SIL OFL 1.1" - }, - "metrics": { - "emSize": 1024, - "baseline": 6.25, - "whitespace": 50 - }, - "resetPoint": 58880, - "showSelector": false, - "selector": "class", - "classSelector": ".icon", - "showMetrics": false, - "showMetadata": true, - "showVersion": true, - "ie7": false - }, - "imagePref": { - "prefix": "icon-", - "png": true, - "useClassSelector": true, - "color": 4473924, - "bgColor": 16777215 - }, - "historySize": 100, - "showCodes": true, - "gridSize": 16, - "showLiga": false - } -} diff --git a/lib/monokai_sublime_slate.rb b/lib/monokai_sublime_slate.rb deleted file mode 100644 index cd2de33..0000000 --- a/lib/monokai_sublime_slate.rb +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- # -# frozen_string_literal: true - -# this is based on https://github.com/rouge-ruby/rouge/blob/master/lib/rouge/themes/monokai_sublime.rb -# but without the added background, and changed styling for JSON keys to be soft_yellow instead of white - -module Rouge - module Themes - class MonokaiSublimeSlate < CSSTheme - name 'monokai.sublime.slate' - - palette :black => '#000000' - palette :bright_green => '#a6e22e' - palette :bright_pink => '#f92672' - palette :carmine => '#960050' - palette :dark => '#49483e' - palette :dark_grey => '#888888' - palette :dark_red => '#aa0000' - palette :dimgrey => '#75715e' - palette :emperor => '#555555' - palette :grey => '#999999' - palette :light_grey => '#aaaaaa' - palette :light_violet => '#ae81ff' - palette :soft_cyan => '#66d9ef' - palette :soft_yellow => '#e6db74' - palette :very_dark => '#1e0010' - palette :whitish => '#f8f8f2' - palette :orange => '#f6aa11' - palette :white => '#ffffff' - - style Generic::Heading, :fg => :grey - style Literal::String::Regex, :fg => :orange - style Generic::Output, :fg => :dark_grey - style Generic::Prompt, :fg => :emperor - style Generic::Strong, :bold => false - style Generic::Subheading, :fg => :light_grey - style Name::Builtin, :fg => :orange - style Comment::Multiline, - Comment::Preproc, - Comment::Single, - Comment::Special, - Comment, :fg => :dimgrey - style Error, - Generic::Error, - Generic::Traceback, :fg => :carmine - style Generic::Deleted, - Generic::Inserted, - Generic::Emph, :fg => :dark - style Keyword::Constant, - Keyword::Declaration, - Keyword::Reserved, - Name::Constant, - Keyword::Type, :fg => :soft_cyan - style Literal::Number::Float, - Literal::Number::Hex, - Literal::Number::Integer::Long, - Literal::Number::Integer, - Literal::Number::Oct, - Literal::Number, - Literal::String::Char, - Literal::String::Escape, - Literal::String::Symbol, :fg => :light_violet - style Literal::String::Doc, - Literal::String::Double, - Literal::String::Backtick, - Literal::String::Heredoc, - Literal::String::Interpol, - Literal::String::Other, - Literal::String::Single, - Literal::String, :fg => :soft_yellow - style Name::Attribute, - Name::Class, - Name::Decorator, - Name::Exception, - Name::Function, :fg => :bright_green - style Name::Variable::Class, - Name::Namespace, - Name::Entity, - Name::Builtin::Pseudo, - Name::Variable::Global, - Name::Variable::Instance, - Name::Variable, - Text::Whitespace, - Text, - Name, :fg => :white - style Name::Label, :fg => :bright_pink - style Operator::Word, - Name::Tag, - Keyword, - Keyword::Namespace, - Keyword::Pseudo, - Operator, :fg => :bright_pink - end - end - end diff --git a/lib/multilang.rb b/lib/multilang.rb deleted file mode 100644 index 36fbe5b..0000000 --- a/lib/multilang.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Multilang - def block_code(code, full_lang_name) - if full_lang_name - parts = full_lang_name.split('--') - rouge_lang_name = (parts) ? parts[0] : "" # just parts[0] here causes null ref exception when no language specified - super(code, rouge_lang_name).sub("highlight #{rouge_lang_name}") do |match| - match + " tab-" + full_lang_name - end - else - super(code, full_lang_name) - end - end -end - -require 'middleman-core/renderers/redcarpet' -Middleman::Renderers::MiddlemanRedcarpetHTML.send :include, Multilang diff --git a/lib/nesting_unique_head.rb b/lib/nesting_unique_head.rb deleted file mode 100644 index 0127837..0000000 --- a/lib/nesting_unique_head.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Nested unique header generation -require 'middleman-core/renderers/redcarpet' - -class NestingUniqueHeadCounter < Middleman::Renderers::MiddlemanRedcarpetHTML - def initialize - super - @@headers_history = {} if !defined?(@@headers_history) - end - - def header(text, header_level) - friendly_text = text.gsub(/<[^>]*>/,"").parameterize - @@headers_history[header_level] = text.parameterize - - if header_level > 1 - for i in (header_level - 1).downto(1) - friendly_text.prepend("#{@@headers_history[i]}-") if @@headers_history.key?(i) - end - end - - return "#{text}" - end -end diff --git a/lib/toc_data.rb b/lib/toc_data.rb deleted file mode 100644 index 4a04efe..0000000 --- a/lib/toc_data.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'nokogiri' - -def toc_data(page_content) - html_doc = Nokogiri::HTML::DocumentFragment.parse(page_content) - - # get a flat list of headers - headers = [] - html_doc.css('h1, h2, h3').each do |header| - headers.push({ - id: header.attribute('id').to_s, - content: header.children, - title: header.children.to_s.gsub(/<[^>]*>/, ''), - level: header.name[1].to_i, - children: [] - }) - end - - [3,2].each do |header_level| - header_to_nest = nil - headers = headers.reject do |header| - if header[:level] == header_level - header_to_nest[:children].push header if header_to_nest - true - else - header_to_nest = header if header[:level] < header_level - false - end - end - end - headers -end diff --git a/lib/unique_head.rb b/lib/unique_head.rb deleted file mode 100644 index d42bab2..0000000 --- a/lib/unique_head.rb +++ /dev/null @@ -1,24 +0,0 @@ -# Unique header generation -require 'middleman-core/renderers/redcarpet' -require 'digest' -class UniqueHeadCounter < Middleman::Renderers::MiddlemanRedcarpetHTML - def initialize - super - @head_count = {} - end - def header(text, header_level) - friendly_text = text.gsub(/<[^>]*>/,"").parameterize - if friendly_text.strip.length == 0 - # Looks like parameterize removed the whole thing! It removes many unicode - # characters like Chinese and Russian. To get a unique URL, let's just - # URI escape the whole header - friendly_text = Digest::SHA1.hexdigest(text)[0,10] - end - @head_count[friendly_text] ||= 0 - @head_count[friendly_text] += 1 - if @head_count[friendly_text] > 1 - friendly_text += "-#{@head_count[friendly_text]}" - end - return "#{text}" - end -end diff --git a/openapi/address_book.yaml b/openapi/address_book.yaml new file mode 100644 index 0000000..e9c9759 --- /dev/null +++ b/openapi/address_book.yaml @@ -0,0 +1,308 @@ +openapi: 3.0.3 +info: + title: API دفتر آدرس نوبیتکس + version: "1.0.0" + description: | + APIهای مربوط به دفتر آدرس (Address Book) و حالت برداشت امن در نوبیتکس. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: دفتر آدرس + description: مدیریت دفتر آدرس و حالت برداشت امن + +paths: + /address_book: + get: + tags: + - دفتر آدرس + summary: مشاهده لیست آدرس‌های دفتر آدرس + description: | + لیست آدرس‌های ثبت‌شده در دفتر آدرس کاربر را برمی‌گرداند. + + **محدودیت فراخوانی:** ۲۰ درخواست در هر دقیقه + security: + - TokenAuth: [] + parameters: + - name: network + in: query + required: false + description: فیلتر بر اساس شبکه (مثلاً BSC) + schema: + type: string + example: BSC + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + data: + type: array + items: + $ref: "#/components/schemas/AddressBookEntry" + example: + status: ok + data: + - id: 3 + title: TetherBinance + network: BSC + address: 0000xxxx1111zzzz + createdAt: "2023-08-09T10:12:37+00:00" + - id: 4 + title: BinanceCoinOKX + network: BNB + address: 0000xxxx2222zzzz + tag: test17280992 + createdAt: "2023-08-09T10:26:12+00:00" + + post: + tags: + - دفتر آدرس + summary: اضافه کردن آدرس جدید به دفتر آدرس + description: | + یک آدرس جدید به دفتر آدرس کاربر اضافه می‌کند. + + **محدودیت فراخوانی:** ۶ درخواست در هر دقیقه + + برای دریافت `otpCode` باید ابتدا از `/v2/otp/request` با + `usage=address_book` استفاده شود. + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddAddressRequest" + example: + title: test + network: BSC + address: 0000xxxx1111zzzz + tag: test17280992 + otpCode: "123456" + tfaCode: "654321" + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + data: + $ref: "#/components/schemas/AddressBookEntry" + example: + status: ok + data: + id: 5 + title: test + network: BSC + address: 0000xxxx1111zzzz + createdAt: "2023-08-09T10:22:37+00:00" + "200_failed": + description: خطای منطقی با status=failed + content: + application/json: + schema: + $ref: "#/components/schemas/FailedResponse" + example: + status: failed + code: DuplicatedAddress + message: "آدرس قبلا ثبت شده و تکراری می باشد." + + /address_book/{address_id}/delete: + delete: + tags: + - دفتر آدرس + summary: حذف یک دفتر آدرس + description: | + یک آدرس ثبت‌شده در دفتر آدرس را با استفاده از شناسه آن حذف می‌کند. + + **محدودیت فراخوانی:** ۶ درخواست در هر دقیقه + security: + - TokenAuth: [] + parameters: + - name: address_id + in: path + required: true + description: شناسه آدرس در دفتر آدرس + schema: + type: integer + example: 5 + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: + status: ok + "200_failed": + description: خطای منطقی با status=failed + content: + application/json: + schema: + $ref: "#/components/schemas/FailedResponse" + example: + status: failed + code: NotFound + message: "آدرسی با این شناسه وجود ندارد." + + /address_book/whitelist/activate: + post: + tags: + - دفتر آدرس + summary: فعال کردن برداشت امن + description: | + حالت برداشت امن (Whitelist Mode) را فعال می‌کند. + در این حالت برداشت رمزارزی فقط به آدرس‌های موجود در دفتر آدرس مجاز است + (به جز برداشت در شبکه لایتنینگ). + + **محدودیت فراخوانی:** ۶ درخواست در هر دقیقه + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: + status: ok + + /address_book/whitelist/deactivate: + post: + tags: + - دفتر آدرس + summary: غیرفعال کردن برداشت امن + description: | + حالت برداشت امن را غیرفعال می‌کند. + پس از غیرفعال‌سازی، برای حفظ امنیت حساب، امکان برداشت به مدت ۲۴ ساعت + روی حساب کاربر محدود می‌شود. + + **محدودیت فراخوانی:** ۶ درخواست در هر دقیقه + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/DeactivateWhitelistRequest" + example: + otpCode: "1234" + tfaCode: "12345" + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: + status: ok + "200_failed": + description: خطای منطقی با status=failed + content: + application/json: + schema: + $ref: "#/components/schemas/FailedResponse" + example: + status: failed + code: InvalidOTP + message: "مقدار otp وارد شده نادرست است." + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + description: توکن احراز هویت به صورت `Token yourTOKENhereHEX0000` در هدر ارسال می‌شود. + + schemas: + AddressBookEntry: + type: object + properties: + id: + type: integer + title: + type: string + network: + type: string + address: + type: string + tag: + type: string + nullable: true + createdAt: + type: string + format: date-time + + AddAddressRequest: + type: object + required: + - title + - network + - address + - otpCode + - tfaCode + properties: + title: + type: string + network: + type: string + address: + type: string + tag: + type: string + description: تگ (در شبکه‌های تگ‌اجباری الزامی است) + otpCode: + type: string + description: کد تأیید ایمیل/پیامک + tfaCode: + type: string + description: کد تأیید دوعاملی (TOTP) + + DeactivateWhitelistRequest: + type: object + required: + - otpCode + - tfaCode + properties: + otpCode: + type: string + tfaCode: + type: string + + FailedResponse: + type: object + properties: + status: + type: string + example: failed + code: + type: string + message: + type: string \ No newline at end of file diff --git a/openapi/auth.yaml b/openapi/auth.yaml new file mode 100644 index 0000000..131ea5d --- /dev/null +++ b/openapi/auth.yaml @@ -0,0 +1,146 @@ +openapi: 3.0.3 +info: + title: API احراز هویت نوبیتکس + version: "1.0.0" + description: | + APIهای مربوط به احراز هویت (دریافت توکن و خروج/سوزاندن توکن) در نوبیتکس. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: احراز هویت + description: لاگین، دریافت توکن و خروج از حساب + +paths: + /auth/login/: + post: + tags: + - احراز هویت + summary: ورود - دریافت توکن + description: | + با ارسال نام کاربری، گذرواژه، کپچا و کد دوعاملی، توکن احراز هویت برمی‌گرداند. + + - تنها API‌ای است که لازم است یوزرنیم/پسورد به آن ارسال شود. + - توکن معمولی ۴ ساعت اعتبار دارد. + - با `remember=yes` می‌توان توکن ۳۰ روزه دریافت کرد. + - برای استفاده بدون کپچای تصویری، `captcha=api` و ارسال `X-TOTP` در هدر الزامی است. + - هدر `User-Agent` باید از الگوی `TraderBot/<نام نسخه و بات>` پیروی کند. + + **محدودیت فراخوانی:** ۳۰ درخواست در هر ۱۰ دقیقه + **نکته:** انتهای URL باید حتماً `/` داشته باشد. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/LoginRequest" + example: + username: name@example.com + password: secret-password-1234 + captcha: api + remember: yes + parameters: + - name: X-TOTP + in: header + required: true + description: کد دوعاملی + schema: + type: string + example: "123456" + - name: User-Agent + in: header + required: true + description: ایجنت بات، به‌صورت `TraderBot/` + schema: + type: string + example: TraderBot/1.0.0 + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/LoginResponse" + example: + status: success + key: db2055f743c1ac8c30d23278a496283b1e2dd46f + device: AlRyansW + + /auth/logout/: + post: + tags: + - احراز هویت + summary: خروج - سوزاندن توکن + description: | + توکن فعلی را باطل کرده و کاربر را از سیستم خارج می‌کند. + + پس از خروج، توکن دیگر معتبر نخواهد بود. + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/LogoutResponse" + example: + detail: "خروج با موفقیت انجام شد." + message: "خروج با موفقیت انجام شد." + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + description: توکن احراز هویت به صورت `Token yourTOKENhereHEX0000` در هدر ارسال می‌شود. + + schemas: + LoginRequest: + type: object + required: + - username + - password + - captcha + properties: + username: + type: string + description: ایمیل کاربر + example: name@example.com + password: + type: string + description: گذرواژه کاربر + example: secret-password-1234 + captcha: + type: string + description: مقدار کپچا (برای استفاده از API مقدار `api`) + example: api + remember: + type: string + description: آیا توکن بلندمدت (۳۰ روزه) صادر شود؟ (`yes`/`no`) + default: no + example: yes + + LoginResponse: + type: object + properties: + status: + type: string + example: success + key: + type: string + description: توکن احراز هویت + device: + type: string + description: شناسه دستگاه + + LogoutResponse: + type: object + properties: + detail: + type: string + message: + type: string \ No newline at end of file diff --git a/openapi/margin_trade.yaml b/openapi/margin_trade.yaml new file mode 100644 index 0000000..8eb4347 --- /dev/null +++ b/openapi/margin_trade.yaml @@ -0,0 +1,559 @@ +openapi: 3.0.3 +info: + title: API معاملات تعهدی نوبیتکس + version: "1.0.0" + description: | + APIهای مربوط به معاملات تعهدی (Margin)، استخرهای مشارکت، انتقال به کیف‌پول تعهدی، + سفارش‌گذاری تعهدی و مدیریت موقعیت‌ها. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: معاملات تعهدی + description: بازار تعهدی، استخرها، سفارش‌ها و موقعیت‌ها + +paths: + /margin/markets/list: + get: + tags: + - معاملات تعهدی + summary: مشاهده بازارهای معاملات تعهدی + description: | + لیست بازارهای پشتیبانی‌شده برای معاملات تعهدی (Margin) را برمی‌گرداند. + + - محدودیت فراخوانی: ۳۰ درخواست در دقیقه + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + markets: + type: object + additionalProperties: + $ref: "#/components/schemas/MarginMarketSetting" + + /liquidity-pools/list: + get: + tags: + - معاملات تعهدی + summary: مشاهده استخرهای مشارکت ارزی فعال + description: | + استخرهای مشارکت موجود برای معاملات تعهدی و ظرفیت آن‌ها. + + - محدودیت فراخوانی: ۱۲ درخواست در دقیقه + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + pools: + type: object + additionalProperties: + $ref: "#/components/schemas/LiquidityPool" + + /wallets/transfer: + post: + tags: + - معاملات تعهدی + summary: انتقال پول به/از کیف‌پول تعهدی + description: | + انتقال وجه بین کیف‌پول اسپات و کیف‌پول تعهدی. + + - محدودیت فراخوانی: ۱۰ درخواست در دقیقه + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/WalletTransferRequest" + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/WalletTransferResponse" + - $ref: "#/components/schemas/MarginFailedResponse" + + /margin/delegation-limit: + get: + tags: + - معاملات تعهدی + summary: دریافت محدودیت کاربری در مقدار وکالت + description: | + حداکثر مقدار وکالت مجاز برای رمزارز مشخص را برمی‌گرداند. + + - محدودیت فراخوانی: ۱۲ درخواست در دقیقه + security: + - TokenAuth: [] + parameters: + - name: currency + in: query + required: true + schema: + type: string + description: رمزارز مبدا بازار + example: btc + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + example: ok + limit: + type: string + example: "0.039062" + - $ref: "#/components/schemas/MarginFailedResponse" + + /margin/orders/add: + post: + tags: + - معاملات تعهدی + summary: درج سفارش تعهدی + description: | + ثبت سفارش در بازار تعهدی (شامل OCO). + + - محدودیت فراخوانی: ۳۰۰ درخواست در ۱۰ دقیقه + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/MarginOrderAddRequest" + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/MarginOrderAddResponseSingle" + - $ref: "#/components/schemas/MarginOrderAddResponseOCO" + - $ref: "#/components/schemas/MarginFailedResponse" + + /positions/list: + get: + tags: + - معاملات تعهدی + summary: مشاهده لیست موقعیت‌ها + description: | + لیست موقعیت‌های باز (`active`) و تاریخچه موقعیت‌های بسته (`past`). + + - محدودیت فراخوانی: ۳۰ درخواست در دقیقه + - صفحه‌بندی: دارد (پیش‌فرض ۵۰) + security: + - TokenAuth: [] + parameters: + - name: srcCurrency + in: query + schema: + type: string + - name: dstCurrency + in: query + schema: + type: string + - name: status + in: query + schema: + type: string + default: active + enum: [active, past] + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + positions: + type: array + items: + $ref: "#/components/schemas/Position" + hasNext: + type: boolean + + /positions/{positionId}/status: + get: + tags: + - معاملات تعهدی + summary: مشاهده یک موقعیت + description: | + وضعیت یک موقعیت تعهدی خاص را برمی‌گرداند. + + - محدودیت فراخوانی: ۱۰۰ درخواست در ۱۰ دقیقه + security: + - TokenAuth: [] + parameters: + - name: positionId + in: path + required: true + schema: + type: integer + example: 128 + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + position: + $ref: "#/components/schemas/Position" + + /positions/{positionId}/close: + post: + tags: + - معاملات تعهدی + summary: بستن موقعیت + description: | + ثبت سفارش در جهت عکس برای تسویه تعهد و بستن موقعیت. + + - محدودیت فراخوانی: ۳۰۰ درخواست در ۱۰ دقیقه + security: + - TokenAuth: [] + parameters: + - name: positionId + in: path + required: true + schema: + type: integer + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/PositionCloseRequest" + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/MarginOrder" + - $ref: "#/components/schemas/MarginFailedResponse" + + /positions/{positionId}/edit-collateral: + post: + tags: + - معاملات تعهدی + summary: ویرایش وجه تضمین موقعیت باز + description: | + افزایش یا کاهش وجه تضمین یک موقعیت باز. + + - محدودیت فراخوانی: ۶۰ درخواست در دقیقه + security: + - TokenAuth: [] + parameters: + - name: positionId + in: path + required: true + schema: + type: integer + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - collateral + properties: + collateral: + type: string + description: وجه تضمین جدید + example: "230000" + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + example: ok + position: + $ref: "#/components/schemas/Position" + - $ref: "#/components/schemas/MarginFailedResponse" + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + + schemas: + MarginMarketSetting: + type: object + properties: + srcCurrency: + type: string + dstCurrency: + type: string + positionFeeRate: + type: string + maxLeverage: + type: string + sellEnabled: + type: boolean + buyEnabled: + type: boolean + + LiquidityPool: + type: object + properties: + capacity: + type: string + filledCapacity: + type: string + + WalletTransferRequest: + type: object + required: + - currency + - amount + - src + - dst + properties: + currency: + type: string + amount: + type: string + src: + type: string + enum: [spot, margin] + dst: + type: string + enum: [spot, margin] + + WalletTransferResponse: + type: object + properties: + status: + type: string + srcWallet: + type: object + dstWallet: + type: object + + MarginOrderAddRequest: + type: object + properties: + execution: + type: string + default: limit + srcCurrency: + type: string + dstCurrency: + type: string + type: + type: string + default: sell + leverage: + type: string + default: "1" + amount: + type: string + price: + type: string + stopPrice: + type: string + mode: + type: string + stopLimitPrice: + type: string + + MarginOrder: + type: object + properties: + id: + type: integer + type: + type: string + execution: + type: string + tradeType: + type: string + srcCurrency: + type: string + dstCurrency: + type: string + price: + type: string + amount: + type: string + status: + type: string + totalOrderPrice: + type: string + matchedAmount: + type: string + unmatchedAmount: + type: string + leverage: + type: string + side: + type: string + created_at: + type: string + format: date-time + + MarginOrderAddResponseSingle: + type: object + properties: + status: + type: string + order: + $ref: "#/components/schemas/MarginOrder" + + MarginOrderAddResponseOCO: + type: object + properties: + status: + type: string + orders: + type: array + items: + $ref: "#/components/schemas/MarginOrder" + + Position: + type: object + properties: + id: + type: integer + createdAt: + type: string + srcCurrency: + type: string + dstCurrency: + type: string + side: + type: string + status: + type: string + marginType: + type: string + collateral: + type: string + leverage: + type: string + openedAt: + type: string + closedAt: + type: string + nullable: true + liquidationPrice: + type: string + entryPrice: + type: string + exitPrice: + type: string + nullable: true + delegatedAmount: + type: string + nullable: true + liability: + type: string + nullable: true + totalAsset: + type: string + nullable: true + marginRatio: + type: string + nullable: true + liabilityInOrder: + type: string + nullable: true + assetInOrder: + type: string + nullable: true + unrealizedPNL: + type: string + nullable: true + unrealizedPNLPercent: + type: string + nullable: true + expirationDate: + type: string + nullable: true + extensionFee: + type: string + nullable: true + markPrice: + type: string + nullable: true + PNL: + type: string + nullable: true + PNLPercent: + type: string + nullable: true + + PositionCloseRequest: + type: object + properties: + execution: + type: string + default: limit + amount: + type: string + price: + type: string + stopPrice: + type: string + mode: + type: string + stopLimitPrice: + type: string + + MarginFailedResponse: + type: object + properties: + status: + type: string + example: failed + code: + type: string + message: + type: string \ No newline at end of file diff --git a/openapi/market_data.yaml b/openapi/market_data.yaml new file mode 100644 index 0000000..43ef42f --- /dev/null +++ b/openapi/market_data.yaml @@ -0,0 +1,299 @@ +openapi: 3.0.3 +info: + title: API اطلاعات بازار نوبیتکس + version: "1.0.0" + description: | + APIهای عمومی بازار نوبیتکس شامل دفتر سفارشات، عمق بازار، معاملات اخیر، + آمار بازار و داده‌های OHLC. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: اطلاعات بازار + description: تمامی متدهای عمومی مربوط به داده‌های بازار + +paths: + /v2/orderbook: + get: + tags: + - اطلاعات بازار + summary: دریافت دفتر سفارشات + description: دفتر سفارشات (صف خرید و فروش) یک بازار مشخص را برمی‌گرداند. + parameters: + - name: symbol + in: query + required: true + description: نماد بازار (BTCIRT). + schema: + type: string + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/OrderBookResponse" + + /v2/orderbook/depth: + get: + tags: + - اطلاعات بازار + summary: دریافت عمق بازار + description: عمق بازار (تجمیع سفارشات در سطوح قیمتی) را برمی‌گرداند. + parameters: + - name: symbol + in: query + required: true + schema: + type: string + - name: limit + in: query + required: false + schema: + type: integer + default: 50 + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/DepthResponse" + + /v2/trades: + get: + tags: + - اطلاعات بازار + summary: دریافت معاملات اخیر + description: لیست آخرین معاملات انجام‌شده برای یک بازار مشخص را برمی‌گرداند. + parameters: + - name: symbol + in: query + required: true + schema: + type: string + - name: limit + in: query + required: false + schema: + type: integer + default: 50 + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/TradesResponse" + + /v2/statistics/market: + get: + tags: + - اطلاعات بازار + summary: آمار بازار (تک نماد) + description: آمار بازار مانند آخرین قیمت، کمترین/بیشترین قیمت و حجم برای یک نماد را برمی‌گرداند. + parameters: + - name: symbol + in: query + required: true + schema: + type: string + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/MarketStatsResponse" + + /v2/statistics/markets: + get: + tags: + - اطلاعات بازار + summary: آمار بازار (چند نماد) + description: آمار چند بازار را به صورت همزمان برمی‌گرداند. + parameters: + - name: symbols + in: query + required: true + description: لیست نمادها به صورت جداشده با کاما (BTCIRT,ETHUSDT). + schema: + type: string + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/MarketsStatsResponse" + + /v2/ohlc: + get: + tags: + - اطلاعات بازار + summary: دریافت داده‌های OHLC + description: داده‌های کندل (Open, High, Low, Close) برای یک بازار در بازه‌های زمانی مختلف. + parameters: + - name: symbol + in: query + required: true + schema: + type: string + - name: resolution + in: query + required: true + description: تایم‌فریم (مثال:1, 5, 15, 60, 240, 1D و ...). + schema: + type: string + - name: from + in: query + required: true + description: زمان شروع به صورت timestamp (ثانیه). + schema: + type: integer + - name: to + in: query + required: true + description: زمان پایان به صورت timestamp (ثانیه). + schema: + type: integer + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/OHLCResponse" + +components: + schemas: + OrderBookResponse: + type: object + properties: + status: + type: string + bids: + type: array + items: + type: array + items: + type: string + asks: + type: array + items: + type: array + items: + type: string + + DepthResponse: + type: object + properties: + status: + type: string + bids: + type: array + items: + type: object + properties: + price: + type: string + volume: + type: string + asks: + type: array + items: + type: object + properties: + price: + type: string + volume: + type: string + + TradesResponse: + type: object + properties: + status: + type: string + trades: + type: array + items: + type: object + properties: + time: + type: integer + price: + type: string + volume: + type: string + side: + type: string + + MarketStatsResponse: + type: object + properties: + status: + type: string + stats: + type: object + additionalProperties: + type: object + properties: + latest: + type: string + dayLow: + type: string + dayHigh: + type: string + dayVolume: + type: string + + MarketsStatsResponse: + type: object + properties: + status: + type: string + stats: + type: object + additionalProperties: + type: object + properties: + latest: + type: string + dayLow: + type: string + dayHigh: + type: string + dayVolume: + type: string + + OHLCResponse: + type: object + properties: + status: + type: string + t: + type: array + items: + type: integer + o: + type: array + items: + type: string + h: + type: array + items: + type: string + l: + type: array + items: + type: string + c: + type: array + items: + type: string + v: + type: array + items: + type: string \ No newline at end of file diff --git a/openapi/options.yaml b/openapi/options.yaml new file mode 100644 index 0000000..045213d --- /dev/null +++ b/openapi/options.yaml @@ -0,0 +1,299 @@ +openapi: 3.0.3 +info: + title: API تنظیمات سیستم نوبیتکس + version: "1.0.0" + description: | + API تنظیمات عمومی سیستم نوبیتکس شامل رمزارزها، شبکه‌ها، حداقل سفارش‌ها، + دقت قیمت و مقدار، سقف برداشت و سایر گزینه‌ها. + x-logo: + url: 'https://nobitex.ir/logo.png' + altText: Nobitex + +servers: + - url: https://apiv2.nobitex.ir + description: Production Server + - url: https://testnetapiv2.nobitex.ir + description: Testnet Server + +tags: + - name: system-options + x-displayName: تنظیمات سیستم + description: مشاهده تنظیمات عمومی بازار و رمزارزها + +x-tagGroups: + - name: تنظیمات + tags: + - system-options + +paths: + /v2/options: + get: + tags: + - system-options + summary: تنظیمات سیستم + operationId: getSystemOptions + description: | + تنظیمات کلی سیستم نوبیتکس را برمی‌گرداند. + + - شامل: + - لیست رمزارزها و شبکه‌های آن‌ها + - حداقل سفارش‌ها + - دقت قیمت و مقدار در بازارها + - سقف‌های برداشت در سطوح مختلف + - لیست رمزارزهای فعال، برتر، در حال تست و ... + - نیاز به توکن: ندارد + - پارامتر ورودی: ندارد + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + features: + $ref: "#/components/schemas/Features" + coins: + type: array + items: + $ref: "#/components/schemas/CoinOptions" + nobitex: + $ref: "#/components/schemas/NobitexOptions" + example: + status: ok + features: + fcmEnabled: true + chat: "enabled" + walletsToNet: true + autoKYC: true + enabledFeatures: ["feature1", "feature2"] + betaFeatures: ["beta1"] + coins: + - coin: rls + name: Rial + defaultNetwork: FIAT_MONEY + displayPrecision: "10" + stdName: "﷼" + networkList: + FIAT_MONEY: + network: FIAT_MONEY + name: FIAT + isDefault: true + beta: false + depositEnable: true + minConfirm: 0 + withdrawEnable: true + nobitex: + allCurrencies: ["btc", "eth", "usdt"] + activeCurrencies: ["btc", "eth"] + topCurrencies: ["btc"] + +components: + schemas: + Features: + type: object + description: ویژگی‌های فعال سیستم + properties: + fcmEnabled: + type: boolean + description: فعال بودن Firebase Cloud Messaging + example: true + chat: + type: string + description: وضعیت چت + example: "enabled" + walletsToNet: + type: boolean + description: امکان انتقال از کیف پول به شبکه + example: true + autoKYC: + type: boolean + description: احراز هویت خودکار + example: true + enabledFeatures: + type: array + description: لیست ویژگی‌های فعال + items: + type: string + example: ["feature1", "feature2"] + betaFeatures: + type: array + description: لیست ویژگی‌های بتا + items: + type: string + example: ["beta1", "beta2"] + + CoinOptions: + type: object + description: تنظیمات یک رمزارز + properties: + coin: + type: string + description: نماد رمزارز + example: rls + name: + type: string + description: نام رمزارز + example: Rial + defaultNetwork: + type: string + description: شبکه پیش‌فرض + example: FIAT_MONEY + displayPrecision: + type: string + description: دقت نمایش + example: "10" + stdName: + type: string + description: نماد استاندارد + example: "﷼" + networkList: + type: object + description: لیست شبکه‌های پشتیبانی شده + additionalProperties: + $ref: "#/components/schemas/NetworkOptions" + + NetworkOptions: + type: object + description: تنظیمات یک شبکه + properties: + network: + type: string + description: نام شبکه + example: FIAT_MONEY + name: + type: string + description: نام نمایشی شبکه + example: FIAT + isDefault: + type: boolean + description: آیا شبکه پیش‌فرض است + example: true + beta: + type: boolean + description: آیا در حالت بتا است + example: false + addressRegex: + type: string + description: الگوی regex برای آدرس + example: "^[a-zA-Z0-9]+$" + memoRequired: + type: boolean + description: آیا memo الزامی است + example: false + memoRegex: + type: string + description: الگوی regex برای memo + example: "^[0-9]+$" + depositEnable: + type: boolean + description: امکان واریز + example: true + minConfirm: + type: integer + description: حداقل تأییدیه برای واریز + example: 6 + depositInfo: + type: object + description: اطلاعات اضافی واریز + additionalProperties: + type: object + withdrawEnable: + type: boolean + description: امکان برداشت + example: true + withdrawIntegerMultiple: + type: string + description: مضرب صحیح برداشت + example: "1" + withdrawFee: + type: string + description: کارمزد برداشت + example: "0.0005" + withdrawMin: + type: string + description: حداقل برداشت + example: "0.001" + withdrawMax: + type: string + description: حداکثر برداشت + example: "100" + + NobitexOptions: + type: object + description: تنظیمات عمومی نوبیتکس + properties: + allCurrencies: + type: array + description: تمام رمزارزها + items: + type: string + example: ["btc", "eth", "usdt", "xrp"] + activeCurrencies: + type: array + description: رمزارزهای فعال + items: + type: string + example: ["btc", "eth", "usdt"] + xchangeCurrencies: + type: array + description: رمزارزهای قابل تبادل + items: + type: string + example: ["btc", "eth"] + topCurrencies: + type: array + description: رمزارزهای برتر + items: + type: string + example: ["btc", "eth"] + testingCurrencies: + type: array + description: رمزارزهای در حال تست + items: + type: string + example: ["newcoin"] + withdrawLimits: + type: object + description: محدودیت‌های برداشت بر اساس سطح کاربری + additionalProperties: + type: object + example: + level1: + daily: "10000000" + monthly: "100000000" + minOrders: + type: object + description: حداقل مقدار سفارش برای هر بازار + additionalProperties: + type: string + example: + btc-irt: "50000" + eth-irt: "50000" + amountPrecisions: + type: object + description: دقت مقدار برای هر بازار + additionalProperties: + type: string + example: + btc-irt: "8" + eth-irt: "8" + pricePrecisions: + type: object + description: دقت قیمت برای هر بازار + additionalProperties: + type: string + example: + btc-irt: "0" + eth-irt: "0" + giftCard: + type: object + description: تنظیمات کارت هدیه + properties: + physicalFee: + type: string + description: کارمزد کارت فیزیکی + example: "50000" \ No newline at end of file diff --git a/openapi/portfolio.yaml b/openapi/portfolio.yaml new file mode 100644 index 0000000..0358500 --- /dev/null +++ b/openapi/portfolio.yaml @@ -0,0 +1,211 @@ +openapi: 3.0.3 +info: + title: API سود و زیان نوبیتکس + version: "1.0.0" + description: | + APIهای مربوط به پرتفو و گزارش سود و زیان کاربر در نوبیتکس. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: سود و زیان + description: گزارش‌های پرتفو و سود و زیان کاربر + +paths: + /users/portfolio/last-week-daily-profit: + post: + tags: + - سود و زیان + summary: سود و زیان روزانه هفته گذشته + description: | + گزارش سود و زیان روزانه هفته گذشته (یا ۳۰ روز گذشته در صورت monthly=true). + + - محدودیت فراخوانی: ۱۰ درخواست در ۳ دقیقه + - در صورت غیرفعال بودن پرتفو، خطای `PortfolioDisabled` برمی‌گردد. + security: + - TokenAuth: [] + requestBody: + required: false + content: + application/json: + schema: + type: object + properties: + monthly: + type: boolean + description: اگر true باشد، گزارش ۳۰ روز گذشته برمی‌گردد. + default: false + example: true + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + data: + type: array + items: + $ref: "#/components/schemas/DailyProfit" + example: + status: ok + data: + - report_date: "2021-07-05" + total_profit: "0E-10" + total_profit_percentage: "0E-10" + total_balance: "4516559.920590000" + "200_failure": + description: پاسخ ناموفق (status=failed) + content: + application/json: + schema: + $ref: "#/components/schemas/PortfolioFailedResponse" + examples: + disabled: + summary: پرتفو غیرفعال + value: + status: failed + code: PortfolioDisabled + message: "Portfolio feature is not available for your user." + no_data: + summary: بدون داده + value: + status: failed + code: LastWeekDailyProfitFail + message: "اطلاعاتی جهت نمایش وجود ندارد" + + /users/portfolio/last-week-daily-total-profit: + post: + tags: + - سود و زیان + summary: سود و زیان کل به صورت روزانه در هفته گذشته + description: | + سود و زیان کل پرتفو به تفکیک روز، برای هفته گذشته. + + - محدودیت فراخوانی: ۱۰ درخواست در ۳ دقیقه + security: + - TokenAuth: [] + requestBody: + required: false + content: + application/json: + schema: + type: object + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + data: + type: array + items: + $ref: "#/components/schemas/DailyTotalProfit" + "200_failure": + description: پاسخ ناموفق (status=failed) + content: + application/json: + schema: + $ref: "#/components/schemas/PortfolioFailedResponse" + + /users/portfolio/last-month-total-profit: + post: + tags: + - سود و زیان + summary: سود و زیان کل ماه گذشته + description: | + سود و زیان کل پرتفو در ماه گذشته. + + - محدودیت فراخوانی: ۱۰ درخواست در ۳ دقیقه + security: + - TokenAuth: [] + requestBody: + required: false + content: + application/json: + schema: + type: object + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + data: + $ref: "#/components/schemas/MonthlyTotalProfit" + "200_failure": + description: پاسخ ناموفق (status=failed) + content: + application/json: + schema: + $ref: "#/components/schemas/PortfolioFailedResponse" + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + description: توکن احراز هویت به صورت `Token yourTOKENhereHEX0000`. + + schemas: + DailyProfit: + type: object + properties: + report_date: + type: string + format: date + total_profit: + type: string + total_profit_percentage: + type: string + total_balance: + type: string + + DailyTotalProfit: + type: object + properties: + report_date: + type: string + format: date + total_profit: + type: string + total_profit_percentage: + type: string + + MonthlyTotalProfit: + type: object + properties: + total_profit: + type: string + total_profit_percentage: + type: string + + PortfolioFailedResponse: + type: object + properties: + status: + type: string + example: failed + code: + type: string + example: PortfolioDisabled + message: + type: string + example: "Portfolio feature is not available for your user." \ No newline at end of file diff --git a/openapi/referral.yaml b/openapi/referral.yaml new file mode 100644 index 0000000..8125c13 --- /dev/null +++ b/openapi/referral.yaml @@ -0,0 +1,220 @@ +openapi: 3.0.3 +info: + title: API طرح معرفی دوستان نوبیتکس + version: "1.0.0" + description: | + APIهای مربوط به کد دعوت، لینک‌های دعوت و وضعیت معرفی دوستان. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: معرفی دوستان + description: مدیریت کدها و وضعیت طرح معرفی دوستان + +paths: + /users/referral/links-list: + post: + tags: + - معرفی دوستان + summary: فهرست کدهای دعوت + description: | + لیست کدهای دعوت (Referral Links) کاربر و آمار مربوط به هر کدام را برمی‌گرداند. + + - محدودیت فراخوانی: ۵۰ درخواست در هر ۱۰ دقیقه + security: + - TokenAuth: [] + requestBody: + required: false + content: + application/json: + schema: + type: object + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + links: + type: array + items: + $ref: "#/components/schemas/ReferralLink" + + /users/referral/links-add: + post: + tags: + - معرفی دوستان + summary: ایجاد کد دعوت + description: | + ایجاد یک کد دعوت جدید برای کاربر. + + - محدودیت فراخوانی: ۵ درخواست در دقیقه + security: + - TokenAuth: [] + requestBody: + required: false + content: + application/json: + schema: + type: object + properties: + friendShare: + type: integer + description: سهم کارمزد اهدایی به دوست دعوت‌شده + default: 0 + example: 10 + responses: + "200": + description: موفق (کد دعوت ایجاد شد) + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + link: + $ref: "#/components/schemas/ReferralLink" + "200_failure": + description: پاسخ ناموفق (status=failed) + content: + application/json: + schema: + $ref: "#/components/schemas/ReferralFailedResponse" + + /users/referral/referral-status: + post: + tags: + - معرفی دوستان + summary: وضعیت دعوت کاربر + description: | + بررسی می‌کند آیا کاربر فعلی توسط کاربر دیگری دعوت شده است یا خیر. + + - محدودیت فراخوانی: ۵۰ درخواست در هر ۱۰ دقیقه + security: + - TokenAuth: [] + requestBody: + required: false + content: + application/json: + schema: + type: object + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + hasReferrer: + type: boolean + example: true + + /users/referral/set-referrer: + post: + tags: + - معرفی دوستان + summary: ثبت معرف کاربر + description: | + ثبت کد معرف برای کاربر فعلی (تا ۲۴ ساعت پس از ثبت‌نام). + + - محدودیت فراخوانی: ۵۰ درخواست در هر ۱۰ دقیقه + - در صورت گذشت بیش از ۲۴ ساعت، خطای `ReferrerChangeUnavailable` برمی‌گردد. + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - referrerCode + properties: + referrerCode: + type: string + description: کد دعوت کاربر دعوت‌کننده + example: "40404" + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + "200_failure": + description: پاسخ ناموفق (status=failed) + content: + application/json: + schema: + $ref: "#/components/schemas/ReferralFailedResponse" + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + + schemas: + ReferralLink: + type: object + properties: + id: + type: integer + example: 1001 + referralCode: + type: string + example: "40404" + createdAt: + type: string + format: date-time + example: "2020-07-15T11:32:38.326809+00:00" + userShare: + type: integer + example: 20 + friendShare: + type: integer + example: 10 + description: + type: string + example: "Shared on Instagram page X" + statsRegisters: + type: integer + example: 20 + statsTrades: + type: integer + example: 240 + statsProfit: + type: string + description: درآمد ریالی از این کد دعوت + example: "320000" + + ReferralFailedResponse: + type: object + properties: + status: + type: string + example: failed + code: + type: string + example: InvalidGivebackShare + message: + type: string + example: "Human readable error message" \ No newline at end of file diff --git a/openapi/security.yaml b/openapi/security.yaml new file mode 100644 index 0000000..16f50e3 --- /dev/null +++ b/openapi/security.yaml @@ -0,0 +1,182 @@ +openapi: 3.0.3 +info: + title: API امنیت نوبیتکس + version: "1.0.0" + description: | + APIهای امنیتی شامل سابقه ورود، لغو اضطراری برداشت و کد آنتی‌فیشینگ. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: امنیت + description: سابقه ورود، لغو اضطراری، آنتی‌فیشینگ + +paths: + /users/login-attempts: + get: + tags: + - امنیت + summary: سابقه ورود + description: | + لیست تلاش‌های ورود اخیر کاربر را برمی‌گرداند. + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + attempts: + type: array + items: + $ref: "#/components/schemas/LoginAttempt" + + /security/emergency-cancel/activate: + get: + tags: + - امنیت + summary: فعال‌سازی لغو اضطراری برداشت + description: | + امکان لغو اضطراری برداشت را فعال می‌کند. + + پس از فعال‌سازی، لینک لغو در ایمیل/پیامک برداشت‌ها ارسال می‌شود. + در صورت لغو برداشت از این طریق، تا ۷۲ ساعت امکان ثبت برداشت غیرفعال می‌شود. + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + cancelCode: + type: object + properties: + code: + type: string + example: seJlef35L3 + + /security/anti-phishing: + post: + tags: + - امنیت + summary: ایجاد/ویرایش کد آنتی‌فیشینگ + description: | + ایجاد یا تغییر کد آنتی‌فیشینگ کاربر. + + - برای استفاده، نیاز به OTP دارد. + - محدودیت فراخوانی: ۱۰ درخواست در دقیقه + security: + - TokenAuth: [] + requestBody: + required: true + content: + multipart/form-data: + schema: + type: object + required: + - code + - otpCode + properties: + code: + type: string + description: کد آنتی‌فیشینگ انتخابی کاربر + example: sample_anti_phishing + otpCode: + type: string + description: کد یکبارمصرف ارسال‌شده + example: "123456" + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + "200_failure": + description: پاسخ ناموفق + content: + application/json: + schema: + $ref: "#/components/schemas/SecurityFailedResponse" + + get: + tags: + - امنیت + summary: دریافت کد آنتی‌فیشینگ + description: | + کد آنتی‌فیشینگ کاربر (در صورت تنظیم) را برمی‌گرداند. + + - محدودیت فراخوانی: ۱۰ درخواست در دقیقه + security: + - TokenAuth: [] + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + example: ok + antiPhishingCode: + type: string + example: "s****g" + - $ref: "#/components/schemas/SecurityFailedResponse" + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + + schemas: + LoginAttempt: + type: object + properties: + ip: + type: string + example: "46.209.130.106" + username: + type: string + example: "name@example.com" + status: + type: string + example: Successful + createdAt: + type: string + format: date-time + + SecurityFailedResponse: + type: object + properties: + status: + type: string + example: failed + code: + type: string + example: InvalidOTPCode + message: + type: string + example: "Code length must be between 4 and 15 characters" \ No newline at end of file diff --git a/openapi/spot_trade.yaml b/openapi/spot_trade.yaml new file mode 100644 index 0000000..1112da8 --- /dev/null +++ b/openapi/spot_trade.yaml @@ -0,0 +1,454 @@ +openapi: 3.0.3 +info: + title: API معاملات اسپات نوبیتکس + version: "1.0.0" + description: | + APIهای سفارش‌گذاری، مشاهده و لغو سفارشات و لیست معاملات کاربر در بازار اسپات. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: معاملات اسپات + description: سفارش‌گذاری و معاملات بازار اسپات + +paths: + /market/orders/add: + post: + tags: + - معاملات اسپات + summary: ثبت سفارش جدید اسپات + description: | + ثبت سفارش خرید/فروش در بازار اسپات (Limit, Market, Stop, OCO). + + - محدودیت مشترک سفارش‌گذاری: ۳۰۰ درخواست در ۱۰ دقیقه + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/SpotOrderAddRequest" + responses: + "200": + description: موفق + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/SpotOrderAddResponseSingle" + - $ref: "#/components/schemas/SpotOrderAddResponseOCO" + "200_failure": + description: پاسخ ناموفق + content: + application/json: + schema: + $ref: "#/components/schemas/SpotOrderFailedResponse" + + /market/orders/status: + post: + tags: + - معاملات اسپات + summary: مشاهده وضعیت سفارش + description: | + وضعیت یک سفارش را بر اساس `id` یا `clientOrderId` برمی‌گرداند. + + - محدودیت فراخوانی: ۳۰۰ درخواست در دقیقه + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + id: + type: integer + description: شناسه سفارش + example: 5684 + clientOrderId: + type: string + description: شناسه سفارشی که کاربر تعیین کرده است + example: "order1" + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + example: ok + order: + $ref: "#/components/schemas/SpotOrder" + - $ref: "#/components/schemas/SpotOrderFailedResponse" + + /market/orders/list: + get: + tags: + - معاملات اسپات + summary: فهرست سفارش‌های کاربر + description: | + فهرست سفارش‌های کاربر با فیلترها و صفحه‌بندی. + + - محدودیت فراخوانی: ۳۰ درخواست در دقیقه + - صفحه‌بندی: دارد (پیش‌فرض ۱۰۰) + security: + - TokenAuth: [] + parameters: + - name: status + in: query + schema: + type: string + default: open + enum: [all, open, done, close] + - name: type + in: query + schema: + type: string + enum: [buy, sell] + - name: execution + in: query + schema: + type: string + enum: [limit, market, stop_limit, stop_market] + - name: tradeType + in: query + schema: + type: string + enum: [spot, margin] + - name: srcCurrency + in: query + schema: + type: string + - name: dstCurrency + in: query + schema: + type: string + - name: details + in: query + schema: + type: integer + default: 1 + - name: fromId + in: query + schema: + type: integer + - name: order + in: query + schema: + type: string + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + orders: + type: array + items: + $ref: "#/components/schemas/SpotOrder" + + /market/orders/update-status: + post: + tags: + - معاملات اسپات + summary: تغییر وضعیت سفارش (لغو/فعال‌سازی) + description: | + تغییر وضعیت یک سفارش (مثلاً لغو کردن). + + - محدودیت فراخوانی: ۹۰ درخواست در دقیقه + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - status + properties: + order: + type: integer + description: شناسه سفارش + example: 5684 + clientOrderId: + type: string + description: شناسه سفارشی کاربر + example: "order1" + status: + type: string + description: وضعیت جدید + example: canceled + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + example: ok + updatedStatus: + type: string + example: Canceled + order: + $ref: "#/components/schemas/SpotOrder" + - $ref: "#/components/schemas/SpotOrderFailedResponse" + + /market/orders/cancel-old: + post: + tags: + - معاملات اسپات + summary: لغو جمعی سفارشات قدیمی + description: | + لغو دسته‌جمعی سفارشات فعال با فیلترهای زمانی و بازار. + + - محدودیت فراخوانی: ۳۰ درخواست در دقیقه + security: + - TokenAuth: [] + requestBody: + required: false + content: + application/json: + schema: + type: object + properties: + hours: + type: number + description: سفارش‌های قدیمی‌تر از این تعداد ساعت لغو می‌شوند + example: 2.4 + execution: + type: string + enum: [market, limit, stop_market, stop_limit] + tradeType: + type: string + enum: [spot, margin] + srcCurrency: + type: string + dstCurrency: + type: string + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + example: ok + - $ref: "#/components/schemas/SpotOrderFailedResponse" + + /market/trades/list: + get: + tags: + - معاملات اسپات + summary: فهرست معاملات کاربر + description: | + فهرست معاملات ۳ روز اخیر کاربر در بازار اسپات. + + - محدودیت فراخوانی: ۳۰ درخواست در دقیقه + - صفحه‌بندی: دارد (پیش‌فرض ۳۰) + security: + - TokenAuth: [] + parameters: + - name: srcCurrency + in: query + schema: + type: string + - name: dstCurrency + in: query + schema: + type: string + - name: fromId + in: query + schema: + type: integer + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + trades: + type: array + items: + $ref: "#/components/schemas/Trade" + hasNext: + type: boolean + example: false + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + + schemas: + SpotOrderAddRequest: + type: object + properties: + type: + type: string + description: نوع سفارش + example: buy + execution: + type: string + description: نوع اجرا (limit/market/stop_limit/stop_market) + example: limit + srcCurrency: + type: string + example: btc + dstCurrency: + type: string + example: rls + amount: + type: string + example: "0.6" + price: + type: string + example: "520000" + clientOrderId: + type: string + maxLength: 32 + mode: + type: string + description: برای سفارش OCO مقدار `oco` + stopPrice: + type: string + stopLimitPrice: + type: string + + SpotOrder: + type: object + properties: + id: + type: integer + type: + type: string + execution: + type: string + tradeType: + type: string + market: + type: string + srcCurrency: + type: string + dstCurrency: + type: string + price: + type: string + amount: + type: string + totalPrice: + type: string + totalOrderPrice: + type: string + matchedAmount: + type: string + unmatchedAmount: + type: string + status: + type: string + partial: + type: boolean + fee: + type: string + created_at: + type: string + format: date-time + averagePrice: + type: string + clientOrderId: + type: string + pairId: + type: integer + nullable: true + param1: + type: string + description: قیمت توقف در سفارش‌های حد ضرر + + SpotOrderAddResponseSingle: + type: object + properties: + status: + type: string + example: ok + order: + $ref: "#/components/schemas/SpotOrder" + + SpotOrderAddResponseOCO: + type: object + properties: + status: + type: string + example: ok + orders: + type: array + items: + $ref: "#/components/schemas/SpotOrder" + + SpotOrderFailedResponse: + type: object + properties: + status: + type: string + example: failed + code: + type: string + example: InvalidOrderPrice + message: + type: string + clientOrderId: + type: string + + Trade: + type: object + properties: + id: + type: integer + orderId: + type: integer + srcCurrency: + type: string + dstCurrency: + type: string + market: + type: string + timestamp: + type: string + format: date-time + type: + type: string + price: + type: string + amount: + type: string + total: + type: string + fee: + type: string \ No newline at end of file diff --git a/openapi/user_data.yaml b/openapi/user_data.yaml new file mode 100644 index 0000000..e7dd3e7 --- /dev/null +++ b/openapi/user_data.yaml @@ -0,0 +1,500 @@ +openapi: 3.0.3 +info: + title: API اطلاعات کاربر نوبیتکس + version: "1.0.0" + description: | + APIهای مربوط به پروفایل کاربر، کیف‌پول‌ها، کارت و حساب بانکی، + محدودیت‌ها، تراکنش‌ها، و بازارهای مورد علاقه در نوبیتکس. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: اطلاعات کاربر + description: تمام متدهای مربوط به اطلاعات و عملیات کاربر + +paths: + /users/profile: + get: + tags: + - اطلاعات کاربر + summary: دریافت پروفایل کاربر + description: پروفایل کامل کاربر شامل اطلاعات هویتی، بانکی، وضعیت احراز هویت و گزینه‌ها را برمی‌گرداند. + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/UserProfileResponse" + + /users/wallets/generate-address: + post: + tags: + - اطلاعات کاربر + summary: تولید آدرس بلاکچین + description: تولید آدرس واریز بلاکچین برای یک کیف‌پول کاربر بر اساس ارز و شبکه. + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/GenerateAddressRequest" + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/GenerateAddressResponse" + + /users/cards-add: + post: + tags: + - اطلاعات کاربر + summary: افزودن کارت بانکی + description: یک کارت بانکی جدید به حساب کاربر اضافه می‌کند. + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddCardRequest" + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/StatusOnlyResponse" + + /users/accounts-add: + post: + tags: + - اطلاعات کاربر + summary: افزودن حساب بانکی + description: یک حساب بانکی جدید به حساب کاربر اضافه می‌کند. + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddAccountRequest" + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/StatusOnlyResponse" + + /users/limitations: + get: + tags: + - اطلاعات کاربر + summary: دریافت محدودیت‌های کاربر + description: محدودیت‌ها و سطح کاربری حساب کاربر (سقف برداشت/واریز و ...) را برمی‌گرداند. + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/UserLimitationsResponse" + + /users/wallets/list: + get: + tags: + - اطلاعات کاربر + summary: لیست کیف‌پول‌های کاربر + description: لیست کیف‌پول‌های کاربر را (برای نوع اسپات یا مارجین) برمی‌گرداند. + security: + - TokenAuth: [] + parameters: + - name: type + in: query + required: false + description: نوع کیف‌پول (اسپات یا مارجین/فروش تعهدی). + schema: + type: string + default: spot + enum: [spot, margin] + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/WalletsListResponse" + + /v2/wallets: + get: + tags: + - اطلاعات کاربر + summary: لیست انتخابی کیف‌پول‌ها + description: لیست کیف‌پول‌ها برای ارزهای مشخص یا نوع مشخص‌شده را برمی‌گرداند. + security: + - TokenAuth: [] + parameters: + - name: currencies + in: query + required: false + description: لیست ارزها به صورت رشتهٔ جداشده با کاما (btc, rls, usdt). + schema: + type: string + - name: type + in: query + required: false + description: نوع کیف‌پول. + schema: + type: string + default: spot + enum: [spot, margin] + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/V2WalletsResponse" + + /users/wallets/balance: + post: + tags: + - اطلاعات کاربر + summary: دریافت موجودی یک کیف‌پول + description: موجودی کیف‌پول یک ارز مشخص را برمی‌گرداند. + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/WalletBalanceRequest" + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/WalletBalanceResponse" + + /users/wallets/transactions/list: + get: + tags: + - اطلاعات کاربر + summary: لیست تراکنش‌های یک کیف‌پول + description: لیست تراکنش‌های کیف‌پول مشخص را با صفحه‌بندی برمی‌گرداند. + security: + - TokenAuth: [] + parameters: + - name: wallet + in: query + required: true + description: شناسهٔ کیف‌پول. + schema: + type: integer + - name: page + in: query + required: false + description: شماره صفحه. + schema: + type: integer + default: 1 + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/WalletTransactionsListResponse" + + /users/transactions-history: + get: + tags: + - اطلاعات کاربر + summary: تاریخچهٔ تراکنش‌ها (انتخابی) + description: تاریخچهٔ تراکنش‌های کاربر با فیلترهای اختیاری (ارز، نوع، بازهٔ زمانی و ...) را برمی‌گرداند. + security: + - TokenAuth: [] + parameters: + - name: currency + in: query + required: false + schema: + type: string + - name: tp + in: query + required: false + schema: + type: string + - name: from + in: query + required: false + schema: + type: string + format: date-time + - name: to + in: query + required: false + schema: + type: string + format: date-time + - name: from_id + in: query + required: false + schema: + type: integer + - name: page + in: query + required: false + schema: + type: integer + default: 1 + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/UserTransactionsHistoryResponse" + + /users/wallets/deposits/list: + get: + tags: + - اطلاعات کاربر + summary: لیست واریزها + description: لیست واریزهای انجام‌شده به کیف‌پول‌های کاربر را برمی‌گرداند. + security: + - TokenAuth: [] + parameters: + - name: wallet + in: query + required: false + description: شناسهٔ کیف‌پول؛ در صورت عدم ارسال، همه در نظر گرفته می‌شود. + schema: + type: string + default: all + - name: page + in: query + required: false + description: شماره صفحه. + schema: + type: integer + default: 1 + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/WalletDepositsListResponse" + + /users/markets/favorite: + get: + tags: + - اطلاعات کاربر + summary: دریافت لیست بازارهای مورد علاقه + description: لیست بازارهای مورد علاقه انتخاب‌شده توسط کاربر را برمی‌گرداند. + security: + - TokenAuth: [] + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/FavoriteMarketsResponse" + + post: + tags: + - اطلاعات کاربر + summary: ثبت/به‌روزرسانی بازارهای مورد علاقه + description: بازارهای مورد علاقه کاربر را ثبت یا به‌روزرسانی می‌کند. + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/FavoriteMarketsRequest" + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/FavoriteMarketsResponse" + + delete: + tags: + - اطلاعات کاربر + summary: حذف بازارهای مورد علاقه + description: بازارهای مورد علاقه کاربر را حذف می‌کند؛ در صورت ارسال مقدار `All` همه حذف می‌شوند. + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/FavoriteMarketsDeleteRequest" + responses: + "200": + description: موفق + content: + application/json: + schema: + $ref: "#/components/schemas/FavoriteMarketsResponse" + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + description: توکن احراز هویت به صورت `Token yourTOKENhereHEX0000` در هدر ارسال می‌شود. + + schemas: + UserProfileResponse: + type: object + properties: + status: + type: string + profile: + type: object + GenerateAddressRequest: + type: object + properties: + currency: + type: string + network: + type: string + GenerateAddressResponse: + type: object + properties: + status: + type: string + address: + type: string + AddCardRequest: + type: object + properties: + number: + type: string + bank: + type: string + AddAccountRequest: + type: object + properties: + number: + type: string + shaba: + type: string + bank: + type: string + StatusOnlyResponse: + type: object + properties: + status: + type: string + UserLimitationsResponse: + type: object + properties: + status: + type: string + limitations: + type: object + WalletsListResponse: + type: object + properties: + status: + type: string + wallets: + type: array + items: + type: object + V2WalletsResponse: + type: object + properties: + status: + type: string + wallets: + type: object + WalletBalanceRequest: + type: object + properties: + currency: + type: string + WalletBalanceResponse: + type: object + properties: + status: + type: string + balance: + type: string + WalletTransactionsListResponse: + type: object + properties: + status: + type: string + transactions: + type: array + items: + type: object + hasNext: + type: boolean + UserTransactionsHistoryResponse: + type: object + properties: + status: + type: string + transactions: + type: array + items: + type: object + hasNext: + type: boolean + WalletDepositsListResponse: + type: object + properties: + status: + type: string + deposits: + type: array + items: + type: object + hasNext: + type: boolean + FavoriteMarketsResponse: + type: object + properties: + status: + type: string + favoriteMarkets: + type: array + items: + type: string + FavoriteMarketsRequest: + type: object + properties: + market: + type: string + FavoriteMarketsDeleteRequest: + type: object + properties: + market: + type: string \ No newline at end of file diff --git a/openapi/websocket.yaml b/openapi/websocket.yaml new file mode 100644 index 0000000..0134b6b --- /dev/null +++ b/openapi/websocket.yaml @@ -0,0 +1,642 @@ +openapi: 3.0.3 +info: + title: Nobitex WebSocket & HTTP Auth API + version: 1.0.0 + description: | + WebSocket and related HTTP APIs for Nobitex, based on Centrifugo. + + - WebSocket endpoint: wss://ws.nobitex.ir/websocket + - Max concurrent WebSocket connections per IP: 100 + - Max channel subscriptions per connection: 300 + - No token required for public channels + - Token required for private channels (prefix `private:`) + +servers: + - url: wss://ws.nobitex.ir + description: Nobitex WebSocket server (Centrifugo) + +paths: + /auth/ws/token/: + get: + summary: Get WebSocket authentication token + description: | + Returns a connection token used to authenticate WebSocket connections + to private channels (those starting with `private:`). + + - HTTP method: **GET** + - Endpoint: **/auth/ws/token/** + - Requires header: `Authorization: Token ` + + Use the returned `token` when: + - Creating a Centrifuge client (`new Centrifuge(..., { token })`), or + - Sending a raw connect message: `{"connect": {"token": ""}, "id": 1}`. + operationId: getWebsocketToken + security: + - ApiTokenAuth: [ ] + responses: + '200': + description: WebSocket token successfully generated + content: + application/json: + schema: + $ref: '#/components/schemas/WebsocketTokenResponse' + example: + token: "yJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNjMiLCJleHAiOjE3MzE5Mzk0NDIsImlhdCI6MTczMTkzODI0MiwibWV0YSI6e319.AFZjNC0ugUcfchUKjjunNDl1kfemJkA0Y5IYRi1c0mSvIa_XxzQIeVeqg6qnTBzE-HG6zEqXXyCENJtAz7xc7wqcABWbpcHdH0fPtjG4pwDZco9O065RcXacXo7qpCN-IuC0te0qG2_2bAhc-aR7vWgHsTm6GXfrQQh_6uwVHShSarU7" + status: "ok" + '401': + description: Unauthorized – missing or invalid API token + '403': + description: Forbidden – token not allowed to get WS auth token + '429': + description: Too Many Requests – rate limit exceeded + tags: + - وبسوکت + + /websocket: + get: + summary: WebSocket connection endpoint + description: | + WebSocket endpoint for real-time data streaming using Centrifugo protocol. + + **Connection URL:** `wss://ws.nobitex.ir/websocket` + + **Rate Limits:** + - Max 100 concurrent connections per IP + - Max 300 channel subscriptions per connection + + **Authentication:** + - Public channels (prefix `public:`) do not require authentication + - Private channels (prefix `private:`) require a connection token from `/auth/ws/token/` + + **Ping/Pong:** + - Server sends periodic ping messages `{}` + - Client must respond with pong `{}` within 25 seconds + - Official SDKs handle this automatically + + **Channel Patterns:** + - Orderbook: `public:orderbook-{MARKET_SYMBOL}` (e.g., `public:orderbook-BTCIRT`) + - Candles: `public:candle-{MARKET_SYMBOL}-{RESOLUTION}` (e.g., `public:candle-BTCIRT-15`) + - Public trades: `public:trades-{MARKET_SYMBOL}` (e.g., `public:trades-BTCIRT`) + - Market stats (single): `public:market-stats-{MARKET_SYMBOL}` + - Market stats (all): `public:market-stats-all` + - Private orders: `private:orders#{websocketAuthParam}` + - Private trades: `private:trades#{websocketAuthParam}` + + **Resolutions for candles:** + - Minutes: 1, 5, 15, 30 + - Hours: 60, 180, 240, 360, 720 + - Days: D, 2D, 3D + operationId: websocketConnection + tags: + - وبسوکت + x-websocket: true + responses: + '101': + description: Switching Protocols - WebSocket connection established + '400': + description: Bad Request - Invalid WebSocket upgrade request + '429': + description: Too Many Requests - Connection limit exceeded + +components: + securitySchemes: + ApiTokenAuth: + type: apiKey + in: header + name: Authorization + description: | + API token in the form: `Authorization: Token ` + + schemas: + + # ---------- Core WebSocket control messages ---------- + + WebsocketConnectRequest: + type: object + description: | + Raw Centrifugo connect message sent by client when not using an SDK. + properties: + connect: + type: object + description: Connection options (may be empty or contain `token`). + properties: + token: + type: string + description: WebSocket connection token obtained from `/auth/ws/token/`. + additionalProperties: true + id: + type: integer + format: int64 + description: Client-side identifier of the message. + required: + - connect + - id + example: + connect: {} + id: 1 + + WebsocketConnectRequestWithToken: + allOf: + - $ref: '#/components/schemas/WebsocketConnectRequest' + - type: object + description: Connect message including a connection token. + example: + connect: + token: "" + id: 1 + + WebsocketSubscribeRequest: + type: object + description: Subscription request for a single channel. + properties: + id: + type: integer + format: int64 + description: Client-side identifier of the message. + subscribe: + type: object + properties: + channel: + type: string + description: Target channel name. + required: + - channel + required: + - id + - subscribe + example: + id: 2 + subscribe: + channel: "public:orderbook-BTCIRT" + + WebsocketPing: + type: object + description: | + Ping frame payload. Centrifugo sends `{}` and expects `{}` as pong. + additionalProperties: false + example: {} + + WebsocketPushEnvelope: + type: object + description: | + Raw push envelope when not using an official Centrifugo client. + + `pub.data` is a JSON-encoded string that should be parsed to the + corresponding payload type (e.g. OrderbookUpdate, CandleOhlc, etc.). + properties: + push: + type: object + properties: + channel: + type: string + description: Channel name that the message was published to. + pub: + type: object + properties: + data: + type: string + description: JSON-encoded data payload. + offset: + type: integer + format: int64 + description: Stream offset. + required: + - data + - offset + required: + - channel + - pub + required: + - push + + # ---------- HTTP auth ---------- + + WebsocketTokenResponse: + type: object + description: Response returned by GET /auth/ws/token/ + properties: + token: + type: string + description: JWT token used as WebSocket connection token. + status: + type: string + description: Status of the operation. + example: ok + required: + - token + - status + + # ---------- Common monetary & timestamp helpers ---------- + + Monetary: + type: string + description: | + Monetary amount represented as a decimal string. + example: "47150.7989334" + + UnixMillis: + type: integer + format: int64 + description: Unix timestamp in milliseconds. + + UnixSeconds: + type: integer + format: int64 + description: Unix timestamp in seconds. + + # ---------- Channel naming patterns ---------- + + ChannelPatterns: + type: object + description: | + Informational schemas describing channel naming patterns. + + - Public orderbook channel: `public:orderbook-{MARKET_SYMBOL}` + Example: `public:orderbook-BTCIRT`, `public:orderbook-ETHUSDT` + - Public candle channel: `public:candle-{MARKET_SYMBOL}-{RESOLUTION}` + Example: `public:candle-BTCIRT-15` + - Public trades channel: `public:trades-{MARKET_SYMBOL}` + Example: `public:trades-BTCIRT` + - Public market stats (single): `public:market-stats-{MARKET_SYMBOL}` + - Public market stats (all markets): `public:market-stats-all` + - Private orders: `private:orders#{websocketAuthParam}` + - Private trades: `private:trades#{websocketAuthParam}` + + `MARKET_SYMBOL` must be uppercase, e.g. BTCIRT, ETHUSDT. + + `RESOLUTION` is one of: + - Minutes: 1, 5, 15, 30 + - Hours: 60, 180, 240, 360, 720 + - Days: D, 2D, 3D + properties: {} + + # ---------- Orderbook ---------- + + OrderbookLevel: + type: array + description: Price level `[price, amount]`. + minItems: 2 + maxItems: 2 + items: + type: string + example: + - "35077909990" + - "0.009433" + + OrderbookUpdate: + type: object + description: Orderbook snapshot or delta for a given market. + x-channel: "public:orderbook-{MARKET_SYMBOL}" + properties: + asks: + type: array + description: Sell-side orderbook levels `[price, amount]`. + items: + $ref: '#/components/schemas/OrderbookLevel' + bids: + type: array + description: Buy-side orderbook levels `[price, amount]`. + items: + $ref: '#/components/schemas/OrderbookLevel' + lastTradePrice: + type: string + description: Price of the last trade. + example: "35077909990" + lastUpdate: + $ref: '#/components/schemas/UnixMillis' + required: + - asks + - bids + - lastTradePrice + - lastUpdate + example: + asks: + - ["35077909990", "0.009433"] + - ["35078000000", "0.000274"] + - ["35078009660", "0.00057"] + bids: + - ["35020080080", "0.185784"] + - ["35020070060", "0.086916"] + - ["35020030010", "0.000071"] + lastTradePrice: "35077909990" + lastUpdate: 1726581829816 + + # ---------- Candle / OHLC ---------- + + CandleOhlc: + type: object + description: OHLCV candle data. + x-channel: "public:candle-{MARKET_SYMBOL}-{RESOLUTION}" + properties: + t: + $ref: '#/components/schemas/UnixSeconds' + o: + type: number + format: double + description: Open price. + h: + type: number + format: double + description: High price. + l: + type: number + format: double + description: Low price. + c: + type: number + format: double + description: Close price. + v: + type: number + format: double + description: Volume. + required: + - t + - o + - h + - l + - c + - v + example: + t: 1731852900 + o: 6240000001.0 + h: 6250000000.0 + l: 6238000000.0 + c: 6238031033.0 + v: 1.26 + + # ---------- Public trades ---------- + + PublicTrade: + type: object + description: Trade message in a public trades channel. + x-channel: "public:trades-{MARKET_SYMBOL}" + properties: + price: + $ref: '#/components/schemas/Monetary' + time: + $ref: '#/components/schemas/UnixMillis' + type: + type: string + description: Trade side. + enum: [buy, sell] + volume: + $ref: '#/components/schemas/Monetary' + required: + - price + - time + - type + - volume + example: + price: "120000000000" + time: 1762781164192 + type: "sell" + volume: "0.000003" + + # ---------- Market stats ---------- + + MarketStats: + type: object + description: 24h statistics for a single market. + x-channel: "public:market-stats-{MARKET_SYMBOL}" + properties: + isClosed: + type: boolean + description: Whether the market is currently closed. + bestSell: + $ref: '#/components/schemas/Monetary' + bestBuy: + $ref: '#/components/schemas/Monetary' + volumeSrc: + $ref: '#/components/schemas/Monetary' + volumeDst: + $ref: '#/components/schemas/Monetary' + latest: + $ref: '#/components/schemas/Monetary' + mark: + $ref: '#/components/schemas/Monetary' + dayLow: + $ref: '#/components/schemas/Monetary' + dayHigh: + $ref: '#/components/schemas/Monetary' + dayOpen: + $ref: '#/components/schemas/Monetary' + dayClose: + $ref: '#/components/schemas/Monetary' + dayChange: + type: number + format: float + description: Percentage price change over the last 24h. + required: + - isClosed + - bestSell + - bestBuy + - volumeSrc + - volumeDst + - latest + - mark + - dayLow + - dayHigh + - dayOpen + - dayClose + - dayChange + example: + isClosed: false + bestSell: "121073861950" + bestBuy: "120000000000" + volumeSrc: "0.000185131782" + volumeDst: "21590044.0170869949" + latest: "114879999920" + mark: "123288285750" + dayLow: "110850000360" + dayHigh: "121073861950" + dayOpen: "121073861910" + dayClose: "114879999920" + dayChange: -5.12 + + MarketStatsAll: + type: object + description: | + Map of market symbol (e.g. `btc-irt`, `usdt-irt`) to MarketStats. + x-channel: "public:market-stats-all" + additionalProperties: + $ref: '#/components/schemas/MarketStats' + example: + btc-irt: + isClosed: false + bestSell: "121073861950" + bestBuy: "120000000000" + volumeSrc: "0.000185131782" + volumeDst: "21590044.0170869949" + latest: "114879999920" + mark: "123288285750" + dayLow: "110850000360" + dayHigh: "121073861950" + dayOpen: "121073861910" + dayClose: "114879999920" + dayChange: -5.12 + usdt-irt: + isClosed: false + bestSell: "121073861950" + bestBuy: "120000000000" + volumeSrc: "0.000185131782" + volumeDst: "21590044.0170869949" + latest: "114879999920" + mark: "123288285750" + dayLow: "110850000360" + dayHigh: "121073861950" + dayOpen: "121073861910" + dayClose: "114879999920" + dayChange: -5.12 + + # ---------- Private orders (user orders channel) ---------- + + PrivateOrderEvent: + type: object + description: Event published in `private:orders#{websocketAuthParam}`. + x-channel: "private:orders#{websocketAuthParam}" + properties: + amount: + $ref: '#/components/schemas/Monetary' + avgFilledPrice: + $ref: '#/components/schemas/Monetary' + clientOrderId: + type: string + nullable: true + dstCurrency: + type: string + description: Destination currency (e.g. `rls`, `usdt`). + eventTime: + $ref: '#/components/schemas/UnixMillis' + fee: + $ref: '#/components/schemas/Monetary' + filledAmount: + $ref: '#/components/schemas/Monetary' + lastFillTime: + $ref: '#/components/schemas/UnixMillis' + nullable: true + marketType: + type: string + description: Market type of the order. + enum: [Spot, Margin] + orderId: + type: integer + orderType: + type: string + enum: [Market, Limit] + param1: + $ref: '#/components/schemas/Monetary' + nullable: true + price: + $ref: '#/components/schemas/Monetary' + nullable: true + side: + type: string + description: Order side. + enum: [Buy, Sell] + srcCurrency: + type: string + description: Source currency (e.g. `btc`). + status: + type: string + description: Order status (e.g. Done). + tradeAmount: + $ref: '#/components/schemas/Monetary' + nullable: true + tradeId: + type: integer + nullable: true + tradePrice: + $ref: '#/components/schemas/Monetary' + nullable: true + required: + - amount + - avgFilledPrice + - dstCurrency + - eventTime + - fee + - filledAmount + - marketType + - orderId + - orderType + - side + - srcCurrency + - status + example: + amount: "0.0002" + avgFilledPrice: "114879999920" + clientOrderId: null + dstCurrency: "rls" + eventTime: 1762779011366 + fee: "0.00000031" + filledAmount: "0.0002" + lastFillTime: 1762779011258 + marketType: "Spot" + orderId: 278339 + orderType: "Market" + param1: null + price: null + side: "Buy" + srcCurrency: "btc" + status: "Done" + tradeAmount: "0.0002" + tradeId: 92547 + tradePrice: "114879999920" + + # ---------- Private trades (user trades channel) ---------- + + PrivateTradeEvent: + type: object + description: Event published in `private:trades#{websocketAuthParam}`. + x-channel: "private:trades#{websocketAuthParam}" + properties: + id: + type: integer + description: Trade identifier. + orderId: + type: integer + description: Related order identifier. + srcCurrency: + type: string + description: Source currency (e.g. `btc`, `eth`). + dstCurrency: + type: string + description: Destination currency (e.g. `rls`, `usdt`). + timestamp: + type: string + format: date-time + description: Time of the trade (ISO-8601). + type: + type: string + description: Trade side. + enum: [buy, sell] + price: + $ref: '#/components/schemas/Monetary' + amount: + $ref: '#/components/schemas/Monetary' + total: + $ref: '#/components/schemas/Monetary' + fee: + $ref: '#/components/schemas/Monetary' + required: + - id + - orderId + - srcCurrency + - dstCurrency + - timestamp + - type + - price + - amount + - total + - fee + example: + srcCurrency: "btc" + dstCurrency: "rls" + timestamp: "2024-11-23T11:31:27.833332+00:00" + price: "66683959340" + amount: "0.000404" + total: "26940319.57336" + type: "sell" + fee: "47150.7989334" + id: 12942226 + orderId: 520305923 \ No newline at end of file diff --git a/openapi/withdraw.yaml b/openapi/withdraw.yaml new file mode 100644 index 0000000..a891272 --- /dev/null +++ b/openapi/withdraw.yaml @@ -0,0 +1,250 @@ +openapi: 3.0.3 +info: + title: API برداشت نوبیتکس + version: "1.0.0" + description: | + APIهای ثبت، تایید، مشاهده و لیست برداشت‌ها. + +servers: + - url: https://apiv2.nobitex.ir + - url: https://testnetapiv2.nobitex.ir + +tags: + - name: برداشت + description: مدیریت درخواست‌های برداشت رمزارزی و ریالی + +paths: + /users/wallets/withdraw: + post: + tags: + - برداشت + summary: ثبت درخواست برداشت + description: | + ثبت درخواست برداشت از یک کیف‌پول کاربر. + + - محدودیت فراخوانی: ۱۰ درخواست در ۳ دقیقه + security: + - TokenAuth: [] + parameters: + - in: header + name: X-TOTP + schema: + type: string + description: کد دوعاملی (الزامی اگر آدرس در دفتر آدرس نیست) + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/WithdrawRequest" + responses: + "200": + description: موفق یا ناموفق + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/WithdrawResponse" + - $ref: "#/components/schemas/WithdrawFailedResponse" + + /users/wallets/withdraw-confirm: + post: + tags: + - برداشت + summary: تایید درخواست برداشت + description: | + تایید نهایی یک درخواست برداشت با استفاده از کد یکبارمصرف. + + - محدودیت فراخوانی: ۳۰ درخواست در ساعت + security: + - TokenAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - withdraw + - otp + properties: + withdraw: + type: integer + description: شناسه درخواست برداشت + example: 432 + otp: + type: integer + description: کد یکبارمصرف ارسال شده + example: 623005 + responses: + "200": + description: موفق + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/WithdrawResponse" + - $ref: "#/components/schemas/WithdrawFailedResponse" + + /users/wallets/withdraws/list: + get: + tags: + - برداشت + summary: فهرست برداشت‌ها + description: | + لیست آخرین برداشت‌های کاربر. + + - محدودیت فراخوانی: ۶۰ درخواست در ۲ دقیقه + - صفحه‌بندی: دارد (پیش‌فرض ۲۰) + - فیلتر زمانی: دارد + security: + - TokenAuth: [] + parameters: + - name: wallet + in: query + schema: + type: string + default: all + description: شناسه کیف‌پول یا all + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + withdraws: + type: array + items: + $ref: "#/components/schemas/Withdraw" + hasNext: + type: boolean + example: true + + /withdraws/{withdrawId}: + get: + tags: + - برداشت + summary: مشاهده برداشت + description: | + مشاهده وضعیت یک درخواست برداشت. + + - محدودیت فراخوانی: ۶۰ درخواست در ۲ دقیقه + security: + - TokenAuth: [] + parameters: + - name: withdrawId + in: path + required: true + schema: + type: integer + description: شناسه درخواست برداشت + example: 433 + responses: + "200": + description: موفق + content: + application/json: + schema: + type: object + properties: + status: + type: string + example: ok + withdraw: + $ref: "#/components/schemas/Withdraw" + +components: + securitySchemes: + TokenAuth: + type: apiKey + in: header + name: Authorization + + schemas: + WithdrawRequest: + type: object + properties: + wallet: + type: integer + description: شناسه کیف‌پول + example: 3456 + network: + type: string + description: شبکه انتقال + example: BTCLN + invoice: + type: string + description: صورت‌حساب (برای BTCLN الزامی) + amount: + type: string + description: مقدار برداشت + address: + type: string + description: آدرس مقصد یا شبا + explanations: + type: string + description: توضیحات + noTag: + type: boolean + default: false + tag: + type: string + description: تگ انتقال + + Withdraw: + type: object + properties: + id: + type: integer + createdAt: + type: string + format: date-time + status: + type: string + amount: + type: string + currency: + type: string + network: + type: string + invoice: + type: string + nullable: true + address: + type: string + tag: + type: string + nullable: true + wallet_id: + type: integer + blockchain_url: + type: string + nullable: true + is_cancelable: + type: boolean + + WithdrawResponse: + type: object + properties: + status: + type: string + example: ok + withdraw: + $ref: "#/components/schemas/Withdraw" + + WithdrawFailedResponse: + type: object + properties: + status: + type: string + example: failed + code: + type: string + example: InsufficientBalance + message: + type: string \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..3ea4272 --- /dev/null +++ b/package.json @@ -0,0 +1,52 @@ +{ + "name": "docusaurus", + "version": "0.0.0", + "private": true, + "scripts": { + "docusaurus": "docusaurus", + "start": "docusaurus start --port 4000", + "build": "docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "clear": "docusaurus clear", + "serve": "docusaurus serve", + "write-translations": "docusaurus write-translations", + "write-heading-ids": "docusaurus write-heading-ids", + "typecheck": "tsc", + "genapi": "docusaurus gen-api-docs all", + "clean:docs": "find docs -mindepth 1 ! -name '.gitignore' -exec rm -rf {} +", + "dev": "yarn install && yarn clean:docs && yarn genapi && yarn start" + }, + "dependencies": { + "@docusaurus/core": "3.9.2", + "@docusaurus/preset-classic": "3.9.2", + "@mdx-js/react": "^3.0.0", + "clsx": "^2.0.0", + "docusaurus-plugin-openapi-docs": "^4.5.1", + "docusaurus-theme-openapi-docs": "^4.5.1", + "prism-react-renderer": "^2.3.0", + "react": "^19.0.0", + "react-dom": "^19.0.0" + }, + "devDependencies": { + "@docusaurus/module-type-aliases": "3.8.1", + "@docusaurus/tsconfig": "3.8.1", + "@docusaurus/types": "3.8.1", + "typescript": "~5.6.2" + }, + "browserslist": { + "production": [ + ">0.5%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 3 chrome version", + "last 3 firefox version", + "last 5 safari version" + ] + }, + "engines": { + "node": ">=18.0" + } +} diff --git a/plugins/docusaurus-plugin-custom-search/index.tsx b/plugins/docusaurus-plugin-custom-search/index.tsx new file mode 100644 index 0000000..8cb8626 --- /dev/null +++ b/plugins/docusaurus-plugin-custom-search/index.tsx @@ -0,0 +1,416 @@ +const fs = require('fs') +const path = require('path') +const { slug: githubSlug } = require('github-slugger') + +function cleanMarkdownText(text) { + if (!text) return '' + text = text.replace(/`([^`]+)`/g, '$1') + text = text.replace(/\*\*([^*]+)\*\*/g, '$1') + text = text.replace(/\*([^*]+)\*/g, '$1') + text = text.replace(/__([^_]+)__/g, '$1') + text = text.replace(/_([^_]+)_/g, '$1') + text = text.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') + text = text.replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1') + text = text.replace(/<[^>]+>/g, '') + return text.trim() +} + +function extractAllTextFromJSX(content) { + if (!content) return '' + + const texts = [] + + const quotedRegex = /["']([^"']+)["']/g + let match + while ((match = quotedRegex.exec(content)) !== null) { + const text = match[1].trim() + if (text && text.length > 0) { + texts.push(text) + } + } + + return texts.join(' ') +} + +function extractContentFromMarkdown(content) { + const sections = [] + const lines = content.split('\n') + + let currentHeading = null + let currentHeadingSlug = null + let currentLevel = 0 + let currentContent = [] + let beforeFirstHeading = [] + let inCodeBlock = false + let codeBlockContent = [] + let inTable = false + let tableContent = [] + let inJSXBlock = false + let jsxBlockContent = [] + + for (let i = 0; i < lines.length; i++) { + const line = lines[i] + + if (line.trim().startsWith('```')) { + if (inCodeBlock) { + const codeText = codeBlockContent.join(' ').trim() + if (codeText) { + if (currentHeading === null) { + beforeFirstHeading.push(codeText) + } else { + currentContent.push(codeText) + } + } + codeBlockContent = [] + inCodeBlock = false + } else { + inCodeBlock = true + } + continue + } + + if (inCodeBlock) { + codeBlockContent.push(cleanMarkdownText(line)) + continue + } + + const headingJSXMatch = line.match( + /^]*children=\{["']([^"']+)["']\}[^>]*>/ + ) + if (headingJSXMatch) { + if (currentHeading && currentContent.length > 0) { + sections.push({ + level: currentLevel, + headingText: currentHeading, + headingSlug: currentHeadingSlug, + content: currentContent.join(' ').trim(), + }) + } + + const text = cleanMarkdownText(headingJSXMatch[1]) + const slug = githubSlug(text) + + currentHeading = text + currentHeadingSlug = slug + currentLevel = 1 + currentContent = [] + inTable = false + tableContent = [] + continue + } + + const headingMatch = line.match( + /^(#{1,6})\s+(.+?)(?:\s+\{#([a-zA-Z0-9_-]+)\})?$/ + ) + + if (headingMatch) { + if (currentHeading && currentContent.length > 0) { + sections.push({ + level: currentLevel, + headingText: currentHeading, + headingSlug: currentHeadingSlug, + content: currentContent.join(' ').trim(), + }) + } + + const level = headingMatch[1].length + let text = headingMatch[2].trim() + const customId = headingMatch[3] + + text = cleanMarkdownText(text) + const slug = customId || githubSlug(text) + + currentHeading = text + currentHeadingSlug = slug + currentLevel = level + currentContent = [] + inTable = false + tableContent = [] + continue + } + + if (!line.trim()) continue + + if (line.trim().startsWith('|')) { + if (!inTable) inTable = true + const cells = line + .split('|') + .map((cell) => cleanMarkdownText(cell)) + .filter(Boolean) + tableContent.push(...cells) + continue + } else if (inTable) { + if (tableContent.length > 0) { + const tableText = tableContent.join(' ') + if (currentHeading === null) { + beforeFirstHeading.push(tableText) + } else { + currentContent.push(tableText) + } + tableContent = [] + } + inTable = false + } + + const listMatch = line.match(/^[\s]*[-*+]\s+(.+)$/) + if (listMatch) { + const text = cleanMarkdownText(listMatch[1]) + if (currentHeading === null) { + beforeFirstHeading.push(text) + } else { + currentContent.push(text) + } + continue + } + + const numberedListMatch = line.match(/^[\s]*\d+\.\s+(.+)$/) + if (numberedListMatch) { + const text = cleanMarkdownText(numberedListMatch[1]) + if (currentHeading === null) { + beforeFirstHeading.push(text) + } else { + currentContent.push(text) + } + continue + } + + const blockquoteMatch = line.match(/^>\s+(.+)$/) + if (blockquoteMatch) { + const text = cleanMarkdownText(blockquoteMatch[1]) + if (currentHeading === null) { + beforeFirstHeading.push(text) + } else { + currentContent.push(text) + } + continue + } + + if (line.trim().startsWith('<')) { + const jsxText = extractAllTextFromJSX(line) + if (jsxText) { + const cleaned = cleanMarkdownText(jsxText) + if (cleaned) { + if (currentHeading === null) { + beforeFirstHeading.push(cleaned) + } else { + currentContent.push(cleaned) + } + } + } + continue + } + + if ( + line.trim() && + !line.trim().startsWith('---') && + !line.trim().startsWith(':::') && + !line.trim().startsWith('import ') + ) { + const cleanedLine = cleanMarkdownText(line) + if (cleanedLine) { + if (currentHeading === null) { + beforeFirstHeading.push(cleanedLine) + } else { + currentContent.push(cleanedLine) + } + } + } + } + + if (currentHeading && currentContent.length > 0) { + sections.push({ + level: currentLevel, + headingText: currentHeading, + headingSlug: currentHeadingSlug, + content: currentContent.join(' ').trim(), + }) + } + + if (beforeFirstHeading.length > 0) { + sections.unshift({ + level: 0, + headingText: '', + headingSlug: '', + content: beforeFirstHeading.join(' ').trim(), + }) + } + + return sections +} + +function getAllMarkdownFiles(rootDir, subDir) { + const dir = path.join(rootDir, subDir) + const fileList = [] + + if (!fs.existsSync(dir)) return fileList + + function walk(currentDir) { + const files = fs.readdirSync(currentDir) + files.forEach((file) => { + const filePath = path.join(currentDir, file) + const stat = fs.statSync(filePath) + + if (stat.isDirectory()) { + if (!file.startsWith('.') && file !== 'node_modules') { + walk(filePath) + } + } else if (file.match(/\.(md|mdx)$/)) { + fileList.push(filePath) + } + }) + } + + walk(dir) + return fileList +} + +function extractFrontMatter(content) { + const frontMatterMatch = content.match(/^---\n([\s\S]*?)\n---/) + if (frontMatterMatch) { + const frontMatterContent = frontMatterMatch[1] + const titleMatch = frontMatterContent.match(/title:\s*(.+)/) + const slugMatch = frontMatterContent.match(/slug:\s*(.+)/) + const descriptionMatch = frontMatterContent.match(/description:\s*(.+)/) + const sidebarLabelMatch = frontMatterContent.match(/sidebar_label:\s*(.+)/) + + return { + title: titleMatch ? titleMatch[1].trim().replace(/^"|"$/g, '') : null, + slug: slugMatch ? slugMatch[1].trim().replace(/^"|"$/g, '') : null, + description: descriptionMatch + ? descriptionMatch[1].trim().replace(/^"|"$/g, '') + : null, + sidebarLabel: sidebarLabelMatch + ? sidebarLabelMatch[1].trim().replace(/^"|"$/g, '') + : null, + contentWithoutFrontMatter: content + .replace(frontMatterMatch[0], '') + .trim(), + } + } + return { + title: null, + slug: null, + description: null, + sidebarLabel: null, + contentWithoutFrontMatter: content, + } +} + +function buildSearchIndex(siteDir) { + const searchIndex = [] + + const docsFiles = getAllMarkdownFiles(siteDir, 'docs') + const blogFiles = getAllMarkdownFiles(siteDir, 'blog') + const pageFiles = getAllMarkdownFiles(siteDir, 'src/pages') + + const allFiles = [ + ...docsFiles.map((file) => ({ file, type: 'docs' })), + ...blogFiles.map((file) => ({ file, type: 'blog' })), + ...pageFiles.map((file) => ({ file, type: 'pages' })), + ] + + allFiles.forEach(({ file, type }) => { + const content = fs.readFileSync(file, 'utf-8') + const { title, slug, description, sidebarLabel, contentWithoutFrontMatter } = + extractFrontMatter(content) + + const sections = extractContentFromMarkdown(contentWithoutFrontMatter) + + const allFileText = extractAllTextFromJSX(contentWithoutFrontMatter) + + const combinedText = [ + title, + description, + sidebarLabel, + allFileText, + cleanMarkdownText(contentWithoutFrontMatter) + ] + .filter(Boolean) + .join(' ') + .trim() + + if (!sections.length && combinedText) { + sections.push({ + level: 0, + headingText: '', + headingSlug: '', + content: combinedText, + }) + } else if (sections.length > 0) { + if (sections[0]) { + sections[0].content = `${sections[0].content} ${combinedText}`.trim() + } + } + + let relativePath = path.relative(siteDir, file).replace(/\\/g, '/') + relativePath = relativePath.replace(/\.(md|mdx)$/, '') + + let routePath = relativePath + let basePath = '' + + if (type === 'docs') { + routePath = routePath.replace(/^docs\//, '') + } else if (type === 'pages') { + routePath = routePath.replace(/^src\/pages\//, '') + } else if (type === 'blog') { + basePath = '/blog' + routePath = routePath.replace(/^blog\//, '') + } + + if (routePath === 'index') { + routePath = '' + } + + let pageUrl + if (slug) { + pageUrl = slug.startsWith('/') ? slug : `/${slug}` + } else { + pageUrl = `${basePath}/${routePath}`.replace(/\/+/g, '/') + if (pageUrl === '') pageUrl = '/' + } + + pageUrl = pageUrl.replace(/\.api$/, '') + + const pageTitle = title || 'Untitled' + + sections.forEach((section) => { + searchIndex.push({ + pageTitle, + pageUrl, + headingText: section.headingText, + headingSlug: section.headingSlug, + level: section.level, + content: section.content, + url: section.headingSlug + ? `${pageUrl}#${section.headingSlug}` + : pageUrl, + }) + }) + }) + + return searchIndex +} + +module.exports = function pluginCustomSearch(context, options) { + return { + name: 'docusaurus-plugin-custom-search', + + async postBuild({ outDir }) { + const siteDir = context.siteDir + const searchIndex = buildSearchIndex(siteDir) + + const searchIndexPath = path.join(outDir, 'search-index.json') + fs.writeFileSync(searchIndexPath, JSON.stringify(searchIndex, null, 2)) + + console.log(`custom search index created successfully`) + }, + + async contentLoaded({ actions }) { + const { setGlobalData } = actions + const siteDir = context.siteDir + const searchIndex = buildSearchIndex(siteDir) + + setGlobalData({ searchIndex }) + }, + } +} \ No newline at end of file diff --git a/plugins/docusaurus-plugin-custom-search/package.json b/plugins/docusaurus-plugin-custom-search/package.json new file mode 100644 index 0000000..8b36c90 --- /dev/null +++ b/plugins/docusaurus-plugin-custom-search/package.json @@ -0,0 +1,5 @@ +{ + "name": "docusaurus-plugin-custom-search", + "version": "1.0.0", + "main": "index.tsx" +} diff --git a/sidebars.ts b/sidebars.ts new file mode 100644 index 0000000..4e23af6 --- /dev/null +++ b/sidebars.ts @@ -0,0 +1,64 @@ +import type {SidebarsConfig} from '@docusaurus/plugin-content-docs'; +// @ts-ignore +import market_data from './docs/market_data/sidebar.ts'; +// @ts-ignore +import user_data from './docs/user_data/sidebar.ts'; +// @ts-ignore +import spot_trade from './docs/spot_trade/sidebar.ts'; +// @ts-ignore +import margin_trade from './docs/margin_trade/sidebar.ts'; +// @ts-ignore +import withdraw from './docs/withdraw/sidebar.ts'; +// @ts-ignore +import address_book from './docs/address_book/sidebar.ts'; +// @ts-ignore +import security from './docs/security/sidebar.ts'; +// @ts-ignore +import referral from './docs/referral/sidebar.ts'; +// @ts-ignore +import auth from './docs/auth/sidebar.ts'; +// @ts-ignore +import portfolio from './docs/portfolio/sidebar.ts'; +// @ts-ignore +import options from './docs/options/sidebar.ts'; +// @ts-ignore +import ws from './docs/websocket/sidebar'; + +const sortedItems = () => { + const apiSidebars = [ + market_data, + user_data, + spot_trade, + margin_trade, + withdraw, + address_book, + security, + referral, + auth, + portfolio, + options, + ws + ]; + + return apiSidebars.flatMap( + (sidebar) => sidebar.slice(1) + ) as SidebarsConfig['mainSidebar']; +} + +const sidebars: SidebarsConfig = { + mainSidebar: [ + { + type: 'category', + label: 'مستندات API نوبیتکس', + link: { + type: 'generated-index', + title: 'مستندات API نوبیتکس', + description: 'مستندات API نوبیتکس', + slug: '/', + }, + items: sortedItems(), + }, + ], +}; + +export default sidebars; diff --git a/slate.sh b/slate.sh deleted file mode 100755 index a3cc498..0000000 --- a/slate.sh +++ /dev/null @@ -1,248 +0,0 @@ -#!/usr/bin/env bash -set -o errexit #abort if any command fails - -me=$(basename "$0") - -help_message="\ -Usage: $me [] [] -Run commands related to the slate process. - -Commands: - - serve Run the middleman server process, useful for - development. - build Run the build process. - deploy Will build and deploy files to branch. Use - --no-build to only deploy. - -Global Options: - - -h, --help Show this help information. - -v, --verbose Increase verbosity. Useful for debugging. - -Deploy options: - -e, --allow-empty Allow deployment of an empty directory. - -m, --message MESSAGE Specify the message used when committing on the - deploy branch. - -n, --no-hash Don't append the source commit's hash to the deploy - commit's message. - --no-build Do not build the source files. -" - - -run_serve() { - exec bundle exec middleman serve --watcher-force-polling -} - -run_build() { - bundle exec middleman build --clean -} - -parse_args() { - # Set args from a local environment file. - if [ -e ".env" ]; then - source .env - fi - - command= - - # Parse arg flags - # If something is exposed as an environment variable, set/overwrite it - # here. Otherwise, set/overwrite the internal variable instead. - while : ; do - if [[ $1 = "-h" || $1 = "--help" ]]; then - echo "$help_message" - exit 0 - elif [[ $1 = "-v" || $1 = "--verbose" ]]; then - verbose=true - shift - elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then - allow_empty=true - shift - elif [[ ( $1 = "-m" || $1 = "--message" ) && -n $2 ]]; then - commit_message=$2 - shift 2 - elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then - GIT_DEPLOY_APPEND_HASH=false - shift - elif [[ $1 = "--no-build" ]]; then - no_build=true - shift - elif [[ $1 = "serve" || $1 = "build" || $1 = "deploy" ]]; then - if [ ! -z "${command}" ]; then - >&2 echo "You can only specify one command." - exit 1 - fi - command=$1 - shift - elif [ -z $1 ]; then - break - fi - done - - if [ -z "${command}" ]; then - >&2 echo "Command not specified." - exit 1 - fi - - # Set internal option vars from the environment and arg flags. All internal - # vars should be declared here, with sane defaults if applicable. - - # Source directory & target branch. - deploy_directory=build - deploy_branch=gh-pages - - #if no user identity is already set in the current git environment, use this: - default_username=${GIT_DEPLOY_USERNAME:-deploy.sh} - default_email=${GIT_DEPLOY_EMAIL:-} - - #repository to deploy to. must be readable and writable. - repo=origin - - #append commit hash to the end of message by default - append_hash=${GIT_DEPLOY_APPEND_HASH:-true} -} - -main() { - enable_expanded_output - - if ! git diff --exit-code --quiet --cached; then - echo Aborting due to uncommitted changes in the index >&2 - return 1 - fi - - commit_title=`git log -n 1 --format="%s" HEAD` - commit_hash=` git log -n 1 --format="%H" HEAD` - - #default commit message uses last title if a custom one is not supplied - if [[ -z $commit_message ]]; then - commit_message="publish: $commit_title" - fi - - #append hash to commit message unless no hash flag was found - if [ $append_hash = true ]; then - commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash" - fi - - previous_branch=`git rev-parse --abbrev-ref HEAD` - - if [ ! -d "$deploy_directory" ]; then - echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2 - return 1 - fi - - # must use short form of flag in ls for compatibility with macOS and BSD - if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then - echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2 - return 1 - fi - - if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then - # deploy_branch exists in $repo; make sure we have the latest version - - disable_expanded_output - git fetch --force $repo $deploy_branch:$deploy_branch - enable_expanded_output - fi - - # check if deploy_branch exists locally - if git show-ref --verify --quiet "refs/heads/$deploy_branch" - then incremental_deploy - else initial_deploy - fi - - restore_head -} - -initial_deploy() { - git --work-tree "$deploy_directory" checkout --orphan $deploy_branch - git --work-tree "$deploy_directory" add --all - commit+push -} - -incremental_deploy() { - #make deploy_branch the current branch - git symbolic-ref HEAD refs/heads/$deploy_branch - #put the previously committed contents of deploy_branch into the index - git --work-tree "$deploy_directory" reset --mixed --quiet - git --work-tree "$deploy_directory" add --all - - set +o errexit - diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$? - set -o errexit - case $diff in - 0) echo No changes to files in $deploy_directory. Skipping commit.;; - 1) commit+push;; - *) - echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to main, use: git symbolic-ref HEAD refs/heads/main && git reset --mixed >&2 - return $diff - ;; - esac -} - -commit+push() { - set_user_id - git --work-tree "$deploy_directory" commit -m "$commit_message" - - disable_expanded_output - #--quiet is important here to avoid outputting the repo URL, which may contain a secret token - git push --quiet $repo $deploy_branch - enable_expanded_output -} - -#echo expanded commands as they are executed (for debugging) -enable_expanded_output() { - if [ $verbose ]; then - set -o xtrace - set +o verbose - fi -} - -#this is used to avoid outputting the repo URL, which may contain a secret token -disable_expanded_output() { - if [ $verbose ]; then - set +o xtrace - set -o verbose - fi -} - -set_user_id() { - if [[ -z `git config user.name` ]]; then - git config user.name "$default_username" - fi - if [[ -z `git config user.email` ]]; then - git config user.email "$default_email" - fi -} - -restore_head() { - if [[ $previous_branch = "HEAD" ]]; then - #we weren't on any branch before, so just set HEAD back to the commit it was on - git update-ref --no-deref HEAD $commit_hash $deploy_branch - else - git symbolic-ref HEAD refs/heads/$previous_branch - fi - - git reset --mixed -} - -filter() { - sed -e "s|$repo|\$repo|g" -} - -sanitize() { - "$@" 2> >(filter 1>&2) | filter -} - -parse_args "$@" - -if [ "${command}" = "serve" ]; then - run_serve -elif [[ "${command}" = "build" ]]; then - run_build -elif [[ ${command} = "deploy" ]]; then - if [[ ${no_build} != true ]]; then - run_build - fi - main "$@" -fi diff --git a/source/deprecated/index.html.md b/source/deprecated/index.html.md deleted file mode 100644 index 0cfd829..0000000 --- a/source/deprecated/index.html.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: موارد قدیمی API -lang: fa -toc_footers: - - مستندات API نوبیتکس - - سابقه تغییرات API - - شرایط استفاده از API - - سایت نوبیتکس ---- - -# موارد قدیمی API -برخی از APIها به دلیل تغییرات ساختاری یا کارکردی، قدیمی و deprecated محسوب می‌شوند و نباید دیگر از آن‌ها استفاده شود. این موارد صرفاً جهت ثبت در ادامه خواهند آمد، ولی ممکن است در حال حاضر یا هر یک از نسخه‌های آتی نوبیتکس این APIها غیرفعال شوند یا دیگر پاسخگو نباشند. - -## کد دعوت پیش‌فرض - -```shell -curl 'https://apiv2.nobitex.ir/users/get-referral-code' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/get-referral-code \ -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "referredUsersCount": 0, - "referralCode": "84440", - "referralFeeTotalCount": 0, - "referralFeeTotal": 0 -} -``` - -برای دریافت کد دعوت پیش‌فرض از این نوع درخواست استفاده نمایید: - -- آدرس : `GET /users/get-referral-code` diff --git a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum).eot b/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum).eot deleted file mode 100644 index 389ec4b..0000000 Binary files a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum).eot and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Black.eot b/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Black.eot deleted file mode 100644 index a9c2bef..0000000 Binary files a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Black.eot and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Bold.eot b/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Bold.eot deleted file mode 100644 index 7ce9b1b..0000000 Binary files a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Bold.eot and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Light.eot b/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Light.eot deleted file mode 100644 index ee72989..0000000 Binary files a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Light.eot and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Medium.eot b/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Medium.eot deleted file mode 100644 index 3c20c14..0000000 Binary files a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_Medium.eot and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_UltraLight.eot b/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_UltraLight.eot deleted file mode 100644 index c789bb3..0000000 Binary files a/source/fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum)_UltraLight.eot and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum).ttf b/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum).ttf deleted file mode 100644 index 3835c1d..0000000 Binary files a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum).ttf and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Black.ttf b/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Black.ttf deleted file mode 100644 index 42af658..0000000 Binary files a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Black.ttf and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Bold.ttf b/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Bold.ttf deleted file mode 100644 index adbf9e4..0000000 Binary files a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Bold.ttf and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Light.ttf b/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Light.ttf deleted file mode 100644 index fae92bd..0000000 Binary files a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Light.ttf and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Medium.ttf b/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Medium.ttf deleted file mode 100644 index 9622928..0000000 Binary files a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_Medium.ttf and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_UltraLight.ttf b/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_UltraLight.ttf deleted file mode 100644 index 59dfb58..0000000 Binary files a/source/fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum)_UltraLight.ttf and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum).woff b/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum).woff deleted file mode 100644 index 1e6eb36..0000000 Binary files a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum).woff and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Black.woff b/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Black.woff deleted file mode 100644 index 019c556..0000000 Binary files a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Black.woff and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Bold.woff b/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Bold.woff deleted file mode 100644 index 7008b60..0000000 Binary files a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Bold.woff and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Light.woff b/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Light.woff deleted file mode 100644 index ecea926..0000000 Binary files a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Light.woff and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Medium.woff b/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Medium.woff deleted file mode 100644 index 587883a..0000000 Binary files a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_Medium.woff and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_UltraLight.woff b/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_UltraLight.woff deleted file mode 100644 index c815b45..0000000 Binary files a/source/fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum)_UltraLight.woff and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum).woff2 b/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum).woff2 deleted file mode 100644 index c3dcbab..0000000 Binary files a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum).woff2 and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Black.woff2 b/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Black.woff2 deleted file mode 100644 index fc008ef..0000000 Binary files a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Black.woff2 and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Bold.woff2 b/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Bold.woff2 deleted file mode 100644 index 69f7c66..0000000 Binary files a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Bold.woff2 and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Light.woff2 b/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Light.woff2 deleted file mode 100644 index 40f5b09..0000000 Binary files a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Light.woff2 and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Medium.woff2 b/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Medium.woff2 deleted file mode 100644 index 8273b0a..0000000 Binary files a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_Medium.woff2 and /dev/null differ diff --git a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_UltraLight.woff2 b/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_UltraLight.woff2 deleted file mode 100644 index 8b77d17..0000000 Binary files a/source/fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum)_UltraLight.woff2 and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Black-FD.eot b/source/fonts/Vazir/Vazir-Black-FD.eot deleted file mode 100644 index b8bb47c..0000000 Binary files a/source/fonts/Vazir/Vazir-Black-FD.eot and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Black-FD.ttf b/source/fonts/Vazir/Vazir-Black-FD.ttf deleted file mode 100644 index e139bcf..0000000 Binary files a/source/fonts/Vazir/Vazir-Black-FD.ttf and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Black-FD.woff b/source/fonts/Vazir/Vazir-Black-FD.woff deleted file mode 100644 index 40ffb36..0000000 Binary files a/source/fonts/Vazir/Vazir-Black-FD.woff and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Black-FD.woff2 b/source/fonts/Vazir/Vazir-Black-FD.woff2 deleted file mode 100644 index f047a85..0000000 Binary files a/source/fonts/Vazir/Vazir-Black-FD.woff2 and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Bold-FD.eot b/source/fonts/Vazir/Vazir-Bold-FD.eot deleted file mode 100644 index 4325548..0000000 Binary files a/source/fonts/Vazir/Vazir-Bold-FD.eot and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Bold-FD.ttf b/source/fonts/Vazir/Vazir-Bold-FD.ttf deleted file mode 100644 index fa9a57d..0000000 Binary files a/source/fonts/Vazir/Vazir-Bold-FD.ttf and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Bold-FD.woff b/source/fonts/Vazir/Vazir-Bold-FD.woff deleted file mode 100644 index bb9a22c..0000000 Binary files a/source/fonts/Vazir/Vazir-Bold-FD.woff and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Bold-FD.woff2 b/source/fonts/Vazir/Vazir-Bold-FD.woff2 deleted file mode 100644 index 56a02a6..0000000 Binary files a/source/fonts/Vazir/Vazir-Bold-FD.woff2 and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Light-FD.eot b/source/fonts/Vazir/Vazir-Light-FD.eot deleted file mode 100644 index c26b73d..0000000 Binary files a/source/fonts/Vazir/Vazir-Light-FD.eot and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Light-FD.ttf b/source/fonts/Vazir/Vazir-Light-FD.ttf deleted file mode 100644 index b3b36e5..0000000 Binary files a/source/fonts/Vazir/Vazir-Light-FD.ttf and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Light-FD.woff b/source/fonts/Vazir/Vazir-Light-FD.woff deleted file mode 100644 index ab5112e..0000000 Binary files a/source/fonts/Vazir/Vazir-Light-FD.woff and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Light-FD.woff2 b/source/fonts/Vazir/Vazir-Light-FD.woff2 deleted file mode 100644 index b879c34..0000000 Binary files a/source/fonts/Vazir/Vazir-Light-FD.woff2 and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Medium-FD.eot b/source/fonts/Vazir/Vazir-Medium-FD.eot deleted file mode 100644 index 34980eb..0000000 Binary files a/source/fonts/Vazir/Vazir-Medium-FD.eot and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Medium-FD.ttf b/source/fonts/Vazir/Vazir-Medium-FD.ttf deleted file mode 100644 index 696ecde..0000000 Binary files a/source/fonts/Vazir/Vazir-Medium-FD.ttf and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Medium-FD.woff b/source/fonts/Vazir/Vazir-Medium-FD.woff deleted file mode 100644 index a3c7b2e..0000000 Binary files a/source/fonts/Vazir/Vazir-Medium-FD.woff and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Medium-FD.woff2 b/source/fonts/Vazir/Vazir-Medium-FD.woff2 deleted file mode 100644 index 978b73d..0000000 Binary files a/source/fonts/Vazir/Vazir-Medium-FD.woff2 and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Regular-FD.eot b/source/fonts/Vazir/Vazir-Regular-FD.eot deleted file mode 100644 index 5857faf..0000000 Binary files a/source/fonts/Vazir/Vazir-Regular-FD.eot and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Regular-FD.ttf b/source/fonts/Vazir/Vazir-Regular-FD.ttf deleted file mode 100644 index b34b9dd..0000000 Binary files a/source/fonts/Vazir/Vazir-Regular-FD.ttf and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Regular-FD.woff b/source/fonts/Vazir/Vazir-Regular-FD.woff deleted file mode 100644 index f6b3541..0000000 Binary files a/source/fonts/Vazir/Vazir-Regular-FD.woff and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Regular-FD.woff2 b/source/fonts/Vazir/Vazir-Regular-FD.woff2 deleted file mode 100644 index 07aefa9..0000000 Binary files a/source/fonts/Vazir/Vazir-Regular-FD.woff2 and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Thin-FD.eot b/source/fonts/Vazir/Vazir-Thin-FD.eot deleted file mode 100644 index 7df475f..0000000 Binary files a/source/fonts/Vazir/Vazir-Thin-FD.eot and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Thin-FD.ttf b/source/fonts/Vazir/Vazir-Thin-FD.ttf deleted file mode 100644 index c08db72..0000000 Binary files a/source/fonts/Vazir/Vazir-Thin-FD.ttf and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Thin-FD.woff b/source/fonts/Vazir/Vazir-Thin-FD.woff deleted file mode 100644 index 7b0455b..0000000 Binary files a/source/fonts/Vazir/Vazir-Thin-FD.woff and /dev/null differ diff --git a/source/fonts/Vazir/Vazir-Thin-FD.woff2 b/source/fonts/Vazir/Vazir-Thin-FD.woff2 deleted file mode 100644 index 8325f88..0000000 Binary files a/source/fonts/Vazir/Vazir-Thin-FD.woff2 and /dev/null differ diff --git a/source/fonts/slate.eot b/source/fonts/slate.eot deleted file mode 100644 index 13c4839..0000000 Binary files a/source/fonts/slate.eot and /dev/null differ diff --git a/source/fonts/slate.svg b/source/fonts/slate.svg deleted file mode 100644 index 5f34982..0000000 --- a/source/fonts/slate.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -Generated by IcoMoon - - - - - - - - - - diff --git a/source/fonts/slate.ttf b/source/fonts/slate.ttf deleted file mode 100644 index ace9a46..0000000 Binary files a/source/fonts/slate.ttf and /dev/null differ diff --git a/source/fonts/slate.woff b/source/fonts/slate.woff deleted file mode 100644 index 1e72e0e..0000000 Binary files a/source/fonts/slate.woff and /dev/null differ diff --git a/source/fonts/slate.woff2 b/source/fonts/slate.woff2 deleted file mode 100644 index 7c585a7..0000000 Binary files a/source/fonts/slate.woff2 and /dev/null differ diff --git a/source/images/active-convertor.jpg b/source/images/active-convertor.jpg deleted file mode 100644 index 7996fd7..0000000 Binary files a/source/images/active-convertor.jpg and /dev/null differ diff --git a/source/images/active-gateway.jpg b/source/images/active-gateway.jpg deleted file mode 100644 index f169f1b..0000000 Binary files a/source/images/active-gateway.jpg and /dev/null differ diff --git a/source/images/active-plugin.jpg b/source/images/active-plugin.jpg deleted file mode 100644 index 6bc02ff..0000000 Binary files a/source/images/active-plugin.jpg and /dev/null differ diff --git a/source/images/converter-admin.jpg b/source/images/converter-admin.jpg deleted file mode 100644 index 66ed5ed..0000000 Binary files a/source/images/converter-admin.jpg and /dev/null differ diff --git a/source/images/favicon.ico b/source/images/favicon.ico deleted file mode 100644 index ac7b6eb..0000000 Binary files a/source/images/favicon.ico and /dev/null differ diff --git a/source/images/gateway-setting.jpg b/source/images/gateway-setting.jpg deleted file mode 100644 index bd18a93..0000000 Binary files a/source/images/gateway-setting.jpg and /dev/null differ diff --git a/source/images/navbar.png b/source/images/navbar.png deleted file mode 100644 index df38e90..0000000 Binary files a/source/images/navbar.png and /dev/null differ diff --git a/source/images/nobitex-dashboard.jpg b/source/images/nobitex-dashboard.jpg deleted file mode 100644 index 0f2d726..0000000 Binary files a/source/images/nobitex-dashboard.jpg and /dev/null differ diff --git a/source/images/plugin-upload.jpg b/source/images/plugin-upload.jpg deleted file mode 100644 index 46ece4e..0000000 Binary files a/source/images/plugin-upload.jpg and /dev/null differ diff --git a/source/includes/_address_book.md b/source/includes/_address_book.md deleted file mode 100644 index 73e079a..0000000 --- a/source/includes/_address_book.md +++ /dev/null @@ -1,251 +0,0 @@ -# دفتر آدرس و حالت برداشت امن - -دفتر آدرس (address book) و حالت برداشت امن (whitelist mode) -به منظور ارتقاء امنیت و سرعت برداشت رمزارز کاربران پیاده سازی می شود و امکان تعریف آدرس‌های برداشت از پیش تعیین -و تأیید شده را در دفتر آدرس برای کاربر فراهم می آورد. برداشت به آدرس‌های امن دفتر آدرس به رمز دوعاملی یا کد تایید -یکبار مصرف نیازی ندارد. - -## مشاهده لیست آدرس‌های دفتر آدرس - -```shell -curl 'https://apiv2.nobitex.ir/address_book' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -https GET https://apiv2.nobitex.ir/address_book -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "data": [ - { - "id": 3, - "title": "TetherBinance", - "network": "BSC", - "address": "000000xxxxxxx111111111zzzzzzz", - "createdAt": "2023-08-09T10:12:37+00:00" - }, - { - "id": 4, - "title": "BinanceCoinOKX", - "network": "BNB", - "address": "000000xxxxxxx222222222zzzzzzz", - "tag": "test17280992", - "createdAt": "2023-08-09T10:26:12+00:00" - } - ] -} -``` - -برای دریافت دفتر آدرس از این درخواست استفاده نمایید. - -- **درخواست:**: `GET /address_book` -- **محدودیت فراخوانی:** 20 درخواست در هر دقیقه - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|---------|--------|-------------|------------|-------| -| network | string | همه شبکه‌ها | فیلتر شبکه | `BSC` | - -## اضافه کردن آدرس جدید به دفتر آدرس - -```shell -curl -X POST 'https://apiv2.nobitex.ir/address_book' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"title": "test", "network": "BSC", "address": "000000xxxxxxx111111111zzzzzzz", - "otpCode": "123456", "tfaCode": "654321"}' - -``` - -```plaintext -http POST https://apiv2.nobitex.ir/address_book -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "id": 5, - "title": "test", - "network": "BSC", - "address": "000000xxxxxxx111111111zzzzzzz", - "createdAt": "2023-08-09T10:22:37+00:00" - } -} -``` - - -> برای دریافت رمزیکبارمصرف otpCode از درخواست زیر استفاده نمایید: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/v2/otp/request' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - --data '{"type": "email", "usage": "address_book"}' -``` - - -- **درخواست:**: `POST /address_book` -- **محدودیت فراخوانی:** 6 درخواست در هر دقیقه - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|---------|--------|------------------------------|------------------------|---------------------------------| -| title | string | الزامی | عنوان آدرس | `test` | -| network | string | الزامی | شبکه | `BSC` | -| address | string | الزامی | آدرس | `000000xxxxxxx111111111zzzzzzz` | -| tag | string | الزامی در شبکه‌های تگ‌اجباری | تگ | `test17280992` | -| otpCode | string | الزامی | کد تأیید ایمیل و پیامک | `123456` | -| tfaCode | string | الزامی | کد تأیید دوعاملی | `654321` | - -### نکات و ملاحظات - -1. مقدار آدرس در شبکه‌های بدون تگ نمی‌تواند تکراری باشد. -2. در شبکه‌های تگ اجباری است. -3. مقدار تگ‌های یک آدرس در شبکه‌های تگ‌اجباری نمی‌تواند تکراری باشد. (زوج آدرس و تگ باید یکتا باشد.) -4. برای دریافت کد تایید از طریق ایمیل (otpCode) از درخواست روبرو استفاده نمایید. - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -| کد خطا | توضیحات | -|-------------------|----------------------------------------------------------------| -| ParseError | نوع یا شرط الزامی بودن یکی از پارامترهای ورودی رعایت نشده است. | -| InvalidOTP | مقدار tfa وارد شده نادرست است. | -| Invalid2FA | مقدار otp وارد شده نادرست است. | -| Inactive2FA | tfa فعال نیست | -| InvalidAddress | آدرس مربوط به شبکه مشخص شده نمی‌باشد. | -| DuplicatedAddress | آدرس قبلا ثبت شده و تکراری می باشد. | -| InvalidTag | فرمت تگ مطابق شبکه مشخص شده نمی‌باشد. | - - -## حذف یک دفتر آدرس - -```shell -curl 'https://apiv2.nobitex.ir/address_book//delete - -H "Authorization: Token yourTOKENhereHEX000000ook'" - -``` - -```plaintext -https DELETE /address_book//delete -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -- **درخواست:**: `DELETE /address_book//delete` -- **محدودیت فراخوانی:** 6 درخواست در هر دقیقه - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -| کد خطا | توضیحات | -|----------|--------------------------------| -| NotFound | آدرسی با این شناسه وجود ندارد. | - -## فعال کردن برداشت امن -در صورتی که حالت برداشت امن فعال باشد مقصدهای برداشت رمزارزی به آدرس‌های موجود در دفتر آدرس محدود خواهد شد -و به استثنای برداشت در شبکه لایتنینگ، امکان برداشت رمزارزی به آدرس‌های غیر وجود نخواهد داشت. - -```shell -curl -X POST 'https://apiv2.nobitex.ir/address_book/whitelist/activate' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -https POST https://apiv2.nobitex.ir/address_book/whitelist/activate -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -- **درخواست:**: `POST /address_book/whitelist/activate` -- **محدودیت فراخوانی:** 6 درخواست در هر دقیقه - -## غیرفعال کردن برداشت امن -با غیر فعال کردن برداشت امن، به جهت حفظ امنیت حساب امکان برداشت به مدت ۲۴ ساعت روی حساب کاربر محدود خواهد شد. - -```shell -curl 'https://apiv2.nobitex.ir/address_book/whitelist/deactivate' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" - -H "content-type: application/json" \ - --data '{"otpCode": "1234", "tfaCode": "12345"}' -``` - -```plaintext -https POST https://apiv2.nobitex.ir/address_book/whitelist/deactivate -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -- **درخواست:**: `POST /address_book/whitelist/deactivate` -- **محدودیت فراخوانی:** 6 درخواست در هر دقیقه - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|---------|--------|---------|------------------------|---------| -| otpCode | string | الزامی | کد تأیید ایمیل و پیامک | `1234` | -| tfaCode | string | الزامی | کد تأیید دوعاملی | `12345` | - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -| کد خطا | توضیحات | -|-------------|----------------------------------------------------------------| -| ParseError | نوع یا شرط الزامی بودن یکی از پارامترهای ورودی رعایت نشده است. | -| InvalidOTP | مقدار tfa وارد شده نادرست است. | -| Invalid2FA | مقدار otp وارد شده نادرست است. | -| Inactive2FA | tfa فعال نیست | diff --git a/source/includes/_auth.md b/source/includes/_auth.md deleted file mode 100644 index e38e1d0..0000000 --- a/source/includes/_auth.md +++ /dev/null @@ -1,113 +0,0 @@ -

احراز هویت

- -

روش پیشنهادی دریافت توکن

- -روش پیشنهادی نوبیتکس برای دریافت توکن استفاده از API، دریافت آن از پنل کاربری است. برای دریافت توکن می‌توانید با مراجعه به پنل کاربری خود در نوبیتکس، از بخش پروفایل وارد صفحه تنظیمات شده و توکن خود را دریافت نمایید. در صورتی که گزینه «مرا به خاطر بسپار» را در هنگام ورود به نوبیتکس انتخاب کرده باشید، این توکن تا ۳۰ روز یا زمان لاگ‌اوت شما از نوبیتکس معتبر خواهد ماند. - -در ادامه روش دریافت خودکار توکن با استفاده از کد توضیح داده می‌شود. معمولاً دریافت خودکار توکن ضروری نیست و روش پیشنهادی ما برای اغلب کاربران دریافت مستقیم توکن از پنل کاربری است. تنها در صورتی که با مخاطرات ذخیره گذرواژه خود در کد و روش‌های امن این کار آشنا هستید، در استفاده از API مهارت دارید، و از طرفی نیاز به دریافت کاملاً خودکار توکن دارید، از API دریافت توکن استفاده نمایید. - -همین طور پیشنهاد می‌شود که گام‌های اولیه توسعه کد خود را با دریافت توکن از پنل انجام دهید تا با فرآیند استفاده از API نوبیتکس بیشتر آشنا شوید و تنها در صورت نیاز و در گام نهایی‌سازی کد خود اقدام به خودکارسازی دریافت توکن نمایید. لازم به توضیح است که به دلیل مسائل امنیتی مانند شناسایی دوعاملی و کپچا و ... برای دریافت خودکار توکن باید به دقت مستندات این بخش را مطالعه نمایید. - -

ورود - دریافت توکن

-> برای دریافت توکن، از این کد استفاده کنید: - -```shell -curl 'https://apiv2.nobitex.ir/auth/login/' \ - -X POST \ - --header "Content-Type: application/json" \ - --header "X-TOTP: " \ - --header "User-Agent: TraderBot/" \ - --data $'{"username":"name@example.com","password":"secret-password-1234","captcha":"api"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/auth/login/ \ - username=name@example.com password=secret-password-1234 captcha=api -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "success", - "key": "db2055f743c1ac8c30d23278a496283b1e2dd46f", - "device": "AlRyansW" -} -``` - -دریافت توکن به صورت خودکار و با ارسال درخواست به `/auth/login/` صورت می‌گیرد. این تنها APIی است که نیاز دارید -به آن نام کاربری و رمز عبور خود را ارسال کنید. تمامی دیگر APIها از توکن به جای رمز عبور برای احراز هویت استفاده می‌کنند. -توکن‌های صادر شده بعد از چهار ساعت منقضی می‌شوند و باید مجددا با ارسال درخواست لاگین، توکن جدیدی دریافت کنید. -در صورتی که نیاز به ایجاد توکن‌های بلند مدت دارید، از پارامتر `remember=yes` استفاده کنید تا توکن ایجاد شده به مدت سی -روز معتبر بماند. -توجه داشته باشید، در صورتی که قصد استفاده از وب سرویس بدون ورود کپچای تصویری را دارید، نیاز است مقدار captcha حتما برابر api تنظیم شود و کد دوعاملی بر روی حساب کاربری تنظیم گردد و مقدار لحظه ای آن در هدر ریکویست ارسال شود. همینطور مقدار هدر User-Agent را مطابق الگوی TraderBot/XXXXX ارسال نمایید، که بخش XXXXX هر نام یکتایی است که می‌توانید برای بات خود انتخاب کنید. جهت تنظیم کد دوعاملی، توضیحات دقیق‌تر را از اینجا مطالعه فرمایید. - - -* **درخواست:** `/POST /auth/login ` -* **محدودیت فراخوانی:** ۳۰ درخواست در هر ۱۰ دقیقه - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | --------- | --------- | ----- -username | string | الزامی | ایمیل کاربر | `name@example.com` -password | string | الزامی | گذرواژه کاربر | `secret-password-1234` -remember | string | no | آیا توکن بلند مدت صادر شود؟ | `yes` یا `no` -captcha | string | الزامی | کپچا | `api` - - -### پارامترهای هدر - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | --------- |----------------------| ----- -X-TOTP | string | الزامی | کد دوعاملی | `123456` -User-Agent | string | الزامی | ایجنت | `TraderBot/1.0.0` - -### نکات و ملاحظات - -1. دقت نمایید که انتهای آدرس url ارسال درخواست، حتماً باید `/` گذاشته شود. -2. توکن‌های دریافت شده از این روش، بعد از اتمام زمان اعتبار یا انجام عملیات لاگ‌اوت منقضی می‌شوند. زمان پیش‌فرض اعتبار توکن چهار ساعت است که می‌توانید با استفاده از پارامتر `remember` توکن‌هایی با زمان اعتبار یک ماه دریافت نمایید. -3. برای لاگین و دریافت توکن، حتماً باید از آی‌پی ایران درخواست ارسال شود. در غیر این صورت، خطای 429 برگردانده می‌شود. بدیهی است که استفاده از هر VPN یا VPS خارجی، منجر به این خطا خواهد شد. در حالت استفاده از آی‌پی ایران می‌توانید مقدار کپچا را در درخواست برابر `api` مقداردهی کنید. -4. در صورت مشکل در دریافت توکن، می‌توانید مطابق [روش پیشنهادی](#auth-intro) دریافت توکن از توکن‌‌های موجود در تنظیمات پروفایل خود استفاده کنید. - - -

سوالات متداول دریافت توکن

- -### آیا نوبیتکس توکن بلند مدت هم ارائه می‌دهد؟ -در نوبیتکس می‌توانید توکن‌هایی با تاریخ انقضای حداکثر یک ماه دریافت نمایید. در صورتی که گزینه «مرا به خاطر بسپار» را در زمان لاگین به سایت نوبیتکس انتخاب نمایید، توکنی که در بخش پروفایل دریافت می‌کنید برای مدت یک ماه معتبر خواهد بود. در صورتی که از API دریافت توکن استفاده می‌کنید، می‌توانید از پارامتر `remember` استفاده کنید. مد نظر داشته باشید که در صورت انجام عملیات لاگ‌اوت از حساب خود در سایت یا API توکن شما دیگر معتبر نخواهد ماند. - -### من با استفاده از گوگل در نوبیتکس ثبت نام کرده‌ام. چگونه می‌توانم با API کار کنم؟ -[روش پیشنهادی](#auth-intro) دریافت توکن، دریافت آن از پنل کاربری است و با این روش تمام کاربران مستقل از روش ورود به نوبیتکس می‌توانند توکن خود را مشاهده و دریافت نمایند. کاربرانی که با استفاده از حساب گوگل در نوبیتکس ثبت‌نام کرده باشند و بخواهند از روش خودکار دریافت توکن استفاده کنند، می‌توانند از امکان فراموشی رمز عبور استفاده کرده و رمز جدید برای حساب خود تعیین و پس از آن اقدام به استفاده از API نمایند. - -### در هنگام لاگین با خطای MissingCaptcha روبرو شده‌ام. مشکل چیست؟ -مطابق [روش پیشنهادی](#auth-intro) دریافت توکن، برای دریافت توکن به پنل کاربری خود در سایت، بخش «پروفایل: تنظیمات» مراجعه نمایید. اگر از روش خودکار دریافت توکن استفاده می‌کنید، مستندات مربوطه را با دقت مطالعه نمایید. - -### در هنگام لاگین با خطای MissingOTP روبرو شده ام. چگونه این مشکل حل میشود؟ -هنگامی که شناسایی دوعاملی حساب شما فعال باشد، در هنگام استفاده از API نیز می‌بایست این حالت حفظ شده و رمز یکبار مصرف ارسال گردد. این کار از طریق ارسال این رمز با استفاده از پارامتر X-TOTP امکان‌پذیر خواهد بود. تولید کد دوعاملی با استفاده از فرمول استانداردی در کد ممکن است. - - -

خروج - سوزاندن توکن

-> برای خروج یا سوزاندن توکن، از این کد استفاده کنید: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/auth/logout/' \ ---header 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```plaintext -POST /auth/logout/ HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "detail": "خروج با موفقیت انجام شد.", - "message": "خروج با موفقیت انجام شد." -} -``` - -- **درخواست:** `/POST /auth/logout ` diff --git a/source/includes/_intro.md b/source/includes/_intro.md deleted file mode 100644 index afe19a9..0000000 --- a/source/includes/_intro.md +++ /dev/null @@ -1,368 +0,0 @@ -# مستندات API نوبیتکس - -``` -NOBITEX -``` - -به مستندات API [نوبیتکس](https://nobitex.ir)، بزرگترین بازار ارز دیجیتال ایران خوش آمدید. نوبیتکس از ابتدای کار API خود را در اختیار تمامی کاربران و توسعه‌دهندگان گرامی قرار داده است. با استفاده از API نوبیتکس می‌توانید علاوه بر اطلاع از آخرین قیمت‌ها و وضعیت بازار رمزارزها در ایران، اقدام به مدیریت حساب نوبیتکس خود به روش خودکار و مبتنی بر کد نمایید. استفاده از API علاوه بر فراهم‌سازی امکانات نوین برای کاربران، امکان انجام معاملات خودکار که باعث سیال و منصفانه‌تر شدن قیمت در بازارها می‌شود را فراهم می‌کند. - -پیش از استفاده از API نوبیتکس اطمینان حاصل کنید که با -[قوانین نوبیتکس](https://nobitex.ir/policies/terms/) -و همچنین -[قوانین و شرایط استفاده از API نوبیتکس](/terms/) -آشنایی کامل دارید. -همین طور با توجه به احتمال ایجاد تغییرات در بستر نوبیتکس یا ساختار و جزئیات APIها، همواره به اطلاعیه‌های -[کانال رسمی تلگرام نوبیتکس](https://t.me/nobitexmarket) -و [کانال رسمی تلگرام API نوبیتکس](https://t.me/NobitexAPINews) -دقت کنید. به علاوه به صورت مستمر -[صفحه سابقه تغییرات API نوبیتکس](/changelog/) -را رصد کنید تا از تمامی تغییرات API نوبیتکس مطلع باشید. - -در استفاده از API همواره اطمینان حاصل کنید که کد شما قابلیت مواجهه با حالت‌های خطا و شرایط و تغییرات پیش‌بینی نشده را داشته باشد و عکس العمل مناسبی در این خصوص نشان دهد. با توجه به حساسیت‌های بازارهای مالی، لازم است که کدهای استفاده کننده از API به صورت اصولی و با ملاحظاتی مانند کنترل نرخ درخواست‌ها در شرایط مختلف، مدیریت حالت‌های خطا، پیش‌گیری از تشدید آبشاری خطاها، سازوکارهای حفاظت در عمق، وجود سامانه‌های مانیتورینگ و اعلان، وجود سازوکارهای مدیریت ریسک و ... توسعه داده شود. - -اگر برای اولین بار است که از API نوبیتکس استفاده می‌کنید، می‌توانید از بخش -راهنمای شروع به کار با API -کمک بگیرید. - -

احراز هویت و توکن

-``` -Authorization: Token yourTOKENhereHEX0000000000 -``` - -برای استفاده از APIهای غیر عمومی نیاز به ارسال توکن وجود دارد. این توکن باید به عنوان HTTP Header درخواست به صورت زیر ارسال شود: - -`Authorization: Token yourTOKENhereHEX0000000000` - -به جز APIهای بخش‌هایی که عنوان «عمومی» در انتهای نام‌شان آورده شده باشد، برای استفاده از تمام APIها نیاز به ارسال توکن وجود دارد. توکن مشخص می‌کند که کدام کاربر در حال ارسال این درخواست است. - - - -برای دریافت توکن می‌توانید با مراجعه به پنل کاربری خود در نوبیتکس، از بخش پروفایل وارد -صفحه تنظیمات -شده و توکن خود را دریافت نمایید. در صورتی که گزینه «مرا به خاطر بسپار» را در هنگام ورود به نوبیتکس انتخاب کرده باشید، این توکن تا ۳۰ روز یا زمان لاگ‌اوت شما از نوبیتکس معتبر خواهد ماند. - -در صورت تمایل به دریافت دوره‌ای و خودکار توکن، می‌توانید از -API ورود - دریافت توکن -استفاده نمایید. ولی این کار ضروری نیست و روش پیشنهادی ما برای اغلب کاربران دریافت مستقیم توکن از پنل کاربری است. تنها در صورتی که با مخاطرات ذخیره گذرواژه خود در کد و روش‌های امن این کار آشنا هستید، در استفاده از API مهارت دارید، و از طرفی نیاز به دریافت کاملاً خودکار توکن دارید، از API دریافت توکن استفاده نمایید. - -

کلید ای‌پی‌آی (آزمایشی)

- -کلید ای پی آی برای دسترسی امن تر و با مجوز مشخص به ای پی آی‌های نوبیتکس طراحی -شده است. -کلید ای پی آی به شما اجازه می‌دهد به صورت کنترل شده و از روی آی پی مشخص، -به ای پی آی های نوبیتکس دسترسی داشته باشید و مدت زمان اعتبار کلید را مشخص کنید. - -

اهداف و کاربردها

-

چرا API Key؟

-- امنیت بیشتر (امکان تعریف سطح دسترسی محدود) با سه دسترسی READ, WITHDRAW, TRADE -- پشتیبانی از **IP Whitelist** -- قابلیت تنظیم تاریخ انقضای دلخواه -- قابلیت غیرفعال‌سازی یا حذف بدون تغییر پسورد اصلی -- مناسب برای ربات‌ها و اسکریپت‌های خودکار - -

سطوح دسترسی (Permissions)

-- **READ** →دریافت اطلاعات بدون تغییر در دیتابیس -- **TRADE** → عملیات‌های مربوط به معامله و ترید، که منجر به تغییری در دیتابیس می‌شوند. -- **WITHDRAW** → دسترسی عملیات برداشت - -توجه کنید که برای دسترسی به ای پی آی هایی مانند لیست سفارشات، دسترسی READ الزامی است. -هر کلید می‌تواند یکی یا چند دسترسی داشته باشد. - -

ایجاد API Key

- -

آدرس

- -POST /apikeys/create - -

پارامترهای ورودی

- -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|------------------------|----------------|-------------|--------------------------------------------------------------------------|---------------------------------------------| -| `name` | string | الزامی | نام کلید برای شناسایی توسط کاربر | `"my-api-key"` | -| `description` | string | خالی (`''`) | توضیحات دلخواه کاربر | `"API key for internal services"` | -| `permissions` | string (enum) | الزامی | مقادیر مجاز: `READ`, `TRADE`, `WITHDRAW` (به صورت رشته و جداشده با کاما) | `"READ,TRADE"` | -| `ipAddressesWhitelist` | list | `[]` | لیست آدرس‌های IP مجاز (IPv4/IPv6) | `["192.168.1.10", "10.0.0.5"]` | -| `expirationDate` | datetime (UTC) | `None` | تاریخ انقضای کلید (اختیاری) | `"2025-12-31T23:59:59Z"` | - - -

نکات امنیتی

-- ارسال **OTP (2FA)** در هدر `X-totp` الزامی است. -- بعد از ایجاد کلید، یک **ایمیل اطلاع‌رسانی** برای کاربر ارسال می‌شود. -- رویداد ایجاد کلید در لاگ ثبت می‌شود. - -> نمونه درخواست - -```json -{ - "name": "my-api-key", - "description": "API key for internal services", - "permissions": "READ,TRADE", - "ipAddressesWhitelist": [ - "192.168.1.10", - "10.0.0.5" - ], - "expirationDate": "2025-12-31T23:59:59Z" -} -``` - -> نمونه پاسخ - -```json -{ - "key": { - "createdAt": "2025-09-02T16:50:29.381869Z", - "description": "API key for internal services", - "expirationDate": "2025-12-31T23:59:59Z", - "ipAddressesWhitelist": ["192.168.1.10", "10.0.0.5"], - "key": "5XOCQZSPLQM4MiLzuUnZoBuqgYgTKl40W2X5j1pxfIA=", - "name": "my-api-key", - "permissions": "READ,TRADE", - "updatedAt": "2025-09-02T16:50:29.381876Z" - }, - "privateKey": "S5y19KewZzheCWCO4xqMcwwvtR8vQ-hHjE_cdjz-XxE=", - "status": "ok" -} -``` -⚠️ توجه: کلید خصوصی (privateKey) فقط یک بار در پاسخ نمایش داده می‌شود. حتماً آن را در مکان امن (Secret Manager) ذخیره کنید. - -

مدیریت کلیدها

- -

لیست کلیدها

- -GET /apikeys/list - -خروجی: لیست کلیدهای کاربر + وضعیت و اطلاعات آنها. - -

حذف کلید

- -POST /apikeys/delete/ - -ورودی: public_key در آدرس -خروجی: -```json - { - "status": "ok" - } -``` - -کلید عمومی را در یو آر ال قرار دهید. - -#### بروزرسانی کلید - -POST /apikeys/update/ - -قابل تغییر: name, description, ipAddressesWhitelist -خروجی: شیء کلید به‌روزرسانی‌شده. - -> نمونه درخواست - -```json -{ - "name": "my-api-key", - "description": "API key for internal services", - "ipAddressesWhitelist": [ - "192.168.1.10", - "10.0.0.5" - ] -} -``` - -> نمونه پاسخ - -```json -{ - "key": { - "createdAt": "2025-09-02T16:50:29.381869Z", - "description": "API key for internal services", - "expirationDate": "2025-12-31T23:59:59Z", - "ipAddressesWhitelist": ["192.168.1.10", "10.0.0.5"], - "key": "5XOCQZSPLQM4MiLzuUnZoBuqgYgTKl40W2X5j1pxfIA=", - "name": "my-api-key", - "permissions": "READ,TRADE", - "updatedAt": "2025-09-02T16:50:29.381876Z" - }, - "status": "ok" -} -``` - -

دسترسی ها

- -سه دسترسی خواندن، معامله و برداشت تعریف شده است. - -

READ

- -دسترسی خواندن مخصوص تمام ای پی آی هایی است که تغییری در دیتابیس ایجاد نمی‌کنند. -با ایجاد این دسترسی روی یک کلید، دسترسی به ای پی آی های زیر، ایجاد می‌شود.: - -**اطلاعات کاربر** - -* `users/preferences` -* `users/profile` -* `users/verification/status` -* `notifications/list` -* `users/limitations` - -**مارکت** - -* `market/orders/status` -* `market/orders/list` -* `market/trades/list` - -**پورتفولیو** - -* `users/portfolio/last-week-daily-profit` -* `users/portfolio/last-week-daily-total-profit` -* `users/portfolio/last-month-total-profit` -* `users/portfolio/daily_total_balance` - -**واریز شتابی** - -* `users/payments/ids-list` - -**کیف پول** - -* `users/wallets/list` -* `v2/wallets` -* `users/wallets/balance` -* `users/wallets/transactions/list` -* `users/transactions-history` -* `users/wallets/deposits/list` -* `users/wallets/withdraws/list` -* `users/wallets/deposit/bank` -* `users/wallets/deposit/shetab` -* `withdraws/` - -**معاملات تعهدی** - -* `margin/fee-rates` -* `margin/delegation-limit` -* `margin/v2/delegation-limit` -* `positions/list` -* `positions/active-count` -* `positions//status` -* `positions//edit-collateral/options` -* `margin/predict/` - - -

Trade

-کلید با این دسترسی، به ای پی آی هایی که برای ثبت و کنسل سفارشات و در کل کنترل -سفارشات استفاده می‌شوند، دسترسی دارد. - -با اختصاص این مجوز به یک کلید، دسترسی به ای پی آی های زیر به آن کلید داده می‌شود: - -**معاملات تعهدی** - -* `margin/orders/add` -* `positions//close` -* `positions//edit-collateral` - -**معاملات بازار اسپات** - -* `market/orders/add` -* `market/orders/batch-add` -* `market/orders/update-status` -* `market/orders/cancel-old` -* `market/orders/cancel-batch` -* `users/wallets/convert` - -

Withdraw

- -کلید با این دسترسی، به ای پی آی های برداشت دسترسی دارد. -پیشنهاد می‌کنیم برای این کلید حتما آی پی مشخص کنید. -با اختصاص این مجوز به یک کلید، دسترسی به این اند پوینت ها باز می‌شود: - -* `withdraws//update-status` -* `users/wallets/withdraw` -* `users/wallets/withdraw-confirm` -* `users/wallets/withdraw-cancel` - -

استفاده از کلید API

- -برای استفاده از API باید سه هدر زیر در هر درخواست ارسال شوند: - -| Header | توضیح | -|------------------------|----------------------------------------------------------------------| -| `Nobitex-Key` | کلید عمومی تولید شده توسط کاربر | -| `Nobitex-Signature` | امضای محاسبه‌شده با الگوریتم `Ed25519` | -| `Nobitex-Timestamp` | زمان جاری به ثانیه (Unix timestamp) در منطقه زمانی UTC | - -

نحوه محاسبه امضا (Signature)

- -امضا به صورت زیر محاسبه می‌شود: - -```shell - signature = base64(Ed25519(timestamp + method + url + body)) -``` - -- **timestamp**: عدد ثانیه‌ای (Unix time) بر اساس UTC -- **method**: متد HTTP درخواست (مانند `GET`, `POST`) -- **url**: مسیر کامل درخواست (endpoint) مانند `/market/orders/list?fromId=123` -- **body**: محتوای خام بدنه درخواست (برای متدهای `POST`، `PUT` و …) - -> توجه: مقدار `Nobitex-Key` همان کلید عمومی شماست و باید به صورت ثابت در هدر ارسال شود. - -```bash -curl -X POST "https://apiv2.nobitex.ir/orders/cancel-old" \ - -H "Content-Type: application/json" \ - -H "Nobitex-Key: " \ - -H "Nobitex-Signature: " \ - -H "Nobitex-Timestamp: " \ - -d '{ - "order": 27032, - "status": "canceled" - }' -``` - - -

تنظیم User Agent

-جهت شناسایی و تفکیک بهتر بات‌ها و پشتیبانی از آن‌ها، اکیداً توصیه می‌شود که در تمامی درخواست‌ها مقدار هدر User-Agent را مطابق الگوی `TraderBot/XXXXX` ارسال نمایید، که بخش `XXXXX` هر نام یکتایی است که می‌توانید برای بات خود انتخاب کنید. با رعایت این نام‌گذاری پاسخگویی به درخواست‌های پشتیبانی و عیب‌یابی مشکلات بهتر صورت می‌گیرد. - - -

محدودیت‌ها

-توجه داشته باشید، برای استفاده از APIها محدودیت هایی وجود دارد که در قسمت توضیحات هر کدام از APIها این موارد ذکر شده است. - -همچنین به منظور حفظ امنیت حساب کاربران، در هنگام احرازهویت(لاگین)، در صورتی که دستگاه شما جدید شناخته شود، محدودیت برداشت به مدت یک‌ساعت روی حساب کاربری شما اعمال خواهد شد. کاربرانی که فرایند دریافت توکن با زمان کمتر از این یک‌ساعت دارند میتوانند مقدار device را که در جواب دریافت توکن دریافت کرده‌اند را در مراحل بعدی به همراه دیگر پارامترها ارسال، تا از اعمال این محدودیت جلوگیری نمایند. - -روش دیگری که پیش و روی شماست استفاده از توکن‌های بلندمدت است. - -

تغییرات و موارد قدیمی

-با توجه به ماهیت نوین و تغییرات مستمر مورد نیاز در حوزه رمزارزها، در API نوبیتکس نیز ممکن است در طول زمان تغییراتی ایجاد شود. پشتیبانی طولانی‌مدت از نسخه‌های قدیمی API معمولاً فرآیندی پیچیده و سخت است و باعث کاهش سرعت ایجاد تغییرات جدید در بستر نوبیتکس می‌شود. به همین دلیل API نوبیتکس همواره در عین حفظ ساختار کلی و اجزای اصلی ثابت، در حال بهبود مستمر و به‌روزرسانی است. کاربران گرامی می‌توانند با پیگیری تغییرات API که در [صفحه سابقه تغییرات API نوبیتکس](/changelog/) اطلاع‌رسانی می‌شود، همواره از تغییرات احتمالی ضروری در کد خود مطلع شوند تا بتوانند به صورت بدون وقفه از جدیدترین امکانات و روش‌های دسترسی به API نوبیتکس بهره‌مند شوند. - -مواردی که قبلاً در API موجود بودند ولی در حال حاضر پشتیبانی نمی‌شوند، جهت ثبت سابقه در [صفحه API قدیمی](/deprecated/) موجود هستند. ممکن است APIهای دیگری علاوه بر موارد مستند شده در مستندات پیش‌رو وجود داشته باشند، که این موارد جز API رسمی نوبیتکس نبوده و تضمینی در قبال ادامه‌دار بودن پشتیبانی از آن‌ها وجود ندارد. همین طور در استفاده از APIهای فعلی لازم به توضیح است که ممکن است علاوه بر فیلدهایی که در ورودی یا خروجی مستند شده است، فیلدهای دیگری نیز وجود داشته باشند. این فیلدها تا زمانی که در مستندات اضافه نشده باشند باید به عنوان امکانات آزمایشی و موقت در نظر گرفته شوند و نباید مورد استفاده عموم کاربران قرار گیرد. تنها کافی است که کدهای توسعه داده شده در صورت مشاهده فیلدی غیر از فیلدهای مورد انتظار خود، دچار خطا نشوند و صرفاً وجود آن فیلد را نادیده بگیرند. - -

راهنمای حل مشکلات

- -در صورتی که پاسخ مد نظر خود را از API دریافت نمی‌کنید، ابتدا اطمینان حاصل کنید که تمامی موارد ذکر شده در مستندات مربوطه را به درستی رعایت کرده باشید. بهترین روش حل مشکلات برنامه‌نویسی سعی در ریشه‌یابی مشکلات با تغییر متغیرها و بررسی تمام حالت‌ها و استفاده از روش‌های مرسوم عیب‌یابی کد است. - -در صورت حل نشدن مشکل، مراجعه به بخش [سوالات متداول](#faq) و [ملاحظات عمومی](#general-considerations) می‌تواند در عیب‌یابی مفید باشد. همین طور اگر مشکل مربوط به حساب شما باشد و اقدامی را نه از طریق API و نه از طریق سایت نوبیتکس نتوانید انجام دهید، باید با -پشتیبانی آنلاین نوبیتکس -در ارتباط باشید. - -در صورتی که بخشی از مستندات API مبهم است، یا پیشنهادی درباره APIهای موجود دارید، یا پس از بررسی کامل اطمینان دارید که مشکلی در API نوبیتکس وجود دارد، می‌توانید در -مخزن گیت‌هاب مستندات نوبیتکس API -مورد (issue) جدیدی را ایجاد نمایید و با ما در ارتباط باشید. دقت کنید که این کانال عمومی است و نباید در آن هیچ گونه اطلاعات حساس یا توکن یا سایر اطلاعات حساب خود را مطرح کنید. - - -

راهنمای شروع به کار با API

- -اگر برای اولین بار از API نوبیتکس یا سایر بازارهای رمزارز استفاده می‌کنید، برای شروع کار پیشنهاد می‌شود گام‌های زیر را طی کنید: - -* برای شروع کار با API پیشنهاد می‌شود که ابتدا در نوبیتکس -ثبت‌نام -نمایید و مراحل احراز هویت خود را حداقل تا سطح یک انجام دهید. -* با مراجعه به پنل کاربری خود در نوبیتکس، از بخش پروفایل وارد -صفحه تنظیمات -شده و توکن خود را دریافت نمایید. دسترسی به این توکن به منزله دسترسی کامل به حساب شماست، در نتیجه در حفاظت آن دقت کامل داشته باشید. -* اگر با نرم‌افزار Postman آشنا هستید، می‌توانید برای تست فراخوانی APIهای اصلی نوبیتکس، از -کالکشن Postman نوبیتکس -استفاده کنید. لازم به توضیح است که این کالکشن تنها شامل برخی از APIهای نوبیتکس و کاربرد آن‌ها است و مرجع اصلی مستندات، همین صفحه است. - -همین طور می‌توانید بنا به نیاز خود این موارد را نیز در ادامه در نظر بگیرید: - -* در صورت تمایل به دریافت دوره‌ای و خودکار توکن، می‌توانید از -API ورود - دریافت توکن -استفاده نمایید. diff --git a/source/includes/_market_data.md b/source/includes/_market_data.md deleted file mode 100644 index e5245cf..0000000 --- a/source/includes/_market_data.md +++ /dev/null @@ -1,362 +0,0 @@ -# اطلاعات بازار (عمومی) - -

لیست سفارش‌ها: اردربوک

- -```shell -curl 'https://apiv2.nobitex.ir/v3/orderbook/BTCIRT' -``` - -```plaintext -http GET https://apiv2.nobitex.ir/v3/orderbook/BTCIRT -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "lastUpdate": 1644991756704, - "lastTradePrice": "35650565900", - "asks": [ - ["1476091000", "1.016"], - ["1479700000", "0.2561"] - ], - "bids": [ - ["1470001120", "0.126571"], - ["1470000000", "0.818994"] - ] -} -``` - -برای دریافت لیست سفارش‌ها یا همان اردربوک بازارهای مختلف، از این درخواست استفاده نمایید: - -- **درخواست:** `GET /v3/orderbook/SYMBOL` -- **محدودیت فراخوانی:** 300 درخواست در دقیقه -- **نیاز به ارسال توکن:** ندارد - - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -SYMBOL | string | الزامی | نماد بازار | `BTCIRT` - - - -```shell -curl 'https://apiv2.nobitex.ir/v3/orderbook/all' -``` - -> نمونه پاسخ درخواست /v3/orderbook/all: - -```json -{ - "status": "ok", - "BTCIRT": { - "lastUpdate": 1644991756704, - "asks": [ - ["1476091000", "1.016"], - ["1479700000", "0.2561"] - ],` - "bids": [ - ["1470001120", "0.126571"], - ["1470000000", "0.818994"] - ] - }, - "USDTIRT": { - "lastUpdate": 1644991767392, - "asks": [ - ["277990", "6688.3"], - ["278000", "28185.03"] - ], - "bids": [ - ["277960", "119.31"], - ["271240", "1079.75"] - ] - } -} -``` - - - -### پارامترهای پاسخ -خروجی شامل دو آرایه `asks` و `bids` بوده که در هر یک قیمت و مقدار سفارش‌های بازار وجود دارد. سفارش‌های خرید در `bids` و سفارش‌های فروش در `asks` بازگردانده می‌شوند. هر یک از این آرایه‌ها شامل دوتایی‌های «قیمت، مقدار» هستند. - -همچنین زمان آخرین به‌روزرسانی در اردربوک ذیل پارامتر `lastUpdate` به فرمت یونیکس داده می‌شود. - - -| پارامتر پاسخ | نوع | توضیحات | نمونه | -|--------------------|--------|-------------------------------------------------------|-----------------------------------------------------------| -| `asks` | array | حاوی دوتایی‌های «قیمت، مقدار» از سفارش‌های **فروش** | [["1231", "0.1"],["1243", "1.02"]] | -| `bids` | array | حاوی دوتایی‌های «قیمت، مقدار» از سفارش‌های **خرید** | [["1243", "1"],["1231", "2"]] | -| `lastTradePrice` | string | مبلغ آخرین معامله | "35602702700" | -| `lastUpdate` | int | زمان آخرین به‌روزرسانی به فرمت یونیکس | 1726651067347 | - - - -### روش پیشنهادی نگهداری اردربوک -به این منظور از وب‌سوکت استفاده نمایید. برای اطلاعات بیشتر به [مستندات وب‌سوکت نوبیتکس](#websocket) مراجعه فرمایید. - -در صورتی‌که نمی‌توانید از وب‌سوکت استفاده کنید و در پروژه‌ی خود نیاز به نگهداری آخرین وضعیت اردربوک نوبیتکس هستید، در یک حلقه اقدام به دریافت اردربوک نوبیتکس نمایید. حتماً در میان هر دو بار اجرای حلقه حداقل یک تا ده ثانیه صبر نمایید و از فراخوانی پیاپی و بی‌مکث اردربوک خودداری کنید. به دلیل وجود لایه‌های کش، در صورت فراخوانی در بازه‌های زیر یک ثانیه، همان داده فراخوانی قبلی را دریافت خواهید نمود. اگر در اغلب بازارهای نوبیتکس فعال هستید، می‌توانید در هر فراخوانی کل اردربوک را دریافت نمایید تا نیازی به فراخوانی همزمان چند اردربوک نداشته باشید. اگر کد خود را در چند رشته (ترد) یا پردازه یا سرور اجرا می‌کنید، حتماً اردربوک را در یک مرجع واحد دریافت نمایید و آن را در میان نمونه‌های برنامه خود به اشتراک بگذارید. - -## نمودار عمق (آزمایشی) - -```shell -curl 'https://apiv2.nobitex.ir/v2/depth/BTCIRT' -``` - -```plaintext -http GET https://apiv2.nobitex.ir/v2/depth/BTCIRT -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "lastUpdate": "1658565992195", - "bids": [["7309999000", "2.200274"], ["7310000000", "2.199856"], ["7310025000", "2.102569"]], - "asks": [["7409894000", "0.054789"], ["7447665000", "0.055276"], ["7450000000", "0.059756"]], - "lastTradePrice": "7417000000"} -``` - -برای دریافت داده‌های نمودار عمق، یا همان اردربوک بازارهای مختلف، از این درخواست استفاده نمایید: - -- **درخواست:** `GET /v2/depth/SYMBOL` -- **محدودیت فراخوانی:** 300 درخواست در دقیقه -- **نیاز به ارسال توکن:** ندارد - - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -SYMBOL | string | الزامی | نماد بازار | `BTCIRT` - - - -### پارامترهای پاسخ -خروجی شامل دو آرایه asks و bids بوده که در هر یک قیمت و مقدار سفارش‌های بازار وجود دارد. **سفارش‌های خرید در `bids` و سفارش‌های فروش در `asks` بازگردانده می‌شوند.** هر یک از این آرایه‌ها شامل دوتایی‌های «قیمت، مقدار» هستند که در هر دوتایی، مقدار قیمت، تجمیع شده و گرد شده با دقت مناسب بازار مورد نظر است. - -همچنین زمان آخرین به‌روزرسانی نمودار عمق ذیل پارامتر `lastUpdate` به فرمت یونیکس داده می‌شود. - -همچنین، مبلغ آخرین معامله ذیل پارامتر `lastTradePrice` ارسال می‌شود. - -### روش پیشنهادی نگهداری نمودار عمق -در صورتی که در کد خود نیاز به نگهداری آخرین وضعیت نمودار عمق نوبیتکس هستید، در یک حلقه اقدام به دریافت نمودار عمق نوبیتکس نمایید. حتماً در میان هر دو بار اجرای حلقه حداقل یک تا ده ثانیه صبر نمایید و از فراخوانی پیاپی و بی‌مکث خودداری کنید. به دلیل وجود لایه‌های کش، در صورت فراخوانی در بازه‌های زیر یک ثانیه، همان داده فراخوانی قبلی را دریافت خواهید نمود. - -## لیست معاملات - -```shell -curl 'https://apiv2.nobitex.ir/v2/trades/BCHIRT' -``` - -```plaintext -http GET https://apiv2.nobitex.ir/v2/trades/BCHIRT -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "trades": [ - { - "time": 1588689375067, - "price": "1470000110", - "volume": "0", - "type": "sell" - }, - { - "time": 1588689360464, - "price": "1470000110", - "volume": "0.002", - "type": "buy" - } - ] -} -``` - -برای دریافت لیست معاملات از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET v2/trades/SYMBOL ` -- **محدودیت فراخوانی:** 60 درخواست در دقیقه -- **نیاز به ارسال توکن:** ندارد - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -symbol | string | الزامی | نماد | `BTCIRT` - - - - -پارامتر بازگشتی time زمان دقیق انجام شدن معامله است که با فرمت یونیکس نمایش داده میشود - -## آمار بازار نوبیتکس - -```shell -curl 'https://apiv2.nobitex.ir/market/stats?srcCurrency=btc&dstCurrency=rls' -``` - -```plaintext -http GET https://apiv2.nobitex.ir/market/stats \ - srcCurrency=btc dstCurrency=rls -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "stats": { - "btc-rls": { - "isClosed": false, - "bestSell": "749976360", - "bestBuy": "733059600", - "volumeSrc": "0.2929480000", - "volumeDst": "212724856.0678640000", - "latest": "750350000", - "mark": "747461987", - "dayLow": "686021860", - "dayHigh": "750350000", - "dayOpen": "686021860", - "dayClose": "750350000", - "dayChange": "9.38" - } - } -} -``` - -برای دریافت آخرین آمار بازار نوبیتکس از این نوع درخواست استفاده نمایید: - -- **درخواست** `GET /market/stats` -- **محدودیت فراخوانی:** 20 درخواست در دقیقه - - -### پارامترهای ورودی - - پارامتر | نوع | پیش‌فرض | توضیحات | نمونه --------------|--------|---------|------------|------------ - srcCurrency | string | اختیاری | ارزها مبدا | `btc,usdt` - dstCurrency | string | اختیاری | ارز مقصد | `rls` - -پارامترهای srcCurrency و dstCurrency اختیاری هستند و در صورت وارد نکردن آن‌ها، آمار مربوط به کل بازار نوبیتکس نمایش داده می‌شود. همچنین، وارد کردن هر کدام از این پارامترها به‌تنهایی امکان‌پذیر است؛ برای مثال، اگر `dstCurrency=rls` را تنظیم کنید، تمام بازارهای ریالی را دریافت خواهید کرد. - - - -## آمار OHLC بازار نوبیتکس - -```shell -curl 'https://apiv2.nobitex.ir/market/udf/history?symbol=BTCIRT&resolution=D&from=1562058167&to=1562230967' -``` - -```plaintext -http GET https://apiv2.nobitex.ir/market/udf/history?symbol=BTCIRT&resolution=D&from=1562058167&to=1562230967 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "s": "ok", - "t": [1562095800, 1562182200], - "o": [146272500, 150551000], - "h": [155869600, 161869500], - "l": [140062400, 150551000], - "c": [151440200, 157000000], - "v": [18.221362316, 9.8592626506] -} -``` - -برای توضیحات بیشتر در مورد OHLC به [این لینک](https://en.wikipedia.org/wiki/Open-high-low-close_chart) مراجعه کنید.

-برای دریافت آمار OHLC نوبیتکس از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET /market/udf/history` - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|------------|--------|---------|--------------------------------------------------------------------|--------------| -| symbol | string | الزامی | نماد بازار | `BTCIRT` | -| resolution | string | الزامی | بازه زمانی هر کندل | `D` | -| to | int | الزامی | زمان پایان بازه | `1562230967` | -| from | int | اختیاری | زمان ابتدای بازه | `1562058167` | -| countback | int | اختیاری | تعداد کندل‌های پیش از زمان پایان
(اولویت آن از from بیشتر است) | `4` | -| page | int | `1` | شماره صفحه | `3` | - -> در صورت ورودی اشتباه برای resolution پاسخ به این صورت خواهد بود: - -```json -{ - "s": "error", - "errmsg": "Invalid resolution!" -} -``` - -* پارامتر resolution بازه زمانی کندل‌های خروجی می‌باشد و مقدار آن می‌تواند یکی از مقادیر زیر باشد: - -| دقیقه‌ای | توضیح | ساعتی | توضیح | روزانه | توضیح | -|----------|-----------|-------|-------------|--------|--------| -| `1` | یک دقیقه | `60` | یک ساعت | `D` | یک روز | -| `5` | پنج دقیقه | `180` | سه ساعت | `2D` | دو روز | -| `15` | یک ربع | `240` | چهار ساعت | `3D` | سه روز | -| `30` | نیم ساعت | `360` | شش ساعت | | | -| | | `720` | دوازده ساعت | | | - -* مقادیر from و to زمان شروع و پایان جست‌وجو را مشخص می‌کند و با فرمت یونیکس به ثانیه مشخص می‌شود. - -> در صورت نبودن داده در بازه درخواستی پاسخ به این صورت خواهد بود: - -```json -{ - "s": "no_data" -} -``` - - - - - -### پارامترهای پاسخ - -در هر درخواست بسته به پارامتر countback یا بازه زمانی تعیین شده و resolution انتخابی، تعداد کندل‌های برگشتی متفاوت است. -برای مثال تعداد کندل‌های 1 ساعته از تاریخ 2019/2/9 15:39:41 تا چهار ساعت قبل آن، ۴ تاست. - -| پارامتر | توضیح | نوع | نمونه | -|---------|--------------|-----------|------------------| -| `s` | وضعیت پاسخ | string | `ok` | -| `t` | شروع زمان | [ ] int | `[1562182200]` | -| `o` | قیمت شروع | [ ] float | `[150551000]` | -| `h` | بیشترین قیمت | [ ] float | `[161869500]` | -| `l` | کمترین قیمت | [ ] float | `[150551000]` | -| `c` | قیمت پایانی | [ ] float | `[157000000]` | -| `v` | حجم معاملات | [ ] float | `[9.8592626506]` | - -* در هر درخواست حداکثر 500 کندل بازگردانده می‌شود. برای بازیابی همه کندل‌های یک بازه با بیش از 500 کندل، از پارامتر page برای صفحه‌بندی استفاده نمایید. diff --git a/source/includes/_market_trade.md b/source/includes/_market_trade.md deleted file mode 100644 index d441aa3..0000000 --- a/source/includes/_market_trade.md +++ /dev/null @@ -1,656 +0,0 @@ -# معامله در بازار اسپات - -## ثبت سفارش جدید - -```shell -curl 'https://apiv2.nobitex.ir/market/orders/add' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"type":"buy","srcCurrency":"btc","dstCurrency":"rls","amount":"0.6","price":520000000,"clientOrderId":"order1"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/market/orders/add \ - type=buy srcCurrency=btc dstCurrency=rls amount=0.6 price=520000000 clientOrderId=order1 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "order": { - "type": "sell", - "srcCurrency": "Bitcoin", - "dstCurrency": "ریال", - "price": "520000000", - "amount": "0.6", - "totalPrice": "312000000.0", - "matchedAmount": 0, - "unmatchedAmount": "0.6", - "id": 25, - "status": "Active", - "partial": false, - "fee": 0, - "created_at": "2018-11-28T11:36:13.592827+00:00", - "clientOrderId": "order1", - } -} -``` - -برای ثبت سفارش معامله در بازار نوبیتکس از این درخواست استفاده نمایید. - -- **درخواست:**: `POST /market/orders/add` -- **محدودیت فراخوانی:** 300 درخواست در هر ۱۰ دقیقه (محدودیت مشترک) - -ثبت سفارش الزاماً به معنی انجام معامله نیست و بسته به نوع و قیمت سفارش و وضعیت لحظه‌ای بازار ممکن است معامله انجام شود یا نشود. با درخواست «مشاهده وضعیت سفارش» می‌توانید از وضعیت سفارش خود مطلع شوید. - -سفارش‌ها پس از ثبت، پیش از ورود به دفتر معاملاتی و انجام معامله، مجدداً از نظر اعتبار مورد بررسی قرار گرفته و در صورت نامعتبر بودن، به وضعیت «رد شده» برده خواهند شد. به همین علت در صورتی که سفارش‌های شما ثبت می‌شود ولی بلافاصله به وضعیت «رد شده» تغییر حالت پیدا می‌کنند، پارامترهای ارسالی خود به ویژه مقدار و قیمت سفارش و موجودی حساب خود را دقیق‌تر بررسی نمایید. - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|-------------|----------|--------|--------------------|---------------------------------------------------| -| type | string | الزامی | نوع سفارش | `buy` یا `sell` | -| execution | string | `limit` | نحوه‌ی اجرای سفارش | `market`: با قیمت بازار
`limit`: با قیمت معین | -| srcCurrency | string | الزامی | رمزارز مبدا | `btc` یا `eth` یا `xrp` یا ... | -| dstCurrency | string | الزامی | رمزارز مقصد | `rls` یا `usdt` | -| amount | monetary | الزامی | مقدار رمزارز (حجم) | `0.0623` | -| price | monetary | الزامی | قیمت واحد | `1210000000` | -| clientOrderId | string | `null` | شناسه سفارش کاربر، تا ۳۲ کاراکتر،‌ یکتا برای هر کاربر و در میان سفارش های open/active/inactive (آزمایشی) | `order1` | - - -> نمونه سفارش حد ضرر: - -```shell -curl 'https://apiv2.nobitex.ir/market/orders/add' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"type":"sell","srcCurrency":"doge","dstCurrency":"rls","amount":"64","execution":"stop_market","stopPrice":47500,"clientOrderId":"order1"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/market/orders/add \ - type=sell srcCurrency=doge dstCurrency=rls amount=64 execution=stop_market stopPrice=47500 clientOrderId=order1 -``` - -```json -{ - "status": "ok", - "order": { - "id": 26, - "type": "sell", - "execution": "StopMarket", - "market": "DOGE-RLS", - "srcCurrency": "Dogecoin", - "dstCurrency": "\ufdfc", - "price": "market", - "amount": "64", - "param1": "47500", - "totalPrice": "0", - "totalOrderPrice": "3008000", - "matchedAmount": "0", - "unmatchedAmount": "64", - "status": "Inactive", - "partial": false, - "fee": 0, - "created_at": "2022-01-17T12:14:18.005896+00:00", - "averagePrice": "0", - "clientOrderId": "order1", - } -} -``` - -### سفارش حد ضرر - -این سفارش در زمان رسیدن قیمت بازار به قیمت توقف فعال خواهد شد. کاربرد اصلی آن، جلوگیری از زیان در صورت تغییر غیرمنتظره قیمت بازار است. -با ثبت این نوع سفارش می‌توان بدون نیاز به رصد مداوم بازار، در صورت خروج قیمت از بازه مد نظر، اقدام به تبدیل دارایی نمود. - -#### پارامترهای ویژه حد ضرر - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|-----------|----------|---------|--------------------|-----------------------------------------------------| -| execution | string | الزامی | نحوه‌ی اجرای سفارش | `stop_market`: حد ضرر
`stop_limit`: حد ضرر معین | -| stopPrice | monetary | الزامی | قیمت توقف | `1180000000` | - -> نمونه سفارش OCO: - -```shell -curl 'https://apiv2.nobitex.ir/market/orders/add' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"type":"buy","srcCurrency":"btc","dstCurrency":"usdt","amount":"0.01","mode":"oco","price":42390,"stopPrice":42700,"stopLimitPrice":42715,"clientOrderId":"order1"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/market/orders/add \ - type=buy srcCurrency=btc dstCurrency=usdt amount=0.01 mode=oco price=42390 stopPrice=42700 stopLimitPrice=42715 clientOrderId=order1 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "orders": [ - { - "id": 27, - "type": "buy", - "execution": "Limit", - "market": "BTC-USDT", - "srcCurrency": "Bitcoin", - "dstCurrency": "Tether", - "price": "42390", - "amount": "0.01", - "totalPrice": "0", - "totalOrderPrice": "423.9", - "matchedAmount": "0", - "unmatchedAmount": "0.01", - "status": "Active", - "created_at": "2022-04-10T10:12:38.402795+00:00", - "pairId": 28, - "clientOrderId": "order1" - }, - { - "id": 28, - "type": "buy", - "execution": "StopLimit", - "market": "BTC-USDT", - "srcCurrency": "Bitcoin", - "dstCurrency": "Tether", - "price": "42715", - "amount": "0.01", - "param1": "42700", - "totalPrice": "0", - "totalOrderPrice": "427.15", - "matchedAmount": "0", - "unmatchedAmount": "0.01", - "status": "Inactive", - "created_at": "2022-04-10T10:12:38.402795+00:00", - "pairId": 27, - "clientOrderId": null - } - ] -} -``` - -### سفارش OCO - -یک سفارش OCO در واقع متشکل از دو سفارش است: یک سفارش با _قیمت معین_، و یک سفارش با _حد ضرر معین_. - -در صورتی که هر کدام از این دو سفارش انجام شوند، سفارش دیگر لغو خواهد شد. -به عنوان مثال، اگر قیمت بازار، به قیمت سفارش معین برسد، سفارش معین اجرا می‌شود و سفارش حد ضرر، به طور خودکار لغو می‌گردد. -عکس این حالت نیز برقرار است. اگر قیمت به حد ضرر تعیین شده برسد، سفارش حد ضرر اجرا شده، سفارش با قیمت معین لغو می‌گردد. - -#### پارامترهای ویژه OCO - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------------|----------|---------|------------------|--------------| -| mode | string | الزامی | حالت سفارش | `oco` | -| stopPrice | monetary | الزامی | قیمت توقف حد ضرر | `1180000000` | -| stopLimitPrice | monetary | الزامی | قیمت حد ضرر | `1179500000` | - - - -### حالت‌های خطا - -> در صورت عدم پذیرش سفارش، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message", - "clientOrderId": "order1" -} -``` - -در صورتی که درخواست ثبت سفارش معتبر نباشد، ممکن است یکی از این خطاها برگردانده شود. در صورت دریافت هر یک از این خطاها، آن سفارش شما ثبت نشده است و در صورت تمایل باید درخواست ثبت آن سفارش را دوباره ارسال کنید. - -کد خطا | توضیحات --------- | --------- -InvalidOrderPrice | قیمت سفارش (price) تعیین نشده یا اشتباه است -BadPrice | در سفارش عادی: قیمت تعیین شده برای سفارش نسبت به قیمت فعلی بازار تفاوت زیادی دارد. قیمت سفارش خود را در بازه‌ی ۳۰٪ قیمت کنونی بازار تعیین کنید.
در سفارش حد ضرر: قیمت تعیین شده برای سفارش بازار نمی‌تواند از قیمت توقف بهتر باشد. -PriceConditionFailed | شرط قیمت در سفارش لحاظ نشده است. شرط قیمت میان پارامترهای قیمتی و قیمت بازار تعریف می‌شود. -OverValueOrder | مقدار سفارش فروش (amount) یا ارزش کل سفارش خرید (amount*price) از موجودی کیف پول نوبیتکس شما کمتر است. -SmallOrder | حداقل ارزش معامله رعایت نشده است. حداقل ارزش معامله برای بازارهای ریالی، 3 میلیون ریال و برای بازارهای تتری، ۱۱ تتر است و مبلغ کل سفارش (amount*price) باید بیشتر از این حداقل باشد. -DuplicateOrder | سفارشی با همین مشخصات توسط کاربر شما در بازه زمانی ده ثانیه اخیر ارسال شده است. -InvalidMarketPair | رمزارز مبدا (srcCurrency) یا رمزارز مقصد (dstCurrency) به درستی مقداردهی نشده است یا چنین بازاری در نوبیتکس وجود ندارد. -MarketClosed | بازار مد نظر در حال حاضر به صورت موقت بسته است. -TradingUnavailable | کاربر اجازه‌ی معامله ندارد، فرآیند احراز هویت خود را تکمیل نمایید. -FeatureUnavailable | شما از کاربران مجاز به استفاده از امکانات آزمایشی نیستید. -DuplicateClientOrderId | شناسه سفارش کاربر تکراری است (برای هر کاربر در لحطه فقط یه سفارش open/active/inactive با یک شماره سفارش ممکن است). - -### نکات و ملاحظات -1. **واحدها:** واحد قیمت در بازارهای ریالی به ریال (و نه تومان) می‌باشد. واحد قیمت در بازارهای تتری نیز تتر می‌باشد. واحد پارامتر مقدار (amount) بر حسب رمزارز مبدا (srcCurrency) است. -1. **سفارش مارکت:** برای ثبت سفارش سریع (سفارش مارکت، سفارش به قیمت بازار)، مقدار پارامتر `execution` را برابر `market` ارسال نمایید. منظور از سفارش مارکت سفارشی است که کاربر درخواست دارد تا به بهترین قیمت موجود بازار مورد انجام قرار گیرد. [ℹB](https://www.binance.vision/tutorials/what-is-a-market-order) - [ℹI](https://www.investopedia.com/terms/m/marketorder.asp) -1. **تعیین محدوده مورد انتظار قیمت:** در سفارش‌های مارکت به شدت توصیه می‌شود که پارامتر `price` را نیز مشخص نمایید. این پارامتر در سفارش مارکت تخمین شما از قیمت بازار را نمایش می‌دهد و باعث می‌شود سفارش شما تنها تا جایی پر شود که قیمت معامله در بازه‌ی قیمتی مشخص شده باشد. برای نمونه اگر نوع سفارش خرید مارکت باشد و قیمت ۱۰۰ میلیون تومان تعیین شود، تنها تا جایی در بازار range کشیده می‌شود که قیمت زیر ۱۰۱ میلیون تومان باشد. برای پیش‌گیری از معاملات با قیمت ناخواسته به علت نوسانات دفعی بازار، پیشنهاد می‌شود که حتماً قیمت تقریبی مد نظر خود را در سفارش‌های مارکت نیز ارسال کنید. با این حال اگر اطمینان به کد خود و تبعات احتمالی این موضوع دارید، می‌توانید پارامتر `price` را اصلاً ارسال ننمایید که در این شرایط معامله با قیمت لحظه‌ای بازار جهانی، به هر میزان که باشد تا بازه نوسان ۱٪، انجام خواهد شد. -1. **دقت مقادیر پولی (monetary):** نوع monetary که در پارامترهای `amount` و `price` به کار می‌رود، بسته به بازار هر رمزارز، تعداد رقم اعشار متغیری بین ۰ تا ۸ رقم دارد. در صورت ارسال مقادیر با ارقام اعشاری بیشتر، ارقام بی‌معنی در مقدار به پایین و در قیمت به روش بانکداری گرد خواهند شد.
[مشاهده جدول دقت‌ها](https://nobitex.ir/policies/markets/ "بازارهای رمزارزی نوبیتکس") -1. **clientOrderId**: دقت کنید که این پارامتر برای هر کاربر در میان سفارش های open/active/inactive یکتاست. -1. **سفارش تکراری:** برای جلوگیری از ثبت سفارش تکراری ناشی از اختلالات شبکه و سرور، در صورتی که دو یا چند سفارش با پارامترهای ورودی کاملاً مشابه از جمله نوع و قیمت و مقدار، در بازه‌ی زمانی کمتر از ده ثانیه ارسال نمایید، تنها سفارش اول پذیرفته می‌شود و باقی درخواست‌های مشابه تا ده ثانیه پیام خطای `DuplicateOrder` دریافت می‌کنند. (غیرفعال در حالت Pro) -توصیه می‌شود در صورت استفاده از این حالت Pro حتما از پارامتر `clientOrderId` استفاده نمایید تا از ثبت سفارش تکراری ناشی از اختلالات شبکه و سرور جلوگیری نماید. - -## مشاهده وضعیت سفارش - -```shell -curl 'https://apiv2.nobitex.ir/market/orders/status' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"id":5684}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/market/orders/status \ - id=5684 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "order": { - "unmatchedAmount": "3.0000000000", - "fee": "0E-10", - "matchedAmount": "0E-10", - "partial": false, - "price": "8500000.0000000000", - "created_at": "2018-11-28T12:25:22.696029+00:00", - "id": 5684, - "srcCurrency": "Litecoin", - "totalPrice": "25500000.00000000000000000000", - "type": "sell", - "dstCurrency": "\ufdfc", - "isMyOrder": false, - "status": "Active", - "amount": "3.0000000000", - "clientOrderId": "order1" - } -} -``` - -برای دریافت وضعیت سفارش از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /market/orders/status` -- **محدودیت فراخوانی:** 300 درخواست در هر دقیقه - -###پارامترهای ورودی: - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -id | int | اختیاری | شناسه سفارش | `5684` -clientOrderId | string | اختیاری | شناسه سفارش کاربر (آزمایشی) | `order1` - - -### نکات و ملاحظات - -1. حتما باید حداقل یکی از دو پارامتر ‍`order` و `clientOrderId` ارسال شوند. -2. اگر هر دو پارامتر ‍`order` و `clientOrderId` ارسال شوند، اولویت با `id` است. -3. `clientOrderId` فقط در میان سفارشات open/active/inactive جستجو میشود. -4. `clientOrderId` .در حالت آزمایشی است و ممکن است در آینده تغییر کند - -**انواع مقادیر `status`:** - -* Active: سفارش مقدار پر نشده (`unmatched_amount`) برای شرکت در معاملات دارد و در بازار فعال است. -* Done: سفارش تماما معامله شده است. -* Inactive: سفارش حد ضرر هنوز به محدوده قیمت توقف تعیین شده نرسیده و غیرفعال است. -* Canceled: سفارش پیش از پر شدن کامل توسط کاربر یا سامانه لغو شده است. -سفارش به چند دلیل می‌تواند توسط سامانه لغو شود: - * مقدار سفارش کافی در بازار در بازه ۱٪ قیمت تعیین شده برای پر کردن سفارش وجود نداشته است. - * موجودی کیف پول کاربر از طریق سایر تراکنش‌ها کاهش یافته است و از موجودی لازم برای پر شدن معامله کمتر شده است. - - -### حالت‌های خطا - -> در صورت عدم پذیرش سفارش، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -کد خطا | توضیحات --------- | --------- -NullIdAndClientOrderId | باید یکی از دو پارامتر `id` و `clientOrderId` ارسال شود - -## فهرست سفارش‌های کاربر - - -```shell -curl 'https://apiv2.nobitex.ir/market/orders/list?srcCurrency=btc&dstCurrency=usdt&details=2' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/market/orders/list \ - srcCurrency=btc dstCurrency=usdt details=2 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "orders": [ - { - "id": 173546223, - "type": "sell", - "execution": "Limit", - "status": "Active", - "srcCurrency": "Bitcoin", - "dstCurrency": "Tether", - "price": "9750.01", - "amount": "0.0123", - "matchedAmount": "0E-10", - "averagePrice": "0", - "fee": "0E-10", - "clientOrderId": "order1" - } - ] -} -``` - -برای دریافت فهرست سفارش‌های خود، از این درخواست استفاده نمایید. - -- **درخواست:** `GET /market/orders/list` -- **محدودیت فراخوانی:** 30 درخواست در دقیقه -- **صفحه بندی:** دارد (پیش فرض ۱۰۰) - -### پارامترهای ورودی -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- |----------------------------------------|-----------------------------------------------------------------------------------------| ----- -status | string | `open` | وضعیت سفارش | `all` یا `open` یا `done` یا `close` -type | string | تمام انواع سفارش | نوع سفارش‌های مد نظر، خرید یا فروش | `sell` یا `buy` -execution | string | تمام انواع سفارش گذاری‌ها | لیست سفارشات با نحوه سفارش‌گذاری مشخص | `limit`, `market`, `stop_limit`, `stop_market` -tradeType | string | تمام انواع سفارش | نوع سفارش اسپات یا فروش تعهدی | `spot` یا `margin` -srcCurrency | string | تمام رمزارزها | رمزارز مبدا | `btc` یا `eth` یا `xrp` یا ... -dstCurrency | string | تمام رمزارزها | رمزارز مقصد | `rls` یا `usdt` -details | int | `1` | میزان جزئیات پاسخ، اعداد بزرگ‌تر تعداد فیلدهای بیشتری را از وضعیت هر سفارش بازمی‌گرداند | `1` یا `2` -fromId | int | `1` | با مشخص کردن این پارامتر سفارشات با شناسه بزرگتر از این عدد لیست خواهند شد | `100` -order | string | متغیر براساس پارامترهای `fromId` و `type` | ترتیب دریافت سفارشات | `id` یا `created_at` یا `price` به صورت صعودی و یا به صورت نزولی با اضافه کردن`-` به ابتدای کلید - -### توضیحات تکمیلی پارامترهای ورودی - -* وضعیت سفارش یکی از مقادیر زیر می‌تواند باشد: - * `all`: سفارش‌های در تمامی وضعیت‌ها در پاسخ بازگردانده می‌شوند. - * `open`: سفارش‌های باز، شامل سفارش‌های فعال و غیرفعال بازگردانده می‌شوند. منظور از سفارش‌های باز غیرفعال، مثلاً سفارش‌های حد ضرری است که هنوز فعال نشده باشند. - * `done`: سفارش‌هایی که بخشی یا تمام آن پر شده باشند بازگردانده می‌شوند. - * `close`: سفارش‌هایی که وضعیت آن‌ها «انجام شده» یا «لغو شده» باشد بازگردانده می‌شوند. -* دو وضعیت `active` و `undone` از موارد قدیمی بوده و دیگر پشتیبانی نمی‌شوند. - - -* پارامتر ترتیب ارسال سفارشات می‌تواند یکی از مقادیر زیر را داشته باشد: - * `id` یا `-id`: سفارش‌ها به ترتیب شناسه‌ی سفارش به صورت صعودی و یا نزولی (در صورت ارسال علامت `-`) بازگردانده می‌شوند. - * `created_at` یا `-created_at`: سفارش‌ها در پاسخ براساس زمان سفارش‌گذاری به صورت صعودی/نزولی مرتب می‌شوند. - * `price` یا `-price`: سفارش‌ها در پاسخ بر اساس قیمتشان به صورت صعودی/نزولی مرتب می‌شوند. -* در صورتیکه پارامتر ترتیب ارسال سفارشات در درخواست ارسال نشود: - * اگر پارامتر fromId در درخواست ارسال شده باشد سفارش‌ها در پاسخ براساس شناسه‌ی سفارش به صورت نزولی مرتب می‌شوند. - * اگر پارامتر نوع سفارش ارسال نشده باشد، سفارش‌ها در پاسخ به ترتیب زمان ایجاد سفارش به صورت نزولی بازگردانده می‌شوند. - * اگر نوع سفارش با مقدار `خرید` تعیین شده باشد سفارش‌ها به ترتیب قیمت به صورت نزولی و اگر نوع سفارش با مقدار `فروش` تعیین شده باشد سفارش‌ها به ترتیب قیمت به صورت صعودی بازگردانده می‌شوند. - -### پارامترهای پاسخ -پارامتر | نوع | توضیحات | نمونه ----- | ---- | ---- | ---- -orders | list of Order | فهرست سفارش‌های کاربر | `[{...Order...}, ...]` - -### شی Order -فیلد | نوع | توضیحات | نمونه ----- | ---- | ---- | ---- -type | string | نو ع خرید یا فروش سفارش | `buy` یا `sell` -execution | string | نوع اجرای سفارش | `Limit` یا `Market` یا `StopMarket` یا `StopLimit` -tradeType | string | نوع معامله سفارش | `Spot` یا `Margin` -srcCurrency | string | رمزارز مبدا سفارش | `Bitcoin` یا `Ethereum` یا `TRON` یا ... -dstCurrency | string | رمزارز مقصد سفارش | `﷼` یا `Tether` -price | monetary | قیمت ثبت شده برای سفارش | `2900000000` یا `market` -amount | monetary | مقدار ثبت شده برای سفارش | `0.023324` -matchedAmount | monetary | مقدار پر شده از سفارش | `0.012001` -param1 | monetary | قیمت توقف در حد ضرر | `2790000000` - -
همچنین در صورتی که پارامتر `details=2` باشد این فیلدها نیز برای هر سفارش بازگردانده می‌شود: - -فیلد | نوع | توضیحات | نمونه ----- | ---- | ---- | ---- -id | int | شناسه سفارش | `180258791` -status | string | وضعیت فعلی سفارش | `New` یا `Active` یا `Inactive` یا `Done` یا `Canceled` -fee | monetary | کارمزد سفارش تاکنون | `0.00001` -created_at | datetime | تاریخ ایجاد سفارش | `2020-07-15T11:32:38.326809+00:00` -averagePrice | monetary | میانگین قیمت اجرا شده از سفارش | `2899500000` - -### نکات و ملاحظات -1. در پاسخ به صورت پیش‌فرض اطلاعات ۱۰۰ سفارش بازگردانده می‌شود که با استفاده از پارامترهای ورودی می‌توانید تعداد متفاوتی از سفارش‌های خود را، تا حداکثر ۱۰۰۰ سفارش، دریافت کنید. در صورتی‌که میخواهید تعداد بیشتری از سفارش‌ها و یا سفارش‌های گذشته را دریافت کنید می‌توانید از پارامتر‌های page یا fromId استفاده کنید. توجه کنید که **استفاده‌ی همزمان از این دو پارامتر ممکن نیست** و در صورت ارسال پارامتر fromId یک صفحه از سفارش‌ها به تعداد مشخص بازگردانده می‌شود، که این تعداد با ارسال پارامتر pageSize قابل تنظیم است. همچنین پیشنهاد می‌شود که در صورتی که تعداد زیادی سفارش باز دارید، شناسه آن‌ها را در زمان ثبت سفارش دریافت و ذخیره نمایید و به صورت مستقل با استفاده از درخواست «مشاهده وضعیت سفارش» اطلاعات هر یک را بنا به نیاز به‌روز کنید. همچنین برای اطلاع از معاملات انجام شده خود می‌توانید از درخواست [فهرست معاملات کاربر](/#1cf6f6c643) استفاده نمایید. -2. منظور از وضعیت Done سفارشی است که به صورت صد در صد اجرا شده باشد. ممکن است سفارش شما به تدریج اجرا شود، و در این حالت وضعیت آن کماکان Active می‌ماند. از فیلد matchedAmount برای تشخیص وضعیت اجرا و پر شدن سفارش استفاده کنید. همچنین ممکن است سفارش شما قبل از اجرای کامل، به دلیل درخواست «لغو سفارش» یا کمبود موجودی یا تغییر شدید قیمت بازار (در سفارش‌های مارکت) لغو شود که در این حالت وضعیت آن Canceled خواهد بود، به این معنی که به صورت صد در صد اجرا نشده است ولی می‌تواند مقدار matchedAmount آن بزرگ‌تر از صفر باشد. -3. این API متناظر مواردی مانند Current Open Orders و All Orders در اکسچنج بایننس است. - - -## تغییر وضعیت سفارش - -```shell -curl 'https://apiv2.nobitex.ir/market/orders/update-status' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"order":5684,"status":"canceled"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/market/orders/update-status \ - order=5684 status=canceled -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "updatedStatus": "Canceled", - "order": { - "amount": "60", - "averagePrice": "0", - "clientOrderId": null, - "created_at": "2025-10-28T09:25:17.774332+00:00", - "dstCurrency": "﷼", - "execution": "Market", - "fee": "0", - "id": 5684, - "market": "USDT-RLS", - "matchedAmount": "0", - "partial": false, - "price": "market", - "srcCurrency": "Tether", - "status": "Canceled", - "totalOrderPrice": "2550000", - "totalPrice": "0", - "tradeType": "Spot", - "type": "sell", - "unmatchedAmount": "60" - } -} -``` - -برای تغییر وضعیت یک سفارش (لغو یا فعال‌سازی) از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /market/orders/update-status` -- **محدودیت فراخوانی:** 90 درخواست در دقیقه - -###پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ----------- | ------ | --------- | ----- -order | int | اختیاری | شناسه سفارش | `5684` -clientOrderId | string | اختیاری | شناسه سفارش کاربر (آزمایشی) | `order1` -status | string | الزامی | وضعیت جدید | `canceled` - - -### نکات و ملاحظات - -1. حتما باید حداقل یکی از دو پارامتر ‍`order` و `clientOrderId` ارسال شوند. -2. اگر هر دو پارامتر ‍`order` و `clientOrderId` ارسال شوند، اولویت با `id` است. -3. `clientOrderId` فقط در میان سفارشات open/active/inactive جستجو میشود. -4. `clientOrderId` .در حالت آزمایشی است و ممکن است در آینده تغییر کند -5. مقدار status میتواند از 'new' به 'active' و یا از 'active'/'inactive' به 'canceled' تغییر کند. -در غیر اینصورت، درخواست رد میشود. -6. در صورتی که سفارش درخواست شده جزئی از یک سفارش OCO انجام نشده باشد، هر دو سفارش مرتبط لغو خواهند شد. - -### حالت‌های خطا - -> در صورت عدم پذیرش سفارش، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -کد خطا | توضیحات --------- | --------- -NullIdAndClientOrderId | باید یکی از دو پارامتر `id` و `clientOrderId` ارسال شود - - - -##لغو جمعی سفارشات - -```shell -curl 'https://apiv2.nobitex.ir/market/orders/cancel-old' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"execution":"limit","srcCurrency":"btc","dstCurrency":"rls","hours":2.4}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/market/orders/cancel-old \ - execution=limit srcCurrency=btc dstCurrency=rls hours=2.4 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -برای لغو دسته‌جمعی سفارشات فعال از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /market/orders/cancel-old` -- **محدودیت فراخوانی:** 30 درخواست در دقیقه - -###پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|-------------|--------|---------|------------------|------------------------------------------------------| -| hours | float | اختیاری | زمان سفارش | 4.2 | -| execution | string | اختیاری | نحوه سفارش | `market` یا `limit` یا `stop_market` یا `stop_limit` | -| tradeType | string | اختیاری | نوع معامله سفارش | `spot` یا `margin` | -| srcCurrency | string | اختیاری | ارز مبدا | `btc` | -| dstCurrency | string | اختیاری | ارز مقصد | `rls` | - -### نکات و ملاحظات -1. مقدار hours در واقع مقدار ساعت قبل از زمان ارسال درخواست میباشد. برای مثال اگر مقدار ساعت '2' ارسال شود، سفارش های 2 ساعت قبل لغو خواهند شد. -2. در صورتی که مقدار hours ارسال نشود، تمامی سفارشات فعال مربوط لغو خواهد شد. -3. سفارشات حد ضرر غیرفعال غیر OCO مشمول این نوع لغو نخواهند شد. -4. در بعضی شرایط امکان دارد به شما خطا پاسخ داده شود. این خطاها در فیلد error برگردانده میشوند. - - -### حالت‌های خطا - -> در صورت عدم پذیرش سفارش، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -## فهرست معاملات کاربر - - -```shell -curl 'https://apiv2.nobitex.ir/market/trades/list?srcCurrency=usdt&dstCurrency=rls' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/market/trades/list?srcCurrency=usdt&dstCurrency=rls -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "trades": [ - { - "id": 123412, - "orderId": 1231222, - "srcCurrency": "Tether", - "dstCurrency": "﷼", - "market": "USDT-RLS", - "timestamp": "2022-07-05T09:57:38.560820+00:00", - "type": "sell", - "price": "316800", - "amount": "57.3605", - "total": "18171806.4", - "fee": "27257.7096" - } - ], - "hasNext": false -} -``` - -برای دریافت فهرست معاملات ۳ روز اخیر خود، از این درخواست استفاده نمایید. - -- **درخواست:** `GET /market/trades/list` -- **محدودیت فراخوانی:** 30 درخواست در دقیقه -- **صفحه بندی:** دارد (پیش فرض ۳۰) - - - -### پارامترهای ورودی -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|-------------|--------|---------|-------------------|-----------------| -| srcCurrency | string | اختیاری | رمزارز مبدا بازار | `btc` یا ... | -| dstCurrency | string | اختیاری | رمزارز مقصد بازار | `rls` یا `usdt` | -| fromId | int | اختیاری | حداقل شناسه | 10023 | - -* در فیلتر بازار هر دو پارامتر رمزارز مبدا و مقصد باید مقدار داشته باشند یا هر دو خالی باشند. -* در صورت اختصاص مقدار به حداقل شناسه تنها معاملاتی که شناسه‌ی آن‌ها بیشتر از یا مساوی با حداقل شناسه است برگردانده می‌شوند. - - -### پارامترهای پاسخ -| پارامتر | نوع | توضیحات | نمونه | -|---------|---------------|---------------------|------------------------| -| trades | list of Trade | فهرست معاملان کاربر | `[{...Trade...}, ...]` | -| hasNext | boolean | صفحه بعدی دارد؟ | `false` | - -### شی Trade -| فیلد | نوع | توضیحات | نمونه | -|-------------|----------|--------------------|------------------------------------------| -| id | int | شناسه‌ی معامله | 122545 | -| orderId | int | شناسه‌ی سفارش | 214534534434 | -| srcCurrency | string | رمزارز مبدا معامله | `Bitcoin` یا `Ethereum` یا `TRON` یا ... | -| dstCurrency | string | ارز مقصد معامله | `﷼` یا `Tether` | -| market | string | نماد بازار معامله | `USDT-RLS` | -| timestamp | string | زمان انجام معامله | `2022-07-05T09:57:38.560820+00:00` | -| type | string | نوع خرید یا فروش | `buy` یا `sell` | -| price | monetary | قیمت انجام معامله | `316800` | -| amount | monetary | مقدار معامله شده | `57.3605` | -| total | monetary | قیمت کل معامله | `18171806.4` | -| fee | monetary | کارمزد معامله | `27257.7096` | diff --git a/source/includes/_other.md b/source/includes/_other.md deleted file mode 100644 index 3f06d9c..0000000 --- a/source/includes/_other.md +++ /dev/null @@ -1,200 +0,0 @@ -

سایر

- -

تنظیمات سیستم

- -```shell -curl 'https://apiv2.nobitex.ir/v2/options' -``` - -```plaintext -http GET https://apiv2.nobitex.ir/v2/options -``` - -> ساختار کلی پاسخ به صورت زیر خواهد بود. کلیدهای موجود در هر بخش در مستندات توضیح داده شده‌اند. - -```json -{ - "status": "ok", - "features": { - "fcmEnabled": true, - "chat": "livechat", - "walletsToNet": false, - "autoKYC": true, - "enabledFeatures": [ - "PriceAlert", - "StopLoss", - "GiftCard", - "OCO" - ], - "betaFeatures": [] - }, - "coins": [ - { - "coin": "rls", - "name": "Rial", - "defaultNetwork": "FIAT_MONEY", - "displayPrecision": "10", - "networkList": { - "FIATMONEY": { - "addressRegex": "", - "coin": "rls", - "depositEnable": true, - "isDefault": true, - "minConfirm": 0, - "name": "FIAT", - "network": "FIAT_MONEY", - "withdrawEnable": true, - "withdrawFee": "4_000_0.00000000", - "withdrawIntegerMultiple": "0.10000000", - "withdrawMax": "500_000_000_0.00000000", - "withdrawMin": "15_000_0.00000000" - } - }, - "stdName": "﷼" - }, - ... Other Coins Options - ], - "nobitex": { - "allCurrencies": [ - "rls", - "btc", - ... Other currencies - ], - "activeCurrencies": [ - "rls", - "btc", - "eth", - "ltc", - ... Other active currencies - ], - "xchangeCurrencies": [], - "topCurrencies": [ - "btc", - "eth", - "usdt", - "doge", - "shib", - "trx", - "ada", - "ltc", - "xrp" - ], - "testingCurrencies": [ - "hbar" - ], - "withdrawLimits": { - "normal": { - "dailyCoin": "0", - "dailyRial": "0", - "dailySummation": "0", - "monthlySummation": "0" - }, - "level0": { - "dailyCoin": "0", - "dailyRial": "0", - "dailySummation": "0", - "monthlySummation": "0" - }, - "44": { - "dailyCoin": "1000000000", - "dailyRial": "200000000", - "dailySummation": "1000000000", - "monthlySummation": "15000000000" - }, - ... Other withdraw options - }, - "minOrders": { - "rls": "3000000", - "usdt": "11", - "2": "3000000", - "13": "11" - }, - "amountPrecisions": { - "BTCIRT": "0.000001", - "BTCUSDT": "0.000001", - "ETHIRT": "0.00001", - ... Other amount precisions - }, - "pricePrecisions": { - "BTCIRT": "10", - "BTCUSDT": "0.01", - "ETHIRT": "10", - ... Other market precisions - }, - "giftCard": { - "physicalFee": "360000" - } - } -} -``` - -عملکرد سیستم نوبیتکس بر اساس پارامترهای مختلف تنظیم می‌شود که با استفاده از API «تنظیمات سیستم» می‌توانید مقادیر این پارامترها را دریافت نمایید. مواردی مانند رمزارزهای فعال، حداقل معامله در هر بازار، پله‌های کارمزد، سقف برداشت و بسیاری اطلاعات مفید دیگر از این طریق در دسترس شما قرار خواهد داشت. پاسخ در دو کلید `nobitex` شامل تنظیمات کلی سیستمی، و کلید `coins` شامل تنظیمات مخصوص هر رمزارز بازگردانده می‌شود. همچنین هر رمزارز دارای چندین «شبکه» است که برخی تنظیمات ممکن است فقط در سطح شبکه تعریف شوند یا در سطح رمزارز به صورت عمومی وجود داشته باشند ولی در بعضی شبکه‌های آن رمزارز متفاوت بوده و بازتعریف شوند. - -- **درخواست:** `GET /v2/options` -- **نیاز به ارسال توکن:** ندارد -- **پارامتر ورودی:** ندارد - - - - -### پارامترهای پاسخ - features - -کلید | نوع | توضیحات ----- |-------------| ---- -fcmEnabled | bool | وضعیت فعال بودن FCM -autoKYC | bool | وضعیت فعال بودن احراز خودکار -enabledFeatures | list of str | لیست Featureهای فعال -betaFeatures | list of str | لیست featureهای بتا - - -### پارامترهای پاسخ - nobitex - -کلید | نوع | توضیحات ----- |-------------| ---- -allCurrencies | list of str | نماد تمام رمزارزهای موجود در بازارها -activeCurrencies | list of str | نماد رمزارزهای اصلی و سطح یک -xchangeCurrencies | list of str | نماد رمزارزهای صرافی -topCurrencies | list of str | رمزارزهای برتر بازار -testingCurrencies | list of str | رمزارزهای در حال توسعه و آزمایش -withdrawLimits | dict | محدودیت های روزانه و ماهانه در سطوح مختلف -minOrders | dict | حداقل مبلغ سفارش ریالی و تتری -amountPrecisions | dict | دقت اعشار مقدار در بازارهای مختلف -pricePrecisions | dict | دقت اعشار قیمت در بازارهای مختلف -giftCard | dict | هزینه چاپ گیفت کارتهای فیزیکی - - -### پارامترهای پاسخ - Coins - -فیلد | نوع | توضیحات | نمونه ----- |--------------------------------------------------------------------------------------------------------| ---- | ---- -coin | str | نماد یکتای رمزارز، معمولاً با حروف کوچک | `rls` یا `btc` یا `eth` یا … -name | str | نام انگلیسی رمزارز | `Bitcoin` یا `TRON` یا `Dogecoin` یا … -default_network | str | شبکه پیش‌فرض رمزارز، یکی از کلیدهای NetworkOptions آن رمزارز | `FIAT_MONEY` یا `BTC` یا `BSC` یا … -network_list | dict | یک دیکشنری از شبکه‌های مختلف این رمزارز، با کلیدهای نام انگلیسی هر شبکه و مقادیر از نوع NetworkOptions | -displayPrecision | str | دقت اعشار پیش‌فرض نمایش مقادیر این رمزارز | `0.0001` یا `0.1` یا `1` -stdName | str | عنوان رمز ارز | `ریال` - - -### پارامترهای پاسخ - Network - -فیلد | نوع | توضیحات | نمونه ----- | ---- | ---- | ---- -network | str | نماد یکتای شبکه، معمولاً با حروف بزرگ | `FIAT_MONEY` یا `BTC` یا `BSC` یا … -name | str | نام انگلیسی خوانای شبکه | `BTC` یا `ERC20` یا … -isDefault | boolean | آیا این شبکه پیش‌فرض برای این رمزارز در نوبیتکس است؟ | `false` -beta | boolean | آیا این شبکه هنوز در حالت آزمایشی است؟ | `false` -addressRegex | str | الگوی آدرس‌ها در این شبکه | `^0x[0-9A-Fa-f]{40}$` -memoRequired | boolean | آیا تراکنش روی این شبکه نیازمند ممو است؟ | `false` -memoRegex | str | در صورت وجود، ممو باید چه الگویی داشته باشد؟ | `^[0-9A-Za-z]{1,28}$` -depositEnable | boolean | آیا واریز رمزارز روی این شبکه فعال است؟ | `true` -minConfirm | int | حداقل تعداد کانفیرم شبکه برای تایید اولیه واریز | `1` -depositInfo | dict | فهرست پارامترهای واریز | `{"standard": {"depositMin": "0.01"}}` -depositInfo.standard.depositMin | monetary | حداقل مقدار واریز این رمزارز روی شبکه | `0` -depositInfo.standard.depositMax | monetary | حداکثر مقدار واریز این رمزارز روی شبکه | `1000` -withdrawEnable | boolean | آیا برداشت رمزارز روی این شبکه فعال است؟ | `false` -withdrawIntegerMultiple | monetary | حداقل مقدار تغییر مقدار قابل برداشت | `0.000001` -withdrawFee | monetary | کارمزد برداشت | `0.1` -withdrawMin | monetary | حداقل مقدار قابل برداشت | `0.1` -withdrawMax | monetary | حداکثر مقدار قابل برداشت | `1000` diff --git a/source/includes/_portfolio.md b/source/includes/_portfolio.md deleted file mode 100644 index 05a3ee4..0000000 --- a/source/includes/_portfolio.md +++ /dev/null @@ -1,240 +0,0 @@ -

سود و زیان

- -«پرتفو» یا «پنل سود و زیان» کاربر، گزارشی است که با توجه به معاملات یا افزایش و کاهش قیمت رمزارزها در مارکت میزان سود یا ضرر بدست آمده و درصدهای آنها را نسبت به قیمت خریداری شده (موجودی) نمایش میدهد. - -در حال حاضر این اطلاعات در پرتفو هر کاربر ارائه می‌شود: - -* سود و زیان روزانه هفته گذشته -* سود زیان کل به صورت روزانه در هفته گذشته -* سود و زیان کل ماه گذشته - - - - -

سود و زیان روزانه هفته گذشته

- -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/portfolio/last-week-daily-profit' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/portfolio/last-week-daily-profit \ -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "data": [ - { - "report_date": "2021-06-30", - "total_profit": 0, - "total_profit_percentage": 0, - "total_balance": 0 - }, - { - "report_date": "2021-07-01", - "total_profit": 0, - "total_profit_percentage": 0, - "total_balance": 0 - }, - { - "report_date": "2021-07-02", - "total_profit": 0, - "total_profit_percentage": 0, - "total_balance": 0 - }, - { - "report_date": "2021-07-03", - "total_profit": 0, - "total_profit_percentage": 0, - "total_balance": 0 - }, - { - "report_date": "2021-07-04", - "total_profit": 0, - "total_profit_percentage": 0, - "total_balance": 0 - }, - { - "report_date": "2021-07-05", - "total_profit": "0E-10", - "total_profit_percentage": "0E-10", - "total_balance": "4516559.9205900000" - }, - { - "report_date": "2021-07-06", - "total_profit": "152570.1426800000", - "total_profit_percentage": "3.3780165737", - "total_balance": "4669130.0632700000" - } - ] -} -``` - -> در صورتی که این ویژگی برای کاربر فعال نباشد با این جواب روبرو خواهند شد - -```json -{ - "status": "failed", - "code": "PortfolioDisabled", - "message": "Portfolio feature is not available for your user." -} -``` - -> در صورتی که اطلاعاتی از سود و زیان کاربر وجود نداشته باشد - -```json -{ - "status": "failed", - "code": "LastWeekDailyProfitFail", - "message": "اطلاعاتی جهت نمایش وجود ندارد" -} -``` - -برای دریافت اطلاعات سود و زیان روزانه هفته گذشته از این درخواست استفاده نمایید: - -* **درخواست:** `POST users/portfolio/last-week-daily-profit` -* **محدودیت فراخوانی:** 10 درخواست در 3 دقیقه - -### نکات و ملاحظات: -این API به صورت پیش فرض اطلاعات 7 روز گذشته را ارائه می دهد. برای دریافت اطلاعات ماهانه یا ۳۰ روز گذشته کافیست پارامتر monthly با مقدار true را به همراه این درخواست ارسال نمایید. - -

سود زیان کل به صورت روزانه در هفته گذشته

- -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/portfolio/last-week-daily-total-profit' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/portfolio/last-week-daily-total-profit \ -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "data": [ - { - "report_date": "2021-06-27", - "total_profit": 0, - "total_profit_percentage": 0 - }, - { - "report_date": "2021-06-28", - "total_profit": 0, - "total_profit_percentage": 0 - }, - { - "report_date": "2021-06-29", - "total_profit": "4507274.2415300000", - "total_profit_percentage": "197.3669039200" - }, - { - "report_date": "2021-06-30", - "total_profit": "9020935.7092505000", - "total_profit_percentage": "-307.6135237294" - }, - { - "report_date": "2021-07-01", - "total_profit": "-5373087.9340195000", - "total_profit_percentage": "1302.7642741973" - }, - { - "report_date": "2021-07-02", - "total_profit": "313580813.4306171358", - "total_profit_percentage": "-899.0991999052" - }, - { - "report_date": "2021-07-03", - "total_profit": "313580813.4306171358", - "total_profit_percentage": "-899.0991999052" - } - ] -} -``` - -> در صورتی که این ویژگی برای کاربر فعال نباشد با این جواب روبرو خواهند شد - -```json -{ - "status": "failed", - "code": "PortfolioDisabled", - "message": "Portfolio feature is not available for your user." -} -``` - -> در صورتی که اطلاعاتی از سود و زیان کاربر وجود نداشته باشد - -```json -{ - "status": "failed", - "code": "LastWeekDailyProfitFail", - "message": "اطلاعاتی جهت نمایش وجود ندارد" -} -``` - -برای دریافت اطلاعات سود و زیان روزانه هفته گذشته از این درخواست استفاده نمایید: - -* **درخواست:** `POST users/portfolio/last-week-daily-total-profit` -* **محدودیت فراخوانی:** 10 درخواست در 3 دقیقه - - - -

سود و زیان کل ماه گذشته

- -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/portfolio/last-month-total-profit' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/portfolio/last-month-total-profit \ -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "total_profit": "8987787000.0000000000", - "total_profit_percentage": "83.60700983438201160181729556" - } -} -``` - -> در صورتی که این ویژگی برای کاربر فعال نباشد با این جواب روبرو خواهند شد - -```json -{ - "status": "failed", - "code": "PortfolioDisabled", - "message": "Portfolio feature is not available for your user." -} -``` - -> در صورتی که اطلاعاتی از سود و زیان کاربر وجود نداشته باشد - -```json -{ - "status": "failed", - "code": "LastWeekDailyProfitFail", - "message": "اطلاعاتی جهت نمایش وجود ندارد" -} -``` - -برای دریافت اطلاعات سود و زیان روزانه هفته گذشته از این درخواست استفاده نمایید: - -* **درخواست:** `POST users/portfolio/last-month-total-profit` -* **محدودیت فراخوانی:** 10 درخواست در 3 دقیقه - - - diff --git a/source/includes/_position.md b/source/includes/_position.md deleted file mode 100644 index fabdaa8..0000000 --- a/source/includes/_position.md +++ /dev/null @@ -1,857 +0,0 @@ -# معامله در بازار تعهدی -موقعیت خرید و فروش تعهدی امکان معامله وکالتی را برای کاربران فراهم می‌کند. -استفاده از این ویژگی به منزله پذیرش [شروط، قوانین و ضوابط معاملات تعهدی](https://nobitex.ir/position-terms/) در نوبیتکس است. - - - -## مشاهده بازارهای معاملات تعهدی - -```shell -curl 'https://apiv2.nobitex.ir/margin/markets/list' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/margin/markets/list -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "markets": { - "BTCIRT": { - "srcCurrency": "btc", - "dstCurrency": "rls", - "positionFeeRate": "0.001", - "maxLeverage": "5", - "sellEnabled": true, - "buyEnabled": false - }, - "BTCUSDT": { - "srcCurrency": "btc", - "dstCurrency": "usdt", - "positionFeeRate": "0.001", - "maxLeverage": "5", - "sellEnabled": true, - "buyEnabled": true - }, - "DOGEIRT": { - "srcCurrency": "doge", - "dstCurrency": "rls", - "positionFeeRate": "0.001", - "maxLeverage": "4", - "sellEnabled": true, - "buyEnabled": false - }, - "DOGEUSDT": { - "srcCurrency": "doge", - "dstCurrency": "usdt", - "positionFeeRate": "0.001", - "maxLeverage": "3", - "sellEnabled": true, - "buyEnabled": true - } - } -} -``` - -برای دریافت بازارهای پشتیبانی شده برای معاملات تعهدی از این درخواست استفاده نمایید. - -- **درخواست:**: `GET /margin/markets/list` -- **محدودیت فراخوانی:** ۳۰ درخواست در هر دقیقه - -### پارامترهای پاسخ -| پارامتر | نوع | توضیحات | نمونه | -|------------|---------------------|---------------------|-------------------------------| -| status | string | وضعیت پاسخ | `ok` | -| نماد بازار | MarginMarketSetting | تنظیمات بازار تعهدی | `{"srcCurrency": "btc", ...}` | - -### شی MarginMarketSetting -| فیلد | نوع | توضیحات | نمونه | -|-----------------|---------|-------------------------|--------------------------------| -| srcCurrency | string | رمزارز مبدا بازار | `btc` یا `eth` یا `trx` یا ... | -| dstCurrency | string | رمزارز مقصد بازار | `rls` یا `usdt` | -| positionFeeRate | decimal | نرخ کارمزد تمدید روزانه | `0.001` | -| maxLeverage | decimal | بیشینه ضریب مجاز بازار | `5` | -| sellEnabled | boolean | قابلیت فروش تعهدی | `true` | -| buyEnabled | boolean | قابلیت خرید تعهدی | `true` | - -### نکات و ملاحظات -1. بیشینه ضریب مجاز بازار هم به عمق بازار و هم به سطح کاربری وابسته است. -بدین منظور برای دریافت مقدار دقیق با توجه سطح کاربری تان، درخواست را همراه با توکن احراز هویت خود ارسال نمایید. -2. نرخ کارمزد تمدید روزانه به صورت پله‌ای بر اساس ارزش دارایی وکالت گرفته شده تعیین می‌شود. -برای اطلاعات بیشتر به قوانین معاملات تعهدی مراجعه نمایید. - - -## مشاهده استخرهای مشارکت ارزی فعال - -```shell -curl 'https://apiv2.nobitex.ir/liquidity-pools/list' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/liquidity-pools/list -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "pools": { - "btc": { - "capacity": "30", - "filledCapacity": "28.082343" - }, - "ltc": { - "capacity": "160", - "filledCapacity": "149.234" - }, - "doge": { - "capacity": "5000000", - "filledCapacity": "5000000" - } - } -} -``` - -استخرهای مشارکت موجودی مورد نیاز برای اعطای وکالت خرید و فروش تعهدی را تامین می‌کنند. -ظرفیت مشارکت افراد در معاملات تعهدی را موجودی استخرها تعیین می‌کنند. استخرها ممکن است در زمان‌هایی فعال و غیرفعال شوند. -در استخرهای غیرفعال امکان ثبت سفارش جدید تعهدی وجود ندارد (اما بستن موقعیت همچنان میسر است). -برای دریافت ظرفیت استخرهای فعال از این درخواست استفاده نمایید. - -- **درخواست:**: `GET /liquidity-pools/list` -- **محدودیت فراخوانی:** ۱۲ درخواست در هر دقیقه - - -## انتقال پول به کیف‌پول تعهدی - -```shell -curl -X POST 'https://apiv2.nobitex.ir/wallets/transfer' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"currency": "rls", "amount": "2500000000", "src": "spot", "dst": "margin"}' - -``` - -```plaintext -http POST https://apiv2.nobitex.ir/liquidity-pools/list \ - currency=rls&amount=2500000000&src=spot&dst=margin -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "srcWallet": { - "id": 53456, - "currency": "rls", - "balance": "1870000000", - "blockedBalance": "420000000", - "activeBalance": "1450000000", - "rialBalance": "1870000000", - "rialBalanceSell": "1870000000", - "depositAddress": null, - "depositTag": null, - "depositInfo": { - "FIAT_MONEY": { - "address": null, - "tag": null - } - } - }, - "dstWallet": { - "id": 86459, - "currency": "rls", - "balance": "2500000000", - "blockedBalance": "0", - "activeBalance": "2500000000", - "rialBalance": "2500000000", - "rialBalanceSell": "2500000000" - } -} -``` - -وجوه تضمین قبل از دریافت وکالت خرید و فروش تعهدی باید در کیف‌پول تعهدی قرار گیرند. -برای انتقال موجودی میان دو کیف‌پول اسپات و تعهدی از این درخواست استفاده نمایید. - -- **درخواست:**: `POST /wallets/transfer` -- **محدودیت فراخوانی:** ۱۰ درخواست در هر دقیقه - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------|----------|---------|------------------|--------------------| -| currency | string | الزامی | ارز وجه تضمین | `rls` یا `usdt` | -| amount | monetary | الزامی | مقدار انتقال | `2500000000` | -| src | string | الزامی | نوع کیف‌پول مبدا | `spot` یا `margin` | -| dst | string | الزامی | نوع کیف‌پول مقصد | `spot` یا `margin` | - - -### نکات و ملاحظات -1. نوع کیف‌پول مبدا و مقصد نباید یکسان باشد. -2. کیف‌پول تعهدی ضمن اولین انتقال به آن ایجاد می‌شود. -پس از آن موجودی این کیف‌پول را می‌توان از طریق [لیست کیف‌پول‌ها](/#1ff004071d) مشاهده کرد. - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "InsufficientBalance", - "message": "Amount cannot exceed active balance" -} -``` - -| کد خطا | توضیحات | -|---------------------|-------------------------------------------------------------| -| ParseError | فرمت ورودی‌ها مطابق فرمت خواسته شده نیست. | -| InvalidAmount | مقدار نامعتبر است. | -| SameDestination | کیف مبدا و مقصد از یک نوع (هر دو اسپات یا هر دو تعهدی) است. | -| WalletNotFound | کیف‌پول تعهدی برای ارزهای غیر از ریال و تتر وجود ندارد. | -| InsufficientBalance | مقدار انتقال از موجودی آزاد کیف‌پول مبدا بیشتر است. | - - -## دریافت محدودیت کاربری در مقدار وکالت - -```shell -curl 'https://apiv2.nobitex.ir/margin/delegation-limit?currency=btc' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" - -``` - -```plaintext -http GET https://apiv2.nobitex.ir/margin/delegation-limit \ - currency=btc -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "limit": "0.039062" -} -``` - -برای دریافت سقف مقدار قابل استفاده در موقعیت‌های خرید و فروش که متناسب با سطح کاربری است، از این درخواست استفاده کنید. -در موقعیت فروش از موجودی رمزارز مبدا بازار و در موقعیت خرید از موجودی رمزارز مقصد بازار استعلام بگیرید. - -- **درخواست:**: `GET /margin/delegation-limit` -- **محدودیت فراخوانی:** ۱۲ درخواست در هر دقیقه - - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------|----------|---------|----------------------------------------------------|---------------| -| currency | string | الزامی | رمزارز درخواستی برای اخذ وکالت (رمزارز مبدا بازار) | `btc` یا ... | - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -| کد خطا | توضیحات | -|----------------------|----------------------------------------------------------------| -| ParseError | فرمت ورودی‌ها مطابق فرمت خواسته شده نیست. | -| TradeLimitation | کاربر سطح احراز کافی ندارد. | -| UnsupportedMarginSrc | رمزارز درخواستی برای معاملات خرید/فروش تعهدی پشتیبانی نمی‌شود. | -| MarginClosed | معاملات خرید/فروش تعهدی بسته شده یا باز نشده است. | - -### نکات و ملاحظات -1. با هر بار باز کردن سفارش جدید، این سقف کاهش یافته و با بستن موقعیت و تسویه این سقف افزایش می‌یابد. -به نوعی این مقدار برابر میزان باقیمانده از مقدار مجاز کاربری شما بری وکالت گیری می‌باشد. -2. مقدار هر سفارش فروش تعهدی باید همواره از سقف وکالت باقیمانده رمزارز مبدا کمتر باشد. -3. ارزش کل هر سفارش خرید تعهدی (قیمت × مقدار) باید همواره از سقف وکالت باقیمانده ارز مقصد کمتر باشد. - - -## درج سفارش تعهدی - -```shell -curl -X POST 'https://apiv2.nobitex.ir/margin/orders/add' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"srcCurrency": "btc", "dstCurrency": "rls", "leverage": "2", "amount": "0.01", "price": "6400000000"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/margin/orders/add \ - srcCurrency=btc&dstCurrency=rls&amount=0.01&price=6400000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "order": { - "id": 25, - "type": "sell", - "execution": "Limit", - "tradeType": "Margin", - "srcCurrency": "btc", - "dstCurrency": "rls", - "price": "6400000000", - "amount": "0.01", - "status": "Active", - "totalPrice": "0", - "totalOrderPrice": "64000000", - "matchedAmount": 0, - "unmatchedAmount": "0.01", - "leverage": "2", - "side": "open", - "partial": false, - "fee": 0, - "created_at": "2022-10-20T11:36:13.592827+00:00", - "averagePrice": "0" - } -} -``` - -برای درج سفارش در بازار تعهدی از این درخواست استفاده نمایید. - -- **درخواست:**: `POST /margin/orders/add` -- **محدودیت فراخوانی:** ۳۰۰ درخواست در هر ۱۰ دقیقه - - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|-------------|----------|---------|-------------------------|-----------------| -| execution | string | `limit` | نحوه‌ی اجرای سفارش | `limit` یا ... | -| srcCurrency | string | الزامی | رمزارز مبدا بازار | `btc` یا ... | -| dstCurrency | string | الزامی | ارز مقصد بازار | `rls` یا `usdt` | -| type | string | sell | جهت خرید یا فروش | `sell` یا `buy` | -| leverage | monetary | 1 | ضریب وکالت | `2` | -| amount | monetary | الزامی | مقدار مورد تقاضای وکالت | `0.01` | -| price | monetary | الزامی | قیمت سفارش گذاری | `13400000000` | -| stopPrice | monetary | اختیاری | قیمت توقف در حد ضرر | `12600000000` | - -### پارامترهای پاسخ -| پارامتر | نوع | توضیحات | نمونه | -|---------|------------------|-------------|-------------------| -| order | [Order](/#order) | سفارش تعهدی | `{"id": 25, ...}` | - -### سفارش OCO - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------------|----------|---------|-------------------------|-----------------| -| mode | string | الزامی | حالت سفارش | `oco` | -| srcCurrency | string | الزامی | رمزارز مبدا بازار | `btc` یا ... | -| dstCurrency | string | الزامی | ارز مقصد بازار | `rls` یا `usdt` | -| type | string | sell | جهت خرید یا فروش | `sell` یا `buy` | -| leverage | monetary | 1 | ضریب وکالت | `2` | -| amount | monetary | الزامی | مقدار مورد تقاضای وکالت | `0.01` | -| price | monetary | الزامی | قیمت سفارش گذاری | `13400000000` | -| stopPrice | monetary | الزامی | قیمت توقف سفارش حد ضرر | `12600000000` | -| stopLimitPrice | monetary | الزامی | قیمت سفارش حد ضرر | `12610000000` | - -### پارامترهای پاسخ OCO -| پارامتر | نوع | توضیحات | نمونه | -|---------|--------------------------|-----------------|--------------------------------------| -| orders | list of [Order](/#order) | سفارش OCO تعهدی | `[{"id": 25, ...}, {"id": 26, ...}]` | - -### نکات و ملاحظات -1. نوع اجرای سفارش یکی از موارد زیر می‌باشد: - - `limit`: با قیمت معین - - `market`: با قیمت بازار - - `stop_limit`: حد ضرر با قیمت معین - - `stop_market`: حد ضرر با قیمت بازار -2. سفارش‌های خرید و فروش تعهدی ثبت شده را می‌توان در [فهرست سفارش‌های کاربر](/#a2ce8ff7e3) مشاهده کرد. -3. بعد از پر شدن سفارش تعهدی، موقعیت متناظر با آن باز خواهد شد. -4. شرط قیمت سفارش OCO: - - خرید: price < آخرین قیمت بازار < stopPrice و stopLimitPrice - - فروش: price > آخرین قیمت بازار > stopPrice و stopLimitPrice -5. ضریب عددی در محدوده 1 تا ضریب بیشینه هر بازار با دقت 0.5 است، مانند: `1`, `1,5`, `2`, `2,5` و ... - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -| کد خطا | توضیحات | -|----------------------|-----------------------------------------------------------------------------------------| -| FeatureUnavailable | شما از کاربران مجاز به استفاده از امکانات آزمایشی نیستید. | -| ParseError | فرمت ورودی‌ها مطابق فرمت خواسته شده نیست. | -| TradeLimitation | کاربر سطح احراز کافی ندارد. | -| InvalidMarketPair | زوج مبدا/مقصد بازار در میان بازارهای نوبیتکس وجود ندارد. | -| MarketClosed | بازار بسته شده یا هنوز باز نشده است. | -| TradingUnavailable | کاربر محدودیت معامله (از جانب پشتیبانی) دارد. | -| UnsupportedMarginSrc | رمزارز درخواستی برای معاملات خرید/فروش تعهدی پشتیبانی نمی‌شود. | -| MarginClosed | معاملات خرید/فروش تعهدی بسته شده یا باز نشده است. | -| AmountUnavailable | مقدار مورد تقاضا برای اخذ وکالت فروش در استخر موجود نیست. | -| ExceedDlegationLimit | مقدار از سقف مجاز فروش باقی‌مانده کاربر بیشتر است. | -| InsufficientBalance | موجودی کیف‌پول تعهدی کاربر برای تامین وجه تضمین به اندازه مبلغ کل سفارش کافی نیست. | -| LeverageTooHigh | ضریب وکالت درخواست از بیشینه مجاز بازار بسته به استخر یا سطح کاربری بیشتر است. | -| LeverageUnavailable | کاربر محدودیت استفاده از ضریب وکالت (از جانب پشتیبانی) دارد. | -| BadPrice | قیمت سفارش نامعقول است. (مشابه درج سفارش اسپات) | -| SmallOrder | سفارش کوچک است و کمینه اندازه سفارش بازار را رعایت نکرده است. (مشابه درج سفارش اسپات) | -| PriceConditionFailed | شرط قیمت میان پارامترهای قیمتی و قیمت بازار در سفارش لحاظ نشده است. (مشابه اسپات) | -| DuplicateOrder | سفارشی با همین مشخصات توسط شما در بازه زمانی ده ثانیه اخیر ارسال شده است. (مشابه اسپات) | - - -## مشاهده لیست موقعیت‌ها - -```shell -curl 'https://apiv2.nobitex.ir/positions/list?srcCurrency=btc&status=active' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" - -``` - -```plaintext -http GET https://apiv2.nobitex.ir/positions/list \ - srcCurrency=btc&status=active -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "positions": [ - { - "id": 128, - "createdAt": "2022-10-20T11:36:13.604420+00:00", - "srcCurrency": "btc", - "dstCurrency": "rls", - "side": "sell", - "status": "Open", - "marginType": "Isolated Margin", - "collateral": "320000000", - "leverage": "2", - "openedAt": "2022-10-20T11:36:16.562038+00:00", - "closedAt": null, - "liquidationPrice": "25174302690", - "entryPrice": "6400000000", - "exitPrice": null, - "delegatedAmount": "0.03", - "liability": "0.0300450676", - "totalAsset": "831712000", - "marginRatio": "1.49", - "liabilityInOrder": "0", - "assetInOrder": "0", - "unrealizedPNL": "−576435", - "unrealizedPNLPercent": "−0.09", - "expirationDate": "2022-11-20", - "extensionFee": "320000", - "markPrice": "6430000000" - }, - { - "id": 32, - "createdAt": "2022-08-14T15:09:58.001901+00:00", - "srcCurrency": "btc", - "dstCurrency": "usdt", - "side": "sell", - "status": "Closed", - "marginType": "Isolated Margin", - "collateral": "2130", - "leverage": "1", - "openedAt": "2022-08-14T15:10:19.937801+00:00", - "closedAt": "2022-08-17T18:39:52.890674+00:00", - "liquidationPrice": "38986.54", - "entryPrice": "21300", - "exitPrice": "19900", - "PNL": "118.46", - "PNLPercent": "5.56" - } - ], - "hasNext": false -} -``` - -برای دریافت لیست موقعیت‌های باز و تاریخچه موقعیت‌های پایان یافته از این درخواست استفاده کنید. - -- **درخواست:**: `GET /positions/list` -- **محدودیت فراخوانی:** ۳۰ درخواست در هر دقیقه - -- **صفحه‌بندی:** دارد (پیش فرض ۵۰) - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|-------------|----------|----------|-------------------|--------------------| -| srcCurrency | string | همه | رمزارز مبدا بازار | `btc` یا ... | -| dstCurrency | string | همه | ارز مقصد بازار | `rls` یا `usdt` | -| status | string | `active` | وضعیت موقعیت | `active` یا `past` | - -### پارامترهای پاسخ -| پارامتر | نوع | توضیحات | نمونه | -|-----------|------------------|-----------------|------------------------| -| positions | list of Position | لیست موقعیت‌ها | `[{... Position ...}]` | -| hasNext | boolean | صفحه بعدی دارد؟ | `false` | - -### شی Position -| فیلد | نوع | توضیحات | نمونه | -|----------------------|----------|---------------------------------------------------|-------------------------------------------------| -| id | int | شناسه‌ی موقعیت | 128 | -| createdAt | string | زمان درخواست وکالت (درج سفارش) تعهدی | `2022-10-20T11:36:13.604420+00:00` | -| srcCurrency | string | رمزارز مبدا بازار | `btc` یا `eth` یا `trx` یا ... | -| dstCurrency | string | ارز مقصد بازار | `rls` یا `usdt` | -| side | string | جهت خرید و فروش | `sell` یا `buy` | -| status | string | وضعیت | `Open` یا `Closed` یا `Liquidated` یا `Expired` | -| marginType | string | نوع تضمین سفارش | `Isolated Margin` | -| collateral | monetary | وجه تضمین بلوکه شده در کیف‌پول تعهدی | `640000000` | -| leverage | decimal | ضریب وکالت | `2` | -| openedAt | string | تاریخ باز شدن موقعیت | `2022-10-20T11:36:16.562038+00:00` | -| closedAt | string | تاریخ تسویه نهایی موقعیت | `2022-10-25T09:57:38.560820+00:00` | -| liquidationPrice | monetary | قیمت لیکوئید شدن موقعیت | `25174302690` | -| entryPrice | monetary | میانگین قیمت سفارش باز شدن موقعیت | `6400000000` | -| exitPrice | monetary | میانگین قیمت سفارش‌های تسویه تعهد | `6200000000` | -| [ویژه موقعیت باز:] | | | | -| delegatedAmount | monetary | مقدار وکالت گرفته شده در لحظه (به رمزارز مبدا) | `0.03` | -| liability | monetary | مقدار تعهد | `0.0300450676` | -| totalAsset | monetary | دارایی کلی (به رمزارز مقصد) | `831712000` | -| marginRatio | decimal | نسبت تعهد | `1.49` | -| liabilityInOrder | monetary | بخشی از تعهد که سفارش تسویه باز دارد | `0` | -| assetInOrder | monetary | بخشی از دارایی کلی که در سفارش تسویه باز است | `0` | -| unrealizedPNL | monetary | سود و زیان محقق نشده/لحظه‌ای (به رمزارز مقصد) | `-576435` | -| unrealizedPNLPercent | decimal | درصد سود و زیان محقق نشده/لحظه‌ای | `−0.09` | -| expirationDate | string | تاریخ انقضای نهایی موقعیت | `2022-11-20` | -| extensionFee | monetary | مقدار کارمزد تمدید در انتهای روز (به رمزارز مقصد) | `320000` | -| markPrice | monetary | قیمت معیار بازار در لحظه | `6430000000` | -| [ویژه موقعیت بسته:] | | | | -| PNL | monetary | سود و زیان نهایی (به رمزارز مقصد) | `35584000` | -| PNLPercent | decimal | درصد سود و زیان نهایی | `5.56` | - -### نکات و ملاحظات -1. **وضعیت**: این پارامتر در ورودی بر دو قسم است: - * `active`: موقعیت‌های باز و تسویه نشده - * `past`: موقعیت‌های بسته، لیکوئید و منقضی شده که تسویه شده باشد -
همچنین در خروجی بر چند مقدار است: - * `Open`: باز -- همه یا بخشی از سفارش تعهدی در بازار پر شده است. - * `Closed`: بسته -- کاربر مقدار وکالت گرفته شده را بازپرداخت کرده است. - * `Liquidated`: لیکویید شده - * `Expired`: منقضی شده -- هر موقعیت از زمان ثبت سفارش اولیه حداکثر ۳۰ روز می‌تواند باز بماند. -2. **نوع تضمین سفارش**: بر دو قسم می‌تواند باشد. - * `Isolated Margin`: ضرر حداکثر به اندازه وجه تضمین موقعیت خواهد بود. -- پیش‌فرض - * `Cross Margin`: ضرر حداکثر به اندازه تمام موجودی آزاد کیف‌پول تعهدی خواهد بود. -- در آینده -3. **تعهد خرید**: مقدار وکالت گرفته شده + کارمزد سفارش خرید در موقعیت فروش یا - کارمزد سفارش خرید در موقعیت خرید -4. **دارایی کلی**: مقدار وجه تضمین + باقی‌مانده وجه حاصل از فروش در موقعیت فروش یا ارزش لحظه‌ای دارایی خریداری شده در موقعیت خرید -5. **نسبت تعهد**: نسبت اولیه آن ۲ و حداقل نسبت لازم برای لیکوئید نشدن ۱.۱ است. -6. از زمان لیکویید/منقضی شدن یک موقعیت باز تا زمان تسویه تعهد با سفارش‌گذاری سیستمی و معامله در بازار، -ممکنه است اندکی فاصله ایجاد شود. در این بازه، موقعیت لیکویید/منقضی شده به منزله موقعیت فعال باز می‌گردد. - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -| کد خطا | توضیحات | -|----------------------|-----------------------------------------------------------| -| ParseError | فرمت ورودی‌ها مطابق فرمت خواسته شده نیست. | - - -## مشاهده یک موقعیت - -```shell -curl 'https://apiv2.nobitex.ir/positions/128/status' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" - -``` - -```plaintext -http GET https://apiv2.nobitex.ir/positions/128/status -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "position": { - "id": 128, - "createdAt": "2022-10-20T11:36:13.604420+00:00", - "srcCurrency": "btc", - "dstCurrency": "rls", - "side": "sell", - "status": "Open", - "marginType": "Isolated Margin", - "collateral": "320000000", - "leverage": "2", - "openedAt": "2022-10-20T11:36:16.562038+00:00", - "closedAt": null, - "liquidationPrice": "25174302690", - "entryPrice": "6400000000", - "exitPrice": null, - "delegatedAmount": "0.03", - "liability": "0.0300450676", - "totalAsset": "831712000", - "marginRatio": "1.49", - "liabilityInOrder": "0", - "assetInOrder": "0", - "unrealizedPNL": "−576435", - "unrealizedPNLPercent": "−0.09", - "expirationDate": "2022-11-20", - "extensionFee": "320000", - "markPrice": "6430000000" - } -} -``` - -برای مشاهده وضعیت یک موقعیت از این درخواست استفاده کنید. - -- **درخواست:**: `GET /positions/:positionId:/status` -- **محدودیت فراخوانی:** ۱۰۰ درخواست در هر ۱۰ دقیقه (محدودیت مشترک) - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|--------------|-----------|---------|----------------|-------| -| :positionId: | url-param | الزامی | شناسه‌ی موقعیت | `128` | - -### پارامترهای پاسخ -| پارامتر | نوع | توضیحات | نمونه | -|----------|------------------------|---------|--------------------| -| position | [Position](/#position) | موقعیت | `{"id": 128, ...}` | - - -## بستن موقعیت - -```shell -curl -X POST 'https://apiv2.nobitex.ir/positions/128/close' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"amount": "0.0100150225", "price": "6200000000"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/positions/128/close \ - amount=0.0100150225&price=6200000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "order": { - "id": 28, - "type": "buy", - "execution": "Limit", - "tradeType": "Margin", - "srcCurrency": "btc", - "dstCurrency": "rls", - "price": "6200000000", - "amount": "0.0100150225", - "status": "Active", - "totalPrice": "0", - "totalOrderPrice": "62093139", - "matchedAmount": 0, - "unmatchedAmount": "0.0100150225", - "leverage": "2", - "side": "close", - "partial": false, - "fee": 0, - "created_at": "2022-10-25T09:57:38.560820+00:00", - "averagePrice": "0" - } -} -``` - -برای بستن موقعیت با درج سفارش در جهت عکس سفارش اولیه جهت تسویه تعهد از این درخواست استفاده نمایید. -به عبارتی با خرید تعهد موقعیت فروش یا فروش تعهد موقعیت خرید موقعیت شما قابل بسته شدن خواهد شد. - -- **درخواست:**: `POST /positions/:positionId:/close` -- **محدودیت فراخوانی:** ۳۰۰ درخواست در هر ۱۰ دقیقه - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|--------------|-----------|---------|---------------------|----------------| -| :positionId: | url-param | الزامی | شناسه‌ی موقعیت | `128` | -| execution | string | `limit` | نحوه‌ی اجرای سفارش | `limit` یا ... | -| amount | monetary | الزامی | مقدار سفارش | `0.0100150225` | -| price | monetary | الزامی | قیمت سفارش | `12600000000` | -| stopPrice | monetary | اختیاری | قیمت توقف در حد ضرر | `12600000000` | - -### پارامترهای پاسخ -| پارامتر | نوع | توضیحات | نمونه | -|---------|------------------|-----------------|-------------------| -| order | [Order](/#order) | سفارش خرید تعهد | `{"id": 25, ...}` | - -### سفارش OCO - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------------|-----------|---------|------------------------|----------------| -| :positionId: | url-param | الزامی | شناسه‌ی موقعیت | `128` | -| mode | string | الزامی | حالت سفارش | `oco` | -| amount | monetary | الزامی | مقدار سفارش | `0.0100150225` | -| price | monetary | الزامی | قیمت سفارش | `12600000000` | -| price | monetary | الزامی | قیمت سفارش گذاری | `13400000000` | -| stopPrice | monetary | الزامی | قیمت توقف سفارش حد ضرر | `13600000000` | -| stopLimitPrice | monetary | الزامی | قیمت سفارش حد ضرر | `13610000000` | - -### پارامترهای پاسخ OCO -| پارامتر | نوع | توضیحات | نمونه | -|---------|--------------------------|-----------------|--------------------------------------| -| orders | list of [Order](/#order) | سفارش خرید تعهد | `[{"id": 25, ...}, {"id": 26, ...}]` | - -### نکات و ملاحظات -1. نوع اجرای سفارش یکی از موارد زیر می‌باشد: - - `limit`: با قیمت معین - - `market`: با قیمت بازار - - `stop_limit`: حد ضرر با قیمت معین - - `stop_market`: حد ضرر با قیمت بازار -2. سفارش‌های خرید و فروش تعهدی ثبت شده را می‌توان [فهرست سفارش‌های کاربر](/#a2ce8ff7e3) مشاهده کرد. -3. بعد از پر شدن سفارش تسویه تعهد، موقعیت بسته و سود و زیان آن واریز خواهد شد. -4. سفارش‌های تسویه از دارایی کلی موقعیت تامین اعتبار می‌شوند. مقدار سفارش تسویه باید شروط زیر را داشته باشد: - * مجموع مقدار باز سفارشات تسویه موقعیت از تعهد موقعیت بیشتر نباشد. (liability - liabilityInOrder) - * در صورتی که مقدار با همه تعهد باقیمانده برابر نباشد --تسویه نهایی--، سفارش کوچک نباشد. - (مثال: فرض کنید می‌خواهید موقعیت فروش ۰.۰۰۱ بیت‌کوین را با ارزش ۶۴۰ هزار تومان تسویه کنید و کف سفارش کوچک ۳۰۰ هزار تومان باشد. - می‌توانید ۲ سفارش ۳۰۰ هزار تومانی خرید بگذارید. و در پایان برای ۴۰ هزار تومان باقیمانده سفارش کوچک بگذارید. - اما نمی‌توانید سفارش‌های اولیه را کمتر از ۳۰۰ هزار تومان قرار دهید. -- مشابه تبدیل موجودی اندک در کیف پول) - * ارزش کل بخش باز سفارش‌های خرید تسویه (موجودی ضرب در قیمت) از دارایی کلی موقعیت فروش بیشتر نباشد. (totalAsset - assetInOrder) -5. دقت کنید تعهد موقعیت حداکثر ۱۰ رقم دقت دارد که در زمان تسویه نهایی همه آن باید ارسال شود. -6. شرط قیمت سفارش OCO: - - بستن فروش (با سفارش خرید): price < آخرین قیمت بازار < stopPrice و stopLimitPrice - - بستن خرید (با سفارش فروش): price > آخرین قیمت بازار > stopPrice و stopLimitPrice - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -| کد خطا | توضیحات | -|----------------------|---------------------------------------------------------------------------------------| -| ParseError | فرمت ورودی‌ها مطابق فرمت خواسته شده نیست. | -| TradeLimitation | کاربر سطح احراز کافی ندارد. | -| TradingUnavailable | کاربر محدودیت معامله (از جانب پشتیبانی) دارد. | -| NoOpenPosition | موقعیت فعالی با این شناسه وجود ندارد. | -| ExceedLiability | مقدار سفارش از تعهد خرید باقی‌مانده کاربر بیشتر است. | -| ExceedTotalAsset | ارزش کل سفارش از دارایی کلی آزاد کاربر بیشتر است. | -| BadPrice | قیمت سفارش نامعقول است. (مشابه درج سفارش اسپات) | -| SmallOrder | سفارش کوچک است و کمینه اندازه سفارش بازار را رعایت نکرده است. (مشابه درج سفارش اسپات) | -| PriceConditionFailed | شرط قیمت میان پارامترهای قیمتی و قیمت بازار در سفارش لحاظ نشده است. (مشابه اسپات) | - - -## ویرایش وجه تضمین موقعیت باز - -```shell -curl -X POST 'https://apiv2.nobitex.ir/positions/128/edit-collateral' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"collateral": "230000000"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/positions/128/edit-collateral \ - collateral=230000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "position": { - "id": 128, - "createdAt": "2022-10-20T11:36:13.604420+00:00", - "srcCurrency": "btc", - "dstCurrency": "rls", - "side": "sell", - "status": "Open", - "marginType": "Isolated Margin", - "collateral": "230000000", - "leverage": "2", - "openedAt": "2022-10-20T11:36:16.562038+00:00", - "closedAt": null, - "liquidationPrice": "12230682570", - "entryPrice": "6400000000", - "exitPrice": "6100000000", - "PNL": null, - "delegatedAmount": "0.02", - "liability": "0.0200300451", - "totalAsset": "257023981", - "marginRatio": "2.03", - "liabilityInOrder": "0", - "assetInOrder": "0", - "unrealizedPNL": "23423565", - "unrealizedPNLPercent": "10.18", - "expirationDate": "2022-11-20", - "extensionFee": "320000", - "markPrice": "6090000000" - } -} - - -``` - -برای کاهش یا افزایش وجه تضمین موقعیت باز خود از این درخواست استفاده نمایید. - -- **درخواست:**: `POST /positions/:positionId:/edit-collateral` -- **محدودیت فراخوانی:** ۶۰ درخواست در هر دقیقه - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|--------------|-----------|---------|----------------|-------------| -| :positionId: | url-param | الزامی | شناسه‌ی موقعیت | `128` | -| collateral | monetary | الزامی | وجه تضمین جدید | `230000000` | - -### پارامترهای پاسخ - -| پارامتر | نوع | توضیحات | نمونه | -|----------|------------------------|--------------|-------------------| -| position | [Position](/#position) | موقعیت تعهدی | `{"id": 25, ...}` | - -### نکات و ملاحظات -1. در صورتی که موقعیت در سوددهی باشد (نسبت تعهد > نسبت تعهد اولیه = ضریب / 1 + 1)، کاربر می‌تواند مازاد وجه تضمین خود -را تا نسبت تعهد اولیه از بلوکه در بیاورد. -- سود تنها زمان بسته شدن کامل موقعیت قابل دستیابی است. -2. در صورتی که موقعیت به نقطه لیکوئید شدن نزدیک باشد و کاربر بخواهد موقعیت خود (به امید تغییر جهت بازار) باز نگهدارد، -می‌تواند با افزایش وجه تضمین خود، قیمت لیکوئید شدن خود را بهبود دهد. - -### حالت‌های خطا - -> در صورت عدم پذیرش درخواست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ErrorCode", - "message": "Human readable error message" -} -``` - -| کد خطا | توضیحات | -|---------------------|----------------------------------------------------------| -| ParseError | فرمت ورودی‌ها مطابق فرمت خواسته شده نیست. | -| TryAgainLater | موقتا امکان تغییر وجه تضمین وجود ندارد. | -| LowMarginRatio | کاهش وجه تضمین کمتر از نسبت تعهد مجاز (=۲) است. | -| InsufficientBalance | افزایش وجه تضمین بیشتر از موجودی أزاد کیف‌پول تعهدی است. | diff --git a/source/includes/_referral.md b/source/includes/_referral.md deleted file mode 100644 index ffa97c6..0000000 --- a/source/includes/_referral.md +++ /dev/null @@ -1,130 +0,0 @@ -# طرح معرفی دوستان - -نوبیتکس طرحی به نام معرفی دوستان در نظر گرفته است که از طریق آن هم به گسترش نوبیتکس کمک می‌کنید و هم از مزایای آن بهره‌مند می‌شوید. براساس این طرح شما می‌توانید دوستان خود را با لینک اختصاصی خود به نوبیتکس دعوت کنید و درصدی از کارمزد معاملات آن‌ها را به عنوان پاداش دریافت نمایید. برای اطلاعات بیشتر به [صفحه قوانین طرح معرفی دوستان](https://nobitex.ir/policies/referral/) مراجعه کنید. - -معرفی دوستان با استفاده از ایجاد «کد دعوت» انجام می‌شود. هر کاربر نوبیتکس می‌تواند برای خود یک یا چند کد دعوت بسازد. کدهای دعوت معمولاً شامل شش رقم هستند ولی می‌توانند طول متفاوتی داشته باشند یا حتی رشته‌های دلخواه باشند. در زمان ساخت هر کد دعوت می‌توان سهم کاربر معرف و کاربر دعوت شده از کارمزد اهدایی را مشخص نمود. - -با استفاده از «فهرست کدهای دعوت» می‌توانید فهرستی از کدهای دعوت فعلی خود را دریافت نمایید. به همراه این فهرست، میزان سود شما و برخی دیگر از آمار مربوط به کاربران ثبت‌نامی با آن کد دعوت ارسال می‌شود. اگر هنوز کد دعوتی ندارید، برای شروع استفاده از طرح معرفی دوستان می‌توانید با استفاده از «ایجاد کد دعوت»، یک کد دعوت بسازید. - - - - -## فهرست کدهای دعوت - -```shell -curl -X GET 'https://apiv2.nobitex.ir/users/referral/links-list' \ - --header 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```plaintext -http --follow --timeout 3600 GET https://apiv2.nobitex.ir/users/referral/links-list \ - Authorization:'Token yourTOKENhereHEX0000000000' -``` - -* **درخواست:** `POST /users/referral/links-list` -* **محدودیت فراخوانی:** ۵۰ درخواست در هر ۱۰ دقیقه - -### پارامترهای پاسخ -پارامتر | نوع | توضیحات | نمونه ----- | ---- | ---- | ---- -links | list of ReferralLink | فهرست کدهای دعوت این کاربر | `[{...ReferralLink...}, ...]` - -### شی ReferralLink -فیلد | نوع | توضیحات | نمونه ----- | ---- | ---- | ---- -id | int | شناسه یکتای لینک | `1001` -referralCode | string | کد دعوت | `40404` -createdAt | datetime | تاریخ ایجاد کد | `2020-07-15T11:32:38.326809+00:00` -userShare | int | سهم کاربر معرف از کارمزد معاملات کاربر دعوت شده | `20` -friendShare | int | سهم کاربر دعوت شده از کارمزد معاملات خود | `10` -description | string | توضیحات اختیاری کاربر برای این کد | `Shared on Instagram page X` -statsRegisters | int | آمار: کاربران ثبت‌نام کرده با این کد | `20` -statsTrades | int | آمار: مجموع تعداد معاملات کاربران ثبت‌نام کرده با این کد | `240` -statsProfit | monetary: IRR | آمار: مجموع ریالی درآمد کاربر از این کد دعوت | `3200000` - - -## ایجاد کد دعوت - -```shell -curl -X GET 'https://apiv2.nobitex.ir/users/get-referral-code' \ ---header 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```plaintext -http --follow --timeout 3600 GET https://apiv2.nobitex.ir/users/get-referral-code \ - Authorization:'Token yourTOKENhereHEX0000000000' -``` -برای ایجاد یک کد دعوت جدید برای کاربر، از «ایجاد کد دعوت» استفاده نمایید. - -* **درخواست:** `POST /users/referral/links-add` -* **محدودیت فراخوانی:** ۵ درخواست در هر دقیقه - -### پارامترهای ورودی -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | --------- | --------- | ----- -friendShare | int | `0` | سهم کارمزد اهدایی به دوست دعوت شده با این کد | `10` - -### حالت‌های خطا -کد خطا | توضیحات ----- | ---- -InvalidGivebackShare | سهم کارمزد دوست قابل قبول نیست. پارامتر friendShare را بررسی کنید. -TooManyReferralLinks | سهمیه ۳۰ تایی کدهای دعوت قابل ساخت برای هر کاربر به پایان رسیده است. -ReferralCodeUnavailable | امکان ایجاد کد دعوت در حال حاضر وجود ندارد. -ReferralCodeExists | خطایی در ثبت کد دعوت رخ داده است. - - -## وضعیت دعوت کاربر - - -```shell -curl -X GET 'https://apiv2.nobitex.ir/users/referral/referral-status' \ ---header 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```plaintext -http --follow --timeout 3600 GET https://apiv2.nobitex.ir/users/referral/referral-status \ - Authorization:'Token yourTOKENhereHEX0000000000' -``` - -برای اطلاع از این که کاربر فعلی توسط کاربر دیگری به نوبیتکس دعوت شده است یا خیر، از «وضعیت دعوت کاربر» استفاده نمایید. - -* **درخواست:** `POST /users/referral/referral-status` -* **محدودیت فراخوانی:** ۵۰ درخواست در هر ۱۰ دقیقه - -### پارامترهای پاسخ -پارامتر | نوع | توضیحات | نمونه ----- | ---- | ---- | ---- -hasReferrer | boolean | آیا کاربر توسط کاربر دیگری دعوت شده است؟ | `true` - - -## ثبت معرف کاربر - -```shell -curl -X GET 'https://apiv2.nobitex.ir/users/referral/set-referrer' \ - --header 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```plaintext -http --follow --timeout 3600 GET https://apiv2.nobitex.ir/users/referral/set-referrer \ - Authorization:'Token yourTOKENhereHEX0000000000' -``` - -کد دعوت باید در زمان ثبت‌نام توسط کاربر وارد شده یا با استفاده از پیوند دعوت به صورت خودکار پر شود. با این حال تا ۲۴ ساعت -پس از ثبت‌نام نیز امکان ثبت معرف توسط کاربر با استفاده از این API وجود دارد. منظور از کاربر معرف، کاربری است که کاربر فعلی -را دعوت نموده است. - -* **درخواست:** `POST /users/referral/set-referrer` -* **محدودیت فراخوانی:** ۵۰ درخواست در هر ۱۰ دقیقه - -### پارامترهای ورودی -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | --------- | --------- | ----- -referrerCode | string | الزامی | کد دعوت کاربر دعوت کننده | `40404` - -### حالت‌های خطا -کد خطا | توضیحات ----- | ---- -ReferrerChangeUnavailable | بیش از ۲۴ ساعت از ثبت‌نام کاربر گذشته است و تعریف معرف دیگر ممکن نیست. diff --git a/source/includes/_security.md b/source/includes/_security.md deleted file mode 100644 index eea2c52..0000000 --- a/source/includes/_security.md +++ /dev/null @@ -1,186 +0,0 @@ -# امنیت - -## سابقه ورود - -```shell -curl 'https://apiv2.nobitex.ir/users/login-attempts' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/login-attempts \ -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "attempts": [ - { - "ip": "46.209.130.106", - "username": "name@example.com", - "status": "Successful", - "createdAt": "2018-11-28T14:16:08.264308+00:00" - }, - ... - ] -} -``` - -برای دریافت سابقه ورود از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET /users/login-attempts` - - -## فعالسازی لغو اضطراری - -```shell -curl 'https://apiv2.nobitex.ir/security/emergency-cancel/activate' \ - -X GET \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/security/emergency-cancel/activate \ - Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "cancelCode": { - "code": "seJlef35L3" - } -} -``` - - -جهت فعالسازی امکان لغو اضطراریِ درخواست های برداشت از این درخواست استفاده نمائید. -پس از فعالسازی این امکان، پیامک و ایمیل ارسالی پس از ثبت درخواست برداشت، -حاوی لینکی خواهد بود که شما میتوانید با استفاده از آن در صورتی که درخواست برداشت توسط شما ثبت نشده است، در کمترین زمان ممکن و بدون نیاز به لاگین، درخواست های برداشت خود را لغو نمایید. - -- **درخواست:** `GET /security/emergency-cancel/activate` - - -### نکات و ملاحظات -توجه داشته باشید: در صورتی که درخواست برداشت شما توسط این امکان لغو گردد، امکان ثبت درخواست برداشت تا ۷۲ ساعت برای شما غیرفعال خواهد شد. - - - -## آنتی فیشینگ - -جهت امنیت حساب کاربری و همچنین اعتماد بیشتر کاربران به ایمیل هایی که از سمت توبیتکس ارسال میشود نیاز هست که کاربر بتواند کد یونیک برای حساب کاربری خود انتخاب کند که تمامی ایمیل هایی که از سمت نوبیتکس به صورت اتوماتیک ارسال میشود حاوی این کد باشد. -.این کد به کاربر این اطمینان را میدهد که این ایمیل قطعا از نوبیتکس ارسال شده است. - - -### ایجاد کد آنتی فیشینگ - ->نمونه درخواست: - -```shell -curl --location --request POST 'https://apiv2.nobitex.ir/security/anti-phishing' \ ---header 'Authorization: Token yourTOKENhereHEX0000000000' \ ---form 'code="sample_anti_phishing"' \ ---form 'otpCode="123456"' -``` - - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -> برای دریافت رمزیکبارمصرف otpCode باید از API زیر با پارامترهای مشخص شده استفاده نمایید: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/v2/otp/request' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - --data '{"type": "email", "usage": "anti_phishing_code"}' -``` - -> **حالت های خطا** - -> در صورتی که پارامتر کدیکبارمصرف یا آنتی فیشینگ را ارسال نکرده باشید با این خطا روبرو خواهید شد. - -```json -{ - "status": "failed", - "code": "ParseError", - "message": "Missing string value" -} -``` - - -> در صورتی که کدیکبار مصرف ارسال شده، نامعتبر باشد با این خطا روبرو خواهید بود. - -```json -{ - "status": "failed", - "code": "InvalidOTPCode", - "message": "Please use otp/request endpoint" -} -``` - -> در صورتی که طول عبارت ارسالی نامناسب باشد با این خطا مواجه خواهید شد - -```json -{ - "status": "failed", - "code": "InvalidCodeLength", - "message": "Code length must be between 4 and 15 characters" -} -``` - - -* **درخواست:** `POST /security/anti-phishing` -* **محدودیت فراخوانی:** ۱۰ درخواست در هر دقیقه - - -* پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |--------|---------|----------------------------------------------| --------- -code | string | الزامی | کد آنتی فیشینگ تعیین شده توسط کاربر | sample_anti_phishing -otpCode | number | الزامی | کد یکبار مصرف ارسال شده به شماره همراه کاربر | 12345 - - - - -### دریافت کد آنتی فیشینگ - -* **درخواست:** `GET /security/anti-phishing` -* **محدودیت فراخوانی:** ۱۰ درخواست در هر دقیقه - - ->نمونه درخواست: - -```shell -curl --location --request GET 'https://apiv2.nobitex.ir/security/anti-phishing' \ ---header 'Authorization: Token yourTOKENhereHEX0000000000' -``` - - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "antiPhishingCode": "s*********g" -} -``` - -> در صورتی که آنتی‌فیشینگ کد برای کاربر فعال نشده باشد با این پاسخ مواجه خواهید شد - -```json -{ - "status": "failed", - "code": "NotFound", - "message": "AntiPhishingCode is not declared for this user" -} -``` diff --git a/source/includes/_symbols.md b/source/includes/_symbols.md deleted file mode 100644 index 1f5dff6..0000000 --- a/source/includes/_symbols.md +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - diff --git a/source/includes/_user_data.md b/source/includes/_user_data.md deleted file mode 100644 index 060b3e8..0000000 --- a/source/includes/_user_data.md +++ /dev/null @@ -1,765 +0,0 @@ -

اطلاعات کاربر

- -

پروفایل

- -```shell -curl 'https://apiv2.nobitex.ir/users/profile' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/profile \ -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "profile": { - "firstName": "مهدی", - "lastName": "رضایی", - "nationalCode": "011122333", - "email": "name@example.com", - "username": "name@example.com", - "phone": "02142719000-9012", - "mobile": "09151111111", - "city": "مشهد", - "bankCards": [ - { - "number": "6037-9900-0000-0000", - "bank": "ملی", - "owner": "مهدی رضایی", - "confirmed": true, - "status": "confirmed" - } - ], - "bankAccounts": [ - { - "id": 1999, - "number": "0346666666666", - "shaba": "IR460170000000346666666666", - "bank": "ملی", - "owner": "مهدی رضایی", - "confirmed": true, - "status": "confirmed" - } - ], - "verifications": { - "email": true, - "phone": true, - "mobile": true, - "identity": true, - "selfie": false, - "bankAccount": true, - "bankCard": true, - "address": true, - "city": true, - "nationalSerialNumber": true - }, - "pendingVerifications": { - "email": false, - "phone": false, - "mobile": false, - "identity": false, - "selfie": false, - "bankAccount": false, - "bankCard": false - }, - "options": { - "fee": "0.35", - "feeUsdt": "0.2", - "isManualFee": false, - "tfa": false, - "socialLoginEnabled": false - }, - "withdrawEligible": true - }, - "tradeStats": { - "monthTradesTotal": "10867181.5365000000", - "monthTradesCount": 3 - }, - "websocketAuthParam": "1987577cdf7c7422dee369e188e276ee" -} -``` -این api، اطلاعات پروفایل شما، کارت بانکی، حساب بانکی، موارد تایید شده(ایمیل، شماره تلفن، موبایل ...)، تنظمیات مربوط به پروفایل(فی تراکنش، فی مبادلات usdt و ...) و خلاصه آمار مبادلات شما را برمیگرداند. - -برای دریافت پروفایل کاربر از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET /users/profile` - -### پارامترهای ورودی -برای دریافت پاسخ، کافیست توکن احراز هویت را ارسال نمایید - -## تولید آدرس بلاکچین - -```shell -curl 'https://apiv2.nobitex.ir/users/wallets/generate-address' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"currency":"btc", "network": "BSC"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/wallets/generate-address \ - currency=btc -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "address": "LRf3vuTMy4UwD5b72G84hmkfGBQYJeTwUs" -} -``` - -برای تولید آدرس بلاکچین از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /users/wallets/generate-address` -- **محدودیت فراخوانی:** ۳۰ درخواست در ساعت - - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------------------------------------|--------|---------------------------|---------------|--------| -| currency ارجح | string | الزامی (جایگزین wallet) | رمزارز کیف | `btc` | -| wallet قدیمی | string | (در نبود currency الزامی) | شناسه کیف پول | `4159` | -| network | string | اختیاری | شبکه | `BSC` | - - - - -## افزودن کارت بانکی - -```shell -curl 'https://apiv2.nobitex.ir/users/cards-add' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"number":"5041721011111111","bank":"رسالت"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/cards-add \ - number=5041721011111111 bank=رسالت -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -برای افزودن کارت بانکی جدید از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /users/cards-add` -- **محدودیت فراخوانی:** ۳۰ درخواست در هر ۳۰ دقیقه - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -number | string | الزامی | شماره کارت | `5041721011111111` -bank | string | الزامی | نام بانک | `رسالت` - -## افزودن حساب بانکی - -```shell -curl 'https://apiv2.nobitex.ir/users/accounts-add' \ - -X POST \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ - --data '{"number":"5041721011111111","shaba":"IR111111111111111111111111","bank":"رسالت"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/accounts-add \ - number=5041721011111111 shaba=IR111111111111111111111111 bank=رسالت -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -برای افزودن حساب بانکی جدید از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /users/accounts-add` -- **محدودیت فراخوانی:** ۳۰ درخواست در ۳۰ دقیقه - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -number | string | الزامی | شماره حساب | `5041721011111111` -shaba | string | الزامی | شماره شبا | `IR111111111111111111111111` -bank | string | الزامی | نام بانک | `رسالت` - - - -##محدودیت های کاربر - -```shell -curl 'https://apiv2.nobitex.ir/users/limitations' \ - -X GET \ - -H "Authorization: Token yourTOKENhereHEX0000000000" \ - -H "content-type: application/json" \ -``` - -```plaintext -http GET https://apiv2.nobitex.ir/users/limitations -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "limitations": { - "userLevel": "level2", - "features": { - "crypto_trade": false, - "rial_trade": false, - "coin_deposit": false, - "rial_deposit": false, - "coin_withdrawal": false, - "rial_withdrawal": false - }, - "limits": { - "withdrawRialDaily": { - "used": "0", - "limit": "900000000" - }, - "withdrawCoinDaily": { - "used": "0", - "limit": "2000000000" - }, - "withdrawTotalDaily": { - "used": "0", - "limit": "2000000000" - }, - "withdrawTotalMonthly": { - "used": "0", - "limit": "30000000000" - } - } - } -} -``` -### توضیحات -کاربران در نوبیتکس بر اساس سطح کاربری خود، محدودیت هایی در برداشت، واریز و مبادلات خود دارند. هر کاربر نسبت به نیاز خود و میزان مبادلاتی که دارد میتواند با ارائه مدارک مورد نیاز ، سطح کاربری خود را پس از احراز هویت و تایید مدراک، ارتقا دهد. اطلاعات نمایش داده شده در خروجی api شامل همین محدودیت ها میباشد: - - -برای دریافت محدودیت های کاربر از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /users/limitations` - -### پارامترهای ورودی -- در این بخش به ورودی نیاز نیست. -- توکن دریافتی از بخش لاگین باید در هدر ارسال شود. - - -### پارامترهای خروجی -### features: شرایط حساب کاربری -- crypto_trade: امکان مبادله رمز ارزها -- rial_trade: امکان مبادله با ریال -- coin_deposit: امکان واریز رمز ارز به کیف پول نوبیتکس -- rial_deposit: امکان واریز ریال به کیف پول نوبیتکس -- coin_withdrawal: امکان برداشت رمز ارز از کیف پول نوبیتکس به کیف پول دیگر -- rial_withdrawal: امکان برداشت ریال از کیف پول نوبیتکس به حساب بانکی - -### limits: محدودیت های حساب کاربری -- withdrawRialDaily: مقدار مجاز برای برداشت روزانه ریال -- withdrawRialDaily: مقدار مجاز برای برداشت روزانه رمز ارز -- withdrawTotalDaily: مقدار مجاز برای برداشت روزانه مجموع رمز ارز و ریال -- withdrawTotalMonthly: مقدار مجاز برای برداشت ماهیانه مجموع رمز ارز و ریال - -### نکات و ملاحظات -1. تمامی مبالغ در خروجی به ریال هستند. -2. برای اطلاع از جزئیات سطوح کاربری، میزان محدودیت ها، مدارک مورد نیاز هر سطح و توضیحات کامل هر سطح به [سطوح حساب کاربری در نوبیتکس](https://nobitex.net/policies/user-levels/) مراجعه کنید. -#اطلاعات مالی کاربر - -## لیست کیف پول ها - -```shell -curl 'https://apiv2.nobitex.ir/users/wallets/list' \ - --header "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/users/wallets/list \ - Authorization=Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "wallets": [ - { - "depositAddress": null, - "depositTag": null, - "depositInfo": { - "FIAT_MONEY": { - "address": null, - "tag": null - } - }, - "id": 2693280, - "currency": "rls", - "balance": "746212980", - "blockedBalance": "0", - "activeBalance": "746212980", - "rialBalance": 746212980, - "rialBalanceSell": 746212980 - }, - { - "depositAddress": "bc1qp8dvtrhgjae6qhjfmvs2dj80ck0hgdjs6ts720", - "depositTag": null, - "depositInfo": { - "BTC-LEGACY": { - "address": null, - "tag": null - }, - "BTC": { - "address": "bc1qp8dvtrhgjae6qhjfmvs2dj80ck0hgdjs6ts720", - "tag": null - }, - "BTCLN": { - "address": null, - "tag": null - }, - "BSC": { - "address": null, - "tag": null - } - }, - "id": 133778, - "currency": "btc", - "balance": "0", - "blockedBalance": "0", - "activeBalance": "0", - "rialBalance": 0, - "rialBalanceSell": 0 - } - ] -} -``` - -برای دریافت لیست کیف پول های کاربر از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET /users/wallets/list` -- **محدودیت فراخوانی:** 20 درخواست در 2 دقیقه - - -### نکات و ملاحظات -1. کیف پول یک رمزارز در صورتی برای کاربر ایجاد می‌شود که کاربر سفارشی در بازار آن رمزارز ثبت کرده و یا آدرس واریز برای آن ایجاد کرده باشد. -این ویژگی در رمزارزهای آتی نوبیتکس نمایش خواهد یافت. برای رمزارزهای قدیمی کاربران سابق، همه کیف‌پول‌های از پیش موجود کاربر باقی خواهند ماند. -2. در برخی از موارد به دلیل کنترل بار ترافیک ورودی این سرویس، ممکن است پاسخ مورد انتظار دریافت نگردد، در این حالت می بایست مجددا فراخوانی را انجام داد و یا اینکه از این سرویس برای دریافت لیست کیف پول ها استفاده نمائید -3. برای مشخص کردن نوع کیف پول (spot or margin) میتوانید نوع آن را با استفاده از پارامتر type مشخص نمایید. به صورت پیش فرض کیف پول‌های spot لیست خواهند شد - -## لیست کیف پول ها (انتخابی) - -```shell -curl 'https://apiv2.nobitex.ir/v2/wallets?currencies=rls,btc' \ - --header "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/v2/wallets \ - Authorization=Token yourTOKENhereHEX0000000000 - currencies=rls,btc -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "wallets": { - "RLS": { - "id": 133777, - "balance": "0E-10", - "blocked": "0" - }, - "BTC": { - "id": 133778, - "balance": "0E-10", - "blocked": "0" - } - } -} -``` - -برای دریافت لیست کیف پول های کاربر از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET /v2/wallets` -- **محدودیت فراخوانی:** 15 درخواست در دقیقه - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -currencies | string | اختیاری | نوع کیف پول(ارز)، به صورت رشته ای از ارزهای جداشده با کاما | `rls,btc` -type | string | `spot` | نوع کیف پول (اسپات یا فروش تعهدی) | `spot` یا `margin` - - -### نکات و ملاحظات -کیف پول یک رمزارز در صورتی برای کاربر ایجاد می‌شود که کاربر سفارشی در بازار آن رمزارز ثبت کرده و یا آدرس واریز برای آن ایجاد کرده باشد. -این ویژگی در رمزارزهای آتی نوبیتکس نمایش خواهد یافت. برای رمزارزهای قدیمی کاربران سابق، همه کیف‌پول‌های از پیش موجود کاربر باقی خواهند ماند. - - -##موجودی - -```shell -curl 'https://apiv2.nobitex.ir/users/wallets/balance' \ - -X POST \ - --header "Authorization: Token yourTOKENhereHEX0000000000" \ - --data '{"currency":"ltc"}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/wallets/balance \ - currency=ltc -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "balance": "10.2649975000", - "status": "ok" -} -``` - -برای دریافت موجودی کیف پول های خود در نوبیتکس (شامل کیف پول ریالی و کیف پول های رمز ارزی) از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /users/wallets/balance` -- **محدودیت فراخوانی:** ۶۰ درخواست در ۲ دقیقه - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -currency | string | الزامی | نوع کیف پول(ارز) | `ltc` - -### نکات و ملاحظات -1. مقدار بازگشتی برای موجودی، یک عدد است که به صورت string برگردانده میشود. این مقدار می‌تواند اعداد اعشاری زیادی داشته باشد. -2. اگر قصد محاسبات مهمی بر روی این اعداد را دارید، پیشنهاد ما این است که از انواع fixed precision برای نگهداری این اعداد استفاده کنید. - -## لیست تراکنش‌های کیف‌پول - -```shell -curl 'https://apiv2.nobitex.ir/users/wallets/transactions/list?wallet=4159' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/users/wallets/transactions/list \ - wallet=4159 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "transactions": [ - { - "currency": "ltc", - "created_at": "2018-10-17T09:41:08.519151+00:00", - "calculatedFee": "0", - "id": 99050, - "amount": "4.3802000000", - "description": "خرید 4.400 LTC به قیمت واحد ﷼7450000" - }, - { - "currency": "ltc", - "created_at": "2018-10-04T13:05:01.384902+00:00", - "calculatedFee": "0", - "id": 96541, - "amount": "-1.0000000000", - "description": "Withdraw to \"Lgn1zc77mEjk72KvXPqyXq8K1mAfcDE6YR\"" - }, - ... - ], - "hasNext": true -} -``` - -برای دریافت لیست آخرین تراکنش‌های یک کیف پول از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET /users/wallets/transactions/list` -- **محدودیت فراخوانی:** ۶۰ درخواست در ۲ دقیقه -- **صفحه بندی:** دارد (پیشفرض ۵۰) - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ | --------- | ----- -wallet | int | الزامی | شناسه کیف پول(id) | `4159` - -## تاریخچه تراکنش‌ها (انتخابی) - -```shell -curl 'https://apiv2.nobitex.ir/users/transactions-history?currency=ltc' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/users/transactions-history \ - currency=ltc -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "transactions": [ - { - "id": 99050, - "amount": "4.3802000000", - "description": "خرید 4.400 LTC به قیمت واحد ﷼7450000", - "created_at": "2018-10-17T09:41:08.519151+00:00", - "balance": "21.2502000000", - "tp": "buy", - "calculatedFee": null, - "type": "معامله", - "currency": "ltc" - }, - { - "id": 96541, - "amount": "-1.0000000000", - "description": "Withdraw to \"Lgn1zc77mEjk72KvXPqyXq8K1mAfcDE6YR\"", - "created_at": "2018-10-04T13:05:01.384902+00:00", - "balance": "16.8700000000", - "tp": "withdraw", - "calculatedFee": null, - "type": "برداشت", - "currency": "ltc" - } - ], - "hasNext": false -} -``` - -برای دریافت تاریخچه تراکنش‌ها از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET /users/transactions-history` -- **محدودیت فراخوانی:** ۶۰ درخواست در ساعت -- **صفحه بندی:** دارد (پیشفرض ۵۰) - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------|----------|---------|--------------------------|------------------------------------| -| currency | string | اختیاری | ارز/رمزارز تراکنش | `rls` یا `usdt` یا `btc` یا ... | -| tp | string | اختیاری | نوع تراکنش | `deposit` یا `withdraw` یا ... | -| from | datetime | اختیاری | شروع بازه زمانی تراکنش | `2018-10-01T00:00:00.000000+00:00` | -| to | datetime | اختیاری | پایان بازه زمانی تراکنش | `2018-10-20T00:00:00.000000+00:00` | -| from_id | datetime | اختیاری | شناسه‌های بیشتر از ورودی | `96124` | - -### نکات و ملاحظات - -1. لازم است پارامتر `from` در صورت وجود از پارامتر `to` عقب‌تر باشد. -2. بازه زمانی انتخاب شده بین `from` و `to` حداکثر می‌تواند ۹۰ روز باشد. -3. انواع مقادیر `tp`: - * `deposit`: واریز - * `withdraw`: برداشت - * `buy`: دریافتی معامله - * `sell`: پرداختی معامله - * `manual`: سیستمی - * `referral`: ریفرال - * `transfer`: انتقال - * `pnl`: سود/زیان تعهدی - * `delegate`: استخر مشارکت - * `staking`: استیکینگ - * `yield_farming`: ییلد فارمینگ - * `discount`: تخفیف - -## لیست واریزها - -```shell -curl 'https://apiv2.nobitex.ir/users/wallets/deposits/list?wallet=4159' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/users/wallets/deposits/list \ - wallet=4159 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "deposits": [ - { - "txHash": "c5d84268a0bf02307b5a0460a68b61987a9b3009d3a82a817e41558e619ec1d2", - "address": "32KfyTNh162UoKithfDrWHZPYq5uePGmf7", - "confirmed": true, - "transaction": { - "id": 10, - "amount": "3.0000000000", - "currency": "btc", - "description": "Deposit - address:36n452uGq1x4mK7bfyZR8wgE47AnBb2pzi, tx:c5d84268a0bf02307b5a0460a68b61987a9b3009d3a82a817e41558e619ec1d2", - "created_at": "2018-11-06T03:56:18+00:00", - "calculatedFee": "0" - }, - "currency": "Bitcoin", - "blockchainUrl": "https://btc.com/c5d84268a0bf02307b5a0460a68b61987a9b3009d3a82a817e41558e619ec1d2", - "confirmations": 2, - "requiredConfirmations": 3, - "amount": "3.0000000000" - } - ], - "hasNext": true -} -``` - -برای دریافت لیست واریزها از این نوع درخواست استفاده نمایید: - -- **درخواست:** `GET /users/wallets/deposits/list` -- **محدودیت فراخوانی:** ۶۰ درخواست در ۲ دقیقه -- **صفحه بندی:** دارد (پیشفرض ۱۰برای ریال و ۲۰برای سایر) -- **فیلترزمانی:** دارد - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ |------------|---------|---------------| ----- -wallet | string | all | شناسه کیف پول | `4159` - -### نکات و ملاحظات -- از این طریق واریزهای حداکثر سه ماهه اخیر قابل نمایش است. -- صفحه بندی و فیلترزمانی فقط برای حالتی است که wallet تعیین شده باشد و برای حالت پیشفرض یعنی all کارایی ندارد. - - - -

بازارهای مورد علاقه

- -با استفاده از این امکان، کاربران قادر خواهند بود بازارهای مورد علاقه خود را مشخص کنند. - -### دریافت لیست بازارهای مورد علاقه - -```shell -curl 'https://apiv2.nobitex.ir/users/markets/favorite' \ - -X GET - -``` - -```plaintext -http GET https://apiv2.nobitex.ir/users/markets/favorite -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "favoriteMarkets": [ - "XLMIRT", - "BTCUSDT", - "BTCIRT" - ] -} -``` - -- **درخواست:** `GET /users/markets/favorite` -- **محدودیت فراخوانی:** 6 درخواست در ۱ دقیقه -- **نیاز به ارسال توکن:** دارد - - -### ثبت بازار(های) مورد علاقه - -```shell -curl 'https://apiv2.nobitex.ir/users/markets/favorite' \ - -X POST - -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/markets/favorite -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "favoriteMarkets": [ - "BTCIRT", - "DOGEUSDT" - ] -} -``` - - -- **درخواست:** `POST /users/markets/favorite` -- **محدودیت فراخوانی:** 12 درخواست در ۱ دقیقه -- **نیاز به ارسال توکن:** دارد - - -### پارامتر ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ |---------------------------| ----- -market | string | الزامی | نماد بازار comma-separated | `BTCIRT` or `BTCIRT,DOGEUSDT` - - - - - - -### حذف بازار مورد علاقه - -```shell -curl 'https://apiv2.nobitex.ir/users/markets/favorite' \ - -X DELETE - -``` - -```plaintext -http DELETE https://apiv2.nobitex.ir/users/markets/favorite -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "favoriteMarkets": [ - "BTCIRT", - "DOGEUSDT" - ] -} -``` - - -- **درخواست:** `DELETE /users/markets/favorite` -- **محدودیت فراخوانی:** 12 درخواست در ۱ دقیقه -- **نیاز به ارسال توکن:** دارد - - -### پارامتر ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه ------------ | ---- | ------ |-----------------------------------| ----- -market | string | الزامی | نماد بازار و یا All برای حذف همه | `All` or `BTCIRT` - diff --git a/source/includes/_websocket.md b/source/includes/_websocket.md deleted file mode 100644 index 55fa8a7..0000000 --- a/source/includes/_websocket.md +++ /dev/null @@ -1,652 +0,0 @@ -

وب‌سوکت

- - -نوبیتکس برای ارائه اطلاعات لحظه‌ای به کاربران، از وب‌سوکت استفاده می‌کند. این سرویس با استفاده از سرور **Centrifugo** پیاده‌سازی شده است که برای زبان‌های مختلف، **SDK**های متنوعی ارائه می‌دهد تا بتوانید به راحتی در کلاینت‌های خود به وب‌سوکت متصل شوید. - -لیست SDKهای قابل استفاده برای اتصال به وب‌سوکت نوبیتکس: - - -| ماژول SDK | مورد استفاده | -|-----------------------------------------------------------------------|---------------------------------------------------------------| -| [centrifuge-js](https://github.com/centrifugal/centrifuge-js) | برای مرورگر، NodeJS و ReactNative | -| [centrifuge-python](https://github.com/centrifugal/centrifuge-python) | برای استفاده در پایتون و قدرت گرفته از asyncio | -| [centrifuge-java](https://github.com/centrifugal/centrifuge-java) | استفاده در جاوا و اپلیکیشن‌های Android | -| [centrifuge-go](https://github.com/centrifugal/centrifuge-go) | برای Golang | -| [centrifuge-swift](https://github.com/centrifugal/centrifuge-swift) | استفاده از اپلیکشن‌های iOS | -| [centrifuge-dart](https://github.com/centrifugal/centrifuge-dart) | برای Dart و Flutter و استفاده در توسعه‌ی موبایل و وب با آن‌ها | - - -لیست SDKهای غیر رسمی: - -* [centrifuge-csharp](https://github.com/charmy/centrifuge-csharp) - برای C# و .NET و Unity 2022.3+ - - -

اتصال به وب‌سوکت

- ->نصب پکیج SDK با npm: - -```bash -npm install centrifuge -``` - -> اتصال به وب‌سوکت از طریق SDK: - -```javascript -import { Centrifuge } from 'centrifuge'; - -const client = new Centrifuge('wss://ws.nobitex.ir/connection/websocket', {}); -client.on('connected', (ctx) => { - console.log('connected', ctx); -}); -client.connect(); -``` - -> در صورتی که از این SDK استفاده نمی‌کنید، برای اتصال به وب‌سوکت پیام زیر را ارسال نمایید: - -```json -{ - "connect": {}, - "id": 1 -} -``` - -> استفاده مستقیم در HTML؛ در انتهای body این اسکریپت را قرار دهید: - -```html - -``` - - -برای اتصال به وب‌سوکت نوبیتکس، از آدرس زیر استفاده کنید: - -* **آدرس وب‌سوکت:** `wss://ws.nobitex.ir/connection/websocket` -* **محدودیت نرخ:** حداکثر 100 اتصال همزمان برای هر IP -* **نیاز به ارسال توکن:** ندارد - -پس از اتصال، سرور Centrifugo به صورت دوره‌ای پیام‌های `ping` ارسال می‌کند. اگر از SDKهای رسمی استفاده می‌کنید، این ابزارها به صورت خودکار به پیام‌های `ping` پاسخ `pong` می‌دهند. توجه داشته باشید که اگر در زمان ۲۵ ثانیه به پیام‌های `ping` پاسخ داده نشود، سرور به منظور مدیریت بهینه منابع، اتصال را قطع می‌کند. بنابراین اگر از SDK رسمی استفاده نمی‌کنید، از ارسال پیام `PONG` قبل از این زمان اطمینان حاصل کنید. - -در صورتی‌که از SDK رسمی استفاده می‌کنید نیاز به اقدامی برای مدیریت این مکانیزم ندارید. - - - -### اتصال به چند کانال همزمان - -برای اتصال به چند کانال به‌صورت همزمان نیاز به کلاینت‌های مجزا نیست؛ بلکه می‌توانید با استفاده از یک کلاینت به چند کانال همزمان متصل شوید. - -* **محدودیت subscription به کانال‌ها:** حداکثر 300 کانال برای هر connection - -> اتصال به چند کانال با استفاده از یک کلاینت: - -```javascript -const channels = ['public:orderbook-BTCIRT', 'public:orderbook-USDTIRT', 'public:orderbook-FTMIRT'] -const subs = channels.map(channel => { - const sub = client.newSubscription(channel, { delta: 'fossil' }) - sub.subscribe() - sub.on('publication', (ctx) => { - console.log(channel, ctx.data); - }) - return sub -}); -``` - - -### توجه: اتصال به وب‌سوکت با استفاده از SDK زبان‌های دیگر - -برای مطالعه‌ی جزئیات و چگونگی اتصال به وب‌سوکت نوبیتکس با استفاده از SDK زبان‌های دیگر، لطفاً به مستنداتی که در ابتدای بخش قرار دادیم مراجعه فرمایید. در SDK ها و محیط‌های مختلف، تفاوت‌های جزئی وجود دارد. به‌طور مثال در **node.js**، نیاز به نصب و پاس دادن مستقیم ماژول `websocket` به کلاینت در هنگام اتصال می‌باشیم که در [مستندات آن SDK](https://github.com/centrifugal/centrifuge-js?tab=readme-ov-file#using-with-nodejs) به این موضوع اشاره شده. - - -

دریافت توکن

- - - -```shell -curl 'https://apiv2.nobitex.ir/auth/ws/token/' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "token": "yJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNjMiLCJleHAiOjE3MzE5Mzk0NDIsImlhdCI6MTczMTkzODI0MiwibWV0YSI6e319.AFZjNC0ugUcfchUKjjunNDl1kfemJkA0Y5IYRi1c0mSvIa_XxzQIeVeqg6qnTBzE-HG6zEqXXyCENJtAz7xc7wqcABWbpcHdH0fPtjG4pwDZco9O065RcXacXo7qpCN-IuC0te0qG2_2bAhc-aR7vWgHsTm6GXfrQQh_6uwVHShSarU7", - "status": "ok" -} -``` - - -دریافت توکن وبسوکت با ارسال درخواست `GET` به `auth/ws/token/` صورت می‌گیرد. - -- **درخواست:** `GET /auth/ws/token` - - - - -

احراز هویت

- -```javascript -const centrifuge = new Centrifuge('wss://ws.nobitex.ir/connection/websocket', { - token: '' -}); -``` - -> برای احراز هویت به صورت خودکار می توان از قطعه کد زیر استفاده کرد. - -```javascript -import { Centrifuge, UnauthorizedError } from 'centrifuge'; - -async function getToken() { - if (!loggedIn) { - return ""; - } - const res = await fetch('https://apiv2.nobitex.ir/auth/ws/token/', { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - 'Authorization': `Token ApiToken` - } - }); - if (!res.ok) { - if (res.status === 403) { - // Return special error to not proceed with token refreshes, client will be disconnected. - throw new UnauthorizedError(); - } - // Any other error thrown will result into token refresh re-attempts. - throw new Error(`Unexpected status code ${res.status}`); - } - const data = await res.json(); - return data.token; -} - -const client = new Centrifuge( - 'wss://ws.nobitex.ir/connection/websocket', - { - token: '', - getToken: getToken - } -); - -client.on('connected', (ctx) => { - console.log('connected', ctx); -}); -client.connect(); -``` - -> در صورتی که از این SDK استفاده نمی‌کنید، برای اتصال به وب‌سوکت پیام زیر را ارسال نمایید: - -```json -{ - "connect": {"token": ""}, - "id": 1 -} -``` - -کانال‌هایی که با پیشوند private: آغاز میشوند حاوی اطلاعات اختصاصی برای هر کاربر هستند و دسترسی به آن‌ها مستلزم احراز هویت با استفاده از توکن و پارامتر `{websocket_auth_token}` است. - -**انواع کانال ها:** - -| نوع کانال | الگو | توضیحات | نمونه | -|-----------|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------| -| **عمومی** | `public:channelName` | کانال‌های عمومی حاوی اطلاعاتی هستند که برای همه کاربران قابل دسترسی‌اند و نیازی به احراز هویت ندارند. | `public:orderbook-BTCIRT` | -| **خصوصی** | `private:channelName#{websocketAuthParam}` | کانال‌های خصوصی شامل اطلاعات مرتبط با کاربر خاص هستند و دسترسی به آن‌ها نیازمند احراز هویت با استفاده از پارامتر {websocketAuthParam} و توکن است. | `private:trades#1987577cdf7c7422dee369e188e276ee` | - - - -پارامتر {websocketAuthParam} را میبایست از بخش [پروفایل](#user-profile) دریافت کنید. - -**مثال:** کاربر با `websocketAuthParam=1987577cdf7c7422dee369e188e276ee`برای دریافت آخرین معاملاتش میبایست به کانال `private:trades#1987577cdf7c7422dee369e188e276ee` سابسکرایب کند. - - - - - - -

کانال لیست سفارش‌ها: اردربوک

- - -کانال‌هایی با پیشوند زیر شامل اطلاعات **اردربوک** هستند و با هر تغییری در اردربوک، به مشترکین پیام ارسال می‌کنند: - -**الگوی کانال‌های اردربوک:** public:orderbook-* - - - - - - -```javascript -const sub = client.newSubscription('public:orderbook-BTCIRT', { delta: 'fossil' }); -sub.on('subscribed', (ctx) => { - console.log('subscribed'); -}); -sub.on('publication', (ctx) => { - console.log(ctx.data); -}); -sub.subscribe(); -``` - -> در صورتی که از SDK استفاده نمی‌کنید پیام زیر را ارسال نمایید: - -```json -{ - "id": 2, - "subscribe": { - "channel": "public:orderbook-BTCIRT" - } -} -``` - -> که در کنسول، پیامی که `console.log` نموده‌اید به شکل زیر خواهد بود که همان مقدار `data` می‌باشد: - -```json -{ - "asks": [ - ["35077909990", "0.009433"], - ["35078000000", "0.000274"], - ["35078009660", "0.00057"] - ], - "bids": [ - ["35020080080", "0.185784"], - ["35020070060", "0.086916"], - ["35020030010", "0.000071"] - ], - "lastTradePrice": "35077909990", - "lastUpdate": 1726581829816 -} -``` - -> همچنین اگر از SDK رسمی استفاده نمی‌کنید، در صورت اتصال و اشتراک صحیح، پیام‌های دریافتی از کانال به شکل زیر خواهد بود: - -```json -{ - "push": { - "channel": "public:orderbook-BTCIRT", - "pub": { - "data": "{\"asks\": [[\"35077909990\", \"0.009433\"], [\"35078000000\", \"0.000274\"], [\"35078009660\", \"0.00057\"]], \"bids\": [[\"35020080080\", \"0.185784\"], [\"35020070060\", \"0.086916\"], [\"35020030010\", \"0.000071\"]], \"lastTradePrice\": \"35077909990\", \"lastUpdate\": 1726581829816}", - "offset": 989153 - } - } -} -``` - - -**مثال:** برای دریافت تغییرات اردربوک بیت‌کوین به ریال، کافیست به کانال `public:orderbook-BTCIRT` متصل شوید. - - - - - - - -**نکته مهم:** این کانال‌ها تنها در صورت وقوع تغییر در اردربوک پیام ارسال می‌کنند. بنابراین، در بازارهایی با حجم معاملات کم، ممکن است مدت زمان زیادی بین پیام‌ها فاصله باشد. به‌منظور رفع این مشکل توصیه می‌شود قبل از اشتراک در کانال‌های وب‌سوکت، یک بار اطلاعات اولیه اردربوک را از طریق [API اردربوک ورژن ۳](#orderbook-v3) دریافت کنید. - - -**توجه:** استفاده از فلگ { delta: 'fossil' } در تابع `newSubscription` اختیاری است. با استفاده از این فلگ، اطلاعات اردربوک به صورت diff به کلاینت ارسال می‌شود. اگر از کلاینت‌های رسمی Centrifugo استفاده می‌کنید، متوجه تغییری نخواهید شد و صرفاً استفاده از پهنای باند شبکه‌ی شما کاهش چشم‌گیری در حدود ۶۰٪ خواهد کرد. اما در صورتی که از کلاینت رسمی استفاده نمی‌کنید، یا باید از استفاده از این فلگ خودداری کنید و یا باید حتماً الگوریتم بازیابی داده‌ها از حالت فشرده شده به حالت اصلی را پیاده‌سازی کنید. برای این کار از [الگوریتم فسیل](https://fossil-scm.org/) استفاده کرده‌ایم. - -### پارامترهای پاسخ - - پیام‌های وب‌سوکت شامل دو آرایه `asks` و `bids` بوده که در هر یک قیمت و مقدار سفارش‌های بازار وجود دارد. سفارش‌های **خرید** در **`bids`** و سفارش‌های **فروش** در **`asks`** بازگردانده می‌شوند. هر یک از این آرایه‌ها شامل دوتایی‌های «قیمت، مقدار» هستند. - - -| پارامتر پاسخ | نوع | توضیحات | نمونه | -|--------------------|--------|-------------------------------------------------------|-----------------------------------------------------------| -| `asks` | array | حاوی دوتایی‌های «قیمت، مقدار» از سفارش‌های **فروش** | [["1231", "0.1"],["1243", "1.02"]] | -| `bids` | array | حاوی دوتایی‌های «قیمت، مقدار» از سفارش‌های **خرید** | [["1243", "1"],["1231", "2"]] | -| `lastTradePrice` | string | مبلغ آخرین معامله | "35602702700" | -| `lastUpdate` | int | زمان آخرین به‌روزرسانی به فرمت یونیکس | 1726651067347 | - - - -

کانال آمار OHLC بازار نوبیتکس

- -برای توضیحات بیشتر در مورد OHLC به [این لینک](https://en.wikipedia.org/wiki/Open-high-low-close_chart) مراجعه کنید.

- -کانال‌هایی با الگوی زیر شامل اطلاعات کندل بازار مورد نظر است. - - -**الگوی کانال‌های کندل ohlc:** public:candle-{marketSymbol}-{resolution} - - - - - - - - - - -* پارامتر {resolution} بازه زمانی کندل‌های خروجی می‌باشد و مقدار آن می‌تواند یکی از مقادیر زیر باشد: - -| دقیقه‌ای | توضیح | ساعتی | توضیح | روزانه | توضیح | -|----------|-----------|-------|-------------|--------|--------| -| `1` | یک دقیقه | `60` | یک ساعت | `D` | یک روز | -| `5` | پنج دقیقه | `180` | سه ساعت | `2D` | دو روز | -| `15` | یک ربع | `240` | چهار ساعت | `3D` | سه روز | -| `30` | نیم ساعت | `360` | شش ساعت | | | -| | | `720` | دوازده ساعت | | | - -```javascript -const sub = client.newSubscription('public:candle-BTCIRT-15', { delta: 'fossil' }); -sub.on('subscribed', (ctx) => { - console.log('subscribed'); -}); -sub.on('publication', (ctx) => { - console.log(ctx.data); -}); -sub.subscribe(); -``` - -> در صورتی که از SDK استفاده نمی‌کنید پیام زیر را ارسال نمایید: - -```json -{ - "id": 2, - "subscribe": { - "channel": "public:candle-BTCIRT-15" - } -} -``` - -> که در کنسول، پیامی که `console.log` نموده‌اید به شکل زیر خواهد بود که همان مقدار `data` می‌باشد: - -```json -{ - "t": 1731852900, - "o": 6240000001.0, - "h": 6250000000.0, - "l": 6238000000.0, - "c": 6238031033.0, - "v": 1.26 -} -``` - -> همچنین اگر از SDK رسمی استفاده نمی‌کنید، در صورت اتصال و اشتراک صحیح، پیام‌های دریافتی از کانال به شکل زیر خواهد بود: - -```json -{ - "push": { - "channel": "public:candle-BTCUSDT-15", - "pub": { - "data": "{\"t\":1731852900,\"o\":6240000001.0,\"h\":6250000000.0,\"l\":6238000000.0,\"c\":6238031033.0,\"v\":1.26}", - "offset": 34575 - } - } -} -``` - - -**مثال:** برای دریافت کندل های 15 دقیقه ای بازار بیت‌کوین تومان، کافیست به کانال `public:candle-BTCIRT-15` متصل شوید. - - - -**توجه:** استفاده از فلگ { delta: 'fossil' } در تابع `newSubscription` اختیاری است. با استفاده از این فلگ، اطلاعات اردربوک به صورت diff به کلاینت ارسال می‌شود. اگر از کلاینت‌های رسمی Centrifugo استفاده می‌کنید، متوجه تغییری نخواهید شد و صرفاً استفاده از پهنای باند شبکه‌ی شما کاهش چشم‌گیری در حدود ۶۰٪ خواهد کرد. اما در صورتی که از کلاینت رسمی استفاده نمی‌کنید، یا باید از استفاده از این فلگ خودداری کنید و یا باید حتماً الگوریتم بازیابی داده‌ها از حالت فشرده شده به حالت اصلی را پیاده‌سازی کنید. برای این کار از [الگوریتم فسیل](https://fossil-scm.org/) استفاده کرده‌ایم. - -### پارامترهای پاسخ - -ساختار پیام‌های وبسوکت این کانال به این صورت می باشد. - -| پارامتر پاسخ | نوع | توضیحات | نمونه | -|--------------|-------|--------------|-------------------------------------| -| `t` | int | شروع زمان | 1731852900 | -| `o` | float | قیمت شروع | 6240000001.0 | -| `h` | float | بیشترین قیمت | 6250000000.0 | -| `l` | float | کمترین قیمت | 6238000000.0 | -| `c` | float | قیمت پایانی | 6238031033.0 | -| `v` | float | حجم معاملات | 1.26 | - -

کانال‌ عمومی معاملات

-در این کانال تمامی معاملات صورت گرفته در یک بازار منتشر می‌شود. - -**الگوی کانال‌های عمومی معاملات :** public:trades-{marketSymbol} - -> نمونه پیام ارسالی در کانال‌های عمومی معاملات: - -```json -{ - "price": "120000000000", - "time": 1762781164192, - "type": "sell", - "volume": "0.000003" -} -``` - -### پارامترهای پاسخ -| پارامتر پاسخ | نوع | توضیحات | نمونه | -|--------------|----------|-------------|---------------------------------------------------------| -| price | monetary | قیمت معامله | 12000.129 | -| time | int | زمان معامله | 1762781164192 | -| type | string | نوع معامله | sell, buy | -| volume | monetary | حجم معامله | 13.002 | - - -

کانال‌ وضعیت بازارها

-در این کانال‌ها اطلاعات کلی مربوط به وضعیت بازارها طی ۲۴ ساعت اخیر منتشر می‌شود. - -**الگوی کانال‌های‌ وضعیت تک بازار :** public:market-stats-{marketSymbol} - -**کانال‌ وضعیت تمامی بازارها :** public:market-stats-all - -> نمونه پیام ارسالی در کانال‌های وضعیت تک بازار: - -``` json -{ - "isClosed": false, - "bestSell": "121073861950", - "bestBuy": "120000000000", - "volumeSrc": "0.000185131782", - "volumeDst": "21590044.0170869949", - "latest": "114879999920", - "mark": "123288285750", - "dayLow": "110850000360", - "dayHigh": "121073861950", - "dayOpen": "121073861910", - "dayClose": "114879999920", - "dayChange": "-5.12" -} -``` - -### پارامترهای پاسخ - -| پارامتر پاسخ | نوع | توضیحات | نمونه | -|--------------|----------|---------------------------------|-------------------------------| -| isClosed | bool | باز یا بسته بودن بازار | true | -| bestSell | monetary | بهترین قیمت فروش فعلی | 1000 | -| bestBuy | monetary | بهترین قیمت خرید فعلی | 1000 | -| volumeSrc | monetary | حجم معاملات ۲۴ ساعت اخیر | 13.002 | -| volumeDst | monetary | ارزش معاملات ۲۴ ساعت اخیر | 13002 | -| latest | monetary | آخرین قیمت معامله شده | 1002 | -| mark | monetary | قیمت معیار فعلی | 1002 | -| dayLow | monetary | کمترین قیمت ۲۴ ساعت اخیر | 800 | -| dayHigh | monetary | بیشترین قیمت ۲۴ ساعت اخیر | 1200 | -| dayOpen | monetary | نخستین قیمت ۲۴ ساعت اخیر | 800 | -| dayClose | monetary | آخرین قیمت ۲۴ ساعت اخیر | 1200 | -| dayChange | float | درصد تغییر قیمت طی ۲۴ ساعت اخیر | -2.12 | - - -> نمونه پیام ارسالی در کانال‌ وضعیت تمامی بازارها: - -```json -{ - "btc-irt": { - "isClosed": false, - "bestSell": "121073861950", - "bestBuy": "120000000000", - "volumeSrc": "0.000185131782", - "volumeDst": "21590044.0170869949", - "latest": "114879999920", - "mark": "123288285750", - "dayLow": "110850000360", - "dayHigh": "121073861950", - "dayOpen": "121073861910", - "dayClose": "114879999920", - "dayChange": "-5.12" - }, - "usdt-irt": { - "isClosed": false, - "bestSell": "121073861950", - "bestBuy": "120000000000", - "volumeSrc": "0.000185131782", - "volumeDst": "21590044.0170869949", - "latest": "114879999920", - "mark": "123288285750", - "dayLow": "110850000360", - "dayHigh": "121073861950", - "dayOpen": "121073861910", - "dayClose": "114879999920", - "dayChange": "-5.12" - } -} -``` - -

کانال خصوصی سفارشات کاربر

-در این کانال تمامی رخدادهای مربوط به سفارشات کاربر منتشر می‌شود. - -**الگوی کانال سفارشات کاربر:** private:orders#{websocketAuthParam} - -سابسکرایب به این کانال نیازمند احراز هویت از طریق [توکن](#websocket-token) است. - - -### پارامترهای پیام - -> پیام‌های ارسالی کانال به این صورت خواهد بود: - -```json -{ - "amount": "0.0002", - "avgFilledPrice": "114879999920", - "clientOrderId": null, - "dstCurrency": "rls", - "eventTime": 1762779011366, - "fee": "0.00000031", - "filledAmount": "0.0002", - "lastFillTime": 1762779011258, - "marketType": "Spot", - "orderId": 278339, - "orderType": "Market", - "param1": null, - "price": null, - "side": "Buy", - "srcCurrency": "btc", - "status": "Done", - "tradeAmount": "0.0002", - "tradeId": 92547, - "tradePrice": "114879999920" -} -``` - -| فیلد | نوع | توضیحات | نمونه | -|-------------|----------|------------------------------------|-------------------| -| amount | monetary | حجم سفارش | `3.002` | -| avgFilledPrice | monetary | ارزش پر شده‌ سفارش (ریالی یا تتری) | `520305923` | -| clientOrderId | string | شناسه پیگیری کاربر | `1032` | -| dstCurrency | string | ارز مقصد سفارش | `rls`, `usdt` | -| eventTime | int | زمان انجام رخداد | `1762779011258` | -| fee | monetary | کارمزد سفارش | `1.02` | -| filledAmount | monetary | حجم پر شده سفارش | `2.7812` | -| lastFillTime | int | زمان آخرین ترید (nullable) | `1762779011258` | -| marketType | string | نوع بازار سفارش‌گذاری | `Spot`, `Margin` | -| orderId | int | شناسه سفارش | `47150` | -| orderType | string | نوع سفارش | `Market`, `Limit` | -| param1 | monetary | | `47150.7989334` | -| price | monetary | قیمت سفارش (nullable) | `47150.7989334` | -| side | string | جهت سفارش | `Buy`, `Sell` | -| srcCurrency | monetary | ارز مبدا سفارش | `btc` | -| status | string | وضعیت سفارش | `Done` | -| tradeAmount | monetary | حجم آخرین ترید (nullable) | `0.002` | -| tradeId | int | شناسه آخرین ترید (nullable) | `65451` | -| tradePrice | monetary | قیمت آخرین ترید (nullable) | `47150.7989334` | - - - -

کانال خصوصی معاملات کاربر

-به محض انجام شدن هر معامله‌ای برای کاربر، اطلاعات معامله در این کانال برای کاربر منتشر می شود. - - -**الگوی کانال معاملات کاربر:** private:trades#{websocketAuthParam} - - -سابسکرایب به این کانال نیازمند احراز هویت از طریق [توکن](#websocket-token) است. - - - - -```javascript -const sub = client.newSubscription('private:trades#1987577cdf7c7422dee369e188e276ee', { delta: 'fossil' }); -sub.on('subscribed', (ctx) => { - console.log('subscribed'); -}); -sub.on('publication', (ctx) => { - console.log(ctx.data); -}); -sub.subscribe(); -``` - -> در صورتی که از SDK استفاده نمی‌کنید پیام زیر را ارسال نمایید: - -```json -{ - "id": 2, - "subscribe": { - "channel": "private:trades#1987577cdf7c7422dee369e188e276ee" - } -} -``` - -> که در کنسول، پیامی که `console.log` نموده‌اید به شکل زیر خواهد بود که همان مقدار `data` می‌باشد: - -```json -{ - "srcCurrency": "btc", - "dstCurrency": "rls", - "timestamp": "2024-11-23T11:31:27.833332+00:00", - "price": "66683959340", - "amount": "0.000404", - "total": "26940319.57336", - "type": "sell", - "fee": "47150.7989334", - "id": 12942226, - "orderId": 520305923 -} -``` - -> همچنین اگر از SDK رسمی استفاده نمی‌کنید، در صورت اتصال و اشتراک صحیح، پیام‌های دریافتی از کانال به شکل زیر خواهد بود: - -```json -{ - "push": { - "channel": "private:trades#1987577cdf7c7422dee369e188e276ee", - "pub": { - "data": "{\"srcCurrency\":\"btc\",\"dstCurrency\":\"rls\", \"timestamp\":\"2024-11-23T11:31:27.833332+00:00\", \"price\":\"66683959340\",\"amount\":\"0.000404\",\"total\":\"26940319.57336\",\"type\":\"sell\",\"fee\":\"47150.7989334\",\"id\":12942226,\"orderId\":520305923}", - "offset": 34575 - } - } -} -``` - -### پارامترهای پیام - -| فیلد | نوع | توضیحات | نمونه | -|-------------|----------|--------------------|------------------------------------| -| id | int | شناسه‌ی معامله | 12942226 | -| orderId | int | شناسه‌ی سفارش | 520305923 | -| srcCurrency | string | رمزارز مبدا معامله | `btc` یا `eth` یا `xrp` یا ... | -| dstCurrency | string | ارز مقصد معامله | `rls` یا `usdt` | -| timestamp | string | زمان انجام معامله | `2024-11-23T11:31:27.833332+00:00` | -| type | string | نوع خرید یا فروش | `buy` یا `sell` | -| price | monetary | قیمت انجام معامله | `66683959340` | -| amount | monetary | مقدار معامله شده | `0.000404` | -| total | monetary | قیمت کل معامله | `26940319.57336` | -| fee | monetary | کارمزد معامله | `47150.7989334` | diff --git a/source/includes/_withdraw.md b/source/includes/_withdraw.md deleted file mode 100644 index 3b53463..0000000 --- a/source/includes/_withdraw.md +++ /dev/null @@ -1,283 +0,0 @@ -

برداشت

- -

ثبت درخواست برداشت

- -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/wallets/withdraw' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'X-TOTP: 123456' \ - -H 'Content-Type: application/json' \ - --data '{"wallet": 3456, "invoice": "lnbc123m1pskcu80pp5qqqsyqcyq5rqwz..."}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/wallets/withdraw \ - wallet=3456 invoice=lnbc123m1pskcu80pp5qqqsyqcyq5rqwz... -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "withdraw": { - "id": 432, - "createdAt": "2021-12-11T10:13:42.957103+00:00", - "status": "New", - "amount": "0.0123", - "currency": "btc", - "network": "BTCLN", - "invoice": "lnbc123m1pskcu80pp5qqqsyqcyq5rqwz...", - "address": "SaMpLeWaLlEtAdDrEsS", - "tag": "123456", - "wallet_id": 3456, - "blockchain_url": "https://nobitex.ir/receipt/Bitcoin/ewd23d...", - "is_cancelable": true - } -} -``` - -> در صورت وجود داشتن آدرس مقصد در دفتر آدرس، نیازی به ارسال X-TOTP در هدر درخواست نیست. - -> در صورت نبودن آدرس مقصد در دفتر آدرس، پس از ثبت درخواست برداشت، یک کد تایید یکبارمصرف به کاربر ایمیل و پیامک می‌شود. - -برای ثبت درخواست برداشت از این نوع درخواست استفاده نمایید: - -* **درخواست:** `POST /users/wallets/withdraw` -* **محدودیت فراخوانی:** 10 درخواست در 3 دقیقه - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|--------------|----------|---------|-------------------------|--------------------------------------| -| wallet | int | الزامی | شناسه کیف پول کاربر | 3456 | -| network | string | اختیاری | شبکه انتقال1 | "BTCLN" | -| invoice | string | اختیاری | صورت‌حساب2 | "lnbc123m1pskcu80pp5qqqsyqcyq5rqwz..." | -| amount | monetary | اختیاری | مقدار3 | "0.123" | -| address | string | اختیاری | آدرس مقصد4 | "SaMpLeWaLlEtAdDrEsS" | -| explanations | string | اختیاری | توضیحات | "sample explanation" | -| noTag | boolean | false | بدون تگ5 | false | -| tag | string | اختیاری | تگ انتقال6 | "123456" | - -1. **شبکه انتقال:** مقادیر قابل قبول است. در مواردی که چند شبکه برداشت برای رمزارز درخواستی پشتیبانی می‌شود، می‌توان شبکه انتقال را تعیین نمود. -2. **صورت‌حساب:** در انتقال‌های شبکه `BTCLN` الزامی است. در صورت وجود invoice پارامترهای amount و address از آن استخراج شده و در بدنه درخواست بلااستفاده خواهند شد. شبکه صورت‌حساب باید با network در صورت مشخص شدن در درخواست مطابقت داشته باشد. -3. **مقدار:** در صورتی که بدون invoice درخواست برداشت ثبت می‌کنید، الزامی می‌شود. -4. **آدرس مقصد:** برای برداشت‌های ریالی [شناسه حساب بانکی](/#88cb25e727 "دریافت از پروفایل") تایید شده کاربر جهت دریافت وجه و برای برداشت‌های رمزارزی آدرس کیف پول مقصد می‌باشد. در صورتی که از invoice برای برداشت استفاده می‌کنید، بلااستفاده خواهد شد. -5. **بدون تگ:** برای برداشت از شبکه‌های که نیاز به تگ انتقال دارند، **اگر می خواهید تگ انتقال را وارد نکنید، مقدار گزینه‌ی مربوط به آن (noTag) را "true" وارد کنید.** -6. **تگ انتقال:** در شبکه‌هایی که استفاده از تگ ضروری است این پارامتر الزامی است، مگر اینکه noTag فعال شده باشد. [ممو، تگ یا کامنت چیست؟](https://nobitex.ir/mag/what-is-memo/) - - -### حالت‌های خطا - -در صورتی که درخواست برداشت معتبر نباشد، ممکن است یکی از این خطاها برگردانده شود. در صورت دریافت هر یک از این خطاها، درخواست شما ثبت نشده است و در صورت تمایل باید درخواست را دوباره ارسال کنید. - -کد خطا | توضیحات --------- | --------- -InvalidCurrency | بازار رمزارز مورد نظر غیرفعال است -WithdrawUnavailable | کاربر محدودیت برداشت دارد -WithdrawCurrencyUnavailable | امکان برداشت این رمزارز (در این شبکه) وجود ندارد -**Coin**WithdrawDisabled | امکان برداشت این رمزارز موقتا غیرفعال شده است مثال: BTCWithdrawDisabled -InvalidAddressTag | تگ معتبر نمی باشد -MissingAddressTag | تگ فرستاده نشده یا اشتباه است -ExchangeRequiredTag | تگ در این بازار الزامی می باشد -RedundantTag | تگ ارسالی اضافی می باشد -Invalid2FA | کد دوعاملی ارسالی اشتباه است -WithdrawAmountLimitation | مقدار درخواست شده بیشتر از سقف محدودیت های کاربر (روزانه، ماهانه و ...) می باشد -InsufficientBalance | موجودی ناکافی است -WithdrawLimitReached | امکان ثبت درخواست به دلیل «محدودیت در تعداد درخواست با وضعیت مشابه» وجود ندارد -AmountTooLow | مقدار درخواستی از حداقل مقدار مجاز این بازار(شبکه) کمتر می باشد -AmountTooHigh | مقدار درخواستی از حداکثر مقدار مجاز این بازار(شبکه) بیشتر می باشد -InvalidMobileNumber | کاربر موبایل تایید شده ندارد -ShabaWithdrawCannotProceed | امکان ثبت درخواست برداشت ریالی بیشتر از حدمجاز روزانه وجود ندارد -ShabaWithdrawCannotProceed | امکان ثبت درخواست برداشت ریالی بیشتر از حدمجاز روزانه وجود ندارد -NotWhitelistedTargetAddress | حالت برداشت امن روی حساب فعال است اما شبکه، آدرس (یا تگ) در دفتر آدرس شما وجود ندارد - - - - -### نکات و ملاحظات -1. در صورت موجود نبودن آدرس مقصد در دفتر آدرس، این درخواست نیاز به شناسایی دوعاملی دارد. -2. کاربر درخواست دهنده بایستی اجازه برداشت از کیف پول خود را داشته باشد. -(مثلا دارای حداقل سطح مجاز برای برداشت و شماره تماس تایید شده بوده و سقف برداشت مجاز روزانه و ماهانه خود را رد نکرده باشد و شرایط و پیشنیازات ذکر شده در مقررات نوبیتکس را رعایت کرده باشد.) -3. در صورت فعال بودن حالت برداشت امن، شبکه، آدرس (و در صورت الزام شبکه، تگ) انتخاب شده باید در دفتر آدرس شما ثبت شده باشد. -4. درخواست برداشت ثبت شده در این مرحله نیاز به تایید توسط کاربر دارد. - -

تایید درخواست برداشت

- -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/wallets/withdraw-confirm' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"withdraw": 432, "otp": 623005}' -``` - -```plaintext -http POST https://apiv2.nobitex.ir/users/wallets/withdraw-confirm \ - withdraw=432 otp=623005 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "withdraw": { - "id": 432, - "createdAt": "2021-12-11T10:13:42.957103+00:00", - "status": "Verified", - "amount": "0.0123", - "currency": "btc", - "network": "BTCLN", - "invoice": "lnbc123m1pskcu80pp5qqqsyqcyq5rqwz...", - "address": "SaMpLeWaLlEtAdDrEsS", - "tag": "123456", - "wallet_id": 3456, - "blockchain_url": "https://nobitex.ir/receipt/Bitcoin/ewd23d...", - "is_cancelable": true - } -} -``` - -برای تایید درخواست برداشت از این نوع درخواست استفاده نمایید: - -* **درخواست:** `POST /users/wallets/withdraw-confirm` -* **محدودیت فراخوانی:** 30 درخواست در ساعت - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------|-----|--------------------------|-------------------------|--------| -| withdraw | int | الزامی | شناسه درخواست برداشت | 432 | -| otp | int | بسته به آدرس مقصد الزامی | رمز یکبارمصرف ارسال شده | 623005 | - - -### نکات و ملاحظات -1. در برداشت‌های ریالی به شبای تایید شده کاربر و برداشت رمزارزی به آدرس‌های امن دفتر آدرس، نیازی به ارسال رمز یکبارمصرف نیست. -2. برای تایید برداشت به آدرس‌های تایید نشده باید کد یکبارمصرف ارسال شده به شماره تلفن همراه یا ایمیل حساب کاربری خود را استخراج و به این API ارسال نمایید. -3. امکان استفاده از آی‌پی اختصاصی به زودی فراهم خواهد شد. - - -

فهرست برداشت‌ها

- -```shell -curl 'https://apiv2.nobitex.ir/users/wallets/withdraws/list' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - - -```plaintext -http GET https://apiv2.nobitex.ir/users/wallets/withdraws/list -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "withdraws": [ - { - "id": 432, - "createdAt": "2021-12-11T10:13:42.957103+00:00", - "status": "Canceled", - "amount": "0.0123", - "currency": "btc", - "network": "BTCLN", - "invoice": "lnbc123m1pskcu80pp5qqqsyqcyq5rqwz...", - "address": "SaMpLeWaLlEtAdDrEsS", - "tag": "123456", - "wallet_id": 3456, - "blockchain_url": "https://nobitex.ir/receipt/Bitcoin/ewd23d...", - "is_cancelable": true - }, - { - "id": 238, - "createdAt": "2020-09-19T14:17:23.441723+00:00", - "status": "Done", - "amount": "1000000", - "currency": "rls", - "network": "FIAT_MONEY", - "invoice": null, - "address": "\u062a\u062c\u0627\u0631\u062a: IR140180000000003333333333", - "tag": null, - "wallet_id": 3451, - "blockchain_url": null, - "is_cancelable": true - }, - { - "id": 239, - "createdAt": "2018-10-04T12:59:38.196935+00:00", - "status": "Done", - "amount": "1", - "currency": "ltc", - "network": "LTC", - "address": "Lgn1zc77mEjk72KvX...", - "tag": null, - "wallet_id": 3454, - "blockchain_url": "https://live.blockcypher.com/ltc/tx/c1ed4229e598d4cf...", - "is_cancelable": false - } - ], - "hasNext": true -} -``` - -برای دریافت لیست آخرین برداشت‌ها از این نوع درخواست استفاده نمایید: - -* **درخواست:** `GET /users/wallets/withdraws/list` -* **محدودیت فراخوانی:** ۶۰ درخواست در ۲ دقیقه -* **صفحه بندی:** دارد (پیش فرض 20) -* **فیلترزمانی:** دارد - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|---------|--------|---------|---------------------|-------| -| wallet | string | all | شناسه کیف پول کاربر | 3456 | - - - -

مشاهده برداشت

- -```shell -curl 'https://apiv2.nobitex.ir/withdraws/433' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - - -```plaintext -http GET https://apiv2.nobitex.ir/withdraws/433 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "withdraw": { - "id": 433, - "createdAt": "2021-12-14T06:53:11.593812+00:00", - "status": "Processing", - "amount": "0.123", - "currency": "eth", - "network": "BSC", - "invoice": null, - "address": "SaMpLeWaLlEtAdDrEsS", - "tag": null, - "wallet_id": 3458, - "blockchain_url": "https://etherscan.io/tx/tx111111", - "is_cancelable": true - } -} -``` - -برای مشاهده وضعیت یک درخواست برداشت از این نوع درخواست استفاده نمایید: - -* **درخواست:** `GET /withdraws/WITHDRAW` -* **محدودیت فراخوانی:** ۶۰ درخواست در ۲ دقیقه - - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|-------------|-----|---------|----------------------|-------| -| WITHDRAW | int | الزامی | شناسه درخواست برداشت | 433 | diff --git a/source/includes/internal/_2fa.md b/source/includes/internal/_2fa.md deleted file mode 100644 index 3c47dc7..0000000 --- a/source/includes/internal/_2fa.md +++ /dev/null @@ -1,261 +0,0 @@ -# شناسایی دوعاملی -شناسایی دوعاملی جهت افزایش امنیت حساب و دارایی کاربر در زمان ورود، علاوه بر گذرواژه، یک کد شش رقمی تقاضا خواهد نمود که از [احرازگر گوگل](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2 "Google Authenticator") دریافت می‌شود. - -### نکات و ملاحظات - -1. فعالسازی شناسایی دو عاملی برای کاربران سطح دو نوبیتکس اجباری است. -2. احراز هویت در API های این مجموعه الزامی است. - -##فعال‌سازی شناسایی دوعاملی - ->نمونه درخواست: - -```shell -curl 'https://apiv2.nobitex.ir/users/tfa/request' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```javascript -api.get('/users/tfa/request', { - headers: {Authorization: "Token yourTOKENhereHEX0000000000"}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @GET("/users/tfa/request") - Call request2FA(); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.request2FA(); -``` - -```plaintext -GET /users/tfa/request HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "device": { - "id": 1, - "name": "App", - "confirmed": false, - "configUrl": "otpauth://totp/Nobitex%3Atest%40nobitex.net?secret=FXZJ28P2V3U0F4W3U7707EYIKNBJAKR6&algorithm=SHA1&digits=6&period=30&issuer=Nobitex" - } -} -``` - -برای فعال‌سازی شناسایی دوعاملی از این نوع درخواست استفاده نمایید: - -پس از ثبت درخواست، پیامکی حاوی کد شش رقمی جهت تایید دستگاه به شماره همراه کاربر ارسال می‌شود که ظرف مدت 30 دقیقه منقضی خواهد شد. - -- **درخواست:** `GET /users/tfa/request` -- **محدودیت فراخوانی:** 3 درخواست در 10 دقیقه / 10 درخواست در ساعت - - - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok -device | TOTPDevice | اطلاعات تنظیم دستگاه | {"id": 1, ...} - -### شی TOTPDevice - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -id | integer | شناسه دستگاه | 1 -name | string | نام دستگاه | "App" -confirmed | boolean | تایید شده با پیامک | false -configUrl | string | آدرس تنظیم شناسایی دوعاملی در احرازگر گوگل | "otpauth://totp/Nobitex%3Atest%40nobitex.net?secret=FXZJ28P2V3U0F4W3U7707EYIKNBJAKR6&algorithm=SHA1&digits=6&period=30&issuer=Nobitex" - - - -### حالت‌های خطا - -کد خطا | توضیحات ----- | ---- -UnverifiedMobile | کاربر شماره تماس یا ایمیل تایید شده ندارد. -IPRestricted |‌ فراخوانی فقط از داخل ایران امکان‌پذیر است. - - -### نکات و ملاحظات -توجه فرمایید که فراخوانی این درخواست فقط از داخل ایران امکان‌پذیر است - -کاربر با خروجی این API می‌تواند برنامه احرازگر گوگل را فعال نماید. این برنامه هر 30 ثانیه یک بار کد جدیدی تولید می‌کند که تا دو دقیقه قابل استفاده است. -در صورت تنظیم درست احرازگر گوگل می‌توانید برای تایید دستگاه (device) و تکمیل درخواست خود اقدام کنید. - - -##تایید شناسایی دوعاملی - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/tfa/confirm' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"device": 1, "otp": 123456, "sms_otp": 987654}' -``` - -```javascript -api.post('/users/tfa/confirm', {device: 1, otp: 123456, sms_otp: 987654}, { - headers: {Authorization: "Token yourTOKENhereHEX0000000000"}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @FormUrlEncoded - @POST("/users/tfa/confirm") - Call confirm2FA(@Field("device") int deviceId, @Field("otp") int otp, @Field("sms_otp") int smsOtp); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.confirm2FA(1, 123456, 987654); -``` - - - -```plaintext -POST /users/tfa/confirm HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -{"device": 1, "otp": 123456, "sms_otp": 987654} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -پس از تنظیم شناسایی دوعاملی در احرازگر گوگل و دریافت پیامک کد تایید، برای تکمیل درخواست خود از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /users/tfa/confirm` -- **محدودیت فراخوانی:** 10 درخواست در 10 دقیقه / 20 درخواست در ساعت - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | ---- | --------- | --------- -device | integer | الزامی | شناسه دستگاهی که فعال‌سازی شناسایی دوعاملی را درخواست کرده | 1 -otp | integer | الزامی | رمز یکبارمصرف شش رقمی دریافت شده از احرازگر گوگل | 123456 -sms_otp | integer | الزامی | کد تایید شش رقمی پیامک شده به شماره همراه کاربر | 987654 - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok - - -### حالت‌های خطا - -کد خطا | توضیحات ----- | ---- -InvalidOTP | رمز یکبارمصرف نامعتبر است یا زمان لازم برای انتظار پس از ورود اشتباه رمز سپری نشده است. -MissingSmsOTP | کد تایید پیامک شده ارسال نشده است. -InvalidSmsOTP | کد تایید پیامک شده منقضی یا نامعتبر است. - - -### نکات و ملاحظات -1. در صورت اشتباه وارد کردن رمز یکبارمصرف احرازگر گوگل، برای درخواست بعدی با توجه به دفعات اشتباه بایستی به ترتیب 1، 2، 4، 8 و ... ثانیه پیش از درخواست مجدد صبر کنید. -2. حداکثر یک دستگاه دارای شناسایی دوعاملی فعال در هر لحظه برای کاربر مجاز است و در صورت فعال‌سازی دستگاه دیگر، دستگاه قبلی غیر فعال خواهد شد. - - -##غیرفعال‌سازی شناسایی دوعاملی - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/tfa/disable' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"otp": 123456}' -``` - -```javascript -api.post('/users/tfa/disable', {otp: 123456}, { - headers: {Authorization: "Token yourTOKENhereHEX0000000000"}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @FormUrlEncoded - @POST("/users/tfa/disable") - Call disable2FA(@Field("otp") int otp); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.disable2FA(123456); -``` - - - -```plaintext -POST /users/tfa/disable HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -{"otp": 123456} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -برای غیرفعال‌سازی شناسایی دوعاملی از این نوع درخواست استفاده نمایید: - -* **درخواست:** `POST /users/tfa/disable` - -* پارامترهای ورودی: - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | ---- | --------- | --------- -otp | integer | الزامی | رمز یکبارمصرف شش رقمی دریافت شده از احرازگر گوگل | 123456 - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok - - -### حالت‌های خطا - -کد خطا | توضیحات ----- | ---- -InvalidOTP | رمز یکبارمصرف نامعتبر است یا زمان لازم برای انتظار پس از ورود اشتباه رمز سپری نشده است. -IPRestricted |‌ فراخوانی فقط از داخل ایران امکان‌پذیر است. - -### نکات و ملاحظات -1. در صورت اشتباه وارد کردن رمز یکبارمصرف احرازگر گوگل، برای درخواست بعدی با توجه به دفعات اشتباه بایستی به ترتیب 1، 2، 4، 8 و ... ثانیه پیش از درخواست مجدد صبر کنید. -2. توجه فرمایید که فراخوانی این درخواست فقط از داخل ایران امکان‌پذیر است. diff --git a/source/includes/internal/_active_order_count.md b/source/includes/internal/_active_order_count.md deleted file mode 100644 index a0eef36..0000000 --- a/source/includes/internal/_active_order_count.md +++ /dev/null @@ -1,37 +0,0 @@ -# معامله در بازار - -## تعداد سفارش‌های باز کاربر - - -```shell -curl 'https://apiv2.nobitex.ir/market/orders/open-count?tradeType=margin' \ - -H "Authorization: Token yourTOKENhereHEX0000000000" -``` - -```plaintext -http GET https://apiv2.nobitex.ir/market/orders/open-count?tradeType=margin -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "count": 2 -} -``` - -برای دریافت تعداد سفارش‌های باز خود، از این درخواست استفاده نمایید. - -- **درخواست:** `GET /market/orders/open-count` -- **محدودیت فراخوانی:** 15 درخواست در دقیقه - -### پارامترهای ورودی -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|-----------|--------|------------------|-------------------------------|--------------------| -| tradeType | string | تمام انواع سفارش | نوع سفارش اسپات یا فروش تعهدی | `spot` یا `margin` | - -### پارامترهای پاسخ -| پارامتر | نوع | توضیحات | نمونه | -|---------|---------|-------------------------|-------| -| count | integer | تعداد سفارشات باز کاربر | 2 | diff --git a/source/includes/internal/_batch_actions.md b/source/includes/internal/_batch_actions.md deleted file mode 100644 index 351e43f..0000000 --- a/source/includes/internal/_batch_actions.md +++ /dev/null @@ -1,291 +0,0 @@ -#درخواست‌های دسته‌ای -از درخواست‌های دسته‌ای در کاهش تاخیر شبکه استفاده می‌شود. -این دسته از API ها برای بات‌ها معاملاتی ارائه شده و در مرحله **آزمایش بتا** قرار دارد. -در صورت استفاده، احتمال تغییر یا توقف در ارائه API های این بخش را در نظر بگیرید. - -احراز هویت در API های این مجموعه مشابه نسخه تکی هر درخواست است. - -## ثبت سفارش دسته‌ای - -> نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/market/orders/batch-add' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data @- << EOF - {"data": [ - {"type":"buy","srcCurrency":"btc","dstCurrency":"rls","amount":"0.6","price":520000000}, - {"type":"sell","srcCurrency":"doge","dstCurrency":"rls","amount":"64","execution":"stop_market","stopPrice":47500}, - {"type":"buy","srcCurrency":"btc","dstCurrency":"usdt","amount":"0.01","mode":"oco","price":42390,"stopPrice":42700,"stopLimitPrice":42715} - ]} -EOF -``` - -```javascript -api.post('/market/orders/batch-add', { - data: [ - { - type: 'buy', - srcCurrency: 'btc', - dstCurrency: 'rls', - amount: '0.6', - price: 520000000 - }, - { - type: 'sell', - srcCurrency: 'doge', - dstCurrency: 'rls', - amount: '64', - execution: 'stop_market', - stopPrice: 47500 - }, - { - type: 'buy', - srcCurrency: 'btc', - dstCurrency: 'usdt', - amount: '0.01', - mode: 'oco', - price: 42390, - stopPrice: 42700, - stopLimitPrice: 42715 - } - ] -}, { - headers: {Authorization: 'Token yourTOKENhereHEX0000000000', 'Content-Type': 'application/json'}, -}).then((response) => { - console.log(response); -}); -``` - -```plaintext -POST /market/orders/batch-add HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -Content-Type: application/json -{ - "data": [ - {"type":"buy","srcCurrency":"btc","dstCurrency":"rls","amount":"0.6","price":520000000}, - {"type":"sell","srcCurrency":"doge","dstCurrency":"rls","amount":"64","execution":"stop_market","stopPrice":47500, "clientOrderId": "order2"}, - {"type":"buy","srcCurrency":"btc","dstCurrency":"usdt","amount":"0.01","mode":"oco","price":42390,"stopPrice":42700,"stopLimitPrice":42715} - ] -} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "results": [ - { - "status": "ok", - "order": { - "type": "buy", - "execution": "Limit", - "market": "BTC-RLS", - "srcCurrency": "Bitcoin", - "dstCurrency": "ریال", - "price": "520000000", - "amount": "0.6", - "totalPrice": "0", - "totalOrderPrice": "312000000", - "matchedAmount": 0, - "unmatchedAmount": "0.6", - "id": 25, - "status": "Active", - "partial": false, - "fee": 0, - "created_at": "2018-11-28T11:36:13.592827+00:00", - "clientOrderId": null - } - }, - { - "status": "failed", - "code": "OverValueOrder", - "message": "Order validation failed", - "clientOrderId": "order2" - }, - { - "status": "ok", - "orders": [ - { - "id": 26, - "type": "buy", - "execution": "Limit", - "market": "BTC-USDT", - "srcCurrency": "Bitcoin", - "dstCurrency": "Tether", - "price": "42390", - "amount": "0.01", - "totalPrice": "0", - "totalOrderPrice": "423.9", - "matchedAmount": "0", - "unmatchedAmount": "0.01", - "status": "Active", - "created_at": "2022-04-10T10:12:38.402795+00:00", - "pairId": 27, - "clientOrderId": null - }, - { - "id": 27, - "type": "buy", - "execution": "StopLimit", - "market": "BTC-USDT", - "srcCurrency": "Bitcoin", - "dstCurrency": "Tether", - "price": "42715", - "amount": "0.01", - "param1": "42700", - "totalPrice": "0", - "totalOrderPrice": "427.15", - "matchedAmount": "0", - "unmatchedAmount": "0.01", - "status": "Inactive", - "created_at": "2022-04-10T10:12:38.402795+00:00", - "pairId": 26, - "clientOrderId": null - } - ] - } - ] -} -``` - -برای [ثبت سفارش](/#e12b63a512) به صورت دسته‌ای از این نوع درخواست استفاده نمایید: - -* **درخواست:** `POST /market/orders/batch-add` -* **محدودیت فراخوانی:** 300 درخواست در 10 دقیقه -
300 سفارش در 10 دقیقه ([مشترک با ثبت سفارش تکی](/#order_ratelimit)) - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|---------|------|---------|------------------------------|------------------------| -| data | list | الزامی | لیست ورودی‌های ثبت سفارش تکی | [{"amount": ...}, ...] | - -### پارامترهای پاسخ - -| پارامتر | نوع | توضیحات | نمونه | -|---------|--------|------------------------------|-------| -| status | string | وضعیت پاسخ | ok | -| results | list | لیست پاسخ‌های هر درخواست تکی | [] | - -بسته به نوع درخواست از نظر معمولی یا oco بودن و یا مواجهه با خطا، قالب پاسخ متفاوت خواهد بود: - -#### پاسخ موفق حالت معمولی - -| پارامتر | نوع | توضیحات | نمونه | -|---------|--------|------------|-----------------| -| status | string | وضعیت پاسخ | ok | -| order | Order | شی سفارش | {"id": 25, ...} | - -#### پاسخ موفق حالت oco - -| پارامتر | نوع | توضیحات | نمونه | -|---------|------------|-------------------|------------------------------------| -| status | string | وضعیت پاسخ | ok | -| orders | Order list | لیست دو سفارش oco | [{"id": 26, ...}, {"id": 27, ...}] | - -#### پاسخ ناموفق - -| پارامتر | نوع | توضیحات | نمونه | -|---------|--------|------------------------------|--------------------------------------------------------------------------------------| -| status | string | وضعیت پاسخ | ok | -| results | list | لیست پاسخ‌های هر درخواست تکی | [{"status": "failed", "code":"OverValueOrder", "clientOrderId": "order2", ...}, ...] | - -### حالت‌های خطا به به ازای هر سفارش -حالت های خطا همانند درخواست سفارش تکی است. -این خطاها برای هر سفارش به صورت جداگانه ایجاد می‌شوند و مانع اجرای کل درخواست نخواهند شد و هر سفارش به صورت جداگانه اعتبارسنجی می‌شود. - - -| کد خطا | توضیحات | -|-------------------|----------------------------------------------------------| -| ParseError | ورودی‌های الزامی ارسال نشده است. | -| InvalidOrderPrice | در سفارش با قیمت ضروری، قیمت نزدیک به صفر ارسال شده است. | -| InvalidMarketPair | بازاری برای زوج‌ارز درخواست وجود ندارد. | -| MarketClosed | بازار بسته است. | -| TradeLimitation | کاربر محدودیت سفارش‌گذاری دارد. | -| DuplicateOrder | سفارش تکراری است. | - - - -### نکات و ملاحظات -1. **حالت Pro:** امکان فعال‌سازی [حالت Pro](/#pro) و مجاز کردن سفارش تکراری در کمتر از ۱۰ ثانیه، برای کل درخواست وجود دارد. -2. **محدودیت درخواست مشترک:** در صورتی که یک درخواست دسته‌ای، در میانه پردازش سفارش‌ها از محدودیت مشترک ایجاد سفارش را عبور کند، -ادامه ثبت سفارش متوقف شده و سفارش‌های ایجاد شده تا قبل از آن باز می‌گردند. در این حالت تعداد سفارش‌های باز گردانده شده کمتر از تعداد درخواست شده خواهد بود. -3. **قالب درخواست:** تنها فرمت مورد پذیرش درخواست برای ثبت سفارش دسته‌ای، application/json می‌باشد. - -## لغو سفارش دسته‌ای - -با استفاده از این api می‌توان سفارش‌های فعال کاربر را لغو کرد. برای این هدف می‌توان مقدار رمزارز مبدا یا رمزارز مقصد را مشخص کرد که هم می‌توان همزمان آن دو را ارسال کرد و هم به صورت تکی، که در صورت ارسال هر کدام از این مقادیر تمامی ‌سفارش‌های کاربر با ارز مبدا و یا ارز مقصد لغو خواهند شد. - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/market/orders/cancel-batch' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"orderIds":[1,2]}' -``` - -```plaintext -POST /market/orders/cancel-batch HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -Content-Type: application/json -{ - "orderIds":[1,2] -} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "message": "", - "orders": { - "1": { - "status": "failed", - "message": "Systematically placed orders are immutable" - }, - "2": { - "status": "ok" - } - } -} -``` - -* **درخواست:** `POST /market/orders/cancel-batch` -* **محدودیت فراخوانی:** 10 درخواست در هر دقیقه -* حداکثر 20 سفارش در هر درخواست - -### پارامترهای ورودی - -| پارامتر | نوع | پیش‌فرض | توضیحات | نمونه | -|----------------|---------|---------|---------------------|--------| -| orderIds | list | الزامی | شناسه‌های سفارشات | [1,2] | - -### پارامترهای پاسخ - -| پارامتر | نوع | توضیحات | نمونه | -|---------|--------|---------------------|-------| -| status | string | وضعیت پاسخ | ok | -| message | string | علت عدم لغو درخواست | | - -### حالت‌های خطا - - -| متن خطا | توضیحات | -|----------------------------------------------|----------------------------------------------------------| -| The maximum number of orderIds should be 20 | اگر تعداد آیدی ‌سفارشات ارسال شده به API بیشتر از ۲۰ عدد باشد. | -| Order_ids list is empty | اگر لیست آیدی سفارشات ارسال شده، خالی باشد | -| Invalid integer value: "{{incorrect value}}" | اگر لیست ارسال شده حاوی مقادیر نادرست باشد | -| Orders are queued to be cancelled | اگر سفارشات ارسال شده به صورت async حذف گردد. | - -### نکات و ملاحظات -1. با استفاده از این api می‌توان سفارش‌های فعال کاربر را لغو کرد. برای این هدف می‌توان مقدار رمزارز مبدا یا رمزارز مقصد را مشخص کرد که هم می‌توان همزمان آن دو را ارسال کرد و هم به صورت تکی، که در صورت ارسال هر کدام از این مقادیر تمامی ‌سفارش‌های کاربر با ارز مبدا و یا ارز مقصد لغو خواهند شد. -2. برای استفاده از این api می‌توان دو پارامتر دیگر به عنوان‌های hour و execution_type اشاره کرد که پارامترهای اختیاری هستند. -3. پارامتر hour که باید به صورت عدد صحیح وارد شود به این معناست که سفارش‌های فعال کاربر در چند ساعت اخیر کنسل شوند، برای مثال اگر مقدار ۳ برای این پارامتر ارسال شود سفارش‌های فعال سه ساعت اخیر کاربر غیرفعال می‌شوند. -4. پارامتر execution_type را می‌توان ارسال کرد که مقدار این پارامتر مشخص کننده‌ی نوع سفارشاتی است که نیاز به لغو شدند دارند. برای مثال اگر این پارامتر مقدار market داشته باشد‌، سفارشات از نوع market لغو خواهند شد. diff --git a/source/includes/internal/_gift.md b/source/includes/internal/_gift.md deleted file mode 100644 index d88c664..0000000 --- a/source/includes/internal/_gift.md +++ /dev/null @@ -1,503 +0,0 @@ -# گیفت کارت - -کارت هدیه‌ی نوبیتکس، امکان ارسال هدیه‌ به صورت فیزیکی و مجازی را به شخص دیگری فراهم می‌کند. فرایند دریافت هدیه نیز -می‌تواند به صورت داخلی و یا از نوع lightning باشد. -فرآیند کلی به این صورت هست که ابتدا کاربر درخواست خود را از طریق APIی ایجاد هدیه ثبت می‌کند و بعد از چک شدن محدودیت‌های برداشت کاربر شی هدیه ایجاد می‌شود. در این قسمت کاربر می‌تواند نوع هدیه که فیزیکی یا مجازی بودنش و همینطور نوع دریافت که به صورت برداشت داخلی و یا lightningای باشد را انتخاب کند. -مرحله‌ی بعد تایید برداشت ابتدایی هدیه است که در این گام از APIی تایید برداشت معمول استفاده می‌شود و فرآیند ایجاد هدیه تکمیل می‌شود. -گام بعد برای دریافت هدیه دریافت اطلاعات مربوط به هدیه از طریق api لندینگ هدیه است که اگر کاربر فرستنده شماره همراه گیرنده را وارد کرده باشد در این مرحله رمزیکبار مصرف برای کاربر ارسال می‌شود. -در نهایت گیرنده با وارد کردن رمزعبوری که گیرنده برای او مشخص کرده و رمز یکبار مصرف (در صورت ارسال) قادر به دریافت هدیه در APIی دریافت هدیه است. -اگر هدیه از نوع برداشت داخلی باشد برداشت به حساب گیرنده که حتما باید عضو نوبیتکس باشد زده می‌شود. -در غیر این صورت در پاسخ lnurl مربوط به هدیه در پاسخ فرستاده می‌شود. -لازم به ذکر است در صورتی که نوع دریافت lightning باشد گیرنده می‌تواند عضو نوبیتکس نباشد و در این حالت از APIی دریافت هدیه برای کاربران غیر عضو استفاده می‌شود که در صورت صحت اطلاعات ورودی پاسخ lnurl مربوط به هدیه است. -برای هر نوع از دریافت هدیه گیرنده می‌تواند کاربر نوبیتکس نباشد و قبل از دریافت هدیه عضو شود. -از آنجایی در حالت دریافت lightning دریافت کننده می‌تواند کاربر نوبیتکس نباشد برای بعضی از APIهای این مجموعه احراز هویت الزامی نیست. - -##ایجاد هدیه - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/gift/create-gift' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' \ --H 'X-TOTP: 2568148' \ --H 'Content-Type: application/json' \ ---data '{ - "amount": 0.02, - "currency": "bnb", - "gift_type": "digital", - "package_type": "default", - "mobile": "09127759318", - "email": "test@gmail.com", - "gift_sentence": "تقدیم به شما", - "receiver_address": "iran-tehran", - "receiver_postal_code": "3348-8841", - "card_design": "default", - "password": "testpass123", - "redeem_type": "internal", - "redeem_date": "2023-11-12", - "receiver_full_name": "ali karimi", - "otp_enabled": true, -}' -``` - - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "gift_withdraw_id": 158, - "cost": "100" -} -``` - -برای ایجاد هدیه‌ی باید از درخواست با مشخصات زیر استفاده نمایید: -لازم به ذکر است برای فراخوانی این API کاربر باید لاگین باشد. همینطور در صورت انتخاب نوع هدیه‌ی فیزیکی آدرس و کد پستی گیرنده الزامی است. -مرحله‌ی بعد برای ایجاد هدیه و تکمیل فرآیند هدیه فراخوانی تایید برداشت هدیه است و پس از فراخوانی موفق تایید برداشت فرآیند ایجاد هدیه تکمیل خواهد شد. - - -* **درخواست:** `POST /gift/create-gift` -* **محدودیت فراخوانی:** 10 درخواست در دقیقه - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | مقادیر مورد قبول/نمونه -------- |------------|---------|-----------------------------| --------- -amount | monetary | الزامی | مقدار رمزارز | "0.02" -currency | string | الزامی | رمزارز | "BTC" -mobile | string | اختیاری(در صورت غیرفعال کردن دومرحله‌ای) | همراه گیرنده | "9127774565" -email | string | اختیاری | ایمیل گیرنده | "test@gmail.com" -gift_type | string | الزامی | نوع هدیه | "pyshical", "digital" -gift_sentence | string | الزامی | جمله برای گیرنده | "تقدیم به شما" -package_type | string | اختیاری | نوع پکیج | "default" -receiver_address | string | اختیاری | آدرس گیرنده | "iran-tehran" -receiver_postal_code | string | اختیاری | کد پستی گیرنده | "3354-7721" -receiver_full_name | string | الزامی | نام و نام خانوادگی گیرنده | "masoud mohamadi" -card_design | string | الزامی | طرح کارت | "grand","mind","cute","light" -redeem_date | iso-string | اختیاری | تاریخ دریافت | "2022-09-17" -redeem_type | string | الزامی | نوع دریافت | "lightning", "internal" -password | string | الزامی | گذرواژه‌ی گیرنده | "testpass123" -otp_enabled | boolean | الزامی | دومرحله‌ای بودن دریافت هدیه | true - - - -### حالت‌های خطا - -کد خطا | توضیحات ----- | ---- -ValidationError | وارد نشدن آدرس و کد پستی در صورت انتخاب نوع هدیه‌ی فیزیکی -ValidationError | در صورت وارد شدن تاریخ مربوط به گذشته -InvalidAmount |مقدار وارد شده برای مقادیر ثابت ریالی جز مقادیر در نظر گرفته شده نباشد -InvalidRequest |ایمیل وارد شده ایمیل درخواست دهنده باشد در حالت دیجیتال -PleaseEnable2FA |سطح کاربر بالاتر از ۲ باشد و درخواست ریالی نباشد و دوعاملی کاربر فعال نشده باشد -Invalid2FA |دوعاملی کاربر فعال باشد و رمزیکبار مصرف اشتباه وارد شده باشد -WithdrawUnavailable |در صورتی که کاربر محدودیت برداشت داشته باشد و مجوز برداشتی برای او تعریف نشده باشد -WithdrawAmountLimitation |در صورتی که کاربر سقف برداشت مجازش را برای رمزارز مشخصی رد کرده باشد -WithdrawLimitReached |در صورتی که کاربر از سقف تعداد برداشتش عبور کرده باشد -WithdrawCurrencyUnavailable |در صورتی که برداشت از رمزارز درخواست شده امکان پذیر نباشد -WithdrawDisabled |در صورتی که برداشت برای رمزارزی موقتی بسته باشد -InsufficientRialBalance |در صورتی که کاربر مقدار بالانس مورد نیاز برای هزینه‌ی صدور کارت فیزیکی را نداشته باشد -InsufficientBalance |در صورتی که مقدار درخواستی کاربر از مقدار بالانسش بیشتر باشد -AmountTooLow |اگر مقدار درخواستی کاربر کمتر از حداقل مقدار برداشت رمزارز مورد نظر باشد -AmountTooHigh |اگر مقدار درخواستی کاربر بیشتر از حداکثر مقدار برداشت رمزارز مورد نظر باشد -InvalidMobileNumber |اگر کاربر موبایل تایید شده نداشته باشد -InsufficientBalance |در صورتی که تراکنش برای کسر هزینه‌ی صدور کارت فیزیکی موفقیت آمیز نباشد - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- |----------|---------------------| --------- -status | string | وضعیت پاسخ | ok -gift_withdraw_id | integer | شناسه‌ی برداشت | 159 -cost | monetary | هزینه‌ی ایجاد هدیه‌ | "100" - - - -### نکات و ملاحظات -1. آرگومان مورد نیاز برای فراخوانی APIی تایید برداشت در پاسخ این APIی موجود است و مقدار gift_withdraw_id است. -2. در صورتی که نوع هدیه دیجیتال باشد ارسال ایمیل گیرنده الزامی خواهد بود. - - -## تایید برداشت -برای این منظور باید از APIی تایید درخواست برداشت در قسمت برداشت استفاده کرد. - -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/wallets/withdraw-confirm' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"withdraw": 432, "otp": 623005}' -``` - -* **درخواست:** `POST /users/wallets/withdraw-confirm` - -که مقدار withdraw را در این درخواست باید برابر مقدار gift_withdraw_id از پاسخ API ایجاد هدیه قرار داد. - -##لندینگ هدیه -کاربر بعد از اسکن کد هدیه‌ی خود به این صفحه انتقال داده می‌شود. که در انتهای مسیر این API کد هدیه‌ی کاربر قرار دارد. -لازم به ذکر است در صورتی که کاربر فرستنده، شماره موبایل کاربر گیرنده را وارد کرده باشد رمز یکبار مصرف در این مرحله برای کاربر فرستاده خواهد شد. - -* **درخواست:** `GET /gift/redeem-code` -* **محدودیت فراخوانی:** 5 درخواست در ۱ ساعت - -توجه داشته باشید redeem-code در url از نوع string می‌باشد. - -### حالت‌های خطا -کد خطا | توضیحات ----- | ---- -InvalidRedeemCode | در صورتی که کد وارد شده نامعتبر باشد - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- |----------|------------------------------------------------------| --------- -redeem_code | string | کد هدیه‌ي کاربر | "FB57379C" -card_design | string | طرح کارت | "default" -currency | string | رمزارز | "bnb" -amount | monetary | مقدار رمزارز | "0.02" -mobile_provided | boolean | اینکه فرستنده شماره همراه گیرنده را ارسال کرده یا خیر | true -sentence | string | جمله‌ی هدیه | "تقدیم به شما" -redeem_type | string | نوع دریافت هدیه | "lightning" - - -## دریافت هدیه‌ برای کاربران عضو - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/gift/redeem' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' \ --H 'Content-Type: application/json' \ ---data '{ - "redeem_code": "30BBBBCA", - "password": "testpass123", - "otp": "813846" -}' -``` - -> در صورت فراخوانی درست، پاسخ به حالتی که دریافت به صورت lightning این صورت خواهد بود: - -```json -{ - "status": "ok", - "lnUrl": "lnurlZX6N..." -} -``` - -> در صورت فراخوانی درست، پاسخ به حالتی که دریافت داخلی باشد، به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -برای دریافت هدیه‌ی کاربری که عضو نوبیتکس است، فارق از نوع دریافت این API فراخوانی شود. -در این قسمت با توجه به نوع دریافت هدیه‌ی کاربر پاسخ متفاوت فرستاده خواهد شد. -اگر نوع دریافت به صورت داخلی انتخاب شده باشد بعد از بررسی صحت اطلاعات ورودی صرفا پاسخ موفقیت فرستاده خواهد شد. -در صورتی که نوع دریافت lightning باشد در پاسخ lnurl مربوط به هدیه فرستاده خواهد شد. - - - -* **درخواست:** `POST /gift/redeem` -* **محدودیت فراخوانی:** 5 درخواست در ۱ ساعت - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |--------|---------|----------------------------------| --------- -redeem_code | string | الزامی | کد هدیه | "FB57379C" -password | string | الزامی | گذرواژه‌ی هدیه | "testpass123" -otp | string | اختیاری | رمزیکبار مصرف ارسال شده به کاربر | "564785" -key | string | اختیاری | رمزیکبار مصرف ارسال شده به کاربر | "564785" -captcha | string | اختیاری | رمزیکبار مصرف ارسال شده به کاربر | "564785" -client | string | اختیاری | رمزیکبار مصرف ارسال شده به کاربر | "564785" -1. آرگومان otp در این API اختیاری است زمانی نیاز به ارسال است که در پاسخ لندینگ مقدار mobile_provided صحیح (true) باشد. -2. در این مرحله برای امنیت بیشتر کاربران ارسال کپچا اجباری است. - - -### حالت‌های خطا -کد خطا | توضیحات ----- | ---- -InvalidCaptcha | در صورت اشتباه وارد شدن کپچا -InvalidOTP | اگر رمزیکبار مصرف ارسال شده به گوشی کاربر اشتباه وارد شده باشد -InvalidPassword |اگر پین یا رمزعبور مشخص شده برای گیرند‌ه‌ی هدیه اشتباه وارد شده باشد -CardIsCanceled |اگر وضعیت هدیه کنسل شده باشد -AlreadyRedeemedOrCanceled |اگر هدیه داخلی باشد و وضعیت قابل ریدیم کردن نداشته باشد -InvalidInitialWithdraw |در صورتی که برداشت اولیه مربوط به هدیه موفق نبوده باشد -LnurlUnavailable |در صورتی که نوع کارت لایتنینگی باشد و مشکلی در دریافت lnurl باشد -InternalWithdrawFailed |در صورتی که نوع کارت داخلی باشد و برداشت به ولت گیرنده موفق نباشد - - -در صورتی که کاربر ایجاده کننده‌ی هدیه شماره همراه کاربر گیرنده را وارد کرده باشد،‌ به این معناست که نحوه‌ی دریافت هدیه به‌صورت دوعاملی هست. - -### پارامترهای پاسخ - -* در حالتی که نوع برداشت داخلی باشد: - -پارامتر | نوع | توضیحات | نمونه -------- |----------|------------| --------- -status | string | وضعیت پاسخ | "ok" - - - -* در حالتی که نوع برداشت lightning باشد: - -پارامتر | نوع | توضیحات | نمونه -------- |----------|------------| --------- -status | string | وضعیت پاسخ | "ok" -lnUrl | string | هدیه lnurl | "lnurlZX6N..." - - - -## دریافت هدیه‌ی lightning برای کاربران غیر عضو - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/gift/redeem-lightning' \ --H 'Content-Type: application/json' \ ---data '{ - "redeem_code": "8AFA1DF3", - "password": "testpass123", - "otp": "158354" -}' -``` - -> در صورت فراخوانی درست، پاسخ در حالت کلی، این صورت خواهد بود: - -```json -{ - "status": "ok", - "lnUrl": "lnurlPURQEQ..." -} -``` - -در صورتی که کاربری عضو نوبیتکس نباشد و نوع هدیه نیز lightning باشد باید از این API برای دریافت هدیه استفاده شود. -این API فقط برای دریافت هدایا از نوع دریافت lightning و زمانی که گیرنده عضو نوبیتکس نباشد استفاده می‌شود. - -در این مرحله برای امنیت بیشتر کاربران ارسال کپچا اجباری است. - - -* **درخواست:** `POST /gift/redeem-lightning` -* **محدودیت فراخوانی:** 5 درخواست در ۱ ساعت -* **احرازهویت:** نیاز ندارد - - - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |--------|---------|----------------------------------| --------- -redeem_code | string | الزامی | کد هدیه | "FB57379C" -password | string | الزامی | گذرواژه‌ی هدیه | "testpass123" -otp | string | اختیاری | رمزیکبار مصرف ارسال شده به کاربر | "254862" -در صورتی که موبایل گیرنده از طرف کاربر گیرنده ارسال شده باشد مقدار otp باید وارد شود. - - -### حالت‌های خطا -کد خطا | توضیحات ----- | ---- -InvalidCaptcha | در صورت اشتباه وارد شدن کپچا -InvalidOTP | اگر رمزیکبار مصرف ارسال شده به گوشی کاربر اشتباه وارد شده باشد -InvalidPassword |اگر پین یا رمزعبور مشخص شده برای گیرند‌ه‌ی هدیه اشتباه وارد شده باشد -CardIsCanceled |اگر وضعیت هدیه کنسل شده باشد -InvalidRequest |اگر نوع دریافت هدیه لایتنینگ نباشد -InvalidInitialWithdraw |در صورتی که برداشت اولیه مربوط به هدیه موفق نبوده باشد -LnurlUnavailable |در صورتی که نوع کارت لایتنینگی باشد و مشکلی در دریافت lnurl باشد - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- |----------|------------| --------- -status | string | وضعیت پاسخ | "ok" -lnUrl | string | هدیه lnurl | "lnurlZX6N..." - - - - -## لیست کارت‌های هدیه‌ی کاربر - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "sent_gift_cards": [ - { - "id": 32, - "full_name": "masoud mohamadi", - "address": "iran-tehran", - "mobile": "09127842542", - "postal_code": "3579-4123", - "package_type": "New", - "redeem_code": "EF9472B7", - "gift_sentence": "تقدیم به شما", - "amount": "0.02", - "sender": { - "username": "test@gmail.com", - "name": "" - }, - "receiver": null, - "currency": "bnb", - "gift_type": "Digital", - "gift_status": "Redeemed", - "card_design": "Default", - "created_at": "2022-02-13T11:42:27.338380+00:00", - "redeem_date": "2023-11-11T20:30:00+00:00" - } - ], - "received_gift_cards": [ - { - "id": 21, - "full_name": "mohsen amini", - "address": "iran-tehran", - "mobile": "09125412335", - "postal_code": "8568-9982", - "package_type": "New", - "redeem_code": "D758A8A2", - "gift_sentence": "جمله‌ی تست هدیه", - "amount": "0.05", - "sender": { - "username": "test@gmail.com", - "name": "" - }, - "receiver": { - "username": "new_user@gmail.com", - "name": "" - }, - "currency": "bnb", - "gift_type": "Digital", - "gift_status": "Redeemed", - "card_design": "Default", - "created_at": "2022-02-10T12:33:08.226370+00:00", - "redeem_date": "2023-11-11T20:30:00+00:00" - } - ] -} -``` - - -این API برای نمایش تمامی هدایای فرستاده شده و یا دریافت شده‌ی کاربر استفاده می‌شود. -در صورتی که کاربر گیرنده عضو نوبیتکس نباشه ایمیل و یا نام و نام خانوادگی مقدار receiver خواهند بود. - -* **درخواست:** `GET /gift/user-gifts` -* **محدودیت فراخوانی:** 60 درخواست در دقیقه - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- |-----------------------------|---------------------------------| --------- -status | string | وضعیت پاسخ | "ok" -sent_gift_cards | list of user sent gifts | لیست هدایای فرستاده شده‌ی کاربر | [] -received_gift_cards | list of user received gifts | لیست هدایای گرفته شده‌ی کاربر | [] - - - -## ایجاد درخواست تعداد بالای هدیه -در صورتی که کاربری درخواست برای تعداد بالای هدیه داشته باشد باید این API فراخوانی شود که درخواست کاربر ثبت شود. -کاربر درخواست کننده باید لاگین باشد. -در پاسخ شناسه‌ی درخواست ساخته شده نیز فرستاده می‌شود که باید در درخواست مربوط به تایید درخواست‌ هدیه‌ی دسته‌ای ارسال شود. - -* **درخواست:** `POST /gift/create-gift-batch` -* **محدودیت فراخوانی:** 10 درخواست در ساعت - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |--------|---------|-----------------| --------- -number | int | اختیاری | تعداد کارت هدیه | 10 -password | string | اختیاری | رمز کارت هدیه | "Sample@password" - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- |---------|-------------------------| --------- -status | string | وضعیت پاسخ | "ok" -batch_id | integer | شناسه‌ی درخواست دسته‌ای | 58 - - -## تایید درخواست تعداد بالای هدیه -برای ارسال رمزیکبار مصرف فرستاده شده به کاربر برای تایید ایجاد تعداد بالای هدیه باید از این API استفاده شود. -مقادیر ورودی رمزیکبار مصرف و شناسه‌ی درخواست ایجاد شده هستند. - -* **درخواست:** `POST /gift/confirm-gift-batch` -* **محدودیت فراخوانی:** 10 درخواست در دقیقه - - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |--------|--------|----------------------------------| --------- -otp | string | اجباری | رمزیکبار مصرف ارسال شده به کاربر | "615519" -batch_id | string | اجباری | شناسه‌ی درخواست ایجاد شده | 58 - - -### حالت‌های خطا -کد خطا | توضیحات ----- | ---- -InvalidOTP | در صورتی که رمزیکبار مصرف تایید برای ایجاد و تایید درخواست هدیه‌ی دسته‌ای اشتباه باشد - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- |---------|-------------------------| --------- -status | string | وضعیت پاسخ | "ok" - - - - -## ارسال مجدد رمزیکبار مصرف - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/gift/resend-gift-otp' \ --H 'Content-Type: application/json' \ ---data '{ - "redeem_code": "07DB85D7210E4D29AEFF112FF53B2C74" -}' -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -در صورت نیاز به ارسال مجدد رمز یکبار مصرف برای دریافت هدیه این API فراخوانی می‌شود. - -* **درخواست:** `POST /gift/resend-gift-otp` -* **محدودیت فراخوانی:** 5 درخواست در ساعت - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |--------|---------|----------------------------------| --------- -redeem_code | string | الزامی | کد هدیه | "07DB85D7210E4D29AEFF112FF53B2C74" - - -### حالت‌های خطا -کد خطا | توضیحات ----- | ---- -MobileNotProvided | اگر موبایل گیرنده وجود نداشته باشد -TooManyRequests | اگر تعداد پیامک‌های ارسالی برای در ۱۲ ساعت گذشته بیشتر از تعداد مجاز ۷ عدد باشد - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- |---------|--------------| --------- -status | string | وضعیت پاسخ | "ok" - diff --git a/source/includes/internal/_notifications.md b/source/includes/internal/_notifications.md deleted file mode 100644 index 27e381e..0000000 --- a/source/includes/internal/_notifications.md +++ /dev/null @@ -1,149 +0,0 @@ -# اعلان‌های کاربر -این اعلانات برای اطلاع‌رسانی به کاربر از سوی نوبیتکس ارسال می‌شود و در بخش اعلانات سایت و اپلیکیشن به نمایش در می‌آید. - -احراز هویت در API های این مجموعه الزامی است. - -## گرفتن لیست اعلانات - ->نمونه درخواست: - -```shell -curl 'https://apiv2.nobitex.ir/notifications/list' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```javascript -api.get('/notifications/list', { - headers: {Authorization: 'Token yourTOKENhereHEX0000000000'}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @GET("/notifications/list") - Call listNotifications(); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.listNotifications(); -``` - -```plaintext -GET /notifications/list HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ شامل حداکثر ۱۰ اعلان اخیر کاربر به ترتیب معکوس زمانی و به این صورت خواهد بود: - -```json -{ - "status": "ok", - "notifications": [ - { - "id": 345, - "message": "پیغام۳", - "createdAt": "2021-10-05T13:39:46.103353+00:00", - "read": false - }, - { - "id": 234, - "message": "پیغام۲", - "createdAt": "2021-10-04T15:29:46.103353+00:00", - "read": false - }, - { - "id": 123, - "message": "به نوبیتکس خوش آمدید!", - "createdAt": "2021-10-04T13:19:46.103353+00:00", - "read": true - } - ] -} -``` - -برای دریافت اعلانات کاربر از این نوع درخواست استفاده نمایید: - -* **درخواست:** `GET /notifications/list` - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------------- |----------------------|-------------------| --------- -status | string | وضعیت پاسخ | ok -notifications | list of Notification | لیستی از اعلان‌ها | [] - -شی Notification: - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -id | integer | شناسه اعلان | 1 -message | string | متن پیام | "به نوبیتکس خوش آمدید!" -createdAt | iso-string | زمان ایجاد | "2021-10-04T13:19:46.103353+00:00" -read | boolean | خوانده شده | false - - - -## تغییر وضعیت اعلان یا اعلان‌ها به خوانده‌شده - ->نمونه درخواست: - -```shell -curl --location 'https://apiv2.nobitex.ir/notifications/read' \ ---header 'Authorization: Token yourTOKENhereHEX0000000000' \ ---data '{"id":"234,345"}' -``` - - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @FormUrlEncoded - @POST("/notifications/read") - Call readNotifications(@Field("id") String notificationIds); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.readNotifications("234,345"); -``` - -```plaintext -POST /notifications/read HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -Content-Type: application/json -{"id": "234,345"} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "processed": 2 -} -``` - -برای تغییر وضعیت اعلانات کاربر از نخوانده به خوانده‌شده، از این نوع درخواست استفاده نمایید: - -* **درخواست:** `POST /notifications/read` -- **محدودیت فراخوانی:** ۱۰ درخواست در دقیقه یا ۶۰ بار در ساعت - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |---------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| --------- -id | string | اختیاری | رشته‌ای از شناسه‌های اعلان‌های درخواستی برای تغییر وضعیت به خوانده‌شده که با کاما از هم جدا شده‌اند. در صورت فرستادن رشته‌ی خالی، هیچ اعلانی خوانده نمی‌شود. | "234,345" - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------------- |--------|-------------------------| --------- -status | string | وضعیت پاسخ | ok -processed | int | تعداد اعلان‌های خوانده‌شده | 2 diff --git a/source/includes/internal/_price_alerts.md b/source/includes/internal/_price_alerts.md deleted file mode 100644 index d40ed5b..0000000 --- a/source/includes/internal/_price_alerts.md +++ /dev/null @@ -1,381 +0,0 @@ -#اعلان‌های قیمت -کاربر می‌تواند رسیدن قیمت در یک بازار به یک قیمت دلخواه و عبور از آن را به کمک این اعلان پایش کند. -به محض گذر از قیمت تعیین شده، به کاربر از طرقی که مشخص کرده اطلاع‌رسانی خواهد شد. -مخاطب این امکان کاربران هستند و استفاده از آن به بات‌ها پیشنهاد نمی‌شود. - - -### نکات و ملاحظات -احراز هویت در API های این مجموعه الزامی است. - -##لیست اعلان‌های قیمت - ->نمونه درخواست: - -```shell -curl 'https://apiv2.nobitex.ir/v2/price-alerts' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```javascript -api.get('/v2/price-alerts', { - headers: {Authorization: 'Token yourTOKENhereHEX0000000000'}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @GET("/v2/price-alerts") - Call listPriceAlerts(); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.listPriceAlerts(); -``` - -```plaintext -GET /v2/price-alerts HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "alerts": [ - { - "id": 1, - "createdAt": "2021-08-08T22:52:59.193208+00:00", - "market": "BTCUSDT", - "type": "Price", - "direction": "+", - "price": "65000.0000000000", - "description": "As a test", - "channel": "Notif" - }, - { - "id": 2, - "createdAt": "2021-08-08T22:59:58.383443+00:00", - "market": "BTCUSDT", - "type": "Price", - "direction": "-", - "price": "62000.0000000000", - "description": "", - "channel": "Email/Notif" - } - ] -} -``` - -برای دریافت اعلان‌های قیمت کاربر از این نوع درخواست استفاده نمایید: - -* **درخواست:** `GET /v2/price-alerts` -* **محدودیت فراخوانی:** 25 درخواست در 5 دقیقه - - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok -alerts | list of PriceAlert | لیست اعلان‌های قیمت کاربر | [] - -### شی PriceAlert - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -id | integer | شناسه اعلان | 1 -createdAt | iso-string | زمان ایجاد | "2021-10-04T13:19:46.103353+00:00" -market | string | بازار مورد نظر | "BTCUSDT" -type | string | نوع اعلان1 | "Price" -direction | string | جهت تغییر بازار2 | "+" -price | monetary | قیمت مورد نظر | "65000.0000000000" -description | string | توضیحات | "" -channel | string | کانال اطلاع‌رسانی3 | "Email/Notif" - -1. **نوع اعلان:** در حال حاضر تنها می‌تواند Price باشد. اعلان نوع Price برای پایش رسیدن به یک قیمت مشخص به‌کار می‌رود. -2. **جهت تغییر بازار:** می‌تواند دو مقدار + یا - داشته باشد. جهت + یعنی اعلان در صورت بیشتر شدن قیمت بازار از قیمت تعیین شده فعال می‌شود و جهت - یعنی در صورت پایین تر آمدن قیمت بازار تا قیمت تعیین شده، اعلان فعال و ارسال خواهد شد. -3. **کانال اطلاع‌رسانی:** می‌تواند هر یک از کانال‌های نوتیفیکیشن (Notif)، ایمیل (Email) یا پیامک (SMS) و یا ترکیبی از آن‌ها باشد. (کانال پیامک در آینده پشتیبانی خواهد شد و در حال حاضر غیرفعال است.) - - -## ایجاد اعلان قیمت - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/v2/price-alerts' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"tp": "price", "market": "btcusdt", "direction": "-", "price": "63000", "channel": "email,notif"}' -``` - -```javascript -api.post('/v2/price-alerts', { - tp: 'price', - market: 'btcusdt', - direction: '-', - price: '63000', - channel: 'email,notif', -}, { - headers: {Authorization: 'Token yourTOKENhereHEX0000000000'}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @FormUrlEncoded - @POST("/v2/price-alerts") - Call createPriceAlert( - @Field("tp") String alertType, - @Field("market") String market, - @Field("direction") String direction, - @Field("price") String price, - @Field("channel") String channel, - ); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.createPriceAlert("price", "btcusdt", "-", "63000", "email,notif"); -``` - -```plaintext -POST /v2/price-alerts HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -Content-Type: application/json -{"tp": "price", "market": "btcusdt", "direction": "-", "price": "63000", "channel": "email,notif"} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "alert": { - "id": 3, - "createdAt": "2021-08-10T20:07:07.977328+00:00", - "market": "BTCUSDT", - "type": "Price", - "direction": "-", - "price": "63000.0000000000", - "description": "", - "channel": "Email/Notif" - } -} -``` - -برای ایجاد یک اعلان قیمت از این نوع درخواست استفاده نمایید: - -* **درخواست:** `POST /v2/price-alerts` -* **محدودیت فراخوانی:** 10 درخواست در 5 دقیقه - - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | ---- | --------- | --------- -type | string | الزامی | نوع اعلان | "price" -market | string | الزامی | بازار مورد نظر | "BTCUSDT" -direction | string | الزامی | جهت تغییر بازار1 | "-" -price | monetary | الزامی | قیمت مورد نظر | "63000" -channel | string | الزامی | کانال اطلاع‌رسانی2 | "email,notif" -description | string | اختیاری | توضیحات | "sample description" - -1. **جهت تغییر بازار:** دو علامت + و - قابل قبول است. -2. **کانال‌های اطلاع‌رسانی:** شامل email ,notif, sms می‌باشد که پیامک در آینده پشتیبانی خواهد شد. -جهت انتخاب چند کانال به کمک ویرگول کانال‌ها را ترکیب کنید. (مثل: `email,notif`) - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok -alert | PriceAlert | اعلان قیمت ایجاد شده | {"id": 3, ...} - - - -### حالت‌های خطا - -کد خطا | توضیحات ----- | ---- -InvalidSymbol | نماد بازار (market) نامعتبر است. -ParseError | مقادیر ورودی‌ها از الگوی خواسته شده پیروی نمی‌کند. -ValidationError | ورودی‌های الزامی ارسال نشده است. - - -## ویرایش اعلان قیمت - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/v2/price-alerts' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"pk": 3, "tp": "price", "market": "btcusdt", "direction": "+", "price": "64000", "channel": "notif"}' -``` - -```javascript -api.post('/v2/price-alerts', { - pk: 3, - tp: 'price', - market: 'btcusdt', - direction: '+', - price: '64000', - channel: 'notif', -}, { - headers: {Authorization: 'Token yourTOKENhereHEX0000000000'}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @FormUrlEncoded - @POST("/v2/price-alerts") - Call updatePriceAlert( - @Field("pk") int alertId, - @Field("tp") String alertType, - @Field("market") String market, - @Field("direction") String direction, - @Field("price") String price, - @Field("channel") String channel, - ); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.updatePriceAlert(3, "price", "btcusdt", "+", "64000", "notif"); -``` - -```plaintext -POST /v2/price-alerts HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -Content-Type: application/json -{"pk": 3, tp": "price", "market": "btcusdt", "direction": "-", "price": "63000", "channel": "email,notif"} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "alert": { - "id": 3, - "createdAt": "2021-08-10T20:07:07.977328+00:00", - "market": "BTCUSDT", - "type": "Price", - "direction": "+", - "price": "64000.0000000000", - "description": "", - "channel": "Notif" - } -} -``` - -برای ویرایش یک اعلان قیمت، از درخواستی مشابه درخواست ایجاد اعلان قیمت استفاده می‌کنیم، با این تفاوت که شناسه اعلان قیمت مورد نظر نیز به پارامترهای ورودی افزوده می‌شود: - -* **درخواست:** `POST /v2/price-alerts` -* **محدودیت فراخوانی:** 10 درخواست در 5 دقیقه - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | ---- | --------- | --------- -pk | integer | الزامی | شناسه یکتای اعلان | 3 ...مشابه پارامترهای ورودی ایجاد اعلان قیمت - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok -alert | PriceAlert | اعلان قیمت به‌روز شده | {"id": 3, ...} - - - -### حالت‌های خطا - * در صورتی که کاربر اعلانی با شناسه ارسال شده نداشته باشد، خطای 404 بازگردانده می‌شود. - * سایر خطاها مشابه حالات خطا در ایجاد اعلان قیمت است. - -## حذف اعلان قیمت - ->نمونه درخواست: - -```shell -curl -X DELETE 'https://apiv2.nobitex.ir/v2/price-alerts?delete_item=1,3' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```javascript -api.delete('/v2/price-alerts?delete_item=1,3', { - headers: {Authorization: 'Token yourTOKENhereHEX0000000000'}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @DELETE("/v2/price-alerts") - Call deletePriceAlerts(@Query("delete_item") String deleteItems); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.deletePriceAlerts("1,3"); -``` - -```plaintext -DELETE /v2/price-alerts?delete_item=1,3 HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok" -} -``` - -برای حذف اعلان‌های قیمت خود از این نوع درخواست استفاده نمایید: - -* **درخواست:** `DELETE /v2/price-alerts` -* **محدودیت فراخوانی:** 25 درخواست در 5 دقیقه - - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | ---- | --------- | --------- -delete_item | string | الزامی | شناسه اعلان‌های قیمت مدنظر حذف | "1,3" - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok - - -### حالت‌های خطا - -کد خطا | توضیحات ----- | ---- -ValidationError | شناسه اعلان قیمتی برای حذف ارسال نشده است. diff --git a/source/includes/internal/_ticketing.md b/source/includes/internal/_ticketing.md deleted file mode 100644 index c1442dc..0000000 --- a/source/includes/internal/_ticketing.md +++ /dev/null @@ -1,586 +0,0 @@ -# تیکتینگ -از این سرویس برای ارتباط مشتریان با پشتیبانان استفاده می‌شود. - -## فهرست تمام تاپیک‌ها -برای دریافت لیست تاپیک‌ها از این درخواست استفاده نمایید. -دقت نمایید که این لیست فقط شامل تاپیک‌هایی می‌باشد که از سمت ادمین، مقدار show_to_users برایشان برابر با True قرار داده شده باشد. - -خروجی براساس فیلد اولویت و سپس نام مرتب شده است. - -* **درخواست:** `GET /ticketing/topics` -* **محدودیت فراخوانی:** ۳۰ درخواست در دقیقه - ->نمونه درخواست: - -```shell -curl GET 'https://apiv2.nobitex.ir/ticketing/topics' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "topics": [ - { - "id": 1, - "title": "مشکل در معاملات" - }, - { - "id": 3, - "title": "مشکل در تراکنش" - } - ] - } -} -``` - -## فهرست تیکت‌های کاربر -برای دریافت لیست تیکت‌هایتان از این درخواست استفاده نمایید. - -* **درخواست:** `GET /ticketing/tickets` -* **محدودیت فراخوانی:** ۳۰ درخواست در دقیقه - ->نمونه درخواست: - -```shell -curl GET 'https://apiv2.nobitex.ir/ticketing/tickets' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "tickets": [ - { - "id": 1000249, - "topic": { - "id": 2, - "title": "احراز" - }, - "state": "sent", - "stateName": "ارسال‌شده", - "createdAt": "2022-11-07T14:25:46.606120+00:00", - "content": "سلام\\n\\nلطفا موارد زیر را بررسی بفرمایید:\\n* مشکل یک\\n* مشکل دو\\n* مشکل سه\\n* مشکل چهار\\n\\n**لطفا** مشکلات بنده را در اسرع وقت بررسی بفرمایید", - "rating": null - }, - { - "id": 1000248, - "topic": { - "id": 2, - "title": "احراز" - }, - "state": "sent", - "stateName": "ارسال‌شده", - "createdAt": "2022-11-07T14:21:56.244413+00:00", - "content": "سلام\\n\\n\\\\r\\\\n\\n\\nکاربر گرامی\\n\\n\\\\r\\\\n\\n\\nاین چه تیکتیه زدی؟! چته؟! چی میگی؟!\\n\\n\\\\r\\\\n\\n\\nخدافظظظ", - "rating": null - } - ] - } -} -``` - -> همان‌طور که در نمونه خروجی بالا نیز مشخص است، محتوای تیکت با فرمت Markdown ذخیره شده است. این مسئله در مورد محتوای کامنت نیز صدق می‌کند. در واقع به‌منظور داشتن قابلیت استایل دادن به محتوای تیکت و کامنت‌ها، از این فرمت استفاده شده است. دقت کنید که مقدار seenAt ممکن است null باشد. - -## جزئیات تیکت (شامل کامنت‌ها و فایل‌های مربوطه) -برای دریافت جزئیات تیکت موردنظرتان از این درخواست استفاده نمایید. - -* **درخواست:** `GET /ticketing/tickets/ticket_id` -* **محدودیت فراخوانی:** ۶۰ درخواست در دقیقه - -توجه فرمایید ticket_id در url درخواست از نوع int می باشد. - ->نمونه درخواست: - -```shell -curl GET 'https://apiv2.nobitex.ir/ticketing/tickets/2546' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "ticket": { - "id": 1000249, - "topic": { - "id": 2, - "title": "احراز" - }, - "state": "sent", - "stateName": "ارسال‌شده", - "createdAt": "2022-11-07T14:25:46.606120+00:00", - "content": "سلام\\n\\nلطفا موارد زیر را بررسی بفرمایید:\\n* مشکل یک\\n* مشکل دو\\n* مشکل سه\\n* مشکل چهار\\n\\n**لطفا** مشکلات بنده را در اسرع وقت بررسی بفرمایید", - "rating": null, - "filesUrls": [ - "/ticketing/attachments/c11bfe26-5998-4708-b404-cf406cad744a" - ], - "comments": [ - { - "actorName": "tabvar@nobitex.ir", - "content": "آقای فلانی لطفا موارد زیر را **سریعا** بررسی فرمایید", - "filesUrls": [], - "createdAt": "2022-11-07T14:38:33.493510+00:00", - "seenAt": null - } - ], - "ratingNote": "" - } - } -} -``` - -> در نظر داشته باشید که با فراخوانی این سرویس توسط کاربر مربوط به این تیکت، فیلد seenAt در کامنت‌هایی که توسط ادمین مسئول ایجاد شده و مقدار قبلی نداشته‌اند، تاریخ و ساعت اکنون در آنها ثبت می‌گردد. - -> در صورتی که تیکت وجود نداشته باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "NotFound", - "message": "ticket does not exist." -} -``` - -## ایجاد تیکت -برای ایجاد تیکت از این درخواست استفاده نمایید. - -* **درخواست:** `POST /ticketing/tickets/create` -* **محدودیت فراخوانی:** ۱۰ درخواست در دقیقه -* **حداکثر تعداد عکس:** ۱۰ عدد -* **حداکثر حجم هر عکس:** یک مگابایت -* **فرمت‌های قابل قبول:** PNG/JPEG/GIF - ->نمونه درخواست: - -```shell -curl POST 'https://apiv2.nobitex.ir/ticketing/tickets/create' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |------------|---------|------------------------------| --------- -content | string | الزامی | محتوای تیکت با فرمت markdown | hello world -topic | number | الزامی | شناسه‌ی موضوع (تاپیک) تیکت | 2 -files | list[file] | اختیاری | عکس‌های پیوست | [photo.jpg] - - -> در صورت فراخوانی درست، پاسخ مشابه پاسخ جزئیات تیکت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "ticket": { - "id": 1000249, - "topic": { - "id": 2, - "title": "احراز" - }, - "state": "sent", - "stateName": "ارسال‌شده", - "createdAt": "2022-11-07T14:25:46.606120+00:00", - "content": "سلام\\n\\nلطفا موارد زیر را بررسی بفرمایید:\\n* مشکل یک\\n* مشکل دو\\n* مشکل سه\\n* مشکل چهار\\n\\n**لطفا** مشکلات بنده را در اسرع وقت بررسی بفرمایید", - "rating": null, - "filesUrls": [ - "/ticketing/attachments/c11bfe26-5998-4708-b404-cf406cad744a" - ], - "comments": [], - "ratingNote": "" - } - } -} -``` - - -> در صورتی که حجم برخی از ضمیمه‌ها بیشتر از مقدار تعیین شده باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "TooLargeFile", - "message": "Some uploaded files are too large." -} -``` - -> در صورتی که فرمت برخی از ضمیمه‌ها مجاز نباشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "InvalidMimeType", - "message": "Incorrect mime type." -} -``` - - -> در صورتی که تعداد ضمیمه‌ها مجاز نباشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "TooManyFiles", - "message": "A maximum of 10 files is allowed." -} -``` - -> در صورتی که خطای اعتبارسنجی اطلاعات ارسالی رخ دهد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ValidationError", - "message": {"content": ["این فیلد اجباری است"]} -} -``` - -## ایجاد کامنت -برای ایجاد کامنت روی یک تیکت از این درخواست استفاده نمایید. - -* **درخواست:** `POST /ticketing/comments/create` -* **محدودیت فراخوانی:** ۳۰ درخواست در دقیقه -* **حداکثر تعداد عکس:** ۱۰ عدد -* **حداکثر حجم هر عکس:** یک مگابایت -* **فرمت‌های قابل قبول:** PNG/JPEG/GIF - - ->نمونه درخواست: - -```shell -curl POST 'https://apiv2.nobitex.ir/ticketing/comments/create' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |------------|---------|-------------------------------| --------- -content | string | الزامی | محتوای کامنت با فرمت markdown | hello world -ticket | number | الزامی | شناسه‌ی تیکت | 2 -files | list[file] | اختیاری | عکسهای پیوست | [photo.jpg] - - - -> در صورت فراخوانی درست، پاسخ مشابه پاسخ جزئیات تیکت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "ticket": { - "id": 1000249, - "topic": { - "id": 2, - "title": "احراز" - }, - "state": "sent", - "stateName": "ارسال‌شده", - "createdAt": "2022-11-07T14:25:46.606120+00:00", - "content": "سلام\\n\\nلطفا موارد زیر را بررسی بفرمایید:\\n* مشکل یک\\n* مشکل دو\\n* مشکل سه\\n* مشکل چهار\\n\\n**لطفا** مشکلات بنده را در اسرع وقت بررسی بفرمایید", - "rating": null, - "filesUrls": [ - "/ticketing/attachments/c11bfe26-5998-4708-b404-cf406cad744a" - ], - "comments": [ - { - "actorName": "tabvar@nobitex.ir", - "content": "آقای فلانی لطفا موارد زیر را **سریعا** بررسی فرمایید", - "filesUrls": [], - "createdAt": "2022-11-07T14:38:33.493510+00:00", - "seenAt": null - } - ], - "ratingNote": "" - } - } -} -``` - -> در صورتی که تیکت وجود نداشته باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "NotFound", - "message": "ticket does not exist." -} -``` - -> در صورتی که تیکت در وضعیت بسته باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ValidationError", - "message": {"ticket": ["comment on spam or closed tickets is impossible."]} -} -``` - - -> در صورتی که حجم برخی از ضمیمه‌ها بیشتر از مقدار تعیین شده باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "TooLargeFile", - "message": "Some uploaded files are too large." -} -``` - -> در صورتی که فرمت برخی از ضمیمه‌ها مجاز نباشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "InvalidMimeType", - "message": "Incorrect mime type." -} -``` - -> در صورتی که تعداد ضمیمه‌ها مجاز نباشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "TooManyFiles", - "message": "A maximum of 10 files is allowed." -} -``` - -> در صورتی که خطای اعتبارسنجی اطلاعات ارسالی رخ دهد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ValidationError", - "message": {"content": ["این فیلد اجباری است"]} -} -``` - - -## بستن تیکت -برای بستن یک تیکت از درخواست زیر استفاده نمایید: - -* **درخواست:** `POST /ticketing/tickets/ticket_id/close` -* **محدودیت فراخوانی:** ۲۰ درخواست در دقیقه - -توجه فرمایید ticket_id در url درخواست از نوع int می باشد. - ->نمونه درخواست: - -```shell -curl POST 'https://apiv2.nobitex.ir/ticketing/tickets//close' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -### پارامترهای ورودی -نیاز نیست. - - -> در صورت فراخوانی درست، پاسخ مشابه پاسخ جزئیات تیکت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "ticket": { - "id": 1000249, - "topic": { - "id": 2, - "title": "احراز" - }, - "state": "closed", - "stateName": "بسته", - "createdAt": "2022-11-07T14:25:46.606120+00:00", - "content": "سلام\\n\\nلطفا موارد زیر را بررسی بفرمایید:\\n* مشکل یک\\n* مشکل دو\\n* مشکل سه\\n* مشکل چهار\\n\\n**لطفا** مشکلات بنده را در اسرع وقت بررسی بفرمایید", - "rating": null, - "filesUrls": [ - "/ticketing/attachments/c11bfe26-5998-4708-b404-cf406cad744a" - ], - "comments": [ - { - "actorName": "tabvar@nobitex.ir", - "content": "آقای فلانی لطفا موارد زیر را **سریعا** بررسی فرمایید", - "filesUrls": [], - "createdAt": "2022-11-07T14:38:33.493510+00:00", - "seenAt": null - } - ], - "ratingNote": "" - } - } -} -``` - -> در صورتی که تیکت وجود نداشته باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "NotFound", - "message": "ticket does not exist." -} -``` - - -## نظرسنجی روی تیکت -برای نظردهی به یک تیکت از درخواست زیر استفاده نمایید: - -* **درخواست:** `POST /ticketing/tickets/ticket_id/rate` -* **محدودیت فراخوانی:** ۲۰ درخواست در دقیقه - -توجه فرمایید ticket_id در url درخواست از نوع int می باشد. - ->نمونه درخواست: - -```shell -curl POST 'https://apiv2.nobitex.ir/ticketing/tickets//rate' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- |------------|---------|---------------| --------- -ratingNote | string | اختیاری | توضیح بیشتر | The response was excellent -rating | number | الزامی | امتیاز ۱ تا ۵ | 5 - - -> در صورت فراخوانی درست، پاسخ مشابه پاسخ جزئیات تیکت خواهد بود: - -```json -{ - "status": "ok", - "data": { - "ticket": { - "id": 1000249, - "topic": { - "id": 2, - "title": "احراز" - }, - "state": "closed", - "stateName": "بسته", - "createdAt": "2022-11-07T14:25:46.606120+00:00", - "content": "سلام\\n\\nلطفا موارد زیر را بررسی بفرمایید:\\n* مشکل یک\\n* مشکل دو\\n* مشکل سه\\n* مشکل چهار\\n\\n**لطفا** مشکلات بنده را در اسرع وقت بررسی بفرمایید", - "rating": 5, - "filesUrls": [ - "/ticketing/attachments/c11bfe26-5998-4708-b404-cf406cad744a" - ], - "comments": [ - { - "actorName": "tabvar@nobitex.ir", - "content": "آقای فلانی لطفا موارد زیر را **سریعا** بررسی فرمایید", - "filesUrls": [], - "createdAt": "2022-11-07T14:38:33.493510+00:00", - "seenAt": null - } - ], - "ratingNote": "خیلی ممنون. مشکلاتم خیلی سریع حل شد" - } - } -} -``` - -> در صورتی که تیکت وجود نداشته باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "NotFound", - "message": "ticket does not exist." -} -``` - - -> در صورتی که تیکت هنوز بسته نشده باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "UnclosedTicket", - "message": "Ticket is not closed yet." -} -``` - -> در صورتی که تیکت قبلا نظرسنجی شده باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "AlreadyRated", - "message": "Ticket is already rated." -} -``` - -> در صورتی که خطای اعتبارسنجی اطلاعات ارسالی رخ دهد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "ValidationError", - "message": [{"rating": "این فیلد اجباری است"}] -} -``` - -## دانلود ضمیمه‌ها -برای دانلود ضمیمه‌ها از این درخواست استفاده نمایید. - -* **درخواست:** `GET /ticketing/attachments/file_hash` -* **محدودیت فراخوانی:** ۱۰ درخواست در دقیقه - -توجه فرمایید file_hash در url درخواست از نوع str می باشد. - ->نمونه درخواست: - -```shell -curl GET 'https://apiv2.nobitex.ir/ticketing/attachments/8a9759e4cedc49bda0856204499fd3de' \ --H 'Authorization: Token yourTOKENhereHEX0000000000' -``` -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```shell -b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\n\x00\x00\x00\x06@\x08\x02\x00\x00\x00:\xce\x8c\x97\x0 -``` - -> در صورتی که نام فایل نامعتبر باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "InvalidFilename", - "message": "Invalid ticket attachment filename." -} -``` - -> در صورتی که فایل وجود نداشته باشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "NotFound", - "message": "Ticket attachment does not exist." -} -``` - -> در صورتی که فایل از نوع ضمیمه‌ی تیکت نباشد، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "failed", - "code": "InvalidFileType", - "message": "The file type is not a ticket attachment." -} -``` diff --git a/source/includes/internal/_transactions.md b/source/includes/internal/_transactions.md deleted file mode 100644 index 45199d2..0000000 --- a/source/includes/internal/_transactions.md +++ /dev/null @@ -1,119 +0,0 @@ -#تراکنش‌های مالی -هر گونه تغییر در موجودی کیف‌پول کاربر توسط یک تراکنش ایجاد و ثبت می‌شود. افزایش یا کسری موجودی در اثر واریز، برداشت، معامله و کارمزد همگی نمونه‌ای از تراکنش‌های مالی کاربر هستند. - - -### نکات و ملاحظات -احراز هویت در API های این مجموعه الزامی است. - - -## تاریخچه تراکنش‌ها - ->نمونه درخواست: - -```shell -curl 'https://apiv2.nobitex.ir/users/transactions-history' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' -``` - -```javascript -api.get('/users/transactions-history', { - headers: {Authorization: 'Token yourTOKENhereHEX0000000000'}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @GET("/users/transactions-history") - Call listTransactions(); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.listTransactions(); -``` - -```plaintext -GET /users/transactions-history HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "transactions": [ - { - "id": 1, - "tp": "deposit", - "type": "واریز", - "created_at": "2021-11-13T14:35:18.766Z", - "currency": "rls", - "amount": "10000000.0000000000", - "balance": "10000000.0000000000", - "description": "واریز شتابی - شماره کارت: 123456******1234 - شماره پیگیری: 39577-bpiZpZw", - "calculatedFee": null - }, - { - "id": 2, - "tp": "sell", - "type": "معامله", - "created_at": "2021-11-23T15:47:12.835Z", - "currency": "rls", - "amount": "-8000000.0000000000", - "balance": "2000000.0000000000", - "description": "خرید 32.00 USDT به قیمت واحد ﷼250000", - "calculatedFee": null - }, - { - "id": 3, - "tp": "buy", - "type": "معامله", - "created_at": "2021-11-23T15:47:12.835Z", - "currency": "usdt", - "amount": "32.0000000000", - "balance": "32.0000000000", - "description": "خرید 32.00 USDT به قیمت واحد ﷼250000", - "calculatedFee": null - } - ], - "hasNext": false -} -``` - -برای دریافت تاریخچه همه تراکنش‌های مالی کاربر از این نوع درخواست استفاده نمایید: - -* **درخواست:** `GET /users/transactions-history` -* **محدودیت فراخوانی:** 60 درخواست در ساعت -* **صفحه بندی:** دارد (پیش فرض 50) - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok -transactions | list of Transaction | لیستی از تراکنش‌ها | [] -hasNext | boolean | آیا لیست ادامه دارد؟ | false - - -### شی Transaction - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -id | integer | شناسه تراکنش | 1 -tp | string | نوع تراکنش | "deposit" -type | string | نوع قابل فهم | "واریز" -createdAt | iso-string | زمان ایجاد | "2021-11-13T14:35:18.766Z" -currency | string | نوع ارز | "rls" -amount | monetary | مقدار | "10000000.0000000000" -balance | monetary | موجودی نهایی | "10000000.0000000000" -description | string | توضیحات | "واریز شتابی - شماره کارت: 123456******1234 - شماره پیگیری: 39577-bpiZpZw" -calculatedFee | monetary | کارمزد حساب شده | null - -1. **نوع تراکنش:** می‌تواند یکی از مقادیر `deposit` (واریز)، `withdraw` (برداشت)، `buy` و `sell` (معامله)، `fee` (کارمزد)، `gateway` (درگاه)، `ex_src` و `ex_dst` (صرافی) و `manual` (سیستمی) باشد. -2. **مقدار:** در تراکنش مقدار منفی نشان‌دهنده کاهش موجودی و مقدار مثبت نشان‌دهنده افزایش موجودی می‌باشد. diff --git a/source/includes/internal/_wallet_invoice.md b/source/includes/internal/_wallet_invoice.md deleted file mode 100644 index efe782e..0000000 --- a/source/includes/internal/_wallet_invoice.md +++ /dev/null @@ -1,255 +0,0 @@ -#صورت‌حساب کیف پول -صورت‌حساب یا فاکتور (invoice) برای دریافت رمزارز در برخی شبکه‌های انتقال استفاده می‌شود. -برای آشنایی با مفاهیم مرتبط با انتقال صورت‌حسابی -[مطلب آموزشی بلاگ](https://blog.nobitex.ir/لایتنینگ-چیست-و-چطور-از-آن-استفاده-کنیم/ "لایتنینگ چیست و چطور از آن استفاده کنیم؟") -را مطالعه نمایید. - -### نکات و ملاحظات -1. در حال حاضر تنها برای کیف پول بیت‌کوین از طریق شبکه لایتنینگ انتقال صورت‌حسابی امکان‌پذیر است. -2. احراز هویت در API های این مجموعه الزامی است. - -##ایجاد صورت‌حساب واریز - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/wallets/invoice/generate' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"wallet": 1, "amount": 100}' -``` - -```javascript -api.post('/users/wallets/invoice/generate', {wallet: 1, amount: 100}, { - headers: {Authorization: "Token yourTOKENhereHEX0000000000"}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @FormUrlEncoded - @POST("/users/wallets/invoice/generate") - Call generateWalletInvoice(@Field("wallet") int walletId, @Field("amount") int amount); -} - -APIService api = retrofit.create(APIService.class); - -Call call = api.generateWalletInvoice(1, 100); -``` - - -```plaintext -POST /users/wallets/invoice/generate HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -Content-Type: application/json -{"wallet": 1, "amount": 100} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "deposit": { - "id": 1, - "amount": "0.0000010000", - "date": "2021-10-17T18:52:31.679312+00:00", - "depositType": "coinDeposit", - "confirmed": true, - "transaction": { - "id": 5, - "amount": "0.0000010000", - "currency": "btc", - "description": "Deposit - address:tbtctest2o21q2ufulqrp85wt6qnxzxgmkd72hgc2du, tx:0001020304050607080900010203040506070809000102030405060708090102", - "created_at": "2021-10-17T18:52:31.679312+00:00", - "balance": null - }, - "txHash": "0001020304050607080900010203040506070809000102030405060708090102", - "address": 123456789, - "currency": "Bitcoin", - "blockchainUrl": "hash: 0001020304050607080900010203040506070809000102030405060708090102", - "requiredConfirmations": 3, - "confirmations": 2, - "isConfirmed": false, - "invoice": "lnbc1u1pskcu80pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcfehky6t5v4uzqer9wphhx6t5z7jut6xdcvpnye3suzk448rqex822kr788q8hxrgtw8muxmnnj4jfj074lgh7czwf8k3wdx3u8y46znnxeqg0e6gqmc57rpw3qnyl7gpnaaqru", - "expired": false - } -} - -``` -برای ایجاد صورت‌حساب واریز از این نوع درخواست استفاده نمایید: - -* **درخواست:** `POST /users/wallets/invoice/generate` -- **محدودیت فراخوانی:** 10 درخواست در 3 دقیقه - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | ---- |----------------------------------------------| --------- -wallet | integer | الزامی | شناسه کیف‌پول کاربر برای رمزارز واریز شده | 1 -amount | integer | الزامی | مقدار رمزارز واریز شده (ساتوشی برای بیتکوین) | 100 - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok -deposit | CoinDeposit | اطلاعات واریز | {"id": 1, ...} - -### شی Deposit - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -id | integer | شناسه واریز | 1 -amount | monetary | مقدار واریز شده | "0.0000010000" -date | iso-string | زمان واریز | "2021-10-17T18:52:31.679312+00:00" -depositType | string | شناسه واریز | 1 -confirmed | boolean | تایید شده در نوبیتکس | true -transaction | Transaction | اطلاعات تراکنش واریز به کیف پول | {"id": 5, ...} - -### شی CoinDeposit (نوع Deposit با depositType = "coinDeposit") - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -txHash | string | هش واریز | "0001020304050607080900010203040506070809000102030405060708090102" -address | string | آدرس یا تگ واریز | 123456789 -currency | string | رمزارز واریزی | "Bitcoin" -blockchainUrl | integer | شناسه واریز | "hash: 0001020304050607080900010203040506070809000102030405060708090102" -requiredConfirmations | integer | تعداد تاییدهای مورد نیاز | 3 -confirmations | integer | تعداد تاییدهای دریافت شده | 2 -isConfirmed | boolean | تایید شده در شبکه رمزارزی | false -invoice | string | صورت‌حساب واریز | "lnbc1u1pskcu80pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcfehky6t5v4uzqer9wphhx6t5z7jut6xdcvpnye3suzk448rqex822kr788q8hxrgtw8muxmnnj4jfj074lgh7czwf8k3wdx3u8y46znnxeqg0e6gqmc57rpw3qnyl7gpnaaqru" -expired | boolean | منقضی شده | false - -### شی Transaction - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -id | integer | شناسه تراکنش | 5 -amount | monetary | مقدار تراکنش | "0.0000010000" -currency | string | رمزارز تراکنش | "btc" -description | string | توضیح تراکنش | "Deposit - address:tbtctest2o21q2ufulqrp85wt6qnxzxgmkd72hgc2du, tx:0001020304050607080900010203040506070809000102030405060708090102" -created_at | iso-string | زمان تراکنش | "2021-10-17T18:52:31.679312+00:00" -balance | integer | موجودی نهایی کیف پول | null - - -### حالت‌های خطا - -کد خطا | توضیحات ----- | ---- -CoinDepositLimitation | کاربر اجازه واریز رمزارز در نوبیتکس را ندارد. -InvalidAmount | مقدار تراکنش در بازه مجاز نیست. -InvalidCurrency | رمزارز کیف‌پول درخواست از انتقال صورت‌حسابی پشتیبانی نمی‌کند. -CoinDepositDisabled | امکان واریز رمزارز در این شبکه به طور مقطعی توسط مدیر سیستم غیر فعال شده است. -NotAvailable | دسترسی به شبکه برای ساخت صورت‌حساب به دلیل اختلالات در اتصال به صورت موقت وجود ندارد. -ParseError |نوع یا شرط الزامی بودن یکی از پارامترهای ورودی رعایت نشده است. - -### نکات و ملاحظات -1. واحد amount برای رمزارز بیت‌کوین در این درخواست معادل -ساتوشی -می‌باشد. -2. در حال حاضر، حداقل واریز 100 ساتوشی و حداکثر واریز 100000 ساتوشی در نظر گرفته شده است. -3. کاربر درخواست دهنده در این API بایستی حداقل سطح مجاز برای واریز رمزارز (سطح یک) را داشته باشد. - - -##تفسیر صورت‌حساب - ->نمونه درخواست: - -```shell -curl -X POST 'https://apiv2.nobitex.ir/users/wallets/invoice/decode' \ - -H 'Authorization: Token yourTOKENhereHEX0000000000' \ - -H 'Content-Type: application/json' \ - --data '{"wallet": 1,"invoice": "lnbc1u1pskcu80pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcfehky6t5v4uzqer9wphhx6t5z7jut6xdcvpnye3suzk448rqex822kr788q8hxrgtw8muxmnnj4jfj074lgh7czwf8k3wdx3u8y46znnxeqg0e6gqmc57rpw3qnyl7gpnaaqru"}' -``` - -```javascript -api.post('/users/wallets/invoice/decode', { - wallet: 1, - invoice: 'lnbc1u1pskcu80pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcfehky6t5v4uzqer9wphhx6t5z7jut6xdcvpnye3suzk448rqex822kr788q8hxrgtw8muxmnnj4jfj074lgh7czwf8k3wdx3u8y46znnxeqg0e6gqmc57rpw3qnyl7gpnaaqru' -}, { - headers: {Authorization: 'Token yourTOKENhereHEX0000000000'}, -}).then((response) => { - console.log(response); -}); -``` - -```java -public interface APIService { - @Headers({"Authorization: Token yourTOKENhereHEX0000000000"}) - @FormUrlEncoded - @POST("/users/wallets/invoice/decode") - Call decodeWalletInvoice(@Field("wallet") int walletId, @Field("invoice") String invoice); -} - -APIService api = retrofit.create(APIService.class); - -String invoice = "lnbc1u1pskcu80pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcfehky6t5v4uzqer9wphhx6t5z7jut6xdcvpnye3suzk448rqex822kr788q8hxrgtw8muxmnnj4jfj074lgh7czwf8k3wdx3u8y46znnxeqg0e6gqmc57rpw3qnyl7gpnaaqru"; -Call call = api.decodeWalletInvoice(1, invoice); -``` - - -```plaintext -POST /users/wallets/invoice/decode HTTP/1.1 -Host: apiv2.nobitex.ir -Authorization: Token yourTOKENhereHEX0000000000 -Content-Type: application/json -{"wallet": 1, "invoice": "lnbc1u1pskcu80pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcfehky6t5v4uzqer9wphhx6t5z7jut6xdcvpnye3suzk448rqex822kr788q8hxrgtw8muxmnnj4jfj074lgh7czwf8k3wdx3u8y46znnxeqg0e6gqmc57rpw3qnyl7gpnaaqru"} -``` - -> در صورت فراخوانی درست، پاسخ به این صورت خواهد بود: - -```json -{ - "status": "ok", - "amount": "0.000001", - "address": "03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad", - "date": 1634496751, - "fee": "0.00000010" -} -``` - -برای استخراج مقادیر موجود در صورت‌حساب رمزگذاری شده از این نوع درخواست استفاده نمایید: - -- **درخواست:** `POST /users/wallets/invoice/decode` -- **محدودیت فراخوانی:** 60 درخواست در 2 دقیقه - -### پارامترهای ورودی - -پارامتر | نوع | پیش‌فرض | توضیحات | نمونه -------- | ---- | ---- | --------- | --------- -wallet | integer | الزامی | شناسه کیف‌پول کاربر که صورت‌حساب برای آن صادر شده | 1 -invoice | string | الزامی | صورت‌حساب کد شده | "lnbc1u1pskcu80pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcfehky6t5v4uzqer9wphhx6t5z7jut6xdcvpnye3suzk448rqex822kr788q8hxrgtw8muxmnnj4jfj074lgh7czwf8k3wdx3u8y46znnxeqg0e6gqmc57rpw3qnyl7gpnaaqru" - -> نمونه صورت‌حساب آزمایشی: - -```json -"lntb1u1pskcu80pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcfehky6t5v4uzqer9wphhx6t5wtu3ws8aua895ruar4kw2ps6vrc4cj2nrsyms6t5n8q38rrpw6nqnus2fen69uwyzru2m65qxvvezmw6y8pxqz9qg3px6jldq40smpgp05rvjk" -``` - - -### پارامترهای پاسخ - -پارامتر | نوع | توضیحات | نمونه -------- | ---- | --------- | --------- -status | string | وضعیت پاسخ | ok -amount | monetary | مقدار صورت‌حساب | "0.000001" -date | int | زمان ایجاد صورت‌حساب | 1634496751 -address | string | کلید عمومی پرداخت کننده | "03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad" -fee | monetary | کارمزد انتقال | "0.00000010" - - -### حالت‌های خطا - -کد خطا | توضیحات ----- | ---- -InvalidInvoice |

صورت‌حساب نامعتبر است یا پشتیبانی نمی‌شود

- - -### نکات و ملاحظات -دقت نمایید صورت‌حساب ثبت شده نمی‌تواند مربوط به شبکه‌های آزمایشی رمزارز باشد. برای تفسیر صورت‌حساب‌های آزمایشی از محیط آزمایشی نوبیتکس استفاده نمایید. diff --git a/source/index.html.md b/source/index.html.md deleted file mode 100644 index 9684cc3..0000000 --- a/source/index.html.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: مستندات API نوبیتکس -lang: fa -language_tabs: - - shell - - plaintext -includes: - - intro - - market_data - - user_data - - market_trade - - position - - withdraw - - websocket - - address_book - - security - - referral - - auth - - portfolio - - other - - general_notes - - faq - - symbols -toc_footers: - - سابقه تغییرات API - - شرایط استفاده از API - - مخزن گیت‌هاب - - کالکشن Postman - - سایت نوبیتکس ---- diff --git a/source/internal.html.md b/source/internal.html.md deleted file mode 100644 index a2ba5d6..0000000 --- a/source/internal.html.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: مستندات API داخلی نوبیتکس -lang: fa -language_tabs: - - shell - - javascript - - java - - swift - - plaintext -includes: - - internal/2fa - - internal/notifications - - internal/wallet_invoice - - internal/price_alerts - - internal/transactions - - internal/gift - - internal/ticketing - - internal/batch_actions - - internal/active_order_count -toc_footers: - - سایت نوبیتکس ---- - -# مستندات API داخلی نوبیتکس - -> جهت استفاده از نمونه کدهای مستند ابتدا تنظیمات زیر را استفاده نمایید. - -```shell -sudo apt install curl -``` - -```javascript -const axios = require("axios"); - -const api = axios.create({baseURL: "https://apiv2.nobitex.ir"}); -``` - -```java -import com.google.gson.JsonObject; -import retrofit2.Call; -import retrofit2.http.GET; -import retrofit2.http.POST; -import retrofit2.http.Headers; -import retrofit2.http.Query; -import retrofit2.http.Field; -import retrofit2.http.FormUrlEncoded; -import retrofit2.converter.gson.GsonConverterFactory; - -Retrofit retrofit = new Retrofit.Builder() - .baseUrl('https://apiv2.nobitex.ir') - .addConverterFactory(GsonConverterFactory.create()) - .build(); -``` - -```swift -// Contact us -``` - -مستندات این بخش، سایر APIهای نوبیتکس را که عموما با بازار نوبیتکس ارتباطی نداشته و بیشتر ناظر به نیازهای ارتباطی و عملکردی سایت و اپلیکیشن نوبیتکس می‌باشد، توضیح می‌دهد. - -توجه داشته باشید بعضی از APIها نیاز به احراز هویت و دریافت توکن دارد که می‌توانید از [مستندات احراز هویت](/#intro-auth) نحوه عملکرد آن را مطالعه کنید. diff --git a/source/javascripts/all.js b/source/javascripts/all.js deleted file mode 100644 index 5f5d406..0000000 --- a/source/javascripts/all.js +++ /dev/null @@ -1,2 +0,0 @@ -//= require ./all_nosearch -//= require ./app/_search diff --git a/source/javascripts/all_nosearch.js b/source/javascripts/all_nosearch.js deleted file mode 100644 index 026e5a2..0000000 --- a/source/javascripts/all_nosearch.js +++ /dev/null @@ -1,27 +0,0 @@ -//= require ./lib/_energize -//= require ./app/_copy -//= require ./app/_toc -//= require ./app/_lang - -function adjustLanguageSelectorWidth() { - const elem = $('.dark-box > .lang-selector'); - elem.width(elem.parent().width()); -} - -$(function() { - loadToc($('#toc'), '.toc-link', '.toc-list-h2', 10); - setupLanguages($('body').data('languages')); - $('.content').imagesLoaded( function() { - window.recacheHeights(); - window.refreshToc(); - }); - - $(window).resize(function() { - adjustLanguageSelectorWidth(); - }); - adjustLanguageSelectorWidth(); -}); - -window.onpopstate = function() { - activateLanguage(getLanguageFromQueryString()); -}; diff --git a/source/javascripts/app/_copy.js b/source/javascripts/app/_copy.js deleted file mode 100644 index 4dfbbb6..0000000 --- a/source/javascripts/app/_copy.js +++ /dev/null @@ -1,15 +0,0 @@ -function copyToClipboard(container) { - const el = document.createElement('textarea'); - el.value = container.textContent.replace(/\n$/, ''); - document.body.appendChild(el); - el.select(); - document.execCommand('copy'); - document.body.removeChild(el); -} - -function setupCodeCopy() { - $('pre.highlight').prepend('
Copy to Clipboard
'); - $('.copy-clipboard').on('click', function() { - copyToClipboard(this.parentNode.children[1]); - }); -} diff --git a/source/javascripts/app/_lang.js b/source/javascripts/app/_lang.js deleted file mode 100644 index cc5ac8b..0000000 --- a/source/javascripts/app/_lang.js +++ /dev/null @@ -1,171 +0,0 @@ -//= require ../lib/_jquery - -/* -Copyright 2008-2013 Concur Technologies, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); you may -not use this file except in compliance with the License. You may obtain -a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. -*/ -;(function () { - 'use strict'; - - var languages = []; - - window.setupLanguages = setupLanguages; - window.activateLanguage = activateLanguage; - window.getLanguageFromQueryString = getLanguageFromQueryString; - - function activateLanguage(language) { - if (!language) return; - if (language === "") return; - - $(".lang-selector a").removeClass('active'); - $(".lang-selector a[data-language-name='" + language + "']").addClass('active'); - for (var i=0; i < languages.length; i++) { - $(".highlight.tab-" + languages[i]).hide(); - $(".lang-specific." + languages[i]).hide(); - } - $(".highlight.tab-" + language).show(); - $(".lang-specific." + language).show(); - - window.recacheHeights(); - - // scroll to the new location of the position - if ($(window.location.hash).get(0)) { - $(window.location.hash).get(0).scrollIntoView(true); - } - } - - // parseURL and stringifyURL are from https://github.com/sindresorhus/query-string - // MIT licensed - // https://github.com/sindresorhus/query-string/blob/7bee64c16f2da1a326579e96977b9227bf6da9e6/license - function parseURL(str) { - if (typeof str !== 'string') { - return {}; - } - - str = str.trim().replace(/^(\?|#|&)/, ''); - - if (!str) { - return {}; - } - - return str.split('&').reduce(function (ret, param) { - var parts = param.replace(/\+/g, ' ').split('='); - var key = parts[0]; - var val = parts[1]; - - key = decodeURIComponent(key); - // missing `=` should be `null`: - // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters - val = val === undefined ? null : decodeURIComponent(val); - - if (!ret.hasOwnProperty(key)) { - ret[key] = val; - } else if (Array.isArray(ret[key])) { - ret[key].push(val); - } else { - ret[key] = [ret[key], val]; - } - - return ret; - }, {}); - }; - - function stringifyURL(obj) { - return obj ? Object.keys(obj).sort().map(function (key) { - var val = obj[key]; - - if (Array.isArray(val)) { - return val.sort().map(function (val2) { - return encodeURIComponent(key) + '=' + encodeURIComponent(val2); - }).join('&'); - } - - return encodeURIComponent(key) + '=' + encodeURIComponent(val); - }).join('&') : ''; - }; - - // gets the language set in the query string - function getLanguageFromQueryString() { - if (location.search.length >= 1) { - var language = parseURL(location.search).language; - if (language) { - return language; - } else if (jQuery.inArray(location.search.substr(1), languages) != -1) { - return location.search.substr(1); - } - } - - return false; - } - - // returns a new query string with the new language in it - function generateNewQueryString(language) { - var url = parseURL(location.search); - if (url.language) { - url.language = language; - return stringifyURL(url); - } - return language; - } - - // if a button is clicked, add the state to the history - function pushURL(language) { - if (!history) { return; } - var hash = window.location.hash; - if (hash) { - hash = hash.replace(/^#+/, ''); - } - history.pushState({}, '', '?' + generateNewQueryString(language) + '#' + hash); - - // save language as next default - if (localStorage) { - localStorage.setItem("language", language); - } - } - - function setupLanguages(l) { - var defaultLanguage = null; - if (localStorage) { - defaultLanguage = localStorage.getItem("language"); - } - - languages = l; - - var presetLanguage = getLanguageFromQueryString(); - if (presetLanguage) { - // the language is in the URL, so use that language! - activateLanguage(presetLanguage); - - if (localStorage) { - localStorage.setItem("language", presetLanguage); - } - } else if ((defaultLanguage !== null) && (jQuery.inArray(defaultLanguage, languages) != -1)) { - // the language was the last selected one saved in localstorage, so use that language! - activateLanguage(defaultLanguage); - } else { - // no language selected, so use the default - activateLanguage(languages[0]); - } - } - - // if we click on a language tab, activate that language - $(function() { - $(".lang-selector a").on("click", function() { - var language = $(this).data("language-name"); - pushURL(language); - activateLanguage(language); - return false; - }); - }); -})(); diff --git a/source/javascripts/app/_search.js b/source/javascripts/app/_search.js deleted file mode 100644 index 0b0ccd9..0000000 --- a/source/javascripts/app/_search.js +++ /dev/null @@ -1,102 +0,0 @@ -//= require ../lib/_lunr -//= require ../lib/_jquery -//= require ../lib/_jquery.highlight -;(function () { - 'use strict'; - - var content, searchResults; - var highlightOpts = { element: 'span', className: 'search-highlight' }; - var searchDelay = 0; - var timeoutHandle = 0; - var index; - - function populate() { - index = lunr(function(){ - - this.ref('id'); - this.field('title', { boost: 10 }); - this.field('body'); - this.pipeline.add(lunr.trimmer, lunr.stopWordFilter); - var lunrConfig = this; - - $('h1, h2').each(function() { - var title = $(this); - var body = title.nextUntil('h1, h2'); - lunrConfig.add({ - id: title.prop('id'), - title: title.text(), - body: body.text() - }); - }); - - }); - determineSearchDelay(); - } - - $(populate); - $(bind); - - function determineSearchDelay() { - if (index.tokenSet.toArray().length>5000) { - searchDelay = 300; - } - } - - function bind() { - content = $('.content'); - searchResults = $('.search-results'); - - $('#input-search').on('keyup',function(e) { - var wait = function() { - return function(executingFunction, waitTime){ - clearTimeout(timeoutHandle); - timeoutHandle = setTimeout(executingFunction, waitTime); - }; - }(); - wait(function(){ - search(e); - }, searchDelay); - }); - } - - function search(event) { - - var searchInput = $('#input-search')[0]; - - unhighlight(); - searchResults.addClass('visible'); - - // ESC clears the field - if (event.keyCode === 27) searchInput.value = ''; - - if (searchInput.value) { - var results = index.search(searchInput.value).filter(function(r) { - return r.score > 0.0001; - }); - - if (results.length) { - searchResults.empty(); - $.each(results, function (index, result) { - var elem = document.getElementById(result.ref); - searchResults.append("
  • " + $(elem).text() + "
  • "); - }); - highlight.call(searchInput); - } else { - searchResults.html('
  • '); - $('.search-results li').text('No Results Found for "' + searchInput.value + '"'); - } - } else { - unhighlight(); - searchResults.removeClass('visible'); - } - } - - function highlight() { - if (this.value) content.highlight(this.value, highlightOpts); - } - - function unhighlight() { - content.unhighlight(highlightOpts); - } -})(); - diff --git a/source/javascripts/app/_toc.js b/source/javascripts/app/_toc.js deleted file mode 100644 index f70bdc0..0000000 --- a/source/javascripts/app/_toc.js +++ /dev/null @@ -1,122 +0,0 @@ -//= require ../lib/_jquery -//= require ../lib/_imagesloaded.min -;(function () { - 'use strict'; - - var htmlPattern = /<[^>]*>/g; - var loaded = false; - - var debounce = function(func, waitTime) { - var timeout = false; - return function() { - if (timeout === false) { - setTimeout(function() { - func(); - timeout = false; - }, waitTime); - timeout = true; - } - }; - }; - - var closeToc = function() { - $(".toc-wrapper").removeClass('open'); - $("#nav-button").removeClass('open'); - }; - - function loadToc($toc, tocLinkSelector, tocListSelector, scrollOffset) { - var headerHeights = {}; - var pageHeight = 0; - var windowHeight = 0; - var originalTitle = document.title; - - var recacheHeights = function() { - headerHeights = {}; - pageHeight = $(document).height(); - windowHeight = $(window).height(); - - $toc.find(tocLinkSelector).each(function() { - var targetId = $(this).attr('href'); - if (targetId[0] === "#") { - headerHeights[targetId] = $("#" + $.escapeSelector(targetId.substring(1))).offset().top; - } - }); - }; - - var refreshToc = function() { - var currentTop = $(document).scrollTop() + scrollOffset; - - if (currentTop + windowHeight >= pageHeight) { - // at bottom of page, so just select last header by making currentTop very large - // this fixes the problem where the last header won't ever show as active if its content - // is shorter than the window height - currentTop = pageHeight + 1000; - } - - var best = null; - for (var name in headerHeights) { - if ((headerHeights[name] < currentTop && headerHeights[name] > headerHeights[best]) || best === null) { - best = name; - } - } - - // Catch the initial load case - if (currentTop == scrollOffset && !loaded) { - best = window.location.hash; - loaded = true; - } - - var $best = $toc.find("[href='" + best + "']").first(); - if (!$best.hasClass("active")) { - // .active is applied to the ToC link we're currently on, and its parent
      s selected by tocListSelector - // .active-expanded is applied to the ToC links that are parents of this one - $toc.find(".active").removeClass("active"); - $toc.find(".active-parent").removeClass("active-parent"); - $best.addClass("active"); - $best.parents(tocListSelector).addClass("active").siblings(tocLinkSelector).addClass('active-parent'); - $best.siblings(tocListSelector).addClass("active"); - $toc.find(tocListSelector).filter(":not(.active)").slideUp(150); - $toc.find(tocListSelector).filter(".active").slideDown(150); - if (window.history.replaceState) { - window.history.replaceState(null, "", best); - } - var thisTitle = $best.data("title"); - if (thisTitle !== undefined && thisTitle.length > 0) { - document.title = thisTitle.replace(htmlPattern, "") + " – " + originalTitle; - } else { - document.title = originalTitle; - } - } - }; - - var makeToc = function() { - recacheHeights(); - refreshToc(); - - $("#nav-button").click(function() { - $(".toc-wrapper").toggleClass('open'); - $("#nav-button").toggleClass('open'); - return false; - }); - $(".page-wrapper").click(closeToc); - $(".toc-link").click(closeToc); - - // reload immediately after scrolling on toc click - $toc.find(tocLinkSelector).click(function() { - setTimeout(function() { - refreshToc(); - }, 0); - }); - - $(window).scroll(debounce(refreshToc, 200)); - $(window).resize(debounce(recacheHeights, 200)); - }; - - makeToc(); - - window.recacheHeights = recacheHeights; - window.refreshToc = refreshToc; - } - - window.loadToc = loadToc; -})(); diff --git a/source/javascripts/lib/_energize.js b/source/javascripts/lib/_energize.js deleted file mode 100644 index 6798f3c..0000000 --- a/source/javascripts/lib/_energize.js +++ /dev/null @@ -1,169 +0,0 @@ -/** - * energize.js v0.1.0 - * - * Speeds up click events on mobile devices. - * https://github.com/davidcalhoun/energize.js - */ - -(function() { // Sandbox - /** - * Don't add to non-touch devices, which don't need to be sped up - */ - if(!('ontouchstart' in window)) return; - - var lastClick = {}, - isThresholdReached, touchstart, touchmove, touchend, - click, closest; - - /** - * isThresholdReached - * - * Compare touchstart with touchend xy coordinates, - * and only fire simulated click event if the coordinates - * are nearby. (don't want clicking to be confused with a swipe) - */ - isThresholdReached = function(startXY, xy) { - return Math.abs(startXY[0] - xy[0]) > 5 || Math.abs(startXY[1] - xy[1]) > 5; - }; - - /** - * touchstart - * - * Save xy coordinates when the user starts touching the screen - */ - touchstart = function(e) { - this.startXY = [e.touches[0].clientX, e.touches[0].clientY]; - this.threshold = false; - }; - - /** - * touchmove - * - * Check if the user is scrolling past the threshold. - * Have to check here because touchend will not always fire - * on some tested devices (Kindle Fire?) - */ - touchmove = function(e) { - // NOOP if the threshold has already been reached - if(this.threshold) return false; - - this.threshold = isThresholdReached(this.startXY, [e.touches[0].clientX, e.touches[0].clientY]); - }; - - /** - * touchend - * - * If the user didn't scroll past the threshold between - * touchstart and touchend, fire a simulated click. - * - * (This will fire before a native click) - */ - touchend = function(e) { - // Don't fire a click if the user scrolled past the threshold - if(this.threshold || isThresholdReached(this.startXY, [e.changedTouches[0].clientX, e.changedTouches[0].clientY])) { - return; - } - - /** - * Create and fire a click event on the target element - * https://developer.mozilla.org/en/DOM/event.initMouseEvent - */ - var touch = e.changedTouches[0], - evt = document.createEvent('MouseEvents'); - evt.initMouseEvent('click', true, true, window, 0, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null); - evt.simulated = true; // distinguish from a normal (nonsimulated) click - e.target.dispatchEvent(evt); - }; - - /** - * click - * - * Because we've already fired a click event in touchend, - * we need to listed for all native click events here - * and suppress them as necessary. - */ - click = function(e) { - /** - * Prevent ghost clicks by only allowing clicks we created - * in the click event we fired (look for e.simulated) - */ - var time = Date.now(), - timeDiff = time - lastClick.time, - x = e.clientX, - y = e.clientY, - xyDiff = [Math.abs(lastClick.x - x), Math.abs(lastClick.y - y)], - target = closest(e.target, 'A') || e.target, // needed for standalone apps - nodeName = target.nodeName, - isLink = nodeName === 'A', - standAlone = window.navigator.standalone && isLink && e.target.getAttribute("href"); - - lastClick.time = time; - lastClick.x = x; - lastClick.y = y; - - /** - * Unfortunately Android sometimes fires click events without touch events (seen on Kindle Fire), - * so we have to add more logic to determine the time of the last click. Not perfect... - * - * Older, simpler check: if((!e.simulated) || standAlone) - */ - if((!e.simulated && (timeDiff < 500 || (timeDiff < 1500 && xyDiff[0] < 50 && xyDiff[1] < 50))) || standAlone) { - e.preventDefault(); - e.stopPropagation(); - if(!standAlone) return false; - } - - /** - * Special logic for standalone web apps - * See http://stackoverflow.com/questions/2898740/iphone-safari-web-app-opens-links-in-new-window - */ - if(standAlone) { - window.location = target.getAttribute("href"); - } - - /** - * Add an energize-focus class to the targeted link (mimics :focus behavior) - * TODO: test and/or remove? Does this work? - */ - if(!target || !target.classList) return; - target.classList.add("energize-focus"); - window.setTimeout(function(){ - target.classList.remove("energize-focus"); - }, 150); - }; - - /** - * closest - * @param {HTMLElement} node current node to start searching from. - * @param {string} tagName the (uppercase) name of the tag you're looking for. - * - * Find the closest ancestor tag of a given node. - * - * Starts at node and goes up the DOM tree looking for a - * matching nodeName, continuing until hitting document.body - */ - closest = function(node, tagName){ - var curNode = node; - - while(curNode !== document.body) { // go up the dom until we find the tag we're after - if(!curNode || curNode.nodeName === tagName) { return curNode; } // found - curNode = curNode.parentNode; // not found, so keep going up - } - - return null; // not found - }; - - /** - * Add all delegated event listeners - * - * All the events we care about bubble up to document, - * so we can take advantage of event delegation. - * - * Note: no need to wait for DOMContentLoaded here - */ - document.addEventListener('touchstart', touchstart, false); - document.addEventListener('touchmove', touchmove, false); - document.addEventListener('touchend', touchend, false); - document.addEventListener('click', click, true); // TODO: why does this use capture? - -})(); \ No newline at end of file diff --git a/source/javascripts/lib/_imagesloaded.min.js b/source/javascripts/lib/_imagesloaded.min.js deleted file mode 100644 index e443a77..0000000 --- a/source/javascripts/lib/_imagesloaded.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * imagesLoaded PACKAGED v4.1.4 - * JavaScript is all like "You images are done yet or what?" - * MIT License - */ - -!function(e,t){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",t):"object"==typeof module&&module.exports?module.exports=t():e.EvEmitter=t()}("undefined"!=typeof window?window:this,function(){function e(){}var t=e.prototype;return t.on=function(e,t){if(e&&t){var i=this._events=this._events||{},n=i[e]=i[e]||[];return n.indexOf(t)==-1&&n.push(t),this}},t.once=function(e,t){if(e&&t){this.on(e,t);var i=this._onceEvents=this._onceEvents||{},n=i[e]=i[e]||{};return n[t]=!0,this}},t.off=function(e,t){var i=this._events&&this._events[e];if(i&&i.length){var n=i.indexOf(t);return n!=-1&&i.splice(n,1),this}},t.emitEvent=function(e,t){var i=this._events&&this._events[e];if(i&&i.length){i=i.slice(0),t=t||[];for(var n=this._onceEvents&&this._onceEvents[e],o=0;o (default options) - * $('#content').highlight('lorem'); - * - * // search for and highlight more terms at once - * // so you can save some time on traversing DOM - * $('#content').highlight(['lorem', 'ipsum']); - * $('#content').highlight('lorem ipsum'); - * - * // search only for entire word 'lorem' - * $('#content').highlight('lorem', { wordsOnly: true }); - * - * // don't ignore case during search of term 'lorem' - * $('#content').highlight('lorem', { caseSensitive: true }); - * - * // wrap every occurrance of term 'ipsum' in content - * // with - * $('#content').highlight('ipsum', { element: 'em', className: 'important' }); - * - * // remove default highlight - * $('#content').unhighlight(); - * - * // remove custom highlight - * $('#content').unhighlight({ element: 'em', className: 'important' }); - * - * - * Copyright (c) 2009 Bartek Szopka - * - * Licensed under MIT license. - * - */ - -jQuery.extend({ - highlight: function (node, re, nodeName, className) { - if (node.nodeType === 3) { - var match = node.data.match(re); - if (match) { - var highlight = document.createElement(nodeName || 'span'); - highlight.className = className || 'highlight'; - var wordNode = node.splitText(match.index); - wordNode.splitText(match[0].length); - var wordClone = wordNode.cloneNode(true); - highlight.appendChild(wordClone); - wordNode.parentNode.replaceChild(highlight, wordNode); - return 1; //skip added node in parent - } - } else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children - !/(script|style)/i.test(node.tagName) && // ignore script and style nodes - !(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted - for (var i = 0; i < node.childNodes.length; i++) { - i += jQuery.highlight(node.childNodes[i], re, nodeName, className); - } - } - return 0; - } -}); - -jQuery.fn.unhighlight = function (options) { - var settings = { className: 'highlight', element: 'span' }; - jQuery.extend(settings, options); - - return this.find(settings.element + "." + settings.className).each(function () { - var parent = this.parentNode; - parent.replaceChild(this.firstChild, this); - parent.normalize(); - }).end(); -}; - -jQuery.fn.highlight = function (words, options) { - var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false }; - jQuery.extend(settings, options); - - if (words.constructor === String) { - words = [words]; - } - words = jQuery.grep(words, function(word, i){ - return word != ''; - }); - words = jQuery.map(words, function(word, i) { - return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); - }); - if (words.length == 0) { return this; }; - - var flag = settings.caseSensitive ? "" : "i"; - var pattern = "(" + words.join("|") + ")"; - if (settings.wordsOnly) { - pattern = "\\b" + pattern + "\\b"; - } - var re = new RegExp(pattern, flag); - - return this.each(function () { - jQuery.highlight(this, re, settings.element, settings.className); - }); -}; - diff --git a/source/javascripts/lib/_jquery.js b/source/javascripts/lib/_jquery.js deleted file mode 100644 index fc6c299..0000000 --- a/source/javascripts/lib/_jquery.js +++ /dev/null @@ -1,10881 +0,0 @@ -/*! - * jQuery JavaScript Library v3.6.0 - * https://jquery.com/ - * - * Includes Sizzle.js - * https://sizzlejs.com/ - * - * Copyright OpenJS Foundation and other contributors - * Released under the MIT license - * https://jquery.org/license - * - * Date: 2021-03-02T17:08Z - */ -( function( global, factory ) { - - "use strict"; - - if ( typeof module === "object" && typeof module.exports === "object" ) { - - // For CommonJS and CommonJS-like environments where a proper `window` - // is present, execute the factory and get jQuery. - // For environments that do not have a `window` with a `document` - // (such as Node.js), expose a factory as module.exports. - // This accentuates the need for the creation of a real `window`. - // e.g. var jQuery = require("jquery")(window); - // See ticket #14549 for more info. - module.exports = global.document ? - factory( global, true ) : - function( w ) { - if ( !w.document ) { - throw new Error( "jQuery requires a window with a document" ); - } - return factory( w ); - }; - } else { - factory( global ); - } - -// Pass this if window is not defined yet -} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { - -// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 -// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode -// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common -// enough that all such attempts are guarded in a try block. -"use strict"; - -var arr = []; - -var getProto = Object.getPrototypeOf; - -var slice = arr.slice; - -var flat = arr.flat ? function( array ) { - return arr.flat.call( array ); -} : function( array ) { - return arr.concat.apply( [], array ); -}; - - -var push = arr.push; - -var indexOf = arr.indexOf; - -var class2type = {}; - -var toString = class2type.toString; - -var hasOwn = class2type.hasOwnProperty; - -var fnToString = hasOwn.toString; - -var ObjectFunctionString = fnToString.call( Object ); - -var support = {}; - -var isFunction = function isFunction( obj ) { - - // Support: Chrome <=57, Firefox <=52 - // In some browsers, typeof returns "function" for HTML elements - // (i.e., `typeof document.createElement( "object" ) === "function"`). - // We don't want to classify *any* DOM node as a function. - // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5 - // Plus for old WebKit, typeof returns "function" for HTML collections - // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756) - return typeof obj === "function" && typeof obj.nodeType !== "number" && - typeof obj.item !== "function"; - }; - - -var isWindow = function isWindow( obj ) { - return obj != null && obj === obj.window; - }; - - -var document = window.document; - - - - var preservedScriptAttributes = { - type: true, - src: true, - nonce: true, - noModule: true - }; - - function DOMEval( code, node, doc ) { - doc = doc || document; - - var i, val, - script = doc.createElement( "script" ); - - script.text = code; - if ( node ) { - for ( i in preservedScriptAttributes ) { - - // Support: Firefox 64+, Edge 18+ - // Some browsers don't support the "nonce" property on scripts. - // On the other hand, just using `getAttribute` is not enough as - // the `nonce` attribute is reset to an empty string whenever it - // becomes browsing-context connected. - // See https://github.com/whatwg/html/issues/2369 - // See https://html.spec.whatwg.org/#nonce-attributes - // The `node.getAttribute` check was added for the sake of - // `jQuery.globalEval` so that it can fake a nonce-containing node - // via an object. - val = node[ i ] || node.getAttribute && node.getAttribute( i ); - if ( val ) { - script.setAttribute( i, val ); - } - } - } - doc.head.appendChild( script ).parentNode.removeChild( script ); - } - - -function toType( obj ) { - if ( obj == null ) { - return obj + ""; - } - - // Support: Android <=2.3 only (functionish RegExp) - return typeof obj === "object" || typeof obj === "function" ? - class2type[ toString.call( obj ) ] || "object" : - typeof obj; -} -/* global Symbol */ -// Defining this global in .eslintrc.json would create a danger of using the global -// unguarded in another place, it seems safer to define global only for this module - - - -var - version = "3.6.0", - - // Define a local copy of jQuery - jQuery = function( selector, context ) { - - // The jQuery object is actually just the init constructor 'enhanced' - // Need init if jQuery is called (just allow error to be thrown if not included) - return new jQuery.fn.init( selector, context ); - }; - -jQuery.fn = jQuery.prototype = { - - // The current version of jQuery being used - jquery: version, - - constructor: jQuery, - - // The default length of a jQuery object is 0 - length: 0, - - toArray: function() { - return slice.call( this ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - - // Return all the elements in a clean array - if ( num == null ) { - return slice.call( this ); - } - - // Return just the one element from the set - return num < 0 ? this[ num + this.length ] : this[ num ]; - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems ) { - - // Build a new jQuery matched element set - var ret = jQuery.merge( this.constructor(), elems ); - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - each: function( callback ) { - return jQuery.each( this, callback ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map( this, function( elem, i ) { - return callback.call( elem, i, elem ); - } ) ); - }, - - slice: function() { - return this.pushStack( slice.apply( this, arguments ) ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - even: function() { - return this.pushStack( jQuery.grep( this, function( _elem, i ) { - return ( i + 1 ) % 2; - } ) ); - }, - - odd: function() { - return this.pushStack( jQuery.grep( this, function( _elem, i ) { - return i % 2; - } ) ); - }, - - eq: function( i ) { - var len = this.length, - j = +i + ( i < 0 ? len : 0 ); - return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); - }, - - end: function() { - return this.prevObject || this.constructor(); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: push, - sort: arr.sort, - splice: arr.splice -}; - -jQuery.extend = jQuery.fn.extend = function() { - var options, name, src, copy, copyIsArray, clone, - target = arguments[ 0 ] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - - // Skip the boolean and the target - target = arguments[ i ] || {}; - i++; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !isFunction( target ) ) { - target = {}; - } - - // Extend jQuery itself if only one argument is passed - if ( i === length ) { - target = this; - i--; - } - - for ( ; i < length; i++ ) { - - // Only deal with non-null/undefined values - if ( ( options = arguments[ i ] ) != null ) { - - // Extend the base object - for ( name in options ) { - copy = options[ name ]; - - // Prevent Object.prototype pollution - // Prevent never-ending loop - if ( name === "__proto__" || target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject( copy ) || - ( copyIsArray = Array.isArray( copy ) ) ) ) { - src = target[ name ]; - - // Ensure proper type for the source value - if ( copyIsArray && !Array.isArray( src ) ) { - clone = []; - } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { - clone = {}; - } else { - clone = src; - } - copyIsArray = false; - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend( { - - // Unique for each copy of jQuery on the page - expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), - - // Assume jQuery is ready without the ready module - isReady: true, - - error: function( msg ) { - throw new Error( msg ); - }, - - noop: function() {}, - - isPlainObject: function( obj ) { - var proto, Ctor; - - // Detect obvious negatives - // Use toString instead of jQuery.type to catch host objects - if ( !obj || toString.call( obj ) !== "[object Object]" ) { - return false; - } - - proto = getProto( obj ); - - // Objects with no prototype (e.g., `Object.create( null )`) are plain - if ( !proto ) { - return true; - } - - // Objects with prototype are plain iff they were constructed by a global Object function - Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; - return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; - }, - - isEmptyObject: function( obj ) { - var name; - - for ( name in obj ) { - return false; - } - return true; - }, - - // Evaluates a script in a provided context; falls back to the global one - // if not specified. - globalEval: function( code, options, doc ) { - DOMEval( code, { nonce: options && options.nonce }, doc ); - }, - - each: function( obj, callback ) { - var length, i = 0; - - if ( isArrayLike( obj ) ) { - length = obj.length; - for ( ; i < length; i++ ) { - if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { - break; - } - } - } else { - for ( i in obj ) { - if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { - break; - } - } - } - - return obj; - }, - - // results is for internal usage only - makeArray: function( arr, results ) { - var ret = results || []; - - if ( arr != null ) { - if ( isArrayLike( Object( arr ) ) ) { - jQuery.merge( ret, - typeof arr === "string" ? - [ arr ] : arr - ); - } else { - push.call( ret, arr ); - } - } - - return ret; - }, - - inArray: function( elem, arr, i ) { - return arr == null ? -1 : indexOf.call( arr, elem, i ); - }, - - // Support: Android <=4.0 only, PhantomJS 1 only - // push.apply(_, arraylike) throws on ancient WebKit - merge: function( first, second ) { - var len = +second.length, - j = 0, - i = first.length; - - for ( ; j < len; j++ ) { - first[ i++ ] = second[ j ]; - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, invert ) { - var callbackInverse, - matches = [], - i = 0, - length = elems.length, - callbackExpect = !invert; - - // Go through the array, only saving the items - // that pass the validator function - for ( ; i < length; i++ ) { - callbackInverse = !callback( elems[ i ], i ); - if ( callbackInverse !== callbackExpect ) { - matches.push( elems[ i ] ); - } - } - - return matches; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var length, value, - i = 0, - ret = []; - - // Go through the array, translating each of the items to their new values - if ( isArrayLike( elems ) ) { - length = elems.length; - for ( ; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret.push( value ); - } - } - - // Go through every key on the object, - } else { - for ( i in elems ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret.push( value ); - } - } - } - - // Flatten any nested arrays - return flat( ret ); - }, - - // A global GUID counter for objects - guid: 1, - - // jQuery.support is not used in Core but other projects attach their - // properties to it so it needs to exist. - support: support -} ); - -if ( typeof Symbol === "function" ) { - jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; -} - -// Populate the class2type map -jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), - function( _i, name ) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); - } ); - -function isArrayLike( obj ) { - - // Support: real iOS 8.2 only (not reproducible in simulator) - // `in` check used to prevent JIT error (gh-2145) - // hasOwn isn't used here due to false negatives - // regarding Nodelist length in IE - var length = !!obj && "length" in obj && obj.length, - type = toType( obj ); - - if ( isFunction( obj ) || isWindow( obj ) ) { - return false; - } - - return type === "array" || length === 0 || - typeof length === "number" && length > 0 && ( length - 1 ) in obj; -} -var Sizzle = -/*! - * Sizzle CSS Selector Engine v2.3.6 - * https://sizzlejs.com/ - * - * Copyright JS Foundation and other contributors - * Released under the MIT license - * https://js.foundation/ - * - * Date: 2021-02-16 - */ -( function( window ) { -var i, - support, - Expr, - getText, - isXML, - tokenize, - compile, - select, - outermostContext, - sortInput, - hasDuplicate, - - // Local document vars - setDocument, - document, - docElem, - documentIsHTML, - rbuggyQSA, - rbuggyMatches, - matches, - contains, - - // Instance-specific data - expando = "sizzle" + 1 * new Date(), - preferredDoc = window.document, - dirruns = 0, - done = 0, - classCache = createCache(), - tokenCache = createCache(), - compilerCache = createCache(), - nonnativeSelectorCache = createCache(), - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - } - return 0; - }, - - // Instance methods - hasOwn = ( {} ).hasOwnProperty, - arr = [], - pop = arr.pop, - pushNative = arr.push, - push = arr.push, - slice = arr.slice, - - // Use a stripped-down indexOf as it's faster than native - // https://jsperf.com/thor-indexof-vs-for/5 - indexOf = function( list, elem ) { - var i = 0, - len = list.length; - for ( ; i < len; i++ ) { - if ( list[ i ] === elem ) { - return i; - } - } - return -1; - }, - - booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" + - "ismap|loop|multiple|open|readonly|required|scoped", - - // Regular expressions - - // http://www.w3.org/TR/css3-selectors/#whitespace - whitespace = "[\\x20\\t\\r\\n\\f]", - - // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram - identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + - "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", - - // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors - attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + - - // Operator (capture 2) - "*([*^$|!~]?=)" + whitespace + - - // "Attribute values must be CSS identifiers [capture 5] - // or strings [capture 3 or capture 4]" - "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + - whitespace + "*\\]", - - pseudos = ":(" + identifier + ")(?:\\((" + - - // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: - // 1. quoted (capture 3; capture 4 or capture 5) - "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + - - // 2. simple (capture 6) - "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + - - // 3. anything else (capture 2) - ".*" + - ")\\)|)", - - // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter - rwhitespace = new RegExp( whitespace + "+", "g" ), - rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + - whitespace + "+$", "g" ), - - rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), - rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + - "*" ), - rdescend = new RegExp( whitespace + "|>" ), - - rpseudo = new RegExp( pseudos ), - ridentifier = new RegExp( "^" + identifier + "$" ), - - matchExpr = { - "ID": new RegExp( "^#(" + identifier + ")" ), - "CLASS": new RegExp( "^\\.(" + identifier + ")" ), - "TAG": new RegExp( "^(" + identifier + "|[*])" ), - "ATTR": new RegExp( "^" + attributes ), - "PSEUDO": new RegExp( "^" + pseudos ), - "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + - whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + - whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), - "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), - - // For use in libraries implementing .is() - // We use this for POS matching in `select` - "needsContext": new RegExp( "^" + whitespace + - "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + - "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) - }, - - rhtml = /HTML$/i, - rinputs = /^(?:input|select|textarea|button)$/i, - rheader = /^h\d$/i, - - rnative = /^[^{]+\{\s*\[native \w/, - - // Easily-parseable/retrievable ID or TAG or CLASS selectors - rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, - - rsibling = /[+~]/, - - // CSS escapes - // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters - runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ), - funescape = function( escape, nonHex ) { - var high = "0x" + escape.slice( 1 ) - 0x10000; - - return nonHex ? - - // Strip the backslash prefix from a non-hex escape sequence - nonHex : - - // Replace a hexadecimal escape sequence with the encoded Unicode code point - // Support: IE <=11+ - // For values outside the Basic Multilingual Plane (BMP), manually construct a - // surrogate pair - high < 0 ? - String.fromCharCode( high + 0x10000 ) : - String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); - }, - - // CSS string/identifier serialization - // https://drafts.csswg.org/cssom/#common-serializing-idioms - rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, - fcssescape = function( ch, asCodePoint ) { - if ( asCodePoint ) { - - // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER - if ( ch === "\0" ) { - return "\uFFFD"; - } - - // Control characters and (dependent upon position) numbers get escaped as code points - return ch.slice( 0, -1 ) + "\\" + - ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; - } - - // Other potentially-special ASCII characters get backslash-escaped - return "\\" + ch; - }, - - // Used for iframes - // See setDocument() - // Removing the function wrapper causes a "Permission Denied" - // error in IE - unloadHandler = function() { - setDocument(); - }, - - inDisabledFieldset = addCombinator( - function( elem ) { - return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; - }, - { dir: "parentNode", next: "legend" } - ); - -// Optimize for push.apply( _, NodeList ) -try { - push.apply( - ( arr = slice.call( preferredDoc.childNodes ) ), - preferredDoc.childNodes - ); - - // Support: Android<4.0 - // Detect silently failing push.apply - // eslint-disable-next-line no-unused-expressions - arr[ preferredDoc.childNodes.length ].nodeType; -} catch ( e ) { - push = { apply: arr.length ? - - // Leverage slice if possible - function( target, els ) { - pushNative.apply( target, slice.call( els ) ); - } : - - // Support: IE<9 - // Otherwise append directly - function( target, els ) { - var j = target.length, - i = 0; - - // Can't trust NodeList.length - while ( ( target[ j++ ] = els[ i++ ] ) ) {} - target.length = j - 1; - } - }; -} - -function Sizzle( selector, context, results, seed ) { - var m, i, elem, nid, match, groups, newSelector, - newContext = context && context.ownerDocument, - - // nodeType defaults to 9, since context defaults to document - nodeType = context ? context.nodeType : 9; - - results = results || []; - - // Return early from calls with invalid selector or context - if ( typeof selector !== "string" || !selector || - nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { - - return results; - } - - // Try to shortcut find operations (as opposed to filters) in HTML documents - if ( !seed ) { - setDocument( context ); - context = context || document; - - if ( documentIsHTML ) { - - // If the selector is sufficiently simple, try using a "get*By*" DOM method - // (excepting DocumentFragment context, where the methods don't exist) - if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { - - // ID selector - if ( ( m = match[ 1 ] ) ) { - - // Document context - if ( nodeType === 9 ) { - if ( ( elem = context.getElementById( m ) ) ) { - - // Support: IE, Opera, Webkit - // TODO: identify versions - // getElementById can match elements by name instead of ID - if ( elem.id === m ) { - results.push( elem ); - return results; - } - } else { - return results; - } - - // Element context - } else { - - // Support: IE, Opera, Webkit - // TODO: identify versions - // getElementById can match elements by name instead of ID - if ( newContext && ( elem = newContext.getElementById( m ) ) && - contains( context, elem ) && - elem.id === m ) { - - results.push( elem ); - return results; - } - } - - // Type selector - } else if ( match[ 2 ] ) { - push.apply( results, context.getElementsByTagName( selector ) ); - return results; - - // Class selector - } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName && - context.getElementsByClassName ) { - - push.apply( results, context.getElementsByClassName( m ) ); - return results; - } - } - - // Take advantage of querySelectorAll - if ( support.qsa && - !nonnativeSelectorCache[ selector + " " ] && - ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) && - - // Support: IE 8 only - // Exclude object elements - ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) { - - newSelector = selector; - newContext = context; - - // qSA considers elements outside a scoping root when evaluating child or - // descendant combinators, which is not what we want. - // In such cases, we work around the behavior by prefixing every selector in the - // list with an ID selector referencing the scope context. - // The technique has to be used as well when a leading combinator is used - // as such selectors are not recognized by querySelectorAll. - // Thanks to Andrew Dupont for this technique. - if ( nodeType === 1 && - ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) { - - // Expand context for sibling selectors - newContext = rsibling.test( selector ) && testContext( context.parentNode ) || - context; - - // We can use :scope instead of the ID hack if the browser - // supports it & if we're not changing the context. - if ( newContext !== context || !support.scope ) { - - // Capture the context ID, setting it first if necessary - if ( ( nid = context.getAttribute( "id" ) ) ) { - nid = nid.replace( rcssescape, fcssescape ); - } else { - context.setAttribute( "id", ( nid = expando ) ); - } - } - - // Prefix every selector in the list - groups = tokenize( selector ); - i = groups.length; - while ( i-- ) { - groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + - toSelector( groups[ i ] ); - } - newSelector = groups.join( "," ); - } - - try { - push.apply( results, - newContext.querySelectorAll( newSelector ) - ); - return results; - } catch ( qsaError ) { - nonnativeSelectorCache( selector, true ); - } finally { - if ( nid === expando ) { - context.removeAttribute( "id" ); - } - } - } - } - } - - // All others - return select( selector.replace( rtrim, "$1" ), context, results, seed ); -} - -/** - * Create key-value caches of limited size - * @returns {function(string, object)} Returns the Object data after storing it on itself with - * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) - * deleting the oldest entry - */ -function createCache() { - var keys = []; - - function cache( key, value ) { - - // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) - if ( keys.push( key + " " ) > Expr.cacheLength ) { - - // Only keep the most recent entries - delete cache[ keys.shift() ]; - } - return ( cache[ key + " " ] = value ); - } - return cache; -} - -/** - * Mark a function for special use by Sizzle - * @param {Function} fn The function to mark - */ -function markFunction( fn ) { - fn[ expando ] = true; - return fn; -} - -/** - * Support testing using an element - * @param {Function} fn Passed the created element and returns a boolean result - */ -function assert( fn ) { - var el = document.createElement( "fieldset" ); - - try { - return !!fn( el ); - } catch ( e ) { - return false; - } finally { - - // Remove from its parent by default - if ( el.parentNode ) { - el.parentNode.removeChild( el ); - } - - // release memory in IE - el = null; - } -} - -/** - * Adds the same handler for all of the specified attrs - * @param {String} attrs Pipe-separated list of attributes - * @param {Function} handler The method that will be applied - */ -function addHandle( attrs, handler ) { - var arr = attrs.split( "|" ), - i = arr.length; - - while ( i-- ) { - Expr.attrHandle[ arr[ i ] ] = handler; - } -} - -/** - * Checks document order of two siblings - * @param {Element} a - * @param {Element} b - * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b - */ -function siblingCheck( a, b ) { - var cur = b && a, - diff = cur && a.nodeType === 1 && b.nodeType === 1 && - a.sourceIndex - b.sourceIndex; - - // Use IE sourceIndex if available on both nodes - if ( diff ) { - return diff; - } - - // Check if b follows a - if ( cur ) { - while ( ( cur = cur.nextSibling ) ) { - if ( cur === b ) { - return -1; - } - } - } - - return a ? 1 : -1; -} - -/** - * Returns a function to use in pseudos for input types - * @param {String} type - */ -function createInputPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === type; - }; -} - -/** - * Returns a function to use in pseudos for buttons - * @param {String} type - */ -function createButtonPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return ( name === "input" || name === "button" ) && elem.type === type; - }; -} - -/** - * Returns a function to use in pseudos for :enabled/:disabled - * @param {Boolean} disabled true for :disabled; false for :enabled - */ -function createDisabledPseudo( disabled ) { - - // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable - return function( elem ) { - - // Only certain elements can match :enabled or :disabled - // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled - // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled - if ( "form" in elem ) { - - // Check for inherited disabledness on relevant non-disabled elements: - // * listed form-associated elements in a disabled fieldset - // https://html.spec.whatwg.org/multipage/forms.html#category-listed - // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled - // * option elements in a disabled optgroup - // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled - // All such elements have a "form" property. - if ( elem.parentNode && elem.disabled === false ) { - - // Option elements defer to a parent optgroup if present - if ( "label" in elem ) { - if ( "label" in elem.parentNode ) { - return elem.parentNode.disabled === disabled; - } else { - return elem.disabled === disabled; - } - } - - // Support: IE 6 - 11 - // Use the isDisabled shortcut property to check for disabled fieldset ancestors - return elem.isDisabled === disabled || - - // Where there is no isDisabled, check manually - /* jshint -W018 */ - elem.isDisabled !== !disabled && - inDisabledFieldset( elem ) === disabled; - } - - return elem.disabled === disabled; - - // Try to winnow out elements that can't be disabled before trusting the disabled property. - // Some victims get caught in our net (label, legend, menu, track), but it shouldn't - // even exist on them, let alone have a boolean value. - } else if ( "label" in elem ) { - return elem.disabled === disabled; - } - - // Remaining elements are neither :enabled nor :disabled - return false; - }; -} - -/** - * Returns a function to use in pseudos for positionals - * @param {Function} fn - */ -function createPositionalPseudo( fn ) { - return markFunction( function( argument ) { - argument = +argument; - return markFunction( function( seed, matches ) { - var j, - matchIndexes = fn( [], seed.length, argument ), - i = matchIndexes.length; - - // Match elements found at the specified indexes - while ( i-- ) { - if ( seed[ ( j = matchIndexes[ i ] ) ] ) { - seed[ j ] = !( matches[ j ] = seed[ j ] ); - } - } - } ); - } ); -} - -/** - * Checks a node for validity as a Sizzle context - * @param {Element|Object=} context - * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value - */ -function testContext( context ) { - return context && typeof context.getElementsByTagName !== "undefined" && context; -} - -// Expose support vars for convenience -support = Sizzle.support = {}; - -/** - * Detects XML nodes - * @param {Element|Object} elem An element or a document - * @returns {Boolean} True iff elem is a non-HTML XML node - */ -isXML = Sizzle.isXML = function( elem ) { - var namespace = elem && elem.namespaceURI, - docElem = elem && ( elem.ownerDocument || elem ).documentElement; - - // Support: IE <=8 - // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes - // https://bugs.jquery.com/ticket/4833 - return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); -}; - -/** - * Sets document-related variables once based on the current document - * @param {Element|Object} [doc] An element or document object to use to set the document - * @returns {Object} Returns the current document - */ -setDocument = Sizzle.setDocument = function( node ) { - var hasCompare, subWindow, - doc = node ? node.ownerDocument || node : preferredDoc; - - // Return early if doc is invalid or already selected - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { - return document; - } - - // Update global variables - document = doc; - docElem = document.documentElement; - documentIsHTML = !isXML( document ); - - // Support: IE 9 - 11+, Edge 12 - 18+ - // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - if ( preferredDoc != document && - ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { - - // Support: IE 11, Edge - if ( subWindow.addEventListener ) { - subWindow.addEventListener( "unload", unloadHandler, false ); - - // Support: IE 9 - 10 only - } else if ( subWindow.attachEvent ) { - subWindow.attachEvent( "onunload", unloadHandler ); - } - } - - // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only, - // Safari 4 - 5 only, Opera <=11.6 - 12.x only - // IE/Edge & older browsers don't support the :scope pseudo-class. - // Support: Safari 6.0 only - // Safari 6.0 supports :scope but it's an alias of :root there. - support.scope = assert( function( el ) { - docElem.appendChild( el ).appendChild( document.createElement( "div" ) ); - return typeof el.querySelectorAll !== "undefined" && - !el.querySelectorAll( ":scope fieldset div" ).length; - } ); - - /* Attributes - ---------------------------------------------------------------------- */ - - // Support: IE<8 - // Verify that getAttribute really returns attributes and not properties - // (excepting IE8 booleans) - support.attributes = assert( function( el ) { - el.className = "i"; - return !el.getAttribute( "className" ); - } ); - - /* getElement(s)By* - ---------------------------------------------------------------------- */ - - // Check if getElementsByTagName("*") returns only elements - support.getElementsByTagName = assert( function( el ) { - el.appendChild( document.createComment( "" ) ); - return !el.getElementsByTagName( "*" ).length; - } ); - - // Support: IE<9 - support.getElementsByClassName = rnative.test( document.getElementsByClassName ); - - // Support: IE<10 - // Check if getElementById returns elements by name - // The broken getElementById methods don't pick up programmatically-set names, - // so use a roundabout getElementsByName test - support.getById = assert( function( el ) { - docElem.appendChild( el ).id = expando; - return !document.getElementsByName || !document.getElementsByName( expando ).length; - } ); - - // ID filter and find - if ( support.getById ) { - Expr.filter[ "ID" ] = function( id ) { - var attrId = id.replace( runescape, funescape ); - return function( elem ) { - return elem.getAttribute( "id" ) === attrId; - }; - }; - Expr.find[ "ID" ] = function( id, context ) { - if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { - var elem = context.getElementById( id ); - return elem ? [ elem ] : []; - } - }; - } else { - Expr.filter[ "ID" ] = function( id ) { - var attrId = id.replace( runescape, funescape ); - return function( elem ) { - var node = typeof elem.getAttributeNode !== "undefined" && - elem.getAttributeNode( "id" ); - return node && node.value === attrId; - }; - }; - - // Support: IE 6 - 7 only - // getElementById is not reliable as a find shortcut - Expr.find[ "ID" ] = function( id, context ) { - if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { - var node, i, elems, - elem = context.getElementById( id ); - - if ( elem ) { - - // Verify the id attribute - node = elem.getAttributeNode( "id" ); - if ( node && node.value === id ) { - return [ elem ]; - } - - // Fall back on getElementsByName - elems = context.getElementsByName( id ); - i = 0; - while ( ( elem = elems[ i++ ] ) ) { - node = elem.getAttributeNode( "id" ); - if ( node && node.value === id ) { - return [ elem ]; - } - } - } - - return []; - } - }; - } - - // Tag - Expr.find[ "TAG" ] = support.getElementsByTagName ? - function( tag, context ) { - if ( typeof context.getElementsByTagName !== "undefined" ) { - return context.getElementsByTagName( tag ); - - // DocumentFragment nodes don't have gEBTN - } else if ( support.qsa ) { - return context.querySelectorAll( tag ); - } - } : - - function( tag, context ) { - var elem, - tmp = [], - i = 0, - - // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too - results = context.getElementsByTagName( tag ); - - // Filter out possible comments - if ( tag === "*" ) { - while ( ( elem = results[ i++ ] ) ) { - if ( elem.nodeType === 1 ) { - tmp.push( elem ); - } - } - - return tmp; - } - return results; - }; - - // Class - Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) { - if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { - return context.getElementsByClassName( className ); - } - }; - - /* QSA/matchesSelector - ---------------------------------------------------------------------- */ - - // QSA and matchesSelector support - - // matchesSelector(:active) reports false when true (IE9/Opera 11.5) - rbuggyMatches = []; - - // qSa(:focus) reports false when true (Chrome 21) - // We allow this because of a bug in IE8/9 that throws an error - // whenever `document.activeElement` is accessed on an iframe - // So, we allow :focus to pass through QSA all the time to avoid the IE error - // See https://bugs.jquery.com/ticket/13378 - rbuggyQSA = []; - - if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) { - - // Build QSA regex - // Regex strategy adopted from Diego Perini - assert( function( el ) { - - var input; - - // Select is set to empty string on purpose - // This is to test IE's treatment of not explicitly - // setting a boolean content attribute, - // since its presence should be enough - // https://bugs.jquery.com/ticket/12359 - docElem.appendChild( el ).innerHTML = "" + - ""; - - // Support: IE8, Opera 11-12.16 - // Nothing should be selected when empty strings follow ^= or $= or *= - // The test attribute must be unknown in Opera but "safe" for WinRT - // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section - if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) { - rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); - } - - // Support: IE8 - // Boolean attributes and "value" are not treated correctly - if ( !el.querySelectorAll( "[selected]" ).length ) { - rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); - } - - // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ - if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { - rbuggyQSA.push( "~=" ); - } - - // Support: IE 11+, Edge 15 - 18+ - // IE 11/Edge don't find elements on a `[name='']` query in some cases. - // Adding a temporary attribute to the document before the selection works - // around the issue. - // Interestingly, IE 10 & older don't seem to have the issue. - input = document.createElement( "input" ); - input.setAttribute( "name", "" ); - el.appendChild( input ); - if ( !el.querySelectorAll( "[name='']" ).length ) { - rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + - whitespace + "*(?:''|\"\")" ); - } - - // Webkit/Opera - :checked should return selected option elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - // IE8 throws error here and will not see later tests - if ( !el.querySelectorAll( ":checked" ).length ) { - rbuggyQSA.push( ":checked" ); - } - - // Support: Safari 8+, iOS 8+ - // https://bugs.webkit.org/show_bug.cgi?id=136851 - // In-page `selector#id sibling-combinator selector` fails - if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { - rbuggyQSA.push( ".#.+[+~]" ); - } - - // Support: Firefox <=3.6 - 5 only - // Old Firefox doesn't throw on a badly-escaped identifier. - el.querySelectorAll( "\\\f" ); - rbuggyQSA.push( "[\\r\\n\\f]" ); - } ); - - assert( function( el ) { - el.innerHTML = "" + - ""; - - // Support: Windows 8 Native Apps - // The type and name attributes are restricted during .innerHTML assignment - var input = document.createElement( "input" ); - input.setAttribute( "type", "hidden" ); - el.appendChild( input ).setAttribute( "name", "D" ); - - // Support: IE8 - // Enforce case-sensitivity of name attribute - if ( el.querySelectorAll( "[name=d]" ).length ) { - rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); - } - - // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) - // IE8 throws error here and will not see later tests - if ( el.querySelectorAll( ":enabled" ).length !== 2 ) { - rbuggyQSA.push( ":enabled", ":disabled" ); - } - - // Support: IE9-11+ - // IE's :disabled selector does not pick up the children of disabled fieldsets - docElem.appendChild( el ).disabled = true; - if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { - rbuggyQSA.push( ":enabled", ":disabled" ); - } - - // Support: Opera 10 - 11 only - // Opera 10-11 does not throw on post-comma invalid pseudos - el.querySelectorAll( "*,:x" ); - rbuggyQSA.push( ",.*:" ); - } ); - } - - if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches || - docElem.webkitMatchesSelector || - docElem.mozMatchesSelector || - docElem.oMatchesSelector || - docElem.msMatchesSelector ) ) ) ) { - - assert( function( el ) { - - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9) - support.disconnectedMatch = matches.call( el, "*" ); - - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( el, "[s!='']:x" ); - rbuggyMatches.push( "!=", pseudos ); - } ); - } - - rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); - rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); - - /* Contains - ---------------------------------------------------------------------- */ - hasCompare = rnative.test( docElem.compareDocumentPosition ); - - // Element contains another - // Purposefully self-exclusive - // As in, an element does not contain itself - contains = hasCompare || rnative.test( docElem.contains ) ? - function( a, b ) { - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - return a === bup || !!( bup && bup.nodeType === 1 && ( - adown.contains ? - adown.contains( bup ) : - a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 - ) ); - } : - function( a, b ) { - if ( b ) { - while ( ( b = b.parentNode ) ) { - if ( b === a ) { - return true; - } - } - } - return false; - }; - - /* Sorting - ---------------------------------------------------------------------- */ - - // Document order sorting - sortOrder = hasCompare ? - function( a, b ) { - - // Flag for duplicate removal - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - // Sort on method existence if only one input has compareDocumentPosition - var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; - if ( compare ) { - return compare; - } - - // Calculate position if both inputs belong to the same document - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? - a.compareDocumentPosition( b ) : - - // Otherwise we know they are disconnected - 1; - - // Disconnected nodes - if ( compare & 1 || - ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { - - // Choose the first element that is related to our preferred document - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - if ( a == document || a.ownerDocument == preferredDoc && - contains( preferredDoc, a ) ) { - return -1; - } - - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - if ( b == document || b.ownerDocument == preferredDoc && - contains( preferredDoc, b ) ) { - return 1; - } - - // Maintain original order - return sortInput ? - ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : - 0; - } - - return compare & 4 ? -1 : 1; - } : - function( a, b ) { - - // Exit early if the nodes are identical - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - var cur, - i = 0, - aup = a.parentNode, - bup = b.parentNode, - ap = [ a ], - bp = [ b ]; - - // Parentless nodes are either documents or disconnected - if ( !aup || !bup ) { - - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - /* eslint-disable eqeqeq */ - return a == document ? -1 : - b == document ? 1 : - /* eslint-enable eqeqeq */ - aup ? -1 : - bup ? 1 : - sortInput ? - ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : - 0; - - // If the nodes are siblings, we can do a quick check - } else if ( aup === bup ) { - return siblingCheck( a, b ); - } - - // Otherwise we need full lists of their ancestors for comparison - cur = a; - while ( ( cur = cur.parentNode ) ) { - ap.unshift( cur ); - } - cur = b; - while ( ( cur = cur.parentNode ) ) { - bp.unshift( cur ); - } - - // Walk down the tree looking for a discrepancy - while ( ap[ i ] === bp[ i ] ) { - i++; - } - - return i ? - - // Do a sibling check if the nodes have a common ancestor - siblingCheck( ap[ i ], bp[ i ] ) : - - // Otherwise nodes in our document sort first - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - /* eslint-disable eqeqeq */ - ap[ i ] == preferredDoc ? -1 : - bp[ i ] == preferredDoc ? 1 : - /* eslint-enable eqeqeq */ - 0; - }; - - return document; -}; - -Sizzle.matches = function( expr, elements ) { - return Sizzle( expr, null, null, elements ); -}; - -Sizzle.matchesSelector = function( elem, expr ) { - setDocument( elem ); - - if ( support.matchesSelector && documentIsHTML && - !nonnativeSelectorCache[ expr + " " ] && - ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && - ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { - - try { - var ret = matches.call( elem, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || support.disconnectedMatch || - - // As well, disconnected nodes are said to be in a document - // fragment in IE 9 - elem.document && elem.document.nodeType !== 11 ) { - return ret; - } - } catch ( e ) { - nonnativeSelectorCache( expr, true ); - } - } - - return Sizzle( expr, document, null, [ elem ] ).length > 0; -}; - -Sizzle.contains = function( context, elem ) { - - // Set document vars if needed - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - if ( ( context.ownerDocument || context ) != document ) { - setDocument( context ); - } - return contains( context, elem ); -}; - -Sizzle.attr = function( elem, name ) { - - // Set document vars if needed - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - if ( ( elem.ownerDocument || elem ) != document ) { - setDocument( elem ); - } - - var fn = Expr.attrHandle[ name.toLowerCase() ], - - // Don't get fooled by Object.prototype properties (jQuery #13807) - val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? - fn( elem, name, !documentIsHTML ) : - undefined; - - return val !== undefined ? - val : - support.attributes || !documentIsHTML ? - elem.getAttribute( name ) : - ( val = elem.getAttributeNode( name ) ) && val.specified ? - val.value : - null; -}; - -Sizzle.escape = function( sel ) { - return ( sel + "" ).replace( rcssescape, fcssescape ); -}; - -Sizzle.error = function( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); -}; - -/** - * Document sorting and removing duplicates - * @param {ArrayLike} results - */ -Sizzle.uniqueSort = function( results ) { - var elem, - duplicates = [], - j = 0, - i = 0; - - // Unless we *know* we can detect duplicates, assume their presence - hasDuplicate = !support.detectDuplicates; - sortInput = !support.sortStable && results.slice( 0 ); - results.sort( sortOrder ); - - if ( hasDuplicate ) { - while ( ( elem = results[ i++ ] ) ) { - if ( elem === results[ i ] ) { - j = duplicates.push( i ); - } - } - while ( j-- ) { - results.splice( duplicates[ j ], 1 ); - } - } - - // Clear input after sorting to release objects - // See https://github.com/jquery/sizzle/pull/225 - sortInput = null; - - return results; -}; - -/** - * Utility function for retrieving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ -getText = Sizzle.getText = function( elem ) { - var node, - ret = "", - i = 0, - nodeType = elem.nodeType; - - if ( !nodeType ) { - - // If no nodeType, this is expected to be an array - while ( ( node = elem[ i++ ] ) ) { - - // Do not traverse comment nodes - ret += getText( node ); - } - } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { - - // Use textContent for elements - // innerText usage removed for consistency of new lines (jQuery #11153) - if ( typeof elem.textContent === "string" ) { - return elem.textContent; - } else { - - // Traverse its children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - ret += getText( elem ); - } - } - } else if ( nodeType === 3 || nodeType === 4 ) { - return elem.nodeValue; - } - - // Do not include comment or processing instruction nodes - - return ret; -}; - -Expr = Sizzle.selectors = { - - // Can be adjusted by the user - cacheLength: 50, - - createPseudo: markFunction, - - match: matchExpr, - - attrHandle: {}, - - find: {}, - - relative: { - ">": { dir: "parentNode", first: true }, - " ": { dir: "parentNode" }, - "+": { dir: "previousSibling", first: true }, - "~": { dir: "previousSibling" } - }, - - preFilter: { - "ATTR": function( match ) { - match[ 1 ] = match[ 1 ].replace( runescape, funescape ); - - // Move the given value to match[3] whether quoted or unquoted - match[ 3 ] = ( match[ 3 ] || match[ 4 ] || - match[ 5 ] || "" ).replace( runescape, funescape ); - - if ( match[ 2 ] === "~=" ) { - match[ 3 ] = " " + match[ 3 ] + " "; - } - - return match.slice( 0, 4 ); - }, - - "CHILD": function( match ) { - - /* matches from matchExpr["CHILD"] - 1 type (only|nth|...) - 2 what (child|of-type) - 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) - 4 xn-component of xn+y argument ([+-]?\d*n|) - 5 sign of xn-component - 6 x of xn-component - 7 sign of y-component - 8 y of y-component - */ - match[ 1 ] = match[ 1 ].toLowerCase(); - - if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { - - // nth-* requires argument - if ( !match[ 3 ] ) { - Sizzle.error( match[ 0 ] ); - } - - // numeric x and y parameters for Expr.filter.CHILD - // remember that false/true cast respectively to 0/1 - match[ 4 ] = +( match[ 4 ] ? - match[ 5 ] + ( match[ 6 ] || 1 ) : - 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) ); - match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); - - // other types prohibit arguments - } else if ( match[ 3 ] ) { - Sizzle.error( match[ 0 ] ); - } - - return match; - }, - - "PSEUDO": function( match ) { - var excess, - unquoted = !match[ 6 ] && match[ 2 ]; - - if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) { - return null; - } - - // Accept quoted arguments as-is - if ( match[ 3 ] ) { - match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; - - // Strip excess characters from unquoted arguments - } else if ( unquoted && rpseudo.test( unquoted ) && - - // Get excess from tokenize (recursively) - ( excess = tokenize( unquoted, true ) ) && - - // advance to the next closing parenthesis - ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { - - // excess is a negative index - match[ 0 ] = match[ 0 ].slice( 0, excess ); - match[ 2 ] = unquoted.slice( 0, excess ); - } - - // Return only captures needed by the pseudo filter method (type and argument) - return match.slice( 0, 3 ); - } - }, - - filter: { - - "TAG": function( nodeNameSelector ) { - var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); - return nodeNameSelector === "*" ? - function() { - return true; - } : - function( elem ) { - return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; - }; - }, - - "CLASS": function( className ) { - var pattern = classCache[ className + " " ]; - - return pattern || - ( pattern = new RegExp( "(^|" + whitespace + - ")" + className + "(" + whitespace + "|$)" ) ) && classCache( - className, function( elem ) { - return pattern.test( - typeof elem.className === "string" && elem.className || - typeof elem.getAttribute !== "undefined" && - elem.getAttribute( "class" ) || - "" - ); - } ); - }, - - "ATTR": function( name, operator, check ) { - return function( elem ) { - var result = Sizzle.attr( elem, name ); - - if ( result == null ) { - return operator === "!="; - } - if ( !operator ) { - return true; - } - - result += ""; - - /* eslint-disable max-len */ - - return operator === "=" ? result === check : - operator === "!=" ? result !== check : - operator === "^=" ? check && result.indexOf( check ) === 0 : - operator === "*=" ? check && result.indexOf( check ) > -1 : - operator === "$=" ? check && result.slice( -check.length ) === check : - operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : - operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : - false; - /* eslint-enable max-len */ - - }; - }, - - "CHILD": function( type, what, _argument, first, last ) { - var simple = type.slice( 0, 3 ) !== "nth", - forward = type.slice( -4 ) !== "last", - ofType = what === "of-type"; - - return first === 1 && last === 0 ? - - // Shortcut for :nth-*(n) - function( elem ) { - return !!elem.parentNode; - } : - - function( elem, _context, xml ) { - var cache, uniqueCache, outerCache, node, nodeIndex, start, - dir = simple !== forward ? "nextSibling" : "previousSibling", - parent = elem.parentNode, - name = ofType && elem.nodeName.toLowerCase(), - useCache = !xml && !ofType, - diff = false; - - if ( parent ) { - - // :(first|last|only)-(child|of-type) - if ( simple ) { - while ( dir ) { - node = elem; - while ( ( node = node[ dir ] ) ) { - if ( ofType ? - node.nodeName.toLowerCase() === name : - node.nodeType === 1 ) { - - return false; - } - } - - // Reverse direction for :only-* (if we haven't yet done so) - start = dir = type === "only" && !start && "nextSibling"; - } - return true; - } - - start = [ forward ? parent.firstChild : parent.lastChild ]; - - // non-xml :nth-child(...) stores cache data on `parent` - if ( forward && useCache ) { - - // Seek `elem` from a previously-cached index - - // ...in a gzip-friendly way - node = parent; - outerCache = node[ expando ] || ( node[ expando ] = {} ); - - // Support: IE <9 only - // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ node.uniqueID ] || - ( outerCache[ node.uniqueID ] = {} ); - - cache = uniqueCache[ type ] || []; - nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; - diff = nodeIndex && cache[ 2 ]; - node = nodeIndex && parent.childNodes[ nodeIndex ]; - - while ( ( node = ++nodeIndex && node && node[ dir ] || - - // Fallback to seeking `elem` from the start - ( diff = nodeIndex = 0 ) || start.pop() ) ) { - - // When found, cache indexes on `parent` and break - if ( node.nodeType === 1 && ++diff && node === elem ) { - uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; - break; - } - } - - } else { - - // Use previously-cached element index if available - if ( useCache ) { - - // ...in a gzip-friendly way - node = elem; - outerCache = node[ expando ] || ( node[ expando ] = {} ); - - // Support: IE <9 only - // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ node.uniqueID ] || - ( outerCache[ node.uniqueID ] = {} ); - - cache = uniqueCache[ type ] || []; - nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; - diff = nodeIndex; - } - - // xml :nth-child(...) - // or :nth-last-child(...) or :nth(-last)?-of-type(...) - if ( diff === false ) { - - // Use the same loop as above to seek `elem` from the start - while ( ( node = ++nodeIndex && node && node[ dir ] || - ( diff = nodeIndex = 0 ) || start.pop() ) ) { - - if ( ( ofType ? - node.nodeName.toLowerCase() === name : - node.nodeType === 1 ) && - ++diff ) { - - // Cache the index of each encountered element - if ( useCache ) { - outerCache = node[ expando ] || - ( node[ expando ] = {} ); - - // Support: IE <9 only - // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ node.uniqueID ] || - ( outerCache[ node.uniqueID ] = {} ); - - uniqueCache[ type ] = [ dirruns, diff ]; - } - - if ( node === elem ) { - break; - } - } - } - } - } - - // Incorporate the offset, then check against cycle size - diff -= last; - return diff === first || ( diff % first === 0 && diff / first >= 0 ); - } - }; - }, - - "PSEUDO": function( pseudo, argument ) { - - // pseudo-class names are case-insensitive - // http://www.w3.org/TR/selectors/#pseudo-classes - // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters - // Remember that setFilters inherits from pseudos - var args, - fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || - Sizzle.error( "unsupported pseudo: " + pseudo ); - - // The user may use createPseudo to indicate that - // arguments are needed to create the filter function - // just as Sizzle does - if ( fn[ expando ] ) { - return fn( argument ); - } - - // But maintain support for old signatures - if ( fn.length > 1 ) { - args = [ pseudo, pseudo, "", argument ]; - return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? - markFunction( function( seed, matches ) { - var idx, - matched = fn( seed, argument ), - i = matched.length; - while ( i-- ) { - idx = indexOf( seed, matched[ i ] ); - seed[ idx ] = !( matches[ idx ] = matched[ i ] ); - } - } ) : - function( elem ) { - return fn( elem, 0, args ); - }; - } - - return fn; - } - }, - - pseudos: { - - // Potentially complex pseudos - "not": markFunction( function( selector ) { - - // Trim the selector passed to compile - // to avoid treating leading and trailing - // spaces as combinators - var input = [], - results = [], - matcher = compile( selector.replace( rtrim, "$1" ) ); - - return matcher[ expando ] ? - markFunction( function( seed, matches, _context, xml ) { - var elem, - unmatched = matcher( seed, null, xml, [] ), - i = seed.length; - - // Match elements unmatched by `matcher` - while ( i-- ) { - if ( ( elem = unmatched[ i ] ) ) { - seed[ i ] = !( matches[ i ] = elem ); - } - } - } ) : - function( elem, _context, xml ) { - input[ 0 ] = elem; - matcher( input, null, xml, results ); - - // Don't keep the element (issue #299) - input[ 0 ] = null; - return !results.pop(); - }; - } ), - - "has": markFunction( function( selector ) { - return function( elem ) { - return Sizzle( selector, elem ).length > 0; - }; - } ), - - "contains": markFunction( function( text ) { - text = text.replace( runescape, funescape ); - return function( elem ) { - return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1; - }; - } ), - - // "Whether an element is represented by a :lang() selector - // is based solely on the element's language value - // being equal to the identifier C, - // or beginning with the identifier C immediately followed by "-". - // The matching of C against the element's language value is performed case-insensitively. - // The identifier C does not have to be a valid language name." - // http://www.w3.org/TR/selectors/#lang-pseudo - "lang": markFunction( function( lang ) { - - // lang value must be a valid identifier - if ( !ridentifier.test( lang || "" ) ) { - Sizzle.error( "unsupported lang: " + lang ); - } - lang = lang.replace( runescape, funescape ).toLowerCase(); - return function( elem ) { - var elemLang; - do { - if ( ( elemLang = documentIsHTML ? - elem.lang : - elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { - - elemLang = elemLang.toLowerCase(); - return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; - } - } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); - return false; - }; - } ), - - // Miscellaneous - "target": function( elem ) { - var hash = window.location && window.location.hash; - return hash && hash.slice( 1 ) === elem.id; - }, - - "root": function( elem ) { - return elem === docElem; - }, - - "focus": function( elem ) { - return elem === document.activeElement && - ( !document.hasFocus || document.hasFocus() ) && - !!( elem.type || elem.href || ~elem.tabIndex ); - }, - - // Boolean properties - "enabled": createDisabledPseudo( false ), - "disabled": createDisabledPseudo( true ), - - "checked": function( elem ) { - - // In CSS3, :checked should return both checked and selected elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - var nodeName = elem.nodeName.toLowerCase(); - return ( nodeName === "input" && !!elem.checked ) || - ( nodeName === "option" && !!elem.selected ); - }, - - "selected": function( elem ) { - - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - // eslint-disable-next-line no-unused-expressions - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - // Contents - "empty": function( elem ) { - - // http://www.w3.org/TR/selectors/#empty-pseudo - // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), - // but not by others (comment: 8; processing instruction: 7; etc.) - // nodeType < 6 works because attributes (2) do not appear as children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - if ( elem.nodeType < 6 ) { - return false; - } - } - return true; - }, - - "parent": function( elem ) { - return !Expr.pseudos[ "empty" ]( elem ); - }, - - // Element/input types - "header": function( elem ) { - return rheader.test( elem.nodeName ); - }, - - "input": function( elem ) { - return rinputs.test( elem.nodeName ); - }, - - "button": function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === "button" || name === "button"; - }, - - "text": function( elem ) { - var attr; - return elem.nodeName.toLowerCase() === "input" && - elem.type === "text" && - - // Support: IE<8 - // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" - ( ( attr = elem.getAttribute( "type" ) ) == null || - attr.toLowerCase() === "text" ); - }, - - // Position-in-collection - "first": createPositionalPseudo( function() { - return [ 0 ]; - } ), - - "last": createPositionalPseudo( function( _matchIndexes, length ) { - return [ length - 1 ]; - } ), - - "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) { - return [ argument < 0 ? argument + length : argument ]; - } ), - - "even": createPositionalPseudo( function( matchIndexes, length ) { - var i = 0; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - } ), - - "odd": createPositionalPseudo( function( matchIndexes, length ) { - var i = 1; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - } ), - - "lt": createPositionalPseudo( function( matchIndexes, length, argument ) { - var i = argument < 0 ? - argument + length : - argument > length ? - length : - argument; - for ( ; --i >= 0; ) { - matchIndexes.push( i ); - } - return matchIndexes; - } ), - - "gt": createPositionalPseudo( function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; ++i < length; ) { - matchIndexes.push( i ); - } - return matchIndexes; - } ) - } -}; - -Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ]; - -// Add button/input type pseudos -for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { - Expr.pseudos[ i ] = createInputPseudo( i ); -} -for ( i in { submit: true, reset: true } ) { - Expr.pseudos[ i ] = createButtonPseudo( i ); -} - -// Easy API for creating new setFilters -function setFilters() {} -setFilters.prototype = Expr.filters = Expr.pseudos; -Expr.setFilters = new setFilters(); - -tokenize = Sizzle.tokenize = function( selector, parseOnly ) { - var matched, match, tokens, type, - soFar, groups, preFilters, - cached = tokenCache[ selector + " " ]; - - if ( cached ) { - return parseOnly ? 0 : cached.slice( 0 ); - } - - soFar = selector; - groups = []; - preFilters = Expr.preFilter; - - while ( soFar ) { - - // Comma and first run - if ( !matched || ( match = rcomma.exec( soFar ) ) ) { - if ( match ) { - - // Don't consume trailing commas as valid - soFar = soFar.slice( match[ 0 ].length ) || soFar; - } - groups.push( ( tokens = [] ) ); - } - - matched = false; - - // Combinators - if ( ( match = rcombinators.exec( soFar ) ) ) { - matched = match.shift(); - tokens.push( { - value: matched, - - // Cast descendant combinators to space - type: match[ 0 ].replace( rtrim, " " ) - } ); - soFar = soFar.slice( matched.length ); - } - - // Filters - for ( type in Expr.filter ) { - if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || - ( match = preFilters[ type ]( match ) ) ) ) { - matched = match.shift(); - tokens.push( { - value: matched, - type: type, - matches: match - } ); - soFar = soFar.slice( matched.length ); - } - } - - if ( !matched ) { - break; - } - } - - // Return the length of the invalid excess - // if we're just parsing - // Otherwise, throw an error or return tokens - return parseOnly ? - soFar.length : - soFar ? - Sizzle.error( selector ) : - - // Cache the tokens - tokenCache( selector, groups ).slice( 0 ); -}; - -function toSelector( tokens ) { - var i = 0, - len = tokens.length, - selector = ""; - for ( ; i < len; i++ ) { - selector += tokens[ i ].value; - } - return selector; -} - -function addCombinator( matcher, combinator, base ) { - var dir = combinator.dir, - skip = combinator.next, - key = skip || dir, - checkNonElements = base && key === "parentNode", - doneName = done++; - - return combinator.first ? - - // Check against closest ancestor/preceding element - function( elem, context, xml ) { - while ( ( elem = elem[ dir ] ) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - return matcher( elem, context, xml ); - } - } - return false; - } : - - // Check against all ancestor/preceding elements - function( elem, context, xml ) { - var oldCache, uniqueCache, outerCache, - newCache = [ dirruns, doneName ]; - - // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching - if ( xml ) { - while ( ( elem = elem[ dir ] ) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - if ( matcher( elem, context, xml ) ) { - return true; - } - } - } - } else { - while ( ( elem = elem[ dir ] ) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - outerCache = elem[ expando ] || ( elem[ expando ] = {} ); - - // Support: IE <9 only - // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ elem.uniqueID ] || - ( outerCache[ elem.uniqueID ] = {} ); - - if ( skip && skip === elem.nodeName.toLowerCase() ) { - elem = elem[ dir ] || elem; - } else if ( ( oldCache = uniqueCache[ key ] ) && - oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { - - // Assign to newCache so results back-propagate to previous elements - return ( newCache[ 2 ] = oldCache[ 2 ] ); - } else { - - // Reuse newcache so results back-propagate to previous elements - uniqueCache[ key ] = newCache; - - // A match means we're done; a fail means we have to keep checking - if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { - return true; - } - } - } - } - } - return false; - }; -} - -function elementMatcher( matchers ) { - return matchers.length > 1 ? - function( elem, context, xml ) { - var i = matchers.length; - while ( i-- ) { - if ( !matchers[ i ]( elem, context, xml ) ) { - return false; - } - } - return true; - } : - matchers[ 0 ]; -} - -function multipleContexts( selector, contexts, results ) { - var i = 0, - len = contexts.length; - for ( ; i < len; i++ ) { - Sizzle( selector, contexts[ i ], results ); - } - return results; -} - -function condense( unmatched, map, filter, context, xml ) { - var elem, - newUnmatched = [], - i = 0, - len = unmatched.length, - mapped = map != null; - - for ( ; i < len; i++ ) { - if ( ( elem = unmatched[ i ] ) ) { - if ( !filter || filter( elem, context, xml ) ) { - newUnmatched.push( elem ); - if ( mapped ) { - map.push( i ); - } - } - } - } - - return newUnmatched; -} - -function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { - if ( postFilter && !postFilter[ expando ] ) { - postFilter = setMatcher( postFilter ); - } - if ( postFinder && !postFinder[ expando ] ) { - postFinder = setMatcher( postFinder, postSelector ); - } - return markFunction( function( seed, results, context, xml ) { - var temp, i, elem, - preMap = [], - postMap = [], - preexisting = results.length, - - // Get initial elements from seed or context - elems = seed || multipleContexts( - selector || "*", - context.nodeType ? [ context ] : context, - [] - ), - - // Prefilter to get matcher input, preserving a map for seed-results synchronization - matcherIn = preFilter && ( seed || !selector ) ? - condense( elems, preMap, preFilter, context, xml ) : - elems, - - matcherOut = matcher ? - - // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, - postFinder || ( seed ? preFilter : preexisting || postFilter ) ? - - // ...intermediate processing is necessary - [] : - - // ...otherwise use results directly - results : - matcherIn; - - // Find primary matches - if ( matcher ) { - matcher( matcherIn, matcherOut, context, xml ); - } - - // Apply postFilter - if ( postFilter ) { - temp = condense( matcherOut, postMap ); - postFilter( temp, [], context, xml ); - - // Un-match failing elements by moving them back to matcherIn - i = temp.length; - while ( i-- ) { - if ( ( elem = temp[ i ] ) ) { - matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); - } - } - } - - if ( seed ) { - if ( postFinder || preFilter ) { - if ( postFinder ) { - - // Get the final matcherOut by condensing this intermediate into postFinder contexts - temp = []; - i = matcherOut.length; - while ( i-- ) { - if ( ( elem = matcherOut[ i ] ) ) { - - // Restore matcherIn since elem is not yet a final match - temp.push( ( matcherIn[ i ] = elem ) ); - } - } - postFinder( null, ( matcherOut = [] ), temp, xml ); - } - - // Move matched elements from seed to results to keep them synchronized - i = matcherOut.length; - while ( i-- ) { - if ( ( elem = matcherOut[ i ] ) && - ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) { - - seed[ temp ] = !( results[ temp ] = elem ); - } - } - } - - // Add elements to results, through postFinder if defined - } else { - matcherOut = condense( - matcherOut === results ? - matcherOut.splice( preexisting, matcherOut.length ) : - matcherOut - ); - if ( postFinder ) { - postFinder( null, results, matcherOut, xml ); - } else { - push.apply( results, matcherOut ); - } - } - } ); -} - -function matcherFromTokens( tokens ) { - var checkContext, matcher, j, - len = tokens.length, - leadingRelative = Expr.relative[ tokens[ 0 ].type ], - implicitRelative = leadingRelative || Expr.relative[ " " ], - i = leadingRelative ? 1 : 0, - - // The foundational matcher ensures that elements are reachable from top-level context(s) - matchContext = addCombinator( function( elem ) { - return elem === checkContext; - }, implicitRelative, true ), - matchAnyContext = addCombinator( function( elem ) { - return indexOf( checkContext, elem ) > -1; - }, implicitRelative, true ), - matchers = [ function( elem, context, xml ) { - var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( - ( checkContext = context ).nodeType ? - matchContext( elem, context, xml ) : - matchAnyContext( elem, context, xml ) ); - - // Avoid hanging onto element (issue #299) - checkContext = null; - return ret; - } ]; - - for ( ; i < len; i++ ) { - if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { - matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; - } else { - matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); - - // Return special upon seeing a positional matcher - if ( matcher[ expando ] ) { - - // Find the next relative operator (if any) for proper handling - j = ++i; - for ( ; j < len; j++ ) { - if ( Expr.relative[ tokens[ j ].type ] ) { - break; - } - } - return setMatcher( - i > 1 && elementMatcher( matchers ), - i > 1 && toSelector( - - // If the preceding token was a descendant combinator, insert an implicit any-element `*` - tokens - .slice( 0, i - 1 ) - .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) - ).replace( rtrim, "$1" ), - matcher, - i < j && matcherFromTokens( tokens.slice( i, j ) ), - j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), - j < len && toSelector( tokens ) - ); - } - matchers.push( matcher ); - } - } - - return elementMatcher( matchers ); -} - -function matcherFromGroupMatchers( elementMatchers, setMatchers ) { - var bySet = setMatchers.length > 0, - byElement = elementMatchers.length > 0, - superMatcher = function( seed, context, xml, results, outermost ) { - var elem, j, matcher, - matchedCount = 0, - i = "0", - unmatched = seed && [], - setMatched = [], - contextBackup = outermostContext, - - // We must always have either seed elements or outermost context - elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ), - - // Use integer dirruns iff this is the outermost matcher - dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), - len = elems.length; - - if ( outermost ) { - - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - outermostContext = context == document || context || outermost; - } - - // Add elements passing elementMatchers directly to results - // Support: IE<9, Safari - // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id - for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { - if ( byElement && elem ) { - j = 0; - - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - if ( !context && elem.ownerDocument != document ) { - setDocument( elem ); - xml = !documentIsHTML; - } - while ( ( matcher = elementMatchers[ j++ ] ) ) { - if ( matcher( elem, context || document, xml ) ) { - results.push( elem ); - break; - } - } - if ( outermost ) { - dirruns = dirrunsUnique; - } - } - - // Track unmatched elements for set filters - if ( bySet ) { - - // They will have gone through all possible matchers - if ( ( elem = !matcher && elem ) ) { - matchedCount--; - } - - // Lengthen the array for every element, matched or not - if ( seed ) { - unmatched.push( elem ); - } - } - } - - // `i` is now the count of elements visited above, and adding it to `matchedCount` - // makes the latter nonnegative. - matchedCount += i; - - // Apply set filters to unmatched elements - // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` - // equals `i`), unless we didn't visit _any_ elements in the above loop because we have - // no element matchers and no seed. - // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that - // case, which will result in a "00" `matchedCount` that differs from `i` but is also - // numerically zero. - if ( bySet && i !== matchedCount ) { - j = 0; - while ( ( matcher = setMatchers[ j++ ] ) ) { - matcher( unmatched, setMatched, context, xml ); - } - - if ( seed ) { - - // Reintegrate element matches to eliminate the need for sorting - if ( matchedCount > 0 ) { - while ( i-- ) { - if ( !( unmatched[ i ] || setMatched[ i ] ) ) { - setMatched[ i ] = pop.call( results ); - } - } - } - - // Discard index placeholder values to get only actual matches - setMatched = condense( setMatched ); - } - - // Add matches to results - push.apply( results, setMatched ); - - // Seedless set matches succeeding multiple successful matchers stipulate sorting - if ( outermost && !seed && setMatched.length > 0 && - ( matchedCount + setMatchers.length ) > 1 ) { - - Sizzle.uniqueSort( results ); - } - } - - // Override manipulation of globals by nested matchers - if ( outermost ) { - dirruns = dirrunsUnique; - outermostContext = contextBackup; - } - - return unmatched; - }; - - return bySet ? - markFunction( superMatcher ) : - superMatcher; -} - -compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { - var i, - setMatchers = [], - elementMatchers = [], - cached = compilerCache[ selector + " " ]; - - if ( !cached ) { - - // Generate a function of recursive functions that can be used to check each element - if ( !match ) { - match = tokenize( selector ); - } - i = match.length; - while ( i-- ) { - cached = matcherFromTokens( match[ i ] ); - if ( cached[ expando ] ) { - setMatchers.push( cached ); - } else { - elementMatchers.push( cached ); - } - } - - // Cache the compiled function - cached = compilerCache( - selector, - matcherFromGroupMatchers( elementMatchers, setMatchers ) - ); - - // Save selector and tokenization - cached.selector = selector; - } - return cached; -}; - -/** - * A low-level selection function that works with Sizzle's compiled - * selector functions - * @param {String|Function} selector A selector or a pre-compiled - * selector function built with Sizzle.compile - * @param {Element} context - * @param {Array} [results] - * @param {Array} [seed] A set of elements to match against - */ -select = Sizzle.select = function( selector, context, results, seed ) { - var i, tokens, token, type, find, - compiled = typeof selector === "function" && selector, - match = !seed && tokenize( ( selector = compiled.selector || selector ) ); - - results = results || []; - - // Try to minimize operations if there is only one selector in the list and no seed - // (the latter of which guarantees us context) - if ( match.length === 1 ) { - - // Reduce context if the leading compound selector is an ID - tokens = match[ 0 ] = match[ 0 ].slice( 0 ); - if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && - context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { - - context = ( Expr.find[ "ID" ]( token.matches[ 0 ] - .replace( runescape, funescape ), context ) || [] )[ 0 ]; - if ( !context ) { - return results; - - // Precompiled matchers will still verify ancestry, so step up a level - } else if ( compiled ) { - context = context.parentNode; - } - - selector = selector.slice( tokens.shift().value.length ); - } - - // Fetch a seed set for right-to-left matching - i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length; - while ( i-- ) { - token = tokens[ i ]; - - // Abort if we hit a combinator - if ( Expr.relative[ ( type = token.type ) ] ) { - break; - } - if ( ( find = Expr.find[ type ] ) ) { - - // Search, expanding context for leading sibling combinators - if ( ( seed = find( - token.matches[ 0 ].replace( runescape, funescape ), - rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) || - context - ) ) ) { - - // If seed is empty or no tokens remain, we can return early - tokens.splice( i, 1 ); - selector = seed.length && toSelector( tokens ); - if ( !selector ) { - push.apply( results, seed ); - return results; - } - - break; - } - } - } - } - - // Compile and execute a filtering function if one is not provided - // Provide `match` to avoid retokenization if we modified the selector above - ( compiled || compile( selector, match ) )( - seed, - context, - !documentIsHTML, - results, - !context || rsibling.test( selector ) && testContext( context.parentNode ) || context - ); - return results; -}; - -// One-time assignments - -// Sort stability -support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; - -// Support: Chrome 14-35+ -// Always assume duplicates if they aren't passed to the comparison function -support.detectDuplicates = !!hasDuplicate; - -// Initialize against the default document -setDocument(); - -// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) -// Detached nodes confoundingly follow *each other* -support.sortDetached = assert( function( el ) { - - // Should return 1, but returns 4 (following) - return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; -} ); - -// Support: IE<8 -// Prevent attribute/property "interpolation" -// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !assert( function( el ) { - el.innerHTML = ""; - return el.firstChild.getAttribute( "href" ) === "#"; -} ) ) { - addHandle( "type|href|height|width", function( elem, name, isXML ) { - if ( !isXML ) { - return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); - } - } ); -} - -// Support: IE<9 -// Use defaultValue in place of getAttribute("value") -if ( !support.attributes || !assert( function( el ) { - el.innerHTML = ""; - el.firstChild.setAttribute( "value", "" ); - return el.firstChild.getAttribute( "value" ) === ""; -} ) ) { - addHandle( "value", function( elem, _name, isXML ) { - if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { - return elem.defaultValue; - } - } ); -} - -// Support: IE<9 -// Use getAttributeNode to fetch booleans when getAttribute lies -if ( !assert( function( el ) { - return el.getAttribute( "disabled" ) == null; -} ) ) { - addHandle( booleans, function( elem, name, isXML ) { - var val; - if ( !isXML ) { - return elem[ name ] === true ? name.toLowerCase() : - ( val = elem.getAttributeNode( name ) ) && val.specified ? - val.value : - null; - } - } ); -} - -return Sizzle; - -} )( window ); - - - -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; - -// Deprecated -jQuery.expr[ ":" ] = jQuery.expr.pseudos; -jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; -jQuery.escapeSelector = Sizzle.escape; - - - - -var dir = function( elem, dir, until ) { - var matched = [], - truncate = until !== undefined; - - while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { - if ( elem.nodeType === 1 ) { - if ( truncate && jQuery( elem ).is( until ) ) { - break; - } - matched.push( elem ); - } - } - return matched; -}; - - -var siblings = function( n, elem ) { - var matched = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - matched.push( n ); - } - } - - return matched; -}; - - -var rneedsContext = jQuery.expr.match.needsContext; - - - -function nodeName( elem, name ) { - - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); - -} -var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); - - - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, not ) { - if ( isFunction( qualifier ) ) { - return jQuery.grep( elements, function( elem, i ) { - return !!qualifier.call( elem, i, elem ) !== not; - } ); - } - - // Single element - if ( qualifier.nodeType ) { - return jQuery.grep( elements, function( elem ) { - return ( elem === qualifier ) !== not; - } ); - } - - // Arraylike of elements (jQuery, arguments, Array) - if ( typeof qualifier !== "string" ) { - return jQuery.grep( elements, function( elem ) { - return ( indexOf.call( qualifier, elem ) > -1 ) !== not; - } ); - } - - // Filtered directly for both simple and complex selectors - return jQuery.filter( qualifier, elements, not ); -} - -jQuery.filter = function( expr, elems, not ) { - var elem = elems[ 0 ]; - - if ( not ) { - expr = ":not(" + expr + ")"; - } - - if ( elems.length === 1 && elem.nodeType === 1 ) { - return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; - } - - return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { - return elem.nodeType === 1; - } ) ); -}; - -jQuery.fn.extend( { - find: function( selector ) { - var i, ret, - len = this.length, - self = this; - - if ( typeof selector !== "string" ) { - return this.pushStack( jQuery( selector ).filter( function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - } ) ); - } - - ret = this.pushStack( [] ); - - for ( i = 0; i < len; i++ ) { - jQuery.find( selector, self[ i ], ret ); - } - - return len > 1 ? jQuery.uniqueSort( ret ) : ret; - }, - filter: function( selector ) { - return this.pushStack( winnow( this, selector || [], false ) ); - }, - not: function( selector ) { - return this.pushStack( winnow( this, selector || [], true ) ); - }, - is: function( selector ) { - return !!winnow( - this, - - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - typeof selector === "string" && rneedsContext.test( selector ) ? - jQuery( selector ) : - selector || [], - false - ).length; - } -} ); - - -// Initialize a jQuery object - - -// A central reference to the root jQuery(document) -var rootjQuery, - - // A simple way to check for HTML strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - // Strict HTML recognition (#11290: must start with <) - // Shortcut simple #id case for speed - rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, - - init = jQuery.fn.init = function( selector, context, root ) { - var match, elem; - - // HANDLE: $(""), $(null), $(undefined), $(false) - if ( !selector ) { - return this; - } - - // Method init() accepts an alternate rootjQuery - // so migrate can support jQuery.sub (gh-2101) - root = root || rootjQuery; - - // Handle HTML strings - if ( typeof selector === "string" ) { - if ( selector[ 0 ] === "<" && - selector[ selector.length - 1 ] === ">" && - selector.length >= 3 ) { - - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = rquickExpr.exec( selector ); - } - - // Match html or make sure no context is specified for #id - if ( match && ( match[ 1 ] || !context ) ) { - - // HANDLE: $(html) -> $(array) - if ( match[ 1 ] ) { - context = context instanceof jQuery ? context[ 0 ] : context; - - // Option to run scripts is true for back-compat - // Intentionally let the error be thrown if parseHTML is not present - jQuery.merge( this, jQuery.parseHTML( - match[ 1 ], - context && context.nodeType ? context.ownerDocument || context : document, - true - ) ); - - // HANDLE: $(html, props) - if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { - for ( match in context ) { - - // Properties of context are called as methods if possible - if ( isFunction( this[ match ] ) ) { - this[ match ]( context[ match ] ); - - // ...and otherwise set as attributes - } else { - this.attr( match, context[ match ] ); - } - } - } - - return this; - - // HANDLE: $(#id) - } else { - elem = document.getElementById( match[ 2 ] ); - - if ( elem ) { - - // Inject the element directly into the jQuery object - this[ 0 ] = elem; - this.length = 1; - } - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return ( context || root ).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(DOMElement) - } else if ( selector.nodeType ) { - this[ 0 ] = selector; - this.length = 1; - return this; - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( isFunction( selector ) ) { - return root.ready !== undefined ? - root.ready( selector ) : - - // Execute immediately if ready is not present - selector( jQuery ); - } - - return jQuery.makeArray( selector, this ); - }; - -// Give the init function the jQuery prototype for later instantiation -init.prototype = jQuery.fn; - -// Initialize central reference -rootjQuery = jQuery( document ); - - -var rparentsprev = /^(?:parents|prev(?:Until|All))/, - - // Methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - -jQuery.fn.extend( { - has: function( target ) { - var targets = jQuery( target, this ), - l = targets.length; - - return this.filter( function() { - var i = 0; - for ( ; i < l; i++ ) { - if ( jQuery.contains( this, targets[ i ] ) ) { - return true; - } - } - } ); - }, - - closest: function( selectors, context ) { - var cur, - i = 0, - l = this.length, - matched = [], - targets = typeof selectors !== "string" && jQuery( selectors ); - - // Positional selectors never match, since there's no _selection_ context - if ( !rneedsContext.test( selectors ) ) { - for ( ; i < l; i++ ) { - for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { - - // Always skip document fragments - if ( cur.nodeType < 11 && ( targets ? - targets.index( cur ) > -1 : - - // Don't pass non-elements to Sizzle - cur.nodeType === 1 && - jQuery.find.matchesSelector( cur, selectors ) ) ) { - - matched.push( cur ); - break; - } - } - } - } - - return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); - }, - - // Determine the position of an element within the set - index: function( elem ) { - - // No argument, return index in parent - if ( !elem ) { - return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; - } - - // Index in selector - if ( typeof elem === "string" ) { - return indexOf.call( jQuery( elem ), this[ 0 ] ); - } - - // Locate the position of the desired element - return indexOf.call( this, - - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[ 0 ] : elem - ); - }, - - add: function( selector, context ) { - return this.pushStack( - jQuery.uniqueSort( - jQuery.merge( this.get(), jQuery( selector, context ) ) - ) - ); - }, - - addBack: function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter( selector ) - ); - } -} ); - -function sibling( cur, dir ) { - while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} - return cur; -} - -jQuery.each( { - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, _i, until ) { - return dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return sibling( elem, "nextSibling" ); - }, - prev: function( elem ) { - return sibling( elem, "previousSibling" ); - }, - nextAll: function( elem ) { - return dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, _i, until ) { - return dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, _i, until ) { - return dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return siblings( ( elem.parentNode || {} ).firstChild, elem ); - }, - children: function( elem ) { - return siblings( elem.firstChild ); - }, - contents: function( elem ) { - if ( elem.contentDocument != null && - - // Support: IE 11+ - // elements with no `data` attribute has an object - // `contentDocument` with a `null` prototype. - getProto( elem.contentDocument ) ) { - - return elem.contentDocument; - } - - // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only - // Treat the template element as a regular one in browsers that - // don't support it. - if ( nodeName( elem, "template" ) ) { - elem = elem.content || elem; - } - - return jQuery.merge( [], elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var matched = jQuery.map( this, fn, until ); - - if ( name.slice( -5 ) !== "Until" ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - matched = jQuery.filter( selector, matched ); - } - - if ( this.length > 1 ) { - - // Remove duplicates - if ( !guaranteedUnique[ name ] ) { - jQuery.uniqueSort( matched ); - } - - // Reverse order for parents* and prev-derivatives - if ( rparentsprev.test( name ) ) { - matched.reverse(); - } - } - - return this.pushStack( matched ); - }; -} ); -var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); - - - -// Convert String-formatted options into Object-formatted ones -function createOptions( options ) { - var object = {}; - jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { - object[ flag ] = true; - } ); - return object; -} - -/* - * Create a callback list using the following parameters: - * - * options: an optional list of space-separated options that will change how - * the callback list behaves or a more traditional option object - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible options: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ -jQuery.Callbacks = function( options ) { - - // Convert options from String-formatted to Object-formatted if needed - // (we check in cache first) - options = typeof options === "string" ? - createOptions( options ) : - jQuery.extend( {}, options ); - - var // Flag to know if list is currently firing - firing, - - // Last fire value for non-forgettable lists - memory, - - // Flag to know if list was already fired - fired, - - // Flag to prevent firing - locked, - - // Actual callback list - list = [], - - // Queue of execution data for repeatable lists - queue = [], - - // Index of currently firing callback (modified by add/remove as needed) - firingIndex = -1, - - // Fire callbacks - fire = function() { - - // Enforce single-firing - locked = locked || options.once; - - // Execute callbacks for all pending executions, - // respecting firingIndex overrides and runtime changes - fired = firing = true; - for ( ; queue.length; firingIndex = -1 ) { - memory = queue.shift(); - while ( ++firingIndex < list.length ) { - - // Run callback and check for early termination - if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && - options.stopOnFalse ) { - - // Jump to end and forget the data so .add doesn't re-fire - firingIndex = list.length; - memory = false; - } - } - } - - // Forget the data if we're done with it - if ( !options.memory ) { - memory = false; - } - - firing = false; - - // Clean up if we're done firing for good - if ( locked ) { - - // Keep an empty list if we have data for future add calls - if ( memory ) { - list = []; - - // Otherwise, this object is spent - } else { - list = ""; - } - } - }, - - // Actual Callbacks object - self = { - - // Add a callback or a collection of callbacks to the list - add: function() { - if ( list ) { - - // If we have memory from a past run, we should fire after adding - if ( memory && !firing ) { - firingIndex = list.length - 1; - queue.push( memory ); - } - - ( function add( args ) { - jQuery.each( args, function( _, arg ) { - if ( isFunction( arg ) ) { - if ( !options.unique || !self.has( arg ) ) { - list.push( arg ); - } - } else if ( arg && arg.length && toType( arg ) !== "string" ) { - - // Inspect recursively - add( arg ); - } - } ); - } )( arguments ); - - if ( memory && !firing ) { - fire(); - } - } - return this; - }, - - // Remove a callback from the list - remove: function() { - jQuery.each( arguments, function( _, arg ) { - var index; - while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { - list.splice( index, 1 ); - - // Handle firing indexes - if ( index <= firingIndex ) { - firingIndex--; - } - } - } ); - return this; - }, - - // Check if a given callback is in the list. - // If no argument is given, return whether or not list has callbacks attached. - has: function( fn ) { - return fn ? - jQuery.inArray( fn, list ) > -1 : - list.length > 0; - }, - - // Remove all callbacks from the list - empty: function() { - if ( list ) { - list = []; - } - return this; - }, - - // Disable .fire and .add - // Abort any current/pending executions - // Clear all callbacks and values - disable: function() { - locked = queue = []; - list = memory = ""; - return this; - }, - disabled: function() { - return !list; - }, - - // Disable .fire - // Also disable .add unless we have memory (since it would have no effect) - // Abort any pending executions - lock: function() { - locked = queue = []; - if ( !memory && !firing ) { - list = memory = ""; - } - return this; - }, - locked: function() { - return !!locked; - }, - - // Call all callbacks with the given context and arguments - fireWith: function( context, args ) { - if ( !locked ) { - args = args || []; - args = [ context, args.slice ? args.slice() : args ]; - queue.push( args ); - if ( !firing ) { - fire(); - } - } - return this; - }, - - // Call all the callbacks with the given arguments - fire: function() { - self.fireWith( this, arguments ); - return this; - }, - - // To know if the callbacks have already been called at least once - fired: function() { - return !!fired; - } - }; - - return self; -}; - - -function Identity( v ) { - return v; -} -function Thrower( ex ) { - throw ex; -} - -function adoptValue( value, resolve, reject, noValue ) { - var method; - - try { - - // Check for promise aspect first to privilege synchronous behavior - if ( value && isFunction( ( method = value.promise ) ) ) { - method.call( value ).done( resolve ).fail( reject ); - - // Other thenables - } else if ( value && isFunction( ( method = value.then ) ) ) { - method.call( value, resolve, reject ); - - // Other non-thenables - } else { - - // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: - // * false: [ value ].slice( 0 ) => resolve( value ) - // * true: [ value ].slice( 1 ) => resolve() - resolve.apply( undefined, [ value ].slice( noValue ) ); - } - - // For Promises/A+, convert exceptions into rejections - // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in - // Deferred#then to conditionally suppress rejection. - } catch ( value ) { - - // Support: Android 4.0 only - // Strict mode functions invoked without .call/.apply get global-object context - reject.apply( undefined, [ value ] ); - } -} - -jQuery.extend( { - - Deferred: function( func ) { - var tuples = [ - - // action, add listener, callbacks, - // ... .then handlers, argument index, [final state] - [ "notify", "progress", jQuery.Callbacks( "memory" ), - jQuery.Callbacks( "memory" ), 2 ], - [ "resolve", "done", jQuery.Callbacks( "once memory" ), - jQuery.Callbacks( "once memory" ), 0, "resolved" ], - [ "reject", "fail", jQuery.Callbacks( "once memory" ), - jQuery.Callbacks( "once memory" ), 1, "rejected" ] - ], - state = "pending", - promise = { - state: function() { - return state; - }, - always: function() { - deferred.done( arguments ).fail( arguments ); - return this; - }, - "catch": function( fn ) { - return promise.then( null, fn ); - }, - - // Keep pipe for back-compat - pipe: function( /* fnDone, fnFail, fnProgress */ ) { - var fns = arguments; - - return jQuery.Deferred( function( newDefer ) { - jQuery.each( tuples, function( _i, tuple ) { - - // Map tuples (progress, done, fail) to arguments (done, fail, progress) - var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; - - // deferred.progress(function() { bind to newDefer or newDefer.notify }) - // deferred.done(function() { bind to newDefer or newDefer.resolve }) - // deferred.fail(function() { bind to newDefer or newDefer.reject }) - deferred[ tuple[ 1 ] ]( function() { - var returned = fn && fn.apply( this, arguments ); - if ( returned && isFunction( returned.promise ) ) { - returned.promise() - .progress( newDefer.notify ) - .done( newDefer.resolve ) - .fail( newDefer.reject ); - } else { - newDefer[ tuple[ 0 ] + "With" ]( - this, - fn ? [ returned ] : arguments - ); - } - } ); - } ); - fns = null; - } ).promise(); - }, - then: function( onFulfilled, onRejected, onProgress ) { - var maxDepth = 0; - function resolve( depth, deferred, handler, special ) { - return function() { - var that = this, - args = arguments, - mightThrow = function() { - var returned, then; - - // Support: Promises/A+ section 2.3.3.3.3 - // https://promisesaplus.com/#point-59 - // Ignore double-resolution attempts - if ( depth < maxDepth ) { - return; - } - - returned = handler.apply( that, args ); - - // Support: Promises/A+ section 2.3.1 - // https://promisesaplus.com/#point-48 - if ( returned === deferred.promise() ) { - throw new TypeError( "Thenable self-resolution" ); - } - - // Support: Promises/A+ sections 2.3.3.1, 3.5 - // https://promisesaplus.com/#point-54 - // https://promisesaplus.com/#point-75 - // Retrieve `then` only once - then = returned && - - // Support: Promises/A+ section 2.3.4 - // https://promisesaplus.com/#point-64 - // Only check objects and functions for thenability - ( typeof returned === "object" || - typeof returned === "function" ) && - returned.then; - - // Handle a returned thenable - if ( isFunction( then ) ) { - - // Special processors (notify) just wait for resolution - if ( special ) { - then.call( - returned, - resolve( maxDepth, deferred, Identity, special ), - resolve( maxDepth, deferred, Thrower, special ) - ); - - // Normal processors (resolve) also hook into progress - } else { - - // ...and disregard older resolution values - maxDepth++; - - then.call( - returned, - resolve( maxDepth, deferred, Identity, special ), - resolve( maxDepth, deferred, Thrower, special ), - resolve( maxDepth, deferred, Identity, - deferred.notifyWith ) - ); - } - - // Handle all other returned values - } else { - - // Only substitute handlers pass on context - // and multiple values (non-spec behavior) - if ( handler !== Identity ) { - that = undefined; - args = [ returned ]; - } - - // Process the value(s) - // Default process is resolve - ( special || deferred.resolveWith )( that, args ); - } - }, - - // Only normal processors (resolve) catch and reject exceptions - process = special ? - mightThrow : - function() { - try { - mightThrow(); - } catch ( e ) { - - if ( jQuery.Deferred.exceptionHook ) { - jQuery.Deferred.exceptionHook( e, - process.stackTrace ); - } - - // Support: Promises/A+ section 2.3.3.3.4.1 - // https://promisesaplus.com/#point-61 - // Ignore post-resolution exceptions - if ( depth + 1 >= maxDepth ) { - - // Only substitute handlers pass on context - // and multiple values (non-spec behavior) - if ( handler !== Thrower ) { - that = undefined; - args = [ e ]; - } - - deferred.rejectWith( that, args ); - } - } - }; - - // Support: Promises/A+ section 2.3.3.3.1 - // https://promisesaplus.com/#point-57 - // Re-resolve promises immediately to dodge false rejection from - // subsequent errors - if ( depth ) { - process(); - } else { - - // Call an optional hook to record the stack, in case of exception - // since it's otherwise lost when execution goes async - if ( jQuery.Deferred.getStackHook ) { - process.stackTrace = jQuery.Deferred.getStackHook(); - } - window.setTimeout( process ); - } - }; - } - - return jQuery.Deferred( function( newDefer ) { - - // progress_handlers.add( ... ) - tuples[ 0 ][ 3 ].add( - resolve( - 0, - newDefer, - isFunction( onProgress ) ? - onProgress : - Identity, - newDefer.notifyWith - ) - ); - - // fulfilled_handlers.add( ... ) - tuples[ 1 ][ 3 ].add( - resolve( - 0, - newDefer, - isFunction( onFulfilled ) ? - onFulfilled : - Identity - ) - ); - - // rejected_handlers.add( ... ) - tuples[ 2 ][ 3 ].add( - resolve( - 0, - newDefer, - isFunction( onRejected ) ? - onRejected : - Thrower - ) - ); - } ).promise(); - }, - - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - return obj != null ? jQuery.extend( obj, promise ) : promise; - } - }, - deferred = {}; - - // Add list-specific methods - jQuery.each( tuples, function( i, tuple ) { - var list = tuple[ 2 ], - stateString = tuple[ 5 ]; - - // promise.progress = list.add - // promise.done = list.add - // promise.fail = list.add - promise[ tuple[ 1 ] ] = list.add; - - // Handle state - if ( stateString ) { - list.add( - function() { - - // state = "resolved" (i.e., fulfilled) - // state = "rejected" - state = stateString; - }, - - // rejected_callbacks.disable - // fulfilled_callbacks.disable - tuples[ 3 - i ][ 2 ].disable, - - // rejected_handlers.disable - // fulfilled_handlers.disable - tuples[ 3 - i ][ 3 ].disable, - - // progress_callbacks.lock - tuples[ 0 ][ 2 ].lock, - - // progress_handlers.lock - tuples[ 0 ][ 3 ].lock - ); - } - - // progress_handlers.fire - // fulfilled_handlers.fire - // rejected_handlers.fire - list.add( tuple[ 3 ].fire ); - - // deferred.notify = function() { deferred.notifyWith(...) } - // deferred.resolve = function() { deferred.resolveWith(...) } - // deferred.reject = function() { deferred.rejectWith(...) } - deferred[ tuple[ 0 ] ] = function() { - deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); - return this; - }; - - // deferred.notifyWith = list.fireWith - // deferred.resolveWith = list.fireWith - // deferred.rejectWith = list.fireWith - deferred[ tuple[ 0 ] + "With" ] = list.fireWith; - } ); - - // Make the deferred a promise - promise.promise( deferred ); - - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - - // All done! - return deferred; - }, - - // Deferred helper - when: function( singleValue ) { - var - - // count of uncompleted subordinates - remaining = arguments.length, - - // count of unprocessed arguments - i = remaining, - - // subordinate fulfillment data - resolveContexts = Array( i ), - resolveValues = slice.call( arguments ), - - // the primary Deferred - primary = jQuery.Deferred(), - - // subordinate callback factory - updateFunc = function( i ) { - return function( value ) { - resolveContexts[ i ] = this; - resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; - if ( !( --remaining ) ) { - primary.resolveWith( resolveContexts, resolveValues ); - } - }; - }; - - // Single- and empty arguments are adopted like Promise.resolve - if ( remaining <= 1 ) { - adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject, - !remaining ); - - // Use .then() to unwrap secondary thenables (cf. gh-3000) - if ( primary.state() === "pending" || - isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { - - return primary.then(); - } - } - - // Multiple arguments are aggregated like Promise.all array elements - while ( i-- ) { - adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject ); - } - - return primary.promise(); - } -} ); - - -// These usually indicate a programmer mistake during development, -// warn about them ASAP rather than swallowing them by default. -var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; - -jQuery.Deferred.exceptionHook = function( error, stack ) { - - // Support: IE 8 - 9 only - // Console exists when dev tools are open, which can happen at any time - if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { - window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); - } -}; - - - - -jQuery.readyException = function( error ) { - window.setTimeout( function() { - throw error; - } ); -}; - - - - -// The deferred used on DOM ready -var readyList = jQuery.Deferred(); - -jQuery.fn.ready = function( fn ) { - - readyList - .then( fn ) - - // Wrap jQuery.readyException in a function so that the lookup - // happens at the time of error handling instead of callback - // registration. - .catch( function( error ) { - jQuery.readyException( error ); - } ); - - return this; -}; - -jQuery.extend( { - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Handle when the DOM is ready - ready: function( wait ) { - - // Abort if there are pending holds or we're already ready - if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { - return; - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); - } -} ); - -jQuery.ready.then = readyList.then; - -// The ready event handler and self cleanup method -function completed() { - document.removeEventListener( "DOMContentLoaded", completed ); - window.removeEventListener( "load", completed ); - jQuery.ready(); -} - -// Catch cases where $(document).ready() is called -// after the browser event has already occurred. -// Support: IE <=9 - 10 only -// Older IE sometimes signals "interactive" too soon -if ( document.readyState === "complete" || - ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { - - // Handle it asynchronously to allow scripts the opportunity to delay ready - window.setTimeout( jQuery.ready ); - -} else { - - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", completed ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", completed ); -} - - - - -// Multifunctional method to get and set values of a collection -// The value/s can optionally be executed if it's a function -var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { - var i = 0, - len = elems.length, - bulk = key == null; - - // Sets many values - if ( toType( key ) === "object" ) { - chainable = true; - for ( i in key ) { - access( elems, fn, i, key[ i ], true, emptyGet, raw ); - } - - // Sets one value - } else if ( value !== undefined ) { - chainable = true; - - if ( !isFunction( value ) ) { - raw = true; - } - - if ( bulk ) { - - // Bulk operations run against the entire set - if ( raw ) { - fn.call( elems, value ); - fn = null; - - // ...except when executing function values - } else { - bulk = fn; - fn = function( elem, _key, value ) { - return bulk.call( jQuery( elem ), value ); - }; - } - } - - if ( fn ) { - for ( ; i < len; i++ ) { - fn( - elems[ i ], key, raw ? - value : - value.call( elems[ i ], i, fn( elems[ i ], key ) ) - ); - } - } - } - - if ( chainable ) { - return elems; - } - - // Gets - if ( bulk ) { - return fn.call( elems ); - } - - return len ? fn( elems[ 0 ], key ) : emptyGet; -}; - - -// Matches dashed string for camelizing -var rmsPrefix = /^-ms-/, - rdashAlpha = /-([a-z])/g; - -// Used by camelCase as callback to replace() -function fcamelCase( _all, letter ) { - return letter.toUpperCase(); -} - -// Convert dashed to camelCase; used by the css and data modules -// Support: IE <=9 - 11, Edge 12 - 15 -// Microsoft forgot to hump their vendor prefix (#9572) -function camelCase( string ) { - return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); -} -var acceptData = function( owner ) { - - // Accepts only: - // - Node - // - Node.ELEMENT_NODE - // - Node.DOCUMENT_NODE - // - Object - // - Any - return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); -}; - - - - -function Data() { - this.expando = jQuery.expando + Data.uid++; -} - -Data.uid = 1; - -Data.prototype = { - - cache: function( owner ) { - - // Check if the owner object already has a cache - var value = owner[ this.expando ]; - - // If not, create one - if ( !value ) { - value = {}; - - // We can accept data for non-element nodes in modern browsers, - // but we should not, see #8335. - // Always return an empty object. - if ( acceptData( owner ) ) { - - // If it is a node unlikely to be stringify-ed or looped over - // use plain assignment - if ( owner.nodeType ) { - owner[ this.expando ] = value; - - // Otherwise secure it in a non-enumerable property - // configurable must be true to allow the property to be - // deleted when data is removed - } else { - Object.defineProperty( owner, this.expando, { - value: value, - configurable: true - } ); - } - } - } - - return value; - }, - set: function( owner, data, value ) { - var prop, - cache = this.cache( owner ); - - // Handle: [ owner, key, value ] args - // Always use camelCase key (gh-2257) - if ( typeof data === "string" ) { - cache[ camelCase( data ) ] = value; - - // Handle: [ owner, { properties } ] args - } else { - - // Copy the properties one-by-one to the cache object - for ( prop in data ) { - cache[ camelCase( prop ) ] = data[ prop ]; - } - } - return cache; - }, - get: function( owner, key ) { - return key === undefined ? - this.cache( owner ) : - - // Always use camelCase key (gh-2257) - owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; - }, - access: function( owner, key, value ) { - - // In cases where either: - // - // 1. No key was specified - // 2. A string key was specified, but no value provided - // - // Take the "read" path and allow the get method to determine - // which value to return, respectively either: - // - // 1. The entire cache object - // 2. The data stored at the key - // - if ( key === undefined || - ( ( key && typeof key === "string" ) && value === undefined ) ) { - - return this.get( owner, key ); - } - - // When the key is not a string, or both a key and value - // are specified, set or extend (existing objects) with either: - // - // 1. An object of properties - // 2. A key and value - // - this.set( owner, key, value ); - - // Since the "set" path can have two possible entry points - // return the expected data based on which path was taken[*] - return value !== undefined ? value : key; - }, - remove: function( owner, key ) { - var i, - cache = owner[ this.expando ]; - - if ( cache === undefined ) { - return; - } - - if ( key !== undefined ) { - - // Support array or space separated string of keys - if ( Array.isArray( key ) ) { - - // If key is an array of keys... - // We always set camelCase keys, so remove that. - key = key.map( camelCase ); - } else { - key = camelCase( key ); - - // If a key with the spaces exists, use it. - // Otherwise, create an array by matching non-whitespace - key = key in cache ? - [ key ] : - ( key.match( rnothtmlwhite ) || [] ); - } - - i = key.length; - - while ( i-- ) { - delete cache[ key[ i ] ]; - } - } - - // Remove the expando if there's no more data - if ( key === undefined || jQuery.isEmptyObject( cache ) ) { - - // Support: Chrome <=35 - 45 - // Webkit & Blink performance suffers when deleting properties - // from DOM nodes, so set to undefined instead - // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) - if ( owner.nodeType ) { - owner[ this.expando ] = undefined; - } else { - delete owner[ this.expando ]; - } - } - }, - hasData: function( owner ) { - var cache = owner[ this.expando ]; - return cache !== undefined && !jQuery.isEmptyObject( cache ); - } -}; -var dataPriv = new Data(); - -var dataUser = new Data(); - - - -// Implementation Summary -// -// 1. Enforce API surface and semantic compatibility with 1.9.x branch -// 2. Improve the module's maintainability by reducing the storage -// paths to a single mechanism. -// 3. Use the same single mechanism to support "private" and "user" data. -// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) -// 5. Avoid exposing implementation details on user objects (eg. expando properties) -// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 - -var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, - rmultiDash = /[A-Z]/g; - -function getData( data ) { - if ( data === "true" ) { - return true; - } - - if ( data === "false" ) { - return false; - } - - if ( data === "null" ) { - return null; - } - - // Only convert to a number if it doesn't change the string - if ( data === +data + "" ) { - return +data; - } - - if ( rbrace.test( data ) ) { - return JSON.parse( data ); - } - - return data; -} - -function dataAttr( elem, key, data ) { - var name; - - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = getData( data ); - } catch ( e ) {} - - // Make sure we set the data so it isn't changed later - dataUser.set( elem, key, data ); - } else { - data = undefined; - } - } - return data; -} - -jQuery.extend( { - hasData: function( elem ) { - return dataUser.hasData( elem ) || dataPriv.hasData( elem ); - }, - - data: function( elem, name, data ) { - return dataUser.access( elem, name, data ); - }, - - removeData: function( elem, name ) { - dataUser.remove( elem, name ); - }, - - // TODO: Now that all calls to _data and _removeData have been replaced - // with direct calls to dataPriv methods, these can be deprecated. - _data: function( elem, name, data ) { - return dataPriv.access( elem, name, data ); - }, - - _removeData: function( elem, name ) { - dataPriv.remove( elem, name ); - } -} ); - -jQuery.fn.extend( { - data: function( key, value ) { - var i, name, data, - elem = this[ 0 ], - attrs = elem && elem.attributes; - - // Gets all values - if ( key === undefined ) { - if ( this.length ) { - data = dataUser.get( elem ); - - if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { - i = attrs.length; - while ( i-- ) { - - // Support: IE 11 only - // The attrs elements can be null (#14894) - if ( attrs[ i ] ) { - name = attrs[ i ].name; - if ( name.indexOf( "data-" ) === 0 ) { - name = camelCase( name.slice( 5 ) ); - dataAttr( elem, name, data[ name ] ); - } - } - } - dataPriv.set( elem, "hasDataAttrs", true ); - } - } - - return data; - } - - // Sets multiple values - if ( typeof key === "object" ) { - return this.each( function() { - dataUser.set( this, key ); - } ); - } - - return access( this, function( value ) { - var data; - - // The calling jQuery object (element matches) is not empty - // (and therefore has an element appears at this[ 0 ]) and the - // `value` parameter was not undefined. An empty jQuery object - // will result in `undefined` for elem = this[ 0 ] which will - // throw an exception if an attempt to read a data cache is made. - if ( elem && value === undefined ) { - - // Attempt to get data from the cache - // The key will always be camelCased in Data - data = dataUser.get( elem, key ); - if ( data !== undefined ) { - return data; - } - - // Attempt to "discover" the data in - // HTML5 custom data-* attrs - data = dataAttr( elem, key ); - if ( data !== undefined ) { - return data; - } - - // We tried really hard, but the data doesn't exist. - return; - } - - // Set the data... - this.each( function() { - - // We always store the camelCased key - dataUser.set( this, key, value ); - } ); - }, null, value, arguments.length > 1, null, true ); - }, - - removeData: function( key ) { - return this.each( function() { - dataUser.remove( this, key ); - } ); - } -} ); - - -jQuery.extend( { - queue: function( elem, type, data ) { - var queue; - - if ( elem ) { - type = ( type || "fx" ) + "queue"; - queue = dataPriv.get( elem, type ); - - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !queue || Array.isArray( data ) ) { - queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); - } else { - queue.push( data ); - } - } - return queue || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - startLength = queue.length, - fn = queue.shift(), - hooks = jQuery._queueHooks( elem, type ), - next = function() { - jQuery.dequeue( elem, type ); - }; - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - startLength--; - } - - if ( fn ) { - - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift( "inprogress" ); - } - - // Clear up the last queue stop function - delete hooks.stop; - fn.call( elem, next, hooks ); - } - - if ( !startLength && hooks ) { - hooks.empty.fire(); - } - }, - - // Not public - generate a queueHooks object, or return the current one - _queueHooks: function( elem, type ) { - var key = type + "queueHooks"; - return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { - empty: jQuery.Callbacks( "once memory" ).add( function() { - dataPriv.remove( elem, [ type + "queue", key ] ); - } ) - } ); - } -} ); - -jQuery.fn.extend( { - queue: function( type, data ) { - var setter = 2; - - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - setter--; - } - - if ( arguments.length < setter ) { - return jQuery.queue( this[ 0 ], type ); - } - - return data === undefined ? - this : - this.each( function() { - var queue = jQuery.queue( this, type, data ); - - // Ensure a hooks for this queue - jQuery._queueHooks( this, type ); - - if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - } ); - }, - dequeue: function( type ) { - return this.each( function() { - jQuery.dequeue( this, type ); - } ); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, obj ) { - var tmp, - count = 1, - defer = jQuery.Deferred(), - elements = this, - i = this.length, - resolve = function() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - }; - - if ( typeof type !== "string" ) { - obj = type; - type = undefined; - } - type = type || "fx"; - - while ( i-- ) { - tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); - if ( tmp && tmp.empty ) { - count++; - tmp.empty.add( resolve ); - } - } - resolve(); - return defer.promise( obj ); - } -} ); -var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; - -var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); - - -var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; - -var documentElement = document.documentElement; - - - - var isAttached = function( elem ) { - return jQuery.contains( elem.ownerDocument, elem ); - }, - composed = { composed: true }; - - // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only - // Check attachment across shadow DOM boundaries when possible (gh-3504) - // Support: iOS 10.0-10.2 only - // Early iOS 10 versions support `attachShadow` but not `getRootNode`, - // leading to errors. We need to check for `getRootNode`. - if ( documentElement.getRootNode ) { - isAttached = function( elem ) { - return jQuery.contains( elem.ownerDocument, elem ) || - elem.getRootNode( composed ) === elem.ownerDocument; - }; - } -var isHiddenWithinTree = function( elem, el ) { - - // isHiddenWithinTree might be called from jQuery#filter function; - // in that case, element will be second argument - elem = el || elem; - - // Inline style trumps all - return elem.style.display === "none" || - elem.style.display === "" && - - // Otherwise, check computed style - // Support: Firefox <=43 - 45 - // Disconnected elements can have computed display: none, so first confirm that elem is - // in the document. - isAttached( elem ) && - - jQuery.css( elem, "display" ) === "none"; - }; - - - -function adjustCSS( elem, prop, valueParts, tween ) { - var adjusted, scale, - maxIterations = 20, - currentValue = tween ? - function() { - return tween.cur(); - } : - function() { - return jQuery.css( elem, prop, "" ); - }, - initial = currentValue(), - unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), - - // Starting value computation is required for potential unit mismatches - initialInUnit = elem.nodeType && - ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && - rcssNum.exec( jQuery.css( elem, prop ) ); - - if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { - - // Support: Firefox <=54 - // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) - initial = initial / 2; - - // Trust units reported by jQuery.css - unit = unit || initialInUnit[ 3 ]; - - // Iteratively approximate from a nonzero starting point - initialInUnit = +initial || 1; - - while ( maxIterations-- ) { - - // Evaluate and update our best guess (doubling guesses that zero out). - // Finish if the scale equals or crosses 1 (making the old*new product non-positive). - jQuery.style( elem, prop, initialInUnit + unit ); - if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { - maxIterations = 0; - } - initialInUnit = initialInUnit / scale; - - } - - initialInUnit = initialInUnit * 2; - jQuery.style( elem, prop, initialInUnit + unit ); - - // Make sure we update the tween properties later on - valueParts = valueParts || []; - } - - if ( valueParts ) { - initialInUnit = +initialInUnit || +initial || 0; - - // Apply relative offset (+=/-=) if specified - adjusted = valueParts[ 1 ] ? - initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : - +valueParts[ 2 ]; - if ( tween ) { - tween.unit = unit; - tween.start = initialInUnit; - tween.end = adjusted; - } - } - return adjusted; -} - - -var defaultDisplayMap = {}; - -function getDefaultDisplay( elem ) { - var temp, - doc = elem.ownerDocument, - nodeName = elem.nodeName, - display = defaultDisplayMap[ nodeName ]; - - if ( display ) { - return display; - } - - temp = doc.body.appendChild( doc.createElement( nodeName ) ); - display = jQuery.css( temp, "display" ); - - temp.parentNode.removeChild( temp ); - - if ( display === "none" ) { - display = "block"; - } - defaultDisplayMap[ nodeName ] = display; - - return display; -} - -function showHide( elements, show ) { - var display, elem, - values = [], - index = 0, - length = elements.length; - - // Determine new display value for elements that need to change - for ( ; index < length; index++ ) { - elem = elements[ index ]; - if ( !elem.style ) { - continue; - } - - display = elem.style.display; - if ( show ) { - - // Since we force visibility upon cascade-hidden elements, an immediate (and slow) - // check is required in this first loop unless we have a nonempty display value (either - // inline or about-to-be-restored) - if ( display === "none" ) { - values[ index ] = dataPriv.get( elem, "display" ) || null; - if ( !values[ index ] ) { - elem.style.display = ""; - } - } - if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { - values[ index ] = getDefaultDisplay( elem ); - } - } else { - if ( display !== "none" ) { - values[ index ] = "none"; - - // Remember what we're overwriting - dataPriv.set( elem, "display", display ); - } - } - } - - // Set the display of the elements in a second loop to avoid constant reflow - for ( index = 0; index < length; index++ ) { - if ( values[ index ] != null ) { - elements[ index ].style.display = values[ index ]; - } - } - - return elements; -} - -jQuery.fn.extend( { - show: function() { - return showHide( this, true ); - }, - hide: function() { - return showHide( this ); - }, - toggle: function( state ) { - if ( typeof state === "boolean" ) { - return state ? this.show() : this.hide(); - } - - return this.each( function() { - if ( isHiddenWithinTree( this ) ) { - jQuery( this ).show(); - } else { - jQuery( this ).hide(); - } - } ); - } -} ); -var rcheckableType = ( /^(?:checkbox|radio)$/i ); - -var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); - -var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); - - - -( function() { - var fragment = document.createDocumentFragment(), - div = fragment.appendChild( document.createElement( "div" ) ), - input = document.createElement( "input" ); - - // Support: Android 4.0 - 4.3 only - // Check state lost if the name is set (#11217) - // Support: Windows Web Apps (WWA) - // `name` and `type` must use .setAttribute for WWA (#14901) - input.setAttribute( "type", "radio" ); - input.setAttribute( "checked", "checked" ); - input.setAttribute( "name", "t" ); - - div.appendChild( input ); - - // Support: Android <=4.1 only - // Older WebKit doesn't clone checked state correctly in fragments - support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; - - // Support: IE <=11 only - // Make sure textarea (and checkbox) defaultValue is properly cloned - div.innerHTML = ""; - support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; - - // Support: IE <=9 only - // IE <=9 replaces "; - support.option = !!div.lastChild; -} )(); - - -// We have to close these tags to support XHTML (#13200) -var wrapMap = { - - // XHTML parsers do not magically insert elements in the - // same way that tag soup parsers do. So we cannot shorten - // this by omitting or other required elements. - thead: [ 1, "", "
      " ], - col: [ 2, "", "
      " ], - tr: [ 2, "", "
      " ], - td: [ 3, "", "
      " ], - - _default: [ 0, "", "" ] -}; - -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - -// Support: IE <=9 only -if ( !support.option ) { - wrapMap.optgroup = wrapMap.option = [ 1, "" ]; -} - - -function getAll( context, tag ) { - - // Support: IE <=9 - 11 only - // Use typeof to avoid zero-argument method invocation on host objects (#15151) - var ret; - - if ( typeof context.getElementsByTagName !== "undefined" ) { - ret = context.getElementsByTagName( tag || "*" ); - - } else if ( typeof context.querySelectorAll !== "undefined" ) { - ret = context.querySelectorAll( tag || "*" ); - - } else { - ret = []; - } - - if ( tag === undefined || tag && nodeName( context, tag ) ) { - return jQuery.merge( [ context ], ret ); - } - - return ret; -} - - -// Mark scripts as having already been evaluated -function setGlobalEval( elems, refElements ) { - var i = 0, - l = elems.length; - - for ( ; i < l; i++ ) { - dataPriv.set( - elems[ i ], - "globalEval", - !refElements || dataPriv.get( refElements[ i ], "globalEval" ) - ); - } -} - - -var rhtml = /<|&#?\w+;/; - -function buildFragment( elems, context, scripts, selection, ignored ) { - var elem, tmp, tag, wrap, attached, j, - fragment = context.createDocumentFragment(), - nodes = [], - i = 0, - l = elems.length; - - for ( ; i < l; i++ ) { - elem = elems[ i ]; - - if ( elem || elem === 0 ) { - - // Add nodes directly - if ( toType( elem ) === "object" ) { - - // Support: Android <=4.0 only, PhantomJS 1 only - // push.apply(_, arraylike) throws on ancient WebKit - jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); - - // Convert non-html into a text node - } else if ( !rhtml.test( elem ) ) { - nodes.push( context.createTextNode( elem ) ); - - // Convert html into DOM nodes - } else { - tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); - - // Deserialize a standard representation - tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); - wrap = wrapMap[ tag ] || wrapMap._default; - tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; - - // Descend through wrappers to the right content - j = wrap[ 0 ]; - while ( j-- ) { - tmp = tmp.lastChild; - } - - // Support: Android <=4.0 only, PhantomJS 1 only - // push.apply(_, arraylike) throws on ancient WebKit - jQuery.merge( nodes, tmp.childNodes ); - - // Remember the top-level container - tmp = fragment.firstChild; - - // Ensure the created nodes are orphaned (#12392) - tmp.textContent = ""; - } - } - } - - // Remove wrapper from fragment - fragment.textContent = ""; - - i = 0; - while ( ( elem = nodes[ i++ ] ) ) { - - // Skip elements already in the context collection (trac-4087) - if ( selection && jQuery.inArray( elem, selection ) > -1 ) { - if ( ignored ) { - ignored.push( elem ); - } - continue; - } - - attached = isAttached( elem ); - - // Append to fragment - tmp = getAll( fragment.appendChild( elem ), "script" ); - - // Preserve script evaluation history - if ( attached ) { - setGlobalEval( tmp ); - } - - // Capture executables - if ( scripts ) { - j = 0; - while ( ( elem = tmp[ j++ ] ) ) { - if ( rscriptType.test( elem.type || "" ) ) { - scripts.push( elem ); - } - } - } - } - - return fragment; -} - - -var rtypenamespace = /^([^.]*)(?:\.(.+)|)/; - -function returnTrue() { - return true; -} - -function returnFalse() { - return false; -} - -// Support: IE <=9 - 11+ -// focus() and blur() are asynchronous, except when they are no-op. -// So expect focus to be synchronous when the element is already active, -// and blur to be synchronous when the element is not already active. -// (focus and blur are always synchronous in other supported browsers, -// this just defines when we can count on it). -function expectSync( elem, type ) { - return ( elem === safeActiveElement() ) === ( type === "focus" ); -} - -// Support: IE <=9 only -// Accessing document.activeElement can throw unexpectedly -// https://bugs.jquery.com/ticket/13393 -function safeActiveElement() { - try { - return document.activeElement; - } catch ( err ) { } -} - -function on( elem, types, selector, data, fn, one ) { - var origFn, type; - - // Types can be a map of types/handlers - if ( typeof types === "object" ) { - - // ( types-Object, selector, data ) - if ( typeof selector !== "string" ) { - - // ( types-Object, data ) - data = data || selector; - selector = undefined; - } - for ( type in types ) { - on( elem, type, selector, data, types[ type ], one ); - } - return elem; - } - - if ( data == null && fn == null ) { - - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if ( fn == null ) { - if ( typeof selector === "string" ) { - - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - if ( fn === false ) { - fn = returnFalse; - } else if ( !fn ) { - return elem; - } - - if ( one === 1 ) { - origFn = fn; - fn = function( event ) { - - // Can use an empty set, since event contains the info - jQuery().off( event ); - return origFn.apply( this, arguments ); - }; - - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); - } - return elem.each( function() { - jQuery.event.add( this, types, fn, data, selector ); - } ); -} - -/* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ -jQuery.event = { - - global: {}, - - add: function( elem, types, handler, data, selector ) { - - var handleObjIn, eventHandle, tmp, - events, t, handleObj, - special, handlers, type, namespaces, origType, - elemData = dataPriv.get( elem ); - - // Only attach events to objects that accept data - if ( !acceptData( elem ) ) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - selector = handleObjIn.selector; - } - - // Ensure that invalid selectors throw exceptions at attach time - // Evaluate against documentElement in case elem is a non-element node (e.g., document) - if ( selector ) { - jQuery.find.matchesSelector( documentElement, selector ); - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - if ( !( events = elemData.events ) ) { - events = elemData.events = Object.create( null ); - } - if ( !( eventHandle = elemData.handle ) ) { - eventHandle = elemData.handle = function( e ) { - - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? - jQuery.event.dispatch.apply( elem, arguments ) : undefined; - }; - } - - // Handle multiple events separated by a space - types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[ t ] ) || []; - type = origType = tmp[ 1 ]; - namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); - - // There *must* be a type, no attaching namespace-only handlers - if ( !type ) { - continue; - } - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = ( selector ? special.delegateType : special.bindType ) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend( { - type: type, - origType: origType, - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - needsContext: selector && jQuery.expr.match.needsContext.test( selector ), - namespace: namespaces.join( "." ) - }, handleObjIn ); - - // Init the event handler queue if we're the first - if ( !( handlers = events[ type ] ) ) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener if the special events handler returns false - if ( !special.setup || - special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if ( selector ) { - handlers.splice( handlers.delegateCount++, 0, handleObj ); - } else { - handlers.push( handleObj ); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - }, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, selector, mappedTypes ) { - - var j, origCount, tmp, - events, t, handleObj, - special, handlers, type, namespaces, origType, - elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); - - if ( !elemData || !( events = elemData.events ) ) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[ t ] ) || []; - type = origType = tmp[ 1 ]; - namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); - - // Unbind all events (on this namespace, if provided) for the element - if ( !type ) { - for ( type in events ) { - jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = ( selector ? special.delegateType : special.bindType ) || type; - handlers = events[ type ] || []; - tmp = tmp[ 2 ] && - new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); - - // Remove matching events - origCount = j = handlers.length; - while ( j-- ) { - handleObj = handlers[ j ]; - - if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !tmp || tmp.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || - selector === "**" && handleObj.selector ) ) { - handlers.splice( j, 1 ); - - if ( handleObj.selector ) { - handlers.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if ( origCount && !handlers.length ) { - if ( !special.teardown || - special.teardown.call( elem, namespaces, elemData.handle ) === false ) { - - jQuery.removeEvent( elem, type, elemData.handle ); - } - - delete events[ type ]; - } - } - - // Remove data and the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - dataPriv.remove( elem, "handle events" ); - } - }, - - dispatch: function( nativeEvent ) { - - var i, j, ret, matched, handleObj, handlerQueue, - args = new Array( arguments.length ), - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( nativeEvent ), - - handlers = ( - dataPriv.get( this, "events" ) || Object.create( null ) - )[ event.type ] || [], - special = jQuery.event.special[ event.type ] || {}; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[ 0 ] = event; - - for ( i = 1; i < arguments.length; i++ ) { - args[ i ] = arguments[ i ]; - } - - event.delegateTarget = this; - - // Call the preDispatch hook for the mapped type, and let it bail if desired - if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { - return; - } - - // Determine handlers - handlerQueue = jQuery.event.handlers.call( this, event, handlers ); - - // Run delegates first; they may want to stop propagation beneath us - i = 0; - while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { - event.currentTarget = matched.elem; - - j = 0; - while ( ( handleObj = matched.handlers[ j++ ] ) && - !event.isImmediatePropagationStopped() ) { - - // If the event is namespaced, then each handler is only invoked if it is - // specially universal or its namespaces are a superset of the event's. - if ( !event.rnamespace || handleObj.namespace === false || - event.rnamespace.test( handleObj.namespace ) ) { - - event.handleObj = handleObj; - event.data = handleObj.data; - - ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || - handleObj.handler ).apply( matched.elem, args ); - - if ( ret !== undefined ) { - if ( ( event.result = ret ) === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - // Call the postDispatch hook for the mapped type - if ( special.postDispatch ) { - special.postDispatch.call( this, event ); - } - - return event.result; - }, - - handlers: function( event, handlers ) { - var i, handleObj, sel, matchedHandlers, matchedSelectors, - handlerQueue = [], - delegateCount = handlers.delegateCount, - cur = event.target; - - // Find delegate handlers - if ( delegateCount && - - // Support: IE <=9 - // Black-hole SVG instance trees (trac-13180) - cur.nodeType && - - // Support: Firefox <=42 - // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) - // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click - // Support: IE 11 only - // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) - !( event.type === "click" && event.button >= 1 ) ) { - - for ( ; cur !== this; cur = cur.parentNode || this ) { - - // Don't check non-elements (#13208) - // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) - if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { - matchedHandlers = []; - matchedSelectors = {}; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - - // Don't conflict with Object.prototype properties (#13203) - sel = handleObj.selector + " "; - - if ( matchedSelectors[ sel ] === undefined ) { - matchedSelectors[ sel ] = handleObj.needsContext ? - jQuery( sel, this ).index( cur ) > -1 : - jQuery.find( sel, this, null, [ cur ] ).length; - } - if ( matchedSelectors[ sel ] ) { - matchedHandlers.push( handleObj ); - } - } - if ( matchedHandlers.length ) { - handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); - } - } - } - } - - // Add the remaining (directly-bound) handlers - cur = this; - if ( delegateCount < handlers.length ) { - handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); - } - - return handlerQueue; - }, - - addProp: function( name, hook ) { - Object.defineProperty( jQuery.Event.prototype, name, { - enumerable: true, - configurable: true, - - get: isFunction( hook ) ? - function() { - if ( this.originalEvent ) { - return hook( this.originalEvent ); - } - } : - function() { - if ( this.originalEvent ) { - return this.originalEvent[ name ]; - } - }, - - set: function( value ) { - Object.defineProperty( this, name, { - enumerable: true, - configurable: true, - writable: true, - value: value - } ); - } - } ); - }, - - fix: function( originalEvent ) { - return originalEvent[ jQuery.expando ] ? - originalEvent : - new jQuery.Event( originalEvent ); - }, - - special: { - load: { - - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - click: { - - // Utilize native event to ensure correct state for checkable inputs - setup: function( data ) { - - // For mutual compressibility with _default, replace `this` access with a local var. - // `|| data` is dead code meant only to preserve the variable through minification. - var el = this || data; - - // Claim the first handler - if ( rcheckableType.test( el.type ) && - el.click && nodeName( el, "input" ) ) { - - // dataPriv.set( el, "click", ... ) - leverageNative( el, "click", returnTrue ); - } - - // Return false to allow normal processing in the caller - return false; - }, - trigger: function( data ) { - - // For mutual compressibility with _default, replace `this` access with a local var. - // `|| data` is dead code meant only to preserve the variable through minification. - var el = this || data; - - // Force setup before triggering a click - if ( rcheckableType.test( el.type ) && - el.click && nodeName( el, "input" ) ) { - - leverageNative( el, "click" ); - } - - // Return non-false to allow normal event-path propagation - return true; - }, - - // For cross-browser consistency, suppress native .click() on links - // Also prevent it if we're currently inside a leveraged native-event stack - _default: function( event ) { - var target = event.target; - return rcheckableType.test( target.type ) && - target.click && nodeName( target, "input" ) && - dataPriv.get( target, "click" ) || - nodeName( target, "a" ); - } - }, - - beforeunload: { - postDispatch: function( event ) { - - // Support: Firefox 20+ - // Firefox doesn't alert if the returnValue field is not set. - if ( event.result !== undefined && event.originalEvent ) { - event.originalEvent.returnValue = event.result; - } - } - } - } -}; - -// Ensure the presence of an event listener that handles manually-triggered -// synthetic events by interrupting progress until reinvoked in response to -// *native* events that it fires directly, ensuring that state changes have -// already occurred before other listeners are invoked. -function leverageNative( el, type, expectSync ) { - - // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add - if ( !expectSync ) { - if ( dataPriv.get( el, type ) === undefined ) { - jQuery.event.add( el, type, returnTrue ); - } - return; - } - - // Register the controller as a special universal handler for all event namespaces - dataPriv.set( el, type, false ); - jQuery.event.add( el, type, { - namespace: false, - handler: function( event ) { - var notAsync, result, - saved = dataPriv.get( this, type ); - - if ( ( event.isTrigger & 1 ) && this[ type ] ) { - - // Interrupt processing of the outer synthetic .trigger()ed event - // Saved data should be false in such cases, but might be a leftover capture object - // from an async native handler (gh-4350) - if ( !saved.length ) { - - // Store arguments for use when handling the inner native event - // There will always be at least one argument (an event object), so this array - // will not be confused with a leftover capture object. - saved = slice.call( arguments ); - dataPriv.set( this, type, saved ); - - // Trigger the native event and capture its result - // Support: IE <=9 - 11+ - // focus() and blur() are asynchronous - notAsync = expectSync( this, type ); - this[ type ](); - result = dataPriv.get( this, type ); - if ( saved !== result || notAsync ) { - dataPriv.set( this, type, false ); - } else { - result = {}; - } - if ( saved !== result ) { - - // Cancel the outer synthetic event - event.stopImmediatePropagation(); - event.preventDefault(); - - // Support: Chrome 86+ - // In Chrome, if an element having a focusout handler is blurred by - // clicking outside of it, it invokes the handler synchronously. If - // that handler calls `.remove()` on the element, the data is cleared, - // leaving `result` undefined. We need to guard against this. - return result && result.value; - } - - // If this is an inner synthetic event for an event with a bubbling surrogate - // (focus or blur), assume that the surrogate already propagated from triggering the - // native event and prevent that from happening again here. - // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the - // bubbling surrogate propagates *after* the non-bubbling base), but that seems - // less bad than duplication. - } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { - event.stopPropagation(); - } - - // If this is a native event triggered above, everything is now in order - // Fire an inner synthetic event with the original arguments - } else if ( saved.length ) { - - // ...and capture the result - dataPriv.set( this, type, { - value: jQuery.event.trigger( - - // Support: IE <=9 - 11+ - // Extend with the prototype to reset the above stopImmediatePropagation() - jQuery.extend( saved[ 0 ], jQuery.Event.prototype ), - saved.slice( 1 ), - this - ) - } ); - - // Abort handling of the native event - event.stopImmediatePropagation(); - } - } - } ); -} - -jQuery.removeEvent = function( elem, type, handle ) { - - // This "if" is needed for plain objects - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle ); - } -}; - -jQuery.Event = function( src, props ) { - - // Allow instantiation without the 'new' keyword - if ( !( this instanceof jQuery.Event ) ) { - return new jQuery.Event( src, props ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = src.defaultPrevented || - src.defaultPrevented === undefined && - - // Support: Android <=2.3 only - src.returnValue === false ? - returnTrue : - returnFalse; - - // Create target properties - // Support: Safari <=6 - 7 only - // Target should not be a text node (#504, #13143) - this.target = ( src.target && src.target.nodeType === 3 ) ? - src.target.parentNode : - src.target; - - this.currentTarget = src.currentTarget; - this.relatedTarget = src.relatedTarget; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || Date.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - constructor: jQuery.Event, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse, - isSimulated: false, - - preventDefault: function() { - var e = this.originalEvent; - - this.isDefaultPrevented = returnTrue; - - if ( e && !this.isSimulated ) { - e.preventDefault(); - } - }, - stopPropagation: function() { - var e = this.originalEvent; - - this.isPropagationStopped = returnTrue; - - if ( e && !this.isSimulated ) { - e.stopPropagation(); - } - }, - stopImmediatePropagation: function() { - var e = this.originalEvent; - - this.isImmediatePropagationStopped = returnTrue; - - if ( e && !this.isSimulated ) { - e.stopImmediatePropagation(); - } - - this.stopPropagation(); - } -}; - -// Includes all common event props including KeyEvent and MouseEvent specific props -jQuery.each( { - altKey: true, - bubbles: true, - cancelable: true, - changedTouches: true, - ctrlKey: true, - detail: true, - eventPhase: true, - metaKey: true, - pageX: true, - pageY: true, - shiftKey: true, - view: true, - "char": true, - code: true, - charCode: true, - key: true, - keyCode: true, - button: true, - buttons: true, - clientX: true, - clientY: true, - offsetX: true, - offsetY: true, - pointerId: true, - pointerType: true, - screenX: true, - screenY: true, - targetTouches: true, - toElement: true, - touches: true, - which: true -}, jQuery.event.addProp ); - -jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { - jQuery.event.special[ type ] = { - - // Utilize native event if possible so blur/focus sequence is correct - setup: function() { - - // Claim the first handler - // dataPriv.set( this, "focus", ... ) - // dataPriv.set( this, "blur", ... ) - leverageNative( this, type, expectSync ); - - // Return false to allow normal processing in the caller - return false; - }, - trigger: function() { - - // Force setup before trigger - leverageNative( this, type ); - - // Return non-false to allow normal event-path propagation - return true; - }, - - // Suppress native focus or blur as it's already being fired - // in leverageNative. - _default: function() { - return true; - }, - - delegateType: delegateType - }; -} ); - -// Create mouseenter/leave events using mouseover/out and event-time checks -// so that event delegation works in jQuery. -// Do the same for pointerenter/pointerleave and pointerover/pointerout -// -// Support: Safari 7 only -// Safari sends mouseenter too often; see: -// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 -// for the description of the bug (it existed in older Chrome versions as well). -jQuery.each( { - mouseenter: "mouseover", - mouseleave: "mouseout", - pointerenter: "pointerover", - pointerleave: "pointerout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, - - handle: function( event ) { - var ret, - target = this, - related = event.relatedTarget, - handleObj = event.handleObj; - - // For mouseenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { - event.type = handleObj.origType; - ret = handleObj.handler.apply( this, arguments ); - event.type = fix; - } - return ret; - } - }; -} ); - -jQuery.fn.extend( { - - on: function( types, selector, data, fn ) { - return on( this, types, selector, data, fn ); - }, - one: function( types, selector, data, fn ) { - return on( this, types, selector, data, fn, 1 ); - }, - off: function( types, selector, fn ) { - var handleObj, type; - if ( types && types.preventDefault && types.handleObj ) { - - // ( event ) dispatched jQuery.Event - handleObj = types.handleObj; - jQuery( types.delegateTarget ).off( - handleObj.namespace ? - handleObj.origType + "." + handleObj.namespace : - handleObj.origType, - handleObj.selector, - handleObj.handler - ); - return this; - } - if ( typeof types === "object" ) { - - // ( types-object [, selector] ) - for ( type in types ) { - this.off( type, selector, types[ type ] ); - } - return this; - } - if ( selector === false || typeof selector === "function" ) { - - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if ( fn === false ) { - fn = returnFalse; - } - return this.each( function() { - jQuery.event.remove( this, types, fn, selector ); - } ); - } -} ); - - -var - - // Support: IE <=10 - 11, Edge 12 - 13 only - // In IE/Edge using regex groups here causes severe slowdowns. - // See https://connect.microsoft.com/IE/feedback/details/1736512/ - rnoInnerhtml = /\s*$/g; - -// Prefer a tbody over its parent table for containing new rows -function manipulationTarget( elem, content ) { - if ( nodeName( elem, "table" ) && - nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { - - return jQuery( elem ).children( "tbody" )[ 0 ] || elem; - } - - return elem; -} - -// Replace/restore the type attribute of script elements for safe DOM manipulation -function disableScript( elem ) { - elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; - return elem; -} -function restoreScript( elem ) { - if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { - elem.type = elem.type.slice( 5 ); - } else { - elem.removeAttribute( "type" ); - } - - return elem; -} - -function cloneCopyEvent( src, dest ) { - var i, l, type, pdataOld, udataOld, udataCur, events; - - if ( dest.nodeType !== 1 ) { - return; - } - - // 1. Copy private data: events, handlers, etc. - if ( dataPriv.hasData( src ) ) { - pdataOld = dataPriv.get( src ); - events = pdataOld.events; - - if ( events ) { - dataPriv.remove( dest, "handle events" ); - - for ( type in events ) { - for ( i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type, events[ type ][ i ] ); - } - } - } - } - - // 2. Copy user data - if ( dataUser.hasData( src ) ) { - udataOld = dataUser.access( src ); - udataCur = jQuery.extend( {}, udataOld ); - - dataUser.set( dest, udataCur ); - } -} - -// Fix IE bugs, see support tests -function fixInput( src, dest ) { - var nodeName = dest.nodeName.toLowerCase(); - - // Fails to persist the checked state of a cloned checkbox or radio button. - if ( nodeName === "input" && rcheckableType.test( src.type ) ) { - dest.checked = src.checked; - - // Fails to return the selected option to the default selected state when cloning options - } else if ( nodeName === "input" || nodeName === "textarea" ) { - dest.defaultValue = src.defaultValue; - } -} - -function domManip( collection, args, callback, ignored ) { - - // Flatten any nested arrays - args = flat( args ); - - var fragment, first, scripts, hasScripts, node, doc, - i = 0, - l = collection.length, - iNoClone = l - 1, - value = args[ 0 ], - valueIsFunction = isFunction( value ); - - // We can't cloneNode fragments that contain checked, in WebKit - if ( valueIsFunction || - ( l > 1 && typeof value === "string" && - !support.checkClone && rchecked.test( value ) ) ) { - return collection.each( function( index ) { - var self = collection.eq( index ); - if ( valueIsFunction ) { - args[ 0 ] = value.call( this, index, self.html() ); - } - domManip( self, args, callback, ignored ); - } ); - } - - if ( l ) { - fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); - first = fragment.firstChild; - - if ( fragment.childNodes.length === 1 ) { - fragment = first; - } - - // Require either new content or an interest in ignored elements to invoke the callback - if ( first || ignored ) { - scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); - hasScripts = scripts.length; - - // Use the original fragment for the last item - // instead of the first because it can end up - // being emptied incorrectly in certain situations (#8070). - for ( ; i < l; i++ ) { - node = fragment; - - if ( i !== iNoClone ) { - node = jQuery.clone( node, true, true ); - - // Keep references to cloned scripts for later restoration - if ( hasScripts ) { - - // Support: Android <=4.0 only, PhantomJS 1 only - // push.apply(_, arraylike) throws on ancient WebKit - jQuery.merge( scripts, getAll( node, "script" ) ); - } - } - - callback.call( collection[ i ], node, i ); - } - - if ( hasScripts ) { - doc = scripts[ scripts.length - 1 ].ownerDocument; - - // Reenable scripts - jQuery.map( scripts, restoreScript ); - - // Evaluate executable scripts on first document insertion - for ( i = 0; i < hasScripts; i++ ) { - node = scripts[ i ]; - if ( rscriptType.test( node.type || "" ) && - !dataPriv.access( node, "globalEval" ) && - jQuery.contains( doc, node ) ) { - - if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { - - // Optional AJAX dependency, but won't run scripts if not present - if ( jQuery._evalUrl && !node.noModule ) { - jQuery._evalUrl( node.src, { - nonce: node.nonce || node.getAttribute( "nonce" ) - }, doc ); - } - } else { - DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); - } - } - } - } - } - } - - return collection; -} - -function remove( elem, selector, keepData ) { - var node, - nodes = selector ? jQuery.filter( selector, elem ) : elem, - i = 0; - - for ( ; ( node = nodes[ i ] ) != null; i++ ) { - if ( !keepData && node.nodeType === 1 ) { - jQuery.cleanData( getAll( node ) ); - } - - if ( node.parentNode ) { - if ( keepData && isAttached( node ) ) { - setGlobalEval( getAll( node, "script" ) ); - } - node.parentNode.removeChild( node ); - } - } - - return elem; -} - -jQuery.extend( { - htmlPrefilter: function( html ) { - return html; - }, - - clone: function( elem, dataAndEvents, deepDataAndEvents ) { - var i, l, srcElements, destElements, - clone = elem.cloneNode( true ), - inPage = isAttached( elem ); - - // Fix IE cloning issues - if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && - !jQuery.isXMLDoc( elem ) ) { - - // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 - destElements = getAll( clone ); - srcElements = getAll( elem ); - - for ( i = 0, l = srcElements.length; i < l; i++ ) { - fixInput( srcElements[ i ], destElements[ i ] ); - } - } - - // Copy the events from the original to the clone - if ( dataAndEvents ) { - if ( deepDataAndEvents ) { - srcElements = srcElements || getAll( elem ); - destElements = destElements || getAll( clone ); - - for ( i = 0, l = srcElements.length; i < l; i++ ) { - cloneCopyEvent( srcElements[ i ], destElements[ i ] ); - } - } else { - cloneCopyEvent( elem, clone ); - } - } - - // Preserve script evaluation history - destElements = getAll( clone, "script" ); - if ( destElements.length > 0 ) { - setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); - } - - // Return the cloned set - return clone; - }, - - cleanData: function( elems ) { - var data, elem, type, - special = jQuery.event.special, - i = 0; - - for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { - if ( acceptData( elem ) ) { - if ( ( data = elem[ dataPriv.expando ] ) ) { - if ( data.events ) { - for ( type in data.events ) { - if ( special[ type ] ) { - jQuery.event.remove( elem, type ); - - // This is a shortcut to avoid jQuery.event.remove's overhead - } else { - jQuery.removeEvent( elem, type, data.handle ); - } - } - } - - // Support: Chrome <=35 - 45+ - // Assign undefined instead of using delete, see Data#remove - elem[ dataPriv.expando ] = undefined; - } - if ( elem[ dataUser.expando ] ) { - - // Support: Chrome <=35 - 45+ - // Assign undefined instead of using delete, see Data#remove - elem[ dataUser.expando ] = undefined; - } - } - } - } -} ); - -jQuery.fn.extend( { - detach: function( selector ) { - return remove( this, selector, true ); - }, - - remove: function( selector ) { - return remove( this, selector ); - }, - - text: function( value ) { - return access( this, function( value ) { - return value === undefined ? - jQuery.text( this ) : - this.empty().each( function() { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - this.textContent = value; - } - } ); - }, null, value, arguments.length ); - }, - - append: function() { - return domManip( this, arguments, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - var target = manipulationTarget( this, elem ); - target.appendChild( elem ); - } - } ); - }, - - prepend: function() { - return domManip( this, arguments, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - var target = manipulationTarget( this, elem ); - target.insertBefore( elem, target.firstChild ); - } - } ); - }, - - before: function() { - return domManip( this, arguments, function( elem ) { - if ( this.parentNode ) { - this.parentNode.insertBefore( elem, this ); - } - } ); - }, - - after: function() { - return domManip( this, arguments, function( elem ) { - if ( this.parentNode ) { - this.parentNode.insertBefore( elem, this.nextSibling ); - } - } ); - }, - - empty: function() { - var elem, - i = 0; - - for ( ; ( elem = this[ i ] ) != null; i++ ) { - if ( elem.nodeType === 1 ) { - - // Prevent memory leaks - jQuery.cleanData( getAll( elem, false ) ); - - // Remove any remaining nodes - elem.textContent = ""; - } - } - - return this; - }, - - clone: function( dataAndEvents, deepDataAndEvents ) { - dataAndEvents = dataAndEvents == null ? false : dataAndEvents; - deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; - - return this.map( function() { - return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); - } ); - }, - - html: function( value ) { - return access( this, function( value ) { - var elem = this[ 0 ] || {}, - i = 0, - l = this.length; - - if ( value === undefined && elem.nodeType === 1 ) { - return elem.innerHTML; - } - - // See if we can take a shortcut and just use innerHTML - if ( typeof value === "string" && !rnoInnerhtml.test( value ) && - !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { - - value = jQuery.htmlPrefilter( value ); - - try { - for ( ; i < l; i++ ) { - elem = this[ i ] || {}; - - // Remove element nodes and prevent memory leaks - if ( elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem, false ) ); - elem.innerHTML = value; - } - } - - elem = 0; - - // If using innerHTML throws an exception, use the fallback method - } catch ( e ) {} - } - - if ( elem ) { - this.empty().append( value ); - } - }, null, value, arguments.length ); - }, - - replaceWith: function() { - var ignored = []; - - // Make the changes, replacing each non-ignored context element with the new content - return domManip( this, arguments, function( elem ) { - var parent = this.parentNode; - - if ( jQuery.inArray( this, ignored ) < 0 ) { - jQuery.cleanData( getAll( this ) ); - if ( parent ) { - parent.replaceChild( elem, this ); - } - } - - // Force callback invocation - }, ignored ); - } -} ); - -jQuery.each( { - appendTo: "append", - prependTo: "prepend", - insertBefore: "before", - insertAfter: "after", - replaceAll: "replaceWith" -}, function( name, original ) { - jQuery.fn[ name ] = function( selector ) { - var elems, - ret = [], - insert = jQuery( selector ), - last = insert.length - 1, - i = 0; - - for ( ; i <= last; i++ ) { - elems = i === last ? this : this.clone( true ); - jQuery( insert[ i ] )[ original ]( elems ); - - // Support: Android <=4.0 only, PhantomJS 1 only - // .get() because push.apply(_, arraylike) throws on ancient WebKit - push.apply( ret, elems.get() ); - } - - return this.pushStack( ret ); - }; -} ); -var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); - -var getStyles = function( elem ) { - - // Support: IE <=11 only, Firefox <=30 (#15098, #14150) - // IE throws on elements created in popups - // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" - var view = elem.ownerDocument.defaultView; - - if ( !view || !view.opener ) { - view = window; - } - - return view.getComputedStyle( elem ); - }; - -var swap = function( elem, options, callback ) { - var ret, name, - old = {}; - - // Remember the old values, and insert the new ones - for ( name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - ret = callback.call( elem ); - - // Revert the old values - for ( name in options ) { - elem.style[ name ] = old[ name ]; - } - - return ret; -}; - - -var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); - - - -( function() { - - // Executing both pixelPosition & boxSizingReliable tests require only one layout - // so they're executed at the same time to save the second computation. - function computeStyleTests() { - - // This is a singleton, we need to execute it only once - if ( !div ) { - return; - } - - container.style.cssText = "position:absolute;left:-11111px;width:60px;" + - "margin-top:1px;padding:0;border:0"; - div.style.cssText = - "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + - "margin:auto;border:1px;padding:1px;" + - "width:60%;top:1%"; - documentElement.appendChild( container ).appendChild( div ); - - var divStyle = window.getComputedStyle( div ); - pixelPositionVal = divStyle.top !== "1%"; - - // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 - reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; - - // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 - // Some styles come back with percentage values, even though they shouldn't - div.style.right = "60%"; - pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; - - // Support: IE 9 - 11 only - // Detect misreporting of content dimensions for box-sizing:border-box elements - boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; - - // Support: IE 9 only - // Detect overflow:scroll screwiness (gh-3699) - // Support: Chrome <=64 - // Don't get tricked when zoom affects offsetWidth (gh-4029) - div.style.position = "absolute"; - scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; - - documentElement.removeChild( container ); - - // Nullify the div so it wouldn't be stored in the memory and - // it will also be a sign that checks already performed - div = null; - } - - function roundPixelMeasures( measure ) { - return Math.round( parseFloat( measure ) ); - } - - var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, - reliableTrDimensionsVal, reliableMarginLeftVal, - container = document.createElement( "div" ), - div = document.createElement( "div" ); - - // Finish early in limited (non-browser) environments - if ( !div.style ) { - return; - } - - // Support: IE <=9 - 11 only - // Style of cloned element affects source element cloned (#8908) - div.style.backgroundClip = "content-box"; - div.cloneNode( true ).style.backgroundClip = ""; - support.clearCloneStyle = div.style.backgroundClip === "content-box"; - - jQuery.extend( support, { - boxSizingReliable: function() { - computeStyleTests(); - return boxSizingReliableVal; - }, - pixelBoxStyles: function() { - computeStyleTests(); - return pixelBoxStylesVal; - }, - pixelPosition: function() { - computeStyleTests(); - return pixelPositionVal; - }, - reliableMarginLeft: function() { - computeStyleTests(); - return reliableMarginLeftVal; - }, - scrollboxSize: function() { - computeStyleTests(); - return scrollboxSizeVal; - }, - - // Support: IE 9 - 11+, Edge 15 - 18+ - // IE/Edge misreport `getComputedStyle` of table rows with width/height - // set in CSS while `offset*` properties report correct values. - // Behavior in IE 9 is more subtle than in newer versions & it passes - // some versions of this test; make sure not to make it pass there! - // - // Support: Firefox 70+ - // Only Firefox includes border widths - // in computed dimensions. (gh-4529) - reliableTrDimensions: function() { - var table, tr, trChild, trStyle; - if ( reliableTrDimensionsVal == null ) { - table = document.createElement( "table" ); - tr = document.createElement( "tr" ); - trChild = document.createElement( "div" ); - - table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; - tr.style.cssText = "border:1px solid"; - - // Support: Chrome 86+ - // Height set through cssText does not get applied. - // Computed height then comes back as 0. - tr.style.height = "1px"; - trChild.style.height = "9px"; - - // Support: Android 8 Chrome 86+ - // In our bodyBackground.html iframe, - // display for all div elements is set to "inline", - // which causes a problem only in Android 8 Chrome 86. - // Ensuring the div is display: block - // gets around this issue. - trChild.style.display = "block"; - - documentElement - .appendChild( table ) - .appendChild( tr ) - .appendChild( trChild ); - - trStyle = window.getComputedStyle( tr ); - reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + - parseInt( trStyle.borderTopWidth, 10 ) + - parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; - - documentElement.removeChild( table ); - } - return reliableTrDimensionsVal; - } - } ); -} )(); - - -function curCSS( elem, name, computed ) { - var width, minWidth, maxWidth, ret, - - // Support: Firefox 51+ - // Retrieving style before computed somehow - // fixes an issue with getting wrong values - // on detached elements - style = elem.style; - - computed = computed || getStyles( elem ); - - // getPropertyValue is needed for: - // .css('filter') (IE 9 only, #12537) - // .css('--customProperty) (#3144) - if ( computed ) { - ret = computed.getPropertyValue( name ) || computed[ name ]; - - if ( ret === "" && !isAttached( elem ) ) { - ret = jQuery.style( elem, name ); - } - - // A tribute to the "awesome hack by Dean Edwards" - // Android Browser returns percentage for some values, - // but width seems to be reliably pixels. - // This is against the CSSOM draft spec: - // https://drafts.csswg.org/cssom/#resolved-values - if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { - - // Remember the original values - width = style.width; - minWidth = style.minWidth; - maxWidth = style.maxWidth; - - // Put in the new values to get a computed value out - style.minWidth = style.maxWidth = style.width = ret; - ret = computed.width; - - // Revert the changed values - style.width = width; - style.minWidth = minWidth; - style.maxWidth = maxWidth; - } - } - - return ret !== undefined ? - - // Support: IE <=9 - 11 only - // IE returns zIndex value as an integer. - ret + "" : - ret; -} - - -function addGetHookIf( conditionFn, hookFn ) { - - // Define the hook, we'll check on the first run if it's really needed. - return { - get: function() { - if ( conditionFn() ) { - - // Hook not needed (or it's not possible to use it due - // to missing dependency), remove it. - delete this.get; - return; - } - - // Hook needed; redefine it so that the support test is not executed again. - return ( this.get = hookFn ).apply( this, arguments ); - } - }; -} - - -var cssPrefixes = [ "Webkit", "Moz", "ms" ], - emptyStyle = document.createElement( "div" ).style, - vendorProps = {}; - -// Return a vendor-prefixed property or undefined -function vendorPropName( name ) { - - // Check for vendor prefixed names - var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), - i = cssPrefixes.length; - - while ( i-- ) { - name = cssPrefixes[ i ] + capName; - if ( name in emptyStyle ) { - return name; - } - } -} - -// Return a potentially-mapped jQuery.cssProps or vendor prefixed property -function finalPropName( name ) { - var final = jQuery.cssProps[ name ] || vendorProps[ name ]; - - if ( final ) { - return final; - } - if ( name in emptyStyle ) { - return name; - } - return vendorProps[ name ] = vendorPropName( name ) || name; -} - - -var - - // Swappable if display is none or starts with table - // except "table", "table-cell", or "table-caption" - // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display - rdisplayswap = /^(none|table(?!-c[ea]).+)/, - rcustomProp = /^--/, - cssShow = { position: "absolute", visibility: "hidden", display: "block" }, - cssNormalTransform = { - letterSpacing: "0", - fontWeight: "400" - }; - -function setPositiveNumber( _elem, value, subtract ) { - - // Any relative (+/-) values have already been - // normalized at this point - var matches = rcssNum.exec( value ); - return matches ? - - // Guard against undefined "subtract", e.g., when used as in cssHooks - Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : - value; -} - -function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { - var i = dimension === "width" ? 1 : 0, - extra = 0, - delta = 0; - - // Adjustment may not be necessary - if ( box === ( isBorderBox ? "border" : "content" ) ) { - return 0; - } - - for ( ; i < 4; i += 2 ) { - - // Both box models exclude margin - if ( box === "margin" ) { - delta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); - } - - // If we get here with a content-box, we're seeking "padding" or "border" or "margin" - if ( !isBorderBox ) { - - // Add padding - delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); - - // For "border" or "margin", add border - if ( box !== "padding" ) { - delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); - - // But still keep track of it otherwise - } else { - extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); - } - - // If we get here with a border-box (content + padding + border), we're seeking "content" or - // "padding" or "margin" - } else { - - // For "content", subtract padding - if ( box === "content" ) { - delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); - } - - // For "content" or "padding", subtract border - if ( box !== "margin" ) { - delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); - } - } - } - - // Account for positive content-box scroll gutter when requested by providing computedVal - if ( !isBorderBox && computedVal >= 0 ) { - - // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border - // Assuming integer scroll gutter, subtract the rest and round down - delta += Math.max( 0, Math.ceil( - elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - - computedVal - - delta - - extra - - 0.5 - - // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter - // Use an explicit zero to avoid NaN (gh-3964) - ) ) || 0; - } - - return delta; -} - -function getWidthOrHeight( elem, dimension, extra ) { - - // Start with computed style - var styles = getStyles( elem ), - - // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). - // Fake content-box until we know it's needed to know the true value. - boxSizingNeeded = !support.boxSizingReliable() || extra, - isBorderBox = boxSizingNeeded && - jQuery.css( elem, "boxSizing", false, styles ) === "border-box", - valueIsBorderBox = isBorderBox, - - val = curCSS( elem, dimension, styles ), - offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); - - // Support: Firefox <=54 - // Return a confounding non-pixel value or feign ignorance, as appropriate. - if ( rnumnonpx.test( val ) ) { - if ( !extra ) { - return val; - } - val = "auto"; - } - - - // Support: IE 9 - 11 only - // Use offsetWidth/offsetHeight for when box sizing is unreliable. - // In those cases, the computed value can be trusted to be border-box. - if ( ( !support.boxSizingReliable() && isBorderBox || - - // Support: IE 10 - 11+, Edge 15 - 18+ - // IE/Edge misreport `getComputedStyle` of table rows with width/height - // set in CSS while `offset*` properties report correct values. - // Interestingly, in some cases IE 9 doesn't suffer from this issue. - !support.reliableTrDimensions() && nodeName( elem, "tr" ) || - - // Fall back to offsetWidth/offsetHeight when value is "auto" - // This happens for inline elements with no explicit setting (gh-3571) - val === "auto" || - - // Support: Android <=4.1 - 4.3 only - // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) - !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && - - // Make sure the element is visible & connected - elem.getClientRects().length ) { - - isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; - - // Where available, offsetWidth/offsetHeight approximate border box dimensions. - // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the - // retrieved value as a content box dimension. - valueIsBorderBox = offsetProp in elem; - if ( valueIsBorderBox ) { - val = elem[ offsetProp ]; - } - } - - // Normalize "" and auto - val = parseFloat( val ) || 0; - - // Adjust for the element's box model - return ( val + - boxModelAdjustment( - elem, - dimension, - extra || ( isBorderBox ? "border" : "content" ), - valueIsBorderBox, - styles, - - // Provide the current computed size to request scroll gutter calculation (gh-3589) - val - ) - ) + "px"; -} - -jQuery.extend( { - - // Add in style property hooks for overriding the default - // behavior of getting and setting a style property - cssHooks: { - opacity: { - get: function( elem, computed ) { - if ( computed ) { - - // We should always get a number back from opacity - var ret = curCSS( elem, "opacity" ); - return ret === "" ? "1" : ret; - } - } - } - }, - - // Don't automatically add "px" to these possibly-unitless properties - cssNumber: { - "animationIterationCount": true, - "columnCount": true, - "fillOpacity": true, - "flexGrow": true, - "flexShrink": true, - "fontWeight": true, - "gridArea": true, - "gridColumn": true, - "gridColumnEnd": true, - "gridColumnStart": true, - "gridRow": true, - "gridRowEnd": true, - "gridRowStart": true, - "lineHeight": true, - "opacity": true, - "order": true, - "orphans": true, - "widows": true, - "zIndex": true, - "zoom": true - }, - - // Add in properties whose names you wish to fix before - // setting or getting the value - cssProps: {}, - - // Get and set the style property on a DOM Node - style: function( elem, name, value, extra ) { - - // Don't set styles on text and comment nodes - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { - return; - } - - // Make sure that we're working with the right name - var ret, type, hooks, - origName = camelCase( name ), - isCustomProp = rcustomProp.test( name ), - style = elem.style; - - // Make sure that we're working with the right name. We don't - // want to query the value if it is a CSS custom property - // since they are user-defined. - if ( !isCustomProp ) { - name = finalPropName( origName ); - } - - // Gets hook for the prefixed version, then unprefixed version - hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; - - // Check if we're setting a value - if ( value !== undefined ) { - type = typeof value; - - // Convert "+=" or "-=" to relative numbers (#7345) - if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { - value = adjustCSS( elem, name, ret ); - - // Fixes bug #9237 - type = "number"; - } - - // Make sure that null and NaN values aren't set (#7116) - if ( value == null || value !== value ) { - return; - } - - // If a number was passed in, add the unit (except for certain CSS properties) - // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append - // "px" to a few hardcoded values. - if ( type === "number" && !isCustomProp ) { - value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); - } - - // background-* props affect original clone's values - if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { - style[ name ] = "inherit"; - } - - // If a hook was provided, use that value, otherwise just set the specified value - if ( !hooks || !( "set" in hooks ) || - ( value = hooks.set( elem, value, extra ) ) !== undefined ) { - - if ( isCustomProp ) { - style.setProperty( name, value ); - } else { - style[ name ] = value; - } - } - - } else { - - // If a hook was provided get the non-computed value from there - if ( hooks && "get" in hooks && - ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { - - return ret; - } - - // Otherwise just get the value from the style object - return style[ name ]; - } - }, - - css: function( elem, name, extra, styles ) { - var val, num, hooks, - origName = camelCase( name ), - isCustomProp = rcustomProp.test( name ); - - // Make sure that we're working with the right name. We don't - // want to modify the value if it is a CSS custom property - // since they are user-defined. - if ( !isCustomProp ) { - name = finalPropName( origName ); - } - - // Try prefixed name followed by the unprefixed name - hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; - - // If a hook was provided get the computed value from there - if ( hooks && "get" in hooks ) { - val = hooks.get( elem, true, extra ); - } - - // Otherwise, if a way to get the computed value exists, use that - if ( val === undefined ) { - val = curCSS( elem, name, styles ); - } - - // Convert "normal" to computed value - if ( val === "normal" && name in cssNormalTransform ) { - val = cssNormalTransform[ name ]; - } - - // Make numeric if forced or a qualifier was provided and val looks numeric - if ( extra === "" || extra ) { - num = parseFloat( val ); - return extra === true || isFinite( num ) ? num || 0 : val; - } - - return val; - } -} ); - -jQuery.each( [ "height", "width" ], function( _i, dimension ) { - jQuery.cssHooks[ dimension ] = { - get: function( elem, computed, extra ) { - if ( computed ) { - - // Certain elements can have dimension info if we invisibly show them - // but it must have a current display style that would benefit - return rdisplayswap.test( jQuery.css( elem, "display" ) ) && - - // Support: Safari 8+ - // Table columns in Safari have non-zero offsetWidth & zero - // getBoundingClientRect().width unless display is changed. - // Support: IE <=11 only - // Running getBoundingClientRect on a disconnected node - // in IE throws an error. - ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? - swap( elem, cssShow, function() { - return getWidthOrHeight( elem, dimension, extra ); - } ) : - getWidthOrHeight( elem, dimension, extra ); - } - }, - - set: function( elem, value, extra ) { - var matches, - styles = getStyles( elem ), - - // Only read styles.position if the test has a chance to fail - // to avoid forcing a reflow. - scrollboxSizeBuggy = !support.scrollboxSize() && - styles.position === "absolute", - - // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) - boxSizingNeeded = scrollboxSizeBuggy || extra, - isBorderBox = boxSizingNeeded && - jQuery.css( elem, "boxSizing", false, styles ) === "border-box", - subtract = extra ? - boxModelAdjustment( - elem, - dimension, - extra, - isBorderBox, - styles - ) : - 0; - - // Account for unreliable border-box dimensions by comparing offset* to computed and - // faking a content-box to get border and padding (gh-3699) - if ( isBorderBox && scrollboxSizeBuggy ) { - subtract -= Math.ceil( - elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - - parseFloat( styles[ dimension ] ) - - boxModelAdjustment( elem, dimension, "border", false, styles ) - - 0.5 - ); - } - - // Convert to pixels if value adjustment is needed - if ( subtract && ( matches = rcssNum.exec( value ) ) && - ( matches[ 3 ] || "px" ) !== "px" ) { - - elem.style[ dimension ] = value; - value = jQuery.css( elem, dimension ); - } - - return setPositiveNumber( elem, value, subtract ); - } - }; -} ); - -jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, - function( elem, computed ) { - if ( computed ) { - return ( parseFloat( curCSS( elem, "marginLeft" ) ) || - elem.getBoundingClientRect().left - - swap( elem, { marginLeft: 0 }, function() { - return elem.getBoundingClientRect().left; - } ) - ) + "px"; - } - } -); - -// These hooks are used by animate to expand properties -jQuery.each( { - margin: "", - padding: "", - border: "Width" -}, function( prefix, suffix ) { - jQuery.cssHooks[ prefix + suffix ] = { - expand: function( value ) { - var i = 0, - expanded = {}, - - // Assumes a single number if not a string - parts = typeof value === "string" ? value.split( " " ) : [ value ]; - - for ( ; i < 4; i++ ) { - expanded[ prefix + cssExpand[ i ] + suffix ] = - parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; - } - - return expanded; - } - }; - - if ( prefix !== "margin" ) { - jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; - } -} ); - -jQuery.fn.extend( { - css: function( name, value ) { - return access( this, function( elem, name, value ) { - var styles, len, - map = {}, - i = 0; - - if ( Array.isArray( name ) ) { - styles = getStyles( elem ); - len = name.length; - - for ( ; i < len; i++ ) { - map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); - } - - return map; - } - - return value !== undefined ? - jQuery.style( elem, name, value ) : - jQuery.css( elem, name ); - }, name, value, arguments.length > 1 ); - } -} ); - - -function Tween( elem, options, prop, end, easing ) { - return new Tween.prototype.init( elem, options, prop, end, easing ); -} -jQuery.Tween = Tween; - -Tween.prototype = { - constructor: Tween, - init: function( elem, options, prop, end, easing, unit ) { - this.elem = elem; - this.prop = prop; - this.easing = easing || jQuery.easing._default; - this.options = options; - this.start = this.now = this.cur(); - this.end = end; - this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); - }, - cur: function() { - var hooks = Tween.propHooks[ this.prop ]; - - return hooks && hooks.get ? - hooks.get( this ) : - Tween.propHooks._default.get( this ); - }, - run: function( percent ) { - var eased, - hooks = Tween.propHooks[ this.prop ]; - - if ( this.options.duration ) { - this.pos = eased = jQuery.easing[ this.easing ]( - percent, this.options.duration * percent, 0, 1, this.options.duration - ); - } else { - this.pos = eased = percent; - } - this.now = ( this.end - this.start ) * eased + this.start; - - if ( this.options.step ) { - this.options.step.call( this.elem, this.now, this ); - } - - if ( hooks && hooks.set ) { - hooks.set( this ); - } else { - Tween.propHooks._default.set( this ); - } - return this; - } -}; - -Tween.prototype.init.prototype = Tween.prototype; - -Tween.propHooks = { - _default: { - get: function( tween ) { - var result; - - // Use a property on the element directly when it is not a DOM element, - // or when there is no matching style property that exists. - if ( tween.elem.nodeType !== 1 || - tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { - return tween.elem[ tween.prop ]; - } - - // Passing an empty string as a 3rd parameter to .css will automatically - // attempt a parseFloat and fallback to a string if the parse fails. - // Simple values such as "10px" are parsed to Float; - // complex values such as "rotate(1rad)" are returned as-is. - result = jQuery.css( tween.elem, tween.prop, "" ); - - // Empty strings, null, undefined and "auto" are converted to 0. - return !result || result === "auto" ? 0 : result; - }, - set: function( tween ) { - - // Use step hook for back compat. - // Use cssHook if its there. - // Use .style if available and use plain properties where available. - if ( jQuery.fx.step[ tween.prop ] ) { - jQuery.fx.step[ tween.prop ]( tween ); - } else if ( tween.elem.nodeType === 1 && ( - jQuery.cssHooks[ tween.prop ] || - tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { - jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); - } else { - tween.elem[ tween.prop ] = tween.now; - } - } - } -}; - -// Support: IE <=9 only -// Panic based approach to setting things on disconnected nodes -Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { - set: function( tween ) { - if ( tween.elem.nodeType && tween.elem.parentNode ) { - tween.elem[ tween.prop ] = tween.now; - } - } -}; - -jQuery.easing = { - linear: function( p ) { - return p; - }, - swing: function( p ) { - return 0.5 - Math.cos( p * Math.PI ) / 2; - }, - _default: "swing" -}; - -jQuery.fx = Tween.prototype.init; - -// Back compat <1.8 extension point -jQuery.fx.step = {}; - - - - -var - fxNow, inProgress, - rfxtypes = /^(?:toggle|show|hide)$/, - rrun = /queueHooks$/; - -function schedule() { - if ( inProgress ) { - if ( document.hidden === false && window.requestAnimationFrame ) { - window.requestAnimationFrame( schedule ); - } else { - window.setTimeout( schedule, jQuery.fx.interval ); - } - - jQuery.fx.tick(); - } -} - -// Animations created synchronously will run synchronously -function createFxNow() { - window.setTimeout( function() { - fxNow = undefined; - } ); - return ( fxNow = Date.now() ); -} - -// Generate parameters to create a standard animation -function genFx( type, includeWidth ) { - var which, - i = 0, - attrs = { height: type }; - - // If we include width, step value is 1 to do all cssExpand values, - // otherwise step value is 2 to skip over Left and Right - includeWidth = includeWidth ? 1 : 0; - for ( ; i < 4; i += 2 - includeWidth ) { - which = cssExpand[ i ]; - attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; - } - - if ( includeWidth ) { - attrs.opacity = attrs.width = type; - } - - return attrs; -} - -function createTween( value, prop, animation ) { - var tween, - collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), - index = 0, - length = collection.length; - for ( ; index < length; index++ ) { - if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { - - // We're done with this property - return tween; - } - } -} - -function defaultPrefilter( elem, props, opts ) { - var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, - isBox = "width" in props || "height" in props, - anim = this, - orig = {}, - style = elem.style, - hidden = elem.nodeType && isHiddenWithinTree( elem ), - dataShow = dataPriv.get( elem, "fxshow" ); - - // Queue-skipping animations hijack the fx hooks - if ( !opts.queue ) { - hooks = jQuery._queueHooks( elem, "fx" ); - if ( hooks.unqueued == null ) { - hooks.unqueued = 0; - oldfire = hooks.empty.fire; - hooks.empty.fire = function() { - if ( !hooks.unqueued ) { - oldfire(); - } - }; - } - hooks.unqueued++; - - anim.always( function() { - - // Ensure the complete handler is called before this completes - anim.always( function() { - hooks.unqueued--; - if ( !jQuery.queue( elem, "fx" ).length ) { - hooks.empty.fire(); - } - } ); - } ); - } - - // Detect show/hide animations - for ( prop in props ) { - value = props[ prop ]; - if ( rfxtypes.test( value ) ) { - delete props[ prop ]; - toggle = toggle || value === "toggle"; - if ( value === ( hidden ? "hide" : "show" ) ) { - - // Pretend to be hidden if this is a "show" and - // there is still data from a stopped show/hide - if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { - hidden = true; - - // Ignore all other no-op show/hide data - } else { - continue; - } - } - orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); - } - } - - // Bail out if this is a no-op like .hide().hide() - propTween = !jQuery.isEmptyObject( props ); - if ( !propTween && jQuery.isEmptyObject( orig ) ) { - return; - } - - // Restrict "overflow" and "display" styles during box animations - if ( isBox && elem.nodeType === 1 ) { - - // Support: IE <=9 - 11, Edge 12 - 15 - // Record all 3 overflow attributes because IE does not infer the shorthand - // from identically-valued overflowX and overflowY and Edge just mirrors - // the overflowX value there. - opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; - - // Identify a display type, preferring old show/hide data over the CSS cascade - restoreDisplay = dataShow && dataShow.display; - if ( restoreDisplay == null ) { - restoreDisplay = dataPriv.get( elem, "display" ); - } - display = jQuery.css( elem, "display" ); - if ( display === "none" ) { - if ( restoreDisplay ) { - display = restoreDisplay; - } else { - - // Get nonempty value(s) by temporarily forcing visibility - showHide( [ elem ], true ); - restoreDisplay = elem.style.display || restoreDisplay; - display = jQuery.css( elem, "display" ); - showHide( [ elem ] ); - } - } - - // Animate inline elements as inline-block - if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { - if ( jQuery.css( elem, "float" ) === "none" ) { - - // Restore the original display value at the end of pure show/hide animations - if ( !propTween ) { - anim.done( function() { - style.display = restoreDisplay; - } ); - if ( restoreDisplay == null ) { - display = style.display; - restoreDisplay = display === "none" ? "" : display; - } - } - style.display = "inline-block"; - } - } - } - - if ( opts.overflow ) { - style.overflow = "hidden"; - anim.always( function() { - style.overflow = opts.overflow[ 0 ]; - style.overflowX = opts.overflow[ 1 ]; - style.overflowY = opts.overflow[ 2 ]; - } ); - } - - // Implement show/hide animations - propTween = false; - for ( prop in orig ) { - - // General show/hide setup for this element animation - if ( !propTween ) { - if ( dataShow ) { - if ( "hidden" in dataShow ) { - hidden = dataShow.hidden; - } - } else { - dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); - } - - // Store hidden/visible for toggle so `.stop().toggle()` "reverses" - if ( toggle ) { - dataShow.hidden = !hidden; - } - - // Show elements before animating them - if ( hidden ) { - showHide( [ elem ], true ); - } - - /* eslint-disable no-loop-func */ - - anim.done( function() { - - /* eslint-enable no-loop-func */ - - // The final step of a "hide" animation is actually hiding the element - if ( !hidden ) { - showHide( [ elem ] ); - } - dataPriv.remove( elem, "fxshow" ); - for ( prop in orig ) { - jQuery.style( elem, prop, orig[ prop ] ); - } - } ); - } - - // Per-property setup - propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); - if ( !( prop in dataShow ) ) { - dataShow[ prop ] = propTween.start; - if ( hidden ) { - propTween.end = propTween.start; - propTween.start = 0; - } - } - } -} - -function propFilter( props, specialEasing ) { - var index, name, easing, value, hooks; - - // camelCase, specialEasing and expand cssHook pass - for ( index in props ) { - name = camelCase( index ); - easing = specialEasing[ name ]; - value = props[ index ]; - if ( Array.isArray( value ) ) { - easing = value[ 1 ]; - value = props[ index ] = value[ 0 ]; - } - - if ( index !== name ) { - props[ name ] = value; - delete props[ index ]; - } - - hooks = jQuery.cssHooks[ name ]; - if ( hooks && "expand" in hooks ) { - value = hooks.expand( value ); - delete props[ name ]; - - // Not quite $.extend, this won't overwrite existing keys. - // Reusing 'index' because we have the correct "name" - for ( index in value ) { - if ( !( index in props ) ) { - props[ index ] = value[ index ]; - specialEasing[ index ] = easing; - } - } - } else { - specialEasing[ name ] = easing; - } - } -} - -function Animation( elem, properties, options ) { - var result, - stopped, - index = 0, - length = Animation.prefilters.length, - deferred = jQuery.Deferred().always( function() { - - // Don't match elem in the :animated selector - delete tick.elem; - } ), - tick = function() { - if ( stopped ) { - return false; - } - var currentTime = fxNow || createFxNow(), - remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), - - // Support: Android 2.3 only - // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) - temp = remaining / animation.duration || 0, - percent = 1 - temp, - index = 0, - length = animation.tweens.length; - - for ( ; index < length; index++ ) { - animation.tweens[ index ].run( percent ); - } - - deferred.notifyWith( elem, [ animation, percent, remaining ] ); - - // If there's more to do, yield - if ( percent < 1 && length ) { - return remaining; - } - - // If this was an empty animation, synthesize a final progress notification - if ( !length ) { - deferred.notifyWith( elem, [ animation, 1, 0 ] ); - } - - // Resolve the animation and report its conclusion - deferred.resolveWith( elem, [ animation ] ); - return false; - }, - animation = deferred.promise( { - elem: elem, - props: jQuery.extend( {}, properties ), - opts: jQuery.extend( true, { - specialEasing: {}, - easing: jQuery.easing._default - }, options ), - originalProperties: properties, - originalOptions: options, - startTime: fxNow || createFxNow(), - duration: options.duration, - tweens: [], - createTween: function( prop, end ) { - var tween = jQuery.Tween( elem, animation.opts, prop, end, - animation.opts.specialEasing[ prop ] || animation.opts.easing ); - animation.tweens.push( tween ); - return tween; - }, - stop: function( gotoEnd ) { - var index = 0, - - // If we are going to the end, we want to run all the tweens - // otherwise we skip this part - length = gotoEnd ? animation.tweens.length : 0; - if ( stopped ) { - return this; - } - stopped = true; - for ( ; index < length; index++ ) { - animation.tweens[ index ].run( 1 ); - } - - // Resolve when we played the last frame; otherwise, reject - if ( gotoEnd ) { - deferred.notifyWith( elem, [ animation, 1, 0 ] ); - deferred.resolveWith( elem, [ animation, gotoEnd ] ); - } else { - deferred.rejectWith( elem, [ animation, gotoEnd ] ); - } - return this; - } - } ), - props = animation.props; - - propFilter( props, animation.opts.specialEasing ); - - for ( ; index < length; index++ ) { - result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); - if ( result ) { - if ( isFunction( result.stop ) ) { - jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = - result.stop.bind( result ); - } - return result; - } - } - - jQuery.map( props, createTween, animation ); - - if ( isFunction( animation.opts.start ) ) { - animation.opts.start.call( elem, animation ); - } - - // Attach callbacks from options - animation - .progress( animation.opts.progress ) - .done( animation.opts.done, animation.opts.complete ) - .fail( animation.opts.fail ) - .always( animation.opts.always ); - - jQuery.fx.timer( - jQuery.extend( tick, { - elem: elem, - anim: animation, - queue: animation.opts.queue - } ) - ); - - return animation; -} - -jQuery.Animation = jQuery.extend( Animation, { - - tweeners: { - "*": [ function( prop, value ) { - var tween = this.createTween( prop, value ); - adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); - return tween; - } ] - }, - - tweener: function( props, callback ) { - if ( isFunction( props ) ) { - callback = props; - props = [ "*" ]; - } else { - props = props.match( rnothtmlwhite ); - } - - var prop, - index = 0, - length = props.length; - - for ( ; index < length; index++ ) { - prop = props[ index ]; - Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; - Animation.tweeners[ prop ].unshift( callback ); - } - }, - - prefilters: [ defaultPrefilter ], - - prefilter: function( callback, prepend ) { - if ( prepend ) { - Animation.prefilters.unshift( callback ); - } else { - Animation.prefilters.push( callback ); - } - } -} ); - -jQuery.speed = function( speed, easing, fn ) { - var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { - complete: fn || !fn && easing || - isFunction( speed ) && speed, - duration: speed, - easing: fn && easing || easing && !isFunction( easing ) && easing - }; - - // Go to the end state if fx are off - if ( jQuery.fx.off ) { - opt.duration = 0; - - } else { - if ( typeof opt.duration !== "number" ) { - if ( opt.duration in jQuery.fx.speeds ) { - opt.duration = jQuery.fx.speeds[ opt.duration ]; - - } else { - opt.duration = jQuery.fx.speeds._default; - } - } - } - - // Normalize opt.queue - true/undefined/null -> "fx" - if ( opt.queue == null || opt.queue === true ) { - opt.queue = "fx"; - } - - // Queueing - opt.old = opt.complete; - - opt.complete = function() { - if ( isFunction( opt.old ) ) { - opt.old.call( this ); - } - - if ( opt.queue ) { - jQuery.dequeue( this, opt.queue ); - } - }; - - return opt; -}; - -jQuery.fn.extend( { - fadeTo: function( speed, to, easing, callback ) { - - // Show any hidden elements after setting opacity to 0 - return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() - - // Animate to the value specified - .end().animate( { opacity: to }, speed, easing, callback ); - }, - animate: function( prop, speed, easing, callback ) { - var empty = jQuery.isEmptyObject( prop ), - optall = jQuery.speed( speed, easing, callback ), - doAnimation = function() { - - // Operate on a copy of prop so per-property easing won't be lost - var anim = Animation( this, jQuery.extend( {}, prop ), optall ); - - // Empty animations, or finishing resolves immediately - if ( empty || dataPriv.get( this, "finish" ) ) { - anim.stop( true ); - } - }; - - doAnimation.finish = doAnimation; - - return empty || optall.queue === false ? - this.each( doAnimation ) : - this.queue( optall.queue, doAnimation ); - }, - stop: function( type, clearQueue, gotoEnd ) { - var stopQueue = function( hooks ) { - var stop = hooks.stop; - delete hooks.stop; - stop( gotoEnd ); - }; - - if ( typeof type !== "string" ) { - gotoEnd = clearQueue; - clearQueue = type; - type = undefined; - } - if ( clearQueue ) { - this.queue( type || "fx", [] ); - } - - return this.each( function() { - var dequeue = true, - index = type != null && type + "queueHooks", - timers = jQuery.timers, - data = dataPriv.get( this ); - - if ( index ) { - if ( data[ index ] && data[ index ].stop ) { - stopQueue( data[ index ] ); - } - } else { - for ( index in data ) { - if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { - stopQueue( data[ index ] ); - } - } - } - - for ( index = timers.length; index--; ) { - if ( timers[ index ].elem === this && - ( type == null || timers[ index ].queue === type ) ) { - - timers[ index ].anim.stop( gotoEnd ); - dequeue = false; - timers.splice( index, 1 ); - } - } - - // Start the next in the queue if the last step wasn't forced. - // Timers currently will call their complete callbacks, which - // will dequeue but only if they were gotoEnd. - if ( dequeue || !gotoEnd ) { - jQuery.dequeue( this, type ); - } - } ); - }, - finish: function( type ) { - if ( type !== false ) { - type = type || "fx"; - } - return this.each( function() { - var index, - data = dataPriv.get( this ), - queue = data[ type + "queue" ], - hooks = data[ type + "queueHooks" ], - timers = jQuery.timers, - length = queue ? queue.length : 0; - - // Enable finishing flag on private data - data.finish = true; - - // Empty the queue first - jQuery.queue( this, type, [] ); - - if ( hooks && hooks.stop ) { - hooks.stop.call( this, true ); - } - - // Look for any active animations, and finish them - for ( index = timers.length; index--; ) { - if ( timers[ index ].elem === this && timers[ index ].queue === type ) { - timers[ index ].anim.stop( true ); - timers.splice( index, 1 ); - } - } - - // Look for any animations in the old queue and finish them - for ( index = 0; index < length; index++ ) { - if ( queue[ index ] && queue[ index ].finish ) { - queue[ index ].finish.call( this ); - } - } - - // Turn off finishing flag - delete data.finish; - } ); - } -} ); - -jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { - var cssFn = jQuery.fn[ name ]; - jQuery.fn[ name ] = function( speed, easing, callback ) { - return speed == null || typeof speed === "boolean" ? - cssFn.apply( this, arguments ) : - this.animate( genFx( name, true ), speed, easing, callback ); - }; -} ); - -// Generate shortcuts for custom animations -jQuery.each( { - slideDown: genFx( "show" ), - slideUp: genFx( "hide" ), - slideToggle: genFx( "toggle" ), - fadeIn: { opacity: "show" }, - fadeOut: { opacity: "hide" }, - fadeToggle: { opacity: "toggle" } -}, function( name, props ) { - jQuery.fn[ name ] = function( speed, easing, callback ) { - return this.animate( props, speed, easing, callback ); - }; -} ); - -jQuery.timers = []; -jQuery.fx.tick = function() { - var timer, - i = 0, - timers = jQuery.timers; - - fxNow = Date.now(); - - for ( ; i < timers.length; i++ ) { - timer = timers[ i ]; - - // Run the timer and safely remove it when done (allowing for external removal) - if ( !timer() && timers[ i ] === timer ) { - timers.splice( i--, 1 ); - } - } - - if ( !timers.length ) { - jQuery.fx.stop(); - } - fxNow = undefined; -}; - -jQuery.fx.timer = function( timer ) { - jQuery.timers.push( timer ); - jQuery.fx.start(); -}; - -jQuery.fx.interval = 13; -jQuery.fx.start = function() { - if ( inProgress ) { - return; - } - - inProgress = true; - schedule(); -}; - -jQuery.fx.stop = function() { - inProgress = null; -}; - -jQuery.fx.speeds = { - slow: 600, - fast: 200, - - // Default speed - _default: 400 -}; - - -// Based off of the plugin by Clint Helfers, with permission. -// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ -jQuery.fn.delay = function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; - type = type || "fx"; - - return this.queue( type, function( next, hooks ) { - var timeout = window.setTimeout( next, time ); - hooks.stop = function() { - window.clearTimeout( timeout ); - }; - } ); -}; - - -( function() { - var input = document.createElement( "input" ), - select = document.createElement( "select" ), - opt = select.appendChild( document.createElement( "option" ) ); - - input.type = "checkbox"; - - // Support: Android <=4.3 only - // Default value for a checkbox should be "on" - support.checkOn = input.value !== ""; - - // Support: IE <=11 only - // Must access selectedIndex to make default options select - support.optSelected = opt.selected; - - // Support: IE <=11 only - // An input loses its value after becoming a radio - input = document.createElement( "input" ); - input.value = "t"; - input.type = "radio"; - support.radioValue = input.value === "t"; -} )(); - - -var boolHook, - attrHandle = jQuery.expr.attrHandle; - -jQuery.fn.extend( { - attr: function( name, value ) { - return access( this, jQuery.attr, name, value, arguments.length > 1 ); - }, - - removeAttr: function( name ) { - return this.each( function() { - jQuery.removeAttr( this, name ); - } ); - } -} ); - -jQuery.extend( { - attr: function( elem, name, value ) { - var ret, hooks, - nType = elem.nodeType; - - // Don't get/set attributes on text, comment and attribute nodes - if ( nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === "undefined" ) { - return jQuery.prop( elem, name, value ); - } - - // Attribute hooks are determined by the lowercase version - // Grab necessary hook if one is defined - if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { - hooks = jQuery.attrHooks[ name.toLowerCase() ] || - ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); - } - - if ( value !== undefined ) { - if ( value === null ) { - jQuery.removeAttr( elem, name ); - return; - } - - if ( hooks && "set" in hooks && - ( ret = hooks.set( elem, value, name ) ) !== undefined ) { - return ret; - } - - elem.setAttribute( name, value + "" ); - return value; - } - - if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { - return ret; - } - - ret = jQuery.find.attr( elem, name ); - - // Non-existent attributes return null, we normalize to undefined - return ret == null ? undefined : ret; - }, - - attrHooks: { - type: { - set: function( elem, value ) { - if ( !support.radioValue && value === "radio" && - nodeName( elem, "input" ) ) { - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } - } - } - }, - - removeAttr: function( elem, value ) { - var name, - i = 0, - - // Attribute names can contain non-HTML whitespace characters - // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 - attrNames = value && value.match( rnothtmlwhite ); - - if ( attrNames && elem.nodeType === 1 ) { - while ( ( name = attrNames[ i++ ] ) ) { - elem.removeAttribute( name ); - } - } - } -} ); - -// Hooks for boolean attributes -boolHook = { - set: function( elem, value, name ) { - if ( value === false ) { - - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else { - elem.setAttribute( name, name ); - } - return name; - } -}; - -jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { - var getter = attrHandle[ name ] || jQuery.find.attr; - - attrHandle[ name ] = function( elem, name, isXML ) { - var ret, handle, - lowercaseName = name.toLowerCase(); - - if ( !isXML ) { - - // Avoid an infinite loop by temporarily removing this function from the getter - handle = attrHandle[ lowercaseName ]; - attrHandle[ lowercaseName ] = ret; - ret = getter( elem, name, isXML ) != null ? - lowercaseName : - null; - attrHandle[ lowercaseName ] = handle; - } - return ret; - }; -} ); - - - - -var rfocusable = /^(?:input|select|textarea|button)$/i, - rclickable = /^(?:a|area)$/i; - -jQuery.fn.extend( { - prop: function( name, value ) { - return access( this, jQuery.prop, name, value, arguments.length > 1 ); - }, - - removeProp: function( name ) { - return this.each( function() { - delete this[ jQuery.propFix[ name ] || name ]; - } ); - } -} ); - -jQuery.extend( { - prop: function( elem, name, value ) { - var ret, hooks, - nType = elem.nodeType; - - // Don't get/set properties on text, comment and attribute nodes - if ( nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { - - // Fix name and attach hooks - name = jQuery.propFix[ name ] || name; - hooks = jQuery.propHooks[ name ]; - } - - if ( value !== undefined ) { - if ( hooks && "set" in hooks && - ( ret = hooks.set( elem, value, name ) ) !== undefined ) { - return ret; - } - - return ( elem[ name ] = value ); - } - - if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { - return ret; - } - - return elem[ name ]; - }, - - propHooks: { - tabIndex: { - get: function( elem ) { - - // Support: IE <=9 - 11 only - // elem.tabIndex doesn't always return the - // correct value when it hasn't been explicitly set - // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - // Use proper attribute retrieval(#12072) - var tabindex = jQuery.find.attr( elem, "tabindex" ); - - if ( tabindex ) { - return parseInt( tabindex, 10 ); - } - - if ( - rfocusable.test( elem.nodeName ) || - rclickable.test( elem.nodeName ) && - elem.href - ) { - return 0; - } - - return -1; - } - } - }, - - propFix: { - "for": "htmlFor", - "class": "className" - } -} ); - -// Support: IE <=11 only -// Accessing the selectedIndex property -// forces the browser to respect setting selected -// on the option -// The getter ensures a default option is selected -// when in an optgroup -// eslint rule "no-unused-expressions" is disabled for this code -// since it considers such accessions noop -if ( !support.optSelected ) { - jQuery.propHooks.selected = { - get: function( elem ) { - - /* eslint no-unused-expressions: "off" */ - - var parent = elem.parentNode; - if ( parent && parent.parentNode ) { - parent.parentNode.selectedIndex; - } - return null; - }, - set: function( elem ) { - - /* eslint no-unused-expressions: "off" */ - - var parent = elem.parentNode; - if ( parent ) { - parent.selectedIndex; - - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } - } - } - }; -} - -jQuery.each( [ - "tabIndex", - "readOnly", - "maxLength", - "cellSpacing", - "cellPadding", - "rowSpan", - "colSpan", - "useMap", - "frameBorder", - "contentEditable" -], function() { - jQuery.propFix[ this.toLowerCase() ] = this; -} ); - - - - - // Strip and collapse whitespace according to HTML spec - // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace - function stripAndCollapse( value ) { - var tokens = value.match( rnothtmlwhite ) || []; - return tokens.join( " " ); - } - - -function getClass( elem ) { - return elem.getAttribute && elem.getAttribute( "class" ) || ""; -} - -function classesToArray( value ) { - if ( Array.isArray( value ) ) { - return value; - } - if ( typeof value === "string" ) { - return value.match( rnothtmlwhite ) || []; - } - return []; -} - -jQuery.fn.extend( { - addClass: function( value ) { - var classes, elem, cur, curValue, clazz, j, finalValue, - i = 0; - - if ( isFunction( value ) ) { - return this.each( function( j ) { - jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); - } ); - } - - classes = classesToArray( value ); - - if ( classes.length ) { - while ( ( elem = this[ i++ ] ) ) { - curValue = getClass( elem ); - cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); - - if ( cur ) { - j = 0; - while ( ( clazz = classes[ j++ ] ) ) { - if ( cur.indexOf( " " + clazz + " " ) < 0 ) { - cur += clazz + " "; - } - } - - // Only assign if different to avoid unneeded rendering. - finalValue = stripAndCollapse( cur ); - if ( curValue !== finalValue ) { - elem.setAttribute( "class", finalValue ); - } - } - } - } - - return this; - }, - - removeClass: function( value ) { - var classes, elem, cur, curValue, clazz, j, finalValue, - i = 0; - - if ( isFunction( value ) ) { - return this.each( function( j ) { - jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); - } ); - } - - if ( !arguments.length ) { - return this.attr( "class", "" ); - } - - classes = classesToArray( value ); - - if ( classes.length ) { - while ( ( elem = this[ i++ ] ) ) { - curValue = getClass( elem ); - - // This expression is here for better compressibility (see addClass) - cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); - - if ( cur ) { - j = 0; - while ( ( clazz = classes[ j++ ] ) ) { - - // Remove *all* instances - while ( cur.indexOf( " " + clazz + " " ) > -1 ) { - cur = cur.replace( " " + clazz + " ", " " ); - } - } - - // Only assign if different to avoid unneeded rendering. - finalValue = stripAndCollapse( cur ); - if ( curValue !== finalValue ) { - elem.setAttribute( "class", finalValue ); - } - } - } - } - - return this; - }, - - toggleClass: function( value, stateVal ) { - var type = typeof value, - isValidValue = type === "string" || Array.isArray( value ); - - if ( typeof stateVal === "boolean" && isValidValue ) { - return stateVal ? this.addClass( value ) : this.removeClass( value ); - } - - if ( isFunction( value ) ) { - return this.each( function( i ) { - jQuery( this ).toggleClass( - value.call( this, i, getClass( this ), stateVal ), - stateVal - ); - } ); - } - - return this.each( function() { - var className, i, self, classNames; - - if ( isValidValue ) { - - // Toggle individual class names - i = 0; - self = jQuery( this ); - classNames = classesToArray( value ); - - while ( ( className = classNames[ i++ ] ) ) { - - // Check each className given, space separated list - if ( self.hasClass( className ) ) { - self.removeClass( className ); - } else { - self.addClass( className ); - } - } - - // Toggle whole class name - } else if ( value === undefined || type === "boolean" ) { - className = getClass( this ); - if ( className ) { - - // Store className if set - dataPriv.set( this, "__className__", className ); - } - - // If the element has a class name or if we're passed `false`, - // then remove the whole classname (if there was one, the above saved it). - // Otherwise bring back whatever was previously saved (if anything), - // falling back to the empty string if nothing was stored. - if ( this.setAttribute ) { - this.setAttribute( "class", - className || value === false ? - "" : - dataPriv.get( this, "__className__" ) || "" - ); - } - } - } ); - }, - - hasClass: function( selector ) { - var className, elem, - i = 0; - - className = " " + selector + " "; - while ( ( elem = this[ i++ ] ) ) { - if ( elem.nodeType === 1 && - ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { - return true; - } - } - - return false; - } -} ); - - - - -var rreturn = /\r/g; - -jQuery.fn.extend( { - val: function( value ) { - var hooks, ret, valueIsFunction, - elem = this[ 0 ]; - - if ( !arguments.length ) { - if ( elem ) { - hooks = jQuery.valHooks[ elem.type ] || - jQuery.valHooks[ elem.nodeName.toLowerCase() ]; - - if ( hooks && - "get" in hooks && - ( ret = hooks.get( elem, "value" ) ) !== undefined - ) { - return ret; - } - - ret = elem.value; - - // Handle most common string cases - if ( typeof ret === "string" ) { - return ret.replace( rreturn, "" ); - } - - // Handle cases where value is null/undef or number - return ret == null ? "" : ret; - } - - return; - } - - valueIsFunction = isFunction( value ); - - return this.each( function( i ) { - var val; - - if ( this.nodeType !== 1 ) { - return; - } - - if ( valueIsFunction ) { - val = value.call( this, i, jQuery( this ).val() ); - } else { - val = value; - } - - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - - } else if ( typeof val === "number" ) { - val += ""; - - } else if ( Array.isArray( val ) ) { - val = jQuery.map( val, function( value ) { - return value == null ? "" : value + ""; - } ); - } - - hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; - - // If set returns undefined, fall back to normal setting - if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { - this.value = val; - } - } ); - } -} ); - -jQuery.extend( { - valHooks: { - option: { - get: function( elem ) { - - var val = jQuery.find.attr( elem, "value" ); - return val != null ? - val : - - // Support: IE <=10 - 11 only - // option.text throws exceptions (#14686, #14858) - // Strip and collapse whitespace - // https://html.spec.whatwg.org/#strip-and-collapse-whitespace - stripAndCollapse( jQuery.text( elem ) ); - } - }, - select: { - get: function( elem ) { - var value, option, i, - options = elem.options, - index = elem.selectedIndex, - one = elem.type === "select-one", - values = one ? null : [], - max = one ? index + 1 : options.length; - - if ( index < 0 ) { - i = max; - - } else { - i = one ? index : 0; - } - - // Loop through all the selected options - for ( ; i < max; i++ ) { - option = options[ i ]; - - // Support: IE <=9 only - // IE8-9 doesn't update selected after form reset (#2551) - if ( ( option.selected || i === index ) && - - // Don't return options that are disabled or in a disabled optgroup - !option.disabled && - ( !option.parentNode.disabled || - !nodeName( option.parentNode, "optgroup" ) ) ) { - - // Get the specific value for the option - value = jQuery( option ).val(); - - // We don't need an array for one selects - if ( one ) { - return value; - } - - // Multi-Selects return an array - values.push( value ); - } - } - - return values; - }, - - set: function( elem, value ) { - var optionSet, option, - options = elem.options, - values = jQuery.makeArray( value ), - i = options.length; - - while ( i-- ) { - option = options[ i ]; - - /* eslint-disable no-cond-assign */ - - if ( option.selected = - jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 - ) { - optionSet = true; - } - - /* eslint-enable no-cond-assign */ - } - - // Force browsers to behave consistently when non-matching value is set - if ( !optionSet ) { - elem.selectedIndex = -1; - } - return values; - } - } - } -} ); - -// Radios and checkboxes getter/setter -jQuery.each( [ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = { - set: function( elem, value ) { - if ( Array.isArray( value ) ) { - return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); - } - } - }; - if ( !support.checkOn ) { - jQuery.valHooks[ this ].get = function( elem ) { - return elem.getAttribute( "value" ) === null ? "on" : elem.value; - }; - } -} ); - - - - -// Return jQuery for attributes-only inclusion - - -support.focusin = "onfocusin" in window; - - -var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - stopPropagationCallback = function( e ) { - e.stopPropagation(); - }; - -jQuery.extend( jQuery.event, { - - trigger: function( event, data, elem, onlyHandlers ) { - - var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, - eventPath = [ elem || document ], - type = hasOwn.call( event, "type" ) ? event.type : event, - namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; - - cur = lastElement = tmp = elem = elem || document; - - // Don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { - return; - } - - if ( type.indexOf( "." ) > -1 ) { - - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split( "." ); - type = namespaces.shift(); - namespaces.sort(); - } - ontype = type.indexOf( ":" ) < 0 && "on" + type; - - // Caller can pass in a jQuery.Event object, Object, or just an event type string - event = event[ jQuery.expando ] ? - event : - new jQuery.Event( type, typeof event === "object" && event ); - - // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) - event.isTrigger = onlyHandlers ? 2 : 3; - event.namespace = namespaces.join( "." ); - event.rnamespace = event.namespace ? - new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : - null; - - // Clean up the event in case it is being reused - event.result = undefined; - if ( !event.target ) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data == null ? - [ event ] : - jQuery.makeArray( data, [ event ] ); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { - - bubbleType = special.delegateType || type; - if ( !rfocusMorph.test( bubbleType + type ) ) { - cur = cur.parentNode; - } - for ( ; cur; cur = cur.parentNode ) { - eventPath.push( cur ); - tmp = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( tmp === ( elem.ownerDocument || document ) ) { - eventPath.push( tmp.defaultView || tmp.parentWindow || window ); - } - } - - // Fire handlers on the event path - i = 0; - while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { - lastElement = cur; - event.type = i > 1 ? - bubbleType : - special.bindType || type; - - // jQuery handler - handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] && - dataPriv.get( cur, "handle" ); - if ( handle ) { - handle.apply( cur, data ); - } - - // Native handler - handle = ontype && cur[ ontype ]; - if ( handle && handle.apply && acceptData( cur ) ) { - event.result = handle.apply( cur, data ); - if ( event.result === false ) { - event.preventDefault(); - } - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if ( !onlyHandlers && !event.isDefaultPrevented() ) { - - if ( ( !special._default || - special._default.apply( eventPath.pop(), data ) === false ) && - acceptData( elem ) ) { - - // Call a native DOM method on the target with the same name as the event. - // Don't do default actions on window, that's where global variables be (#6170) - if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { - - // Don't re-trigger an onFOO event when we call its FOO() method - tmp = elem[ ontype ]; - - if ( tmp ) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - - if ( event.isPropagationStopped() ) { - lastElement.addEventListener( type, stopPropagationCallback ); - } - - elem[ type ](); - - if ( event.isPropagationStopped() ) { - lastElement.removeEventListener( type, stopPropagationCallback ); - } - - jQuery.event.triggered = undefined; - - if ( tmp ) { - elem[ ontype ] = tmp; - } - } - } - } - - return event.result; - }, - - // Piggyback on a donor event to simulate a different one - // Used only for `focus(in | out)` events - simulate: function( type, elem, event ) { - var e = jQuery.extend( - new jQuery.Event(), - event, - { - type: type, - isSimulated: true - } - ); - - jQuery.event.trigger( e, null, elem ); - } - -} ); - -jQuery.fn.extend( { - - trigger: function( type, data ) { - return this.each( function() { - jQuery.event.trigger( type, data, this ); - } ); - }, - triggerHandler: function( type, data ) { - var elem = this[ 0 ]; - if ( elem ) { - return jQuery.event.trigger( type, data, elem, true ); - } - } -} ); - - -// Support: Firefox <=44 -// Firefox doesn't have focus(in | out) events -// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 -// -// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 -// focus(in | out) events fire after focus & blur events, -// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order -// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 -if ( !support.focusin ) { - jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { - - // Attach a single capturing handler on the document while someone wants focusin/focusout - var handler = function( event ) { - jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); - }; - - jQuery.event.special[ fix ] = { - setup: function() { - - // Handle: regular nodes (via `this.ownerDocument`), window - // (via `this.document`) & document (via `this`). - var doc = this.ownerDocument || this.document || this, - attaches = dataPriv.access( doc, fix ); - - if ( !attaches ) { - doc.addEventListener( orig, handler, true ); - } - dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); - }, - teardown: function() { - var doc = this.ownerDocument || this.document || this, - attaches = dataPriv.access( doc, fix ) - 1; - - if ( !attaches ) { - doc.removeEventListener( orig, handler, true ); - dataPriv.remove( doc, fix ); - - } else { - dataPriv.access( doc, fix, attaches ); - } - } - }; - } ); -} -var location = window.location; - -var nonce = { guid: Date.now() }; - -var rquery = ( /\?/ ); - - - -// Cross-browser xml parsing -jQuery.parseXML = function( data ) { - var xml, parserErrorElem; - if ( !data || typeof data !== "string" ) { - return null; - } - - // Support: IE 9 - 11 only - // IE throws on parseFromString with invalid input. - try { - xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); - } catch ( e ) {} - - parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ]; - if ( !xml || parserErrorElem ) { - jQuery.error( "Invalid XML: " + ( - parserErrorElem ? - jQuery.map( parserErrorElem.childNodes, function( el ) { - return el.textContent; - } ).join( "\n" ) : - data - ) ); - } - return xml; -}; - - -var - rbracket = /\[\]$/, - rCRLF = /\r?\n/g, - rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, - rsubmittable = /^(?:input|select|textarea|keygen)/i; - -function buildParams( prefix, obj, traditional, add ) { - var name; - - if ( Array.isArray( obj ) ) { - - // Serialize array item. - jQuery.each( obj, function( i, v ) { - if ( traditional || rbracket.test( prefix ) ) { - - // Treat each array item as a scalar. - add( prefix, v ); - - } else { - - // Item is non-scalar (array or object), encode its numeric index. - buildParams( - prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", - v, - traditional, - add - ); - } - } ); - - } else if ( !traditional && toType( obj ) === "object" ) { - - // Serialize object item. - for ( name in obj ) { - buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); - } - - } else { - - // Serialize scalar item. - add( prefix, obj ); - } -} - -// Serialize an array of form elements or a set of -// key/values into a query string -jQuery.param = function( a, traditional ) { - var prefix, - s = [], - add = function( key, valueOrFunction ) { - - // If value is a function, invoke it and use its return value - var value = isFunction( valueOrFunction ) ? - valueOrFunction() : - valueOrFunction; - - s[ s.length ] = encodeURIComponent( key ) + "=" + - encodeURIComponent( value == null ? "" : value ); - }; - - if ( a == null ) { - return ""; - } - - // If an array was passed in, assume that it is an array of form elements. - if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { - - // Serialize the form elements - jQuery.each( a, function() { - add( this.name, this.value ); - } ); - - } else { - - // If traditional, encode the "old" way (the way 1.3.2 or older - // did it), otherwise encode params recursively. - for ( prefix in a ) { - buildParams( prefix, a[ prefix ], traditional, add ); - } - } - - // Return the resulting serialization - return s.join( "&" ); -}; - -jQuery.fn.extend( { - serialize: function() { - return jQuery.param( this.serializeArray() ); - }, - serializeArray: function() { - return this.map( function() { - - // Can add propHook for "elements" to filter or add form elements - var elements = jQuery.prop( this, "elements" ); - return elements ? jQuery.makeArray( elements ) : this; - } ).filter( function() { - var type = this.type; - - // Use .is( ":disabled" ) so that fieldset[disabled] works - return this.name && !jQuery( this ).is( ":disabled" ) && - rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && - ( this.checked || !rcheckableType.test( type ) ); - } ).map( function( _i, elem ) { - var val = jQuery( this ).val(); - - if ( val == null ) { - return null; - } - - if ( Array.isArray( val ) ) { - return jQuery.map( val, function( val ) { - return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; - } ); - } - - return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; - } ).get(); - } -} ); - - -var - r20 = /%20/g, - rhash = /#.*$/, - rantiCache = /([?&])_=[^&]*/, - rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, - - // #7653, #8125, #8152: local protocol detection - rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, - rnoContent = /^(?:GET|HEAD)$/, - rprotocol = /^\/\//, - - /* Prefilters - * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) - * 2) These are called: - * - BEFORE asking for a transport - * - AFTER param serialization (s.data is a string if s.processData is true) - * 3) key is the dataType - * 4) the catchall symbol "*" can be used - * 5) execution will start with transport dataType and THEN continue down to "*" if needed - */ - prefilters = {}, - - /* Transports bindings - * 1) key is the dataType - * 2) the catchall symbol "*" can be used - * 3) selection will start with transport dataType and THEN go to "*" if needed - */ - transports = {}, - - // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression - allTypes = "*/".concat( "*" ), - - // Anchor tag for parsing the document origin - originAnchor = document.createElement( "a" ); - -originAnchor.href = location.href; - -// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport -function addToPrefiltersOrTransports( structure ) { - - // dataTypeExpression is optional and defaults to "*" - return function( dataTypeExpression, func ) { - - if ( typeof dataTypeExpression !== "string" ) { - func = dataTypeExpression; - dataTypeExpression = "*"; - } - - var dataType, - i = 0, - dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; - - if ( isFunction( func ) ) { - - // For each dataType in the dataTypeExpression - while ( ( dataType = dataTypes[ i++ ] ) ) { - - // Prepend if requested - if ( dataType[ 0 ] === "+" ) { - dataType = dataType.slice( 1 ) || "*"; - ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); - - // Otherwise append - } else { - ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); - } - } - } - }; -} - -// Base inspection function for prefilters and transports -function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { - - var inspected = {}, - seekingTransport = ( structure === transports ); - - function inspect( dataType ) { - var selected; - inspected[ dataType ] = true; - jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { - var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); - if ( typeof dataTypeOrTransport === "string" && - !seekingTransport && !inspected[ dataTypeOrTransport ] ) { - - options.dataTypes.unshift( dataTypeOrTransport ); - inspect( dataTypeOrTransport ); - return false; - } else if ( seekingTransport ) { - return !( selected = dataTypeOrTransport ); - } - } ); - return selected; - } - - return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); -} - -// A special extend for ajax options -// that takes "flat" options (not to be deep extended) -// Fixes #9887 -function ajaxExtend( target, src ) { - var key, deep, - flatOptions = jQuery.ajaxSettings.flatOptions || {}; - - for ( key in src ) { - if ( src[ key ] !== undefined ) { - ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; - } - } - if ( deep ) { - jQuery.extend( true, target, deep ); - } - - return target; -} - -/* Handles responses to an ajax request: - * - finds the right dataType (mediates between content-type and expected dataType) - * - returns the corresponding response - */ -function ajaxHandleResponses( s, jqXHR, responses ) { - - var ct, type, finalDataType, firstDataType, - contents = s.contents, - dataTypes = s.dataTypes; - - // Remove auto dataType and get content-type in the process - while ( dataTypes[ 0 ] === "*" ) { - dataTypes.shift(); - if ( ct === undefined ) { - ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); - } - } - - // Check if we're dealing with a known content-type - if ( ct ) { - for ( type in contents ) { - if ( contents[ type ] && contents[ type ].test( ct ) ) { - dataTypes.unshift( type ); - break; - } - } - } - - // Check to see if we have a response for the expected dataType - if ( dataTypes[ 0 ] in responses ) { - finalDataType = dataTypes[ 0 ]; - } else { - - // Try convertible dataTypes - for ( type in responses ) { - if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { - finalDataType = type; - break; - } - if ( !firstDataType ) { - firstDataType = type; - } - } - - // Or just use first one - finalDataType = finalDataType || firstDataType; - } - - // If we found a dataType - // We add the dataType to the list if needed - // and return the corresponding response - if ( finalDataType ) { - if ( finalDataType !== dataTypes[ 0 ] ) { - dataTypes.unshift( finalDataType ); - } - return responses[ finalDataType ]; - } -} - -/* Chain conversions given the request and the original response - * Also sets the responseXXX fields on the jqXHR instance - */ -function ajaxConvert( s, response, jqXHR, isSuccess ) { - var conv2, current, conv, tmp, prev, - converters = {}, - - // Work with a copy of dataTypes in case we need to modify it for conversion - dataTypes = s.dataTypes.slice(); - - // Create converters map with lowercased keys - if ( dataTypes[ 1 ] ) { - for ( conv in s.converters ) { - converters[ conv.toLowerCase() ] = s.converters[ conv ]; - } - } - - current = dataTypes.shift(); - - // Convert to each sequential dataType - while ( current ) { - - if ( s.responseFields[ current ] ) { - jqXHR[ s.responseFields[ current ] ] = response; - } - - // Apply the dataFilter if provided - if ( !prev && isSuccess && s.dataFilter ) { - response = s.dataFilter( response, s.dataType ); - } - - prev = current; - current = dataTypes.shift(); - - if ( current ) { - - // There's only work to do if current dataType is non-auto - if ( current === "*" ) { - - current = prev; - - // Convert response if prev dataType is non-auto and differs from current - } else if ( prev !== "*" && prev !== current ) { - - // Seek a direct converter - conv = converters[ prev + " " + current ] || converters[ "* " + current ]; - - // If none found, seek a pair - if ( !conv ) { - for ( conv2 in converters ) { - - // If conv2 outputs current - tmp = conv2.split( " " ); - if ( tmp[ 1 ] === current ) { - - // If prev can be converted to accepted input - conv = converters[ prev + " " + tmp[ 0 ] ] || - converters[ "* " + tmp[ 0 ] ]; - if ( conv ) { - - // Condense equivalence converters - if ( conv === true ) { - conv = converters[ conv2 ]; - - // Otherwise, insert the intermediate dataType - } else if ( converters[ conv2 ] !== true ) { - current = tmp[ 0 ]; - dataTypes.unshift( tmp[ 1 ] ); - } - break; - } - } - } - } - - // Apply converter (if not an equivalence) - if ( conv !== true ) { - - // Unless errors are allowed to bubble, catch and return them - if ( conv && s.throws ) { - response = conv( response ); - } else { - try { - response = conv( response ); - } catch ( e ) { - return { - state: "parsererror", - error: conv ? e : "No conversion from " + prev + " to " + current - }; - } - } - } - } - } - } - - return { state: "success", data: response }; -} - -jQuery.extend( { - - // Counter for holding the number of active queries - active: 0, - - // Last-Modified header cache for next request - lastModified: {}, - etag: {}, - - ajaxSettings: { - url: location.href, - type: "GET", - isLocal: rlocalProtocol.test( location.protocol ), - global: true, - processData: true, - async: true, - contentType: "application/x-www-form-urlencoded; charset=UTF-8", - - /* - timeout: 0, - data: null, - dataType: null, - username: null, - password: null, - cache: null, - throws: false, - traditional: false, - headers: {}, - */ - - accepts: { - "*": allTypes, - text: "text/plain", - html: "text/html", - xml: "application/xml, text/xml", - json: "application/json, text/javascript" - }, - - contents: { - xml: /\bxml\b/, - html: /\bhtml/, - json: /\bjson\b/ - }, - - responseFields: { - xml: "responseXML", - text: "responseText", - json: "responseJSON" - }, - - // Data converters - // Keys separate source (or catchall "*") and destination types with a single space - converters: { - - // Convert anything to text - "* text": String, - - // Text to html (true = no transformation) - "text html": true, - - // Evaluate text as a json expression - "text json": JSON.parse, - - // Parse text as xml - "text xml": jQuery.parseXML - }, - - // For options that shouldn't be deep extended: - // you can add your own custom options here if - // and when you create one that shouldn't be - // deep extended (see ajaxExtend) - flatOptions: { - url: true, - context: true - } - }, - - // Creates a full fledged settings object into target - // with both ajaxSettings and settings fields. - // If target is omitted, writes into ajaxSettings. - ajaxSetup: function( target, settings ) { - return settings ? - - // Building a settings object - ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : - - // Extending ajaxSettings - ajaxExtend( jQuery.ajaxSettings, target ); - }, - - ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), - ajaxTransport: addToPrefiltersOrTransports( transports ), - - // Main method - ajax: function( url, options ) { - - // If url is an object, simulate pre-1.5 signature - if ( typeof url === "object" ) { - options = url; - url = undefined; - } - - // Force options to be an object - options = options || {}; - - var transport, - - // URL without anti-cache param - cacheURL, - - // Response headers - responseHeadersString, - responseHeaders, - - // timeout handle - timeoutTimer, - - // Url cleanup var - urlAnchor, - - // Request state (becomes false upon send and true upon completion) - completed, - - // To know if global events are to be dispatched - fireGlobals, - - // Loop variable - i, - - // uncached part of the url - uncached, - - // Create the final options object - s = jQuery.ajaxSetup( {}, options ), - - // Callbacks context - callbackContext = s.context || s, - - // Context for global events is callbackContext if it is a DOM node or jQuery collection - globalEventContext = s.context && - ( callbackContext.nodeType || callbackContext.jquery ) ? - jQuery( callbackContext ) : - jQuery.event, - - // Deferreds - deferred = jQuery.Deferred(), - completeDeferred = jQuery.Callbacks( "once memory" ), - - // Status-dependent callbacks - statusCode = s.statusCode || {}, - - // Headers (they are sent all at once) - requestHeaders = {}, - requestHeadersNames = {}, - - // Default abort message - strAbort = "canceled", - - // Fake xhr - jqXHR = { - readyState: 0, - - // Builds headers hashtable if needed - getResponseHeader: function( key ) { - var match; - if ( completed ) { - if ( !responseHeaders ) { - responseHeaders = {}; - while ( ( match = rheaders.exec( responseHeadersString ) ) ) { - responseHeaders[ match[ 1 ].toLowerCase() + " " ] = - ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) - .concat( match[ 2 ] ); - } - } - match = responseHeaders[ key.toLowerCase() + " " ]; - } - return match == null ? null : match.join( ", " ); - }, - - // Raw string - getAllResponseHeaders: function() { - return completed ? responseHeadersString : null; - }, - - // Caches the header - setRequestHeader: function( name, value ) { - if ( completed == null ) { - name = requestHeadersNames[ name.toLowerCase() ] = - requestHeadersNames[ name.toLowerCase() ] || name; - requestHeaders[ name ] = value; - } - return this; - }, - - // Overrides response content-type header - overrideMimeType: function( type ) { - if ( completed == null ) { - s.mimeType = type; - } - return this; - }, - - // Status-dependent callbacks - statusCode: function( map ) { - var code; - if ( map ) { - if ( completed ) { - - // Execute the appropriate callbacks - jqXHR.always( map[ jqXHR.status ] ); - } else { - - // Lazy-add the new callbacks in a way that preserves old ones - for ( code in map ) { - statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; - } - } - } - return this; - }, - - // Cancel the request - abort: function( statusText ) { - var finalText = statusText || strAbort; - if ( transport ) { - transport.abort( finalText ); - } - done( 0, finalText ); - return this; - } - }; - - // Attach deferreds - deferred.promise( jqXHR ); - - // Add protocol if not provided (prefilters might expect it) - // Handle falsy url in the settings object (#10093: consistency with old signature) - // We also use the url parameter if available - s.url = ( ( url || s.url || location.href ) + "" ) - .replace( rprotocol, location.protocol + "//" ); - - // Alias method option to type as per ticket #12004 - s.type = options.method || options.type || s.method || s.type; - - // Extract dataTypes list - s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; - - // A cross-domain request is in order when the origin doesn't match the current origin. - if ( s.crossDomain == null ) { - urlAnchor = document.createElement( "a" ); - - // Support: IE <=8 - 11, Edge 12 - 15 - // IE throws exception on accessing the href property if url is malformed, - // e.g. http://example.com:80x/ - try { - urlAnchor.href = s.url; - - // Support: IE <=8 - 11 only - // Anchor's host property isn't correctly set when s.url is relative - urlAnchor.href = urlAnchor.href; - s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== - urlAnchor.protocol + "//" + urlAnchor.host; - } catch ( e ) { - - // If there is an error parsing the URL, assume it is crossDomain, - // it can be rejected by the transport if it is invalid - s.crossDomain = true; - } - } - - // Convert data if not already a string - if ( s.data && s.processData && typeof s.data !== "string" ) { - s.data = jQuery.param( s.data, s.traditional ); - } - - // Apply prefilters - inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); - - // If request was aborted inside a prefilter, stop there - if ( completed ) { - return jqXHR; - } - - // We can fire global events as of now if asked to - // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) - fireGlobals = jQuery.event && s.global; - - // Watch for a new set of requests - if ( fireGlobals && jQuery.active++ === 0 ) { - jQuery.event.trigger( "ajaxStart" ); - } - - // Uppercase the type - s.type = s.type.toUpperCase(); - - // Determine if request has content - s.hasContent = !rnoContent.test( s.type ); - - // Save the URL in case we're toying with the If-Modified-Since - // and/or If-None-Match header later on - // Remove hash to simplify url manipulation - cacheURL = s.url.replace( rhash, "" ); - - // More options handling for requests with no content - if ( !s.hasContent ) { - - // Remember the hash so we can put it back - uncached = s.url.slice( cacheURL.length ); - - // If data is available and should be processed, append data to url - if ( s.data && ( s.processData || typeof s.data === "string" ) ) { - cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; - - // #9682: remove data so that it's not used in an eventual retry - delete s.data; - } - - // Add or update anti-cache param if needed - if ( s.cache === false ) { - cacheURL = cacheURL.replace( rantiCache, "$1" ); - uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + - uncached; - } - - // Put hash and anti-cache on the URL that will be requested (gh-1732) - s.url = cacheURL + uncached; - - // Change '%20' to '+' if this is encoded form body content (gh-2658) - } else if ( s.data && s.processData && - ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { - s.data = s.data.replace( r20, "+" ); - } - - // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. - if ( s.ifModified ) { - if ( jQuery.lastModified[ cacheURL ] ) { - jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); - } - if ( jQuery.etag[ cacheURL ] ) { - jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); - } - } - - // Set the correct header, if data is being sent - if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { - jqXHR.setRequestHeader( "Content-Type", s.contentType ); - } - - // Set the Accepts header for the server, depending on the dataType - jqXHR.setRequestHeader( - "Accept", - s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? - s.accepts[ s.dataTypes[ 0 ] ] + - ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : - s.accepts[ "*" ] - ); - - // Check for headers option - for ( i in s.headers ) { - jqXHR.setRequestHeader( i, s.headers[ i ] ); - } - - // Allow custom headers/mimetypes and early abort - if ( s.beforeSend && - ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { - - // Abort if not done already and return - return jqXHR.abort(); - } - - // Aborting is no longer a cancellation - strAbort = "abort"; - - // Install callbacks on deferreds - completeDeferred.add( s.complete ); - jqXHR.done( s.success ); - jqXHR.fail( s.error ); - - // Get transport - transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); - - // If no transport, we auto-abort - if ( !transport ) { - done( -1, "No Transport" ); - } else { - jqXHR.readyState = 1; - - // Send global event - if ( fireGlobals ) { - globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); - } - - // If request was aborted inside ajaxSend, stop there - if ( completed ) { - return jqXHR; - } - - // Timeout - if ( s.async && s.timeout > 0 ) { - timeoutTimer = window.setTimeout( function() { - jqXHR.abort( "timeout" ); - }, s.timeout ); - } - - try { - completed = false; - transport.send( requestHeaders, done ); - } catch ( e ) { - - // Rethrow post-completion exceptions - if ( completed ) { - throw e; - } - - // Propagate others as results - done( -1, e ); - } - } - - // Callback for when everything is done - function done( status, nativeStatusText, responses, headers ) { - var isSuccess, success, error, response, modified, - statusText = nativeStatusText; - - // Ignore repeat invocations - if ( completed ) { - return; - } - - completed = true; - - // Clear timeout if it exists - if ( timeoutTimer ) { - window.clearTimeout( timeoutTimer ); - } - - // Dereference transport for early garbage collection - // (no matter how long the jqXHR object will be used) - transport = undefined; - - // Cache response headers - responseHeadersString = headers || ""; - - // Set readyState - jqXHR.readyState = status > 0 ? 4 : 0; - - // Determine if successful - isSuccess = status >= 200 && status < 300 || status === 304; - - // Get response data - if ( responses ) { - response = ajaxHandleResponses( s, jqXHR, responses ); - } - - // Use a noop converter for missing script but not if jsonp - if ( !isSuccess && - jQuery.inArray( "script", s.dataTypes ) > -1 && - jQuery.inArray( "json", s.dataTypes ) < 0 ) { - s.converters[ "text script" ] = function() {}; - } - - // Convert no matter what (that way responseXXX fields are always set) - response = ajaxConvert( s, response, jqXHR, isSuccess ); - - // If successful, handle type chaining - if ( isSuccess ) { - - // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. - if ( s.ifModified ) { - modified = jqXHR.getResponseHeader( "Last-Modified" ); - if ( modified ) { - jQuery.lastModified[ cacheURL ] = modified; - } - modified = jqXHR.getResponseHeader( "etag" ); - if ( modified ) { - jQuery.etag[ cacheURL ] = modified; - } - } - - // if no content - if ( status === 204 || s.type === "HEAD" ) { - statusText = "nocontent"; - - // if not modified - } else if ( status === 304 ) { - statusText = "notmodified"; - - // If we have data, let's convert it - } else { - statusText = response.state; - success = response.data; - error = response.error; - isSuccess = !error; - } - } else { - - // Extract error from statusText and normalize for non-aborts - error = statusText; - if ( status || !statusText ) { - statusText = "error"; - if ( status < 0 ) { - status = 0; - } - } - } - - // Set data for the fake xhr object - jqXHR.status = status; - jqXHR.statusText = ( nativeStatusText || statusText ) + ""; - - // Success/Error - if ( isSuccess ) { - deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); - } else { - deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); - } - - // Status-dependent callbacks - jqXHR.statusCode( statusCode ); - statusCode = undefined; - - if ( fireGlobals ) { - globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", - [ jqXHR, s, isSuccess ? success : error ] ); - } - - // Complete - completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); - - if ( fireGlobals ) { - globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); - - // Handle the global AJAX counter - if ( !( --jQuery.active ) ) { - jQuery.event.trigger( "ajaxStop" ); - } - } - } - - return jqXHR; - }, - - getJSON: function( url, data, callback ) { - return jQuery.get( url, data, callback, "json" ); - }, - - getScript: function( url, callback ) { - return jQuery.get( url, undefined, callback, "script" ); - } -} ); - -jQuery.each( [ "get", "post" ], function( _i, method ) { - jQuery[ method ] = function( url, data, callback, type ) { - - // Shift arguments if data argument was omitted - if ( isFunction( data ) ) { - type = type || callback; - callback = data; - data = undefined; - } - - // The url can be an options object (which then must have .url) - return jQuery.ajax( jQuery.extend( { - url: url, - type: method, - dataType: type, - data: data, - success: callback - }, jQuery.isPlainObject( url ) && url ) ); - }; -} ); - -jQuery.ajaxPrefilter( function( s ) { - var i; - for ( i in s.headers ) { - if ( i.toLowerCase() === "content-type" ) { - s.contentType = s.headers[ i ] || ""; - } - } -} ); - - -jQuery._evalUrl = function( url, options, doc ) { - return jQuery.ajax( { - url: url, - - // Make this explicit, since user can override this through ajaxSetup (#11264) - type: "GET", - dataType: "script", - cache: true, - async: false, - global: false, - - // Only evaluate the response if it is successful (gh-4126) - // dataFilter is not invoked for failure responses, so using it instead - // of the default converter is kludgy but it works. - converters: { - "text script": function() {} - }, - dataFilter: function( response ) { - jQuery.globalEval( response, options, doc ); - } - } ); -}; - - -jQuery.fn.extend( { - wrapAll: function( html ) { - var wrap; - - if ( this[ 0 ] ) { - if ( isFunction( html ) ) { - html = html.call( this[ 0 ] ); - } - - // The elements to wrap the target around - wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); - - if ( this[ 0 ].parentNode ) { - wrap.insertBefore( this[ 0 ] ); - } - - wrap.map( function() { - var elem = this; - - while ( elem.firstElementChild ) { - elem = elem.firstElementChild; - } - - return elem; - } ).append( this ); - } - - return this; - }, - - wrapInner: function( html ) { - if ( isFunction( html ) ) { - return this.each( function( i ) { - jQuery( this ).wrapInner( html.call( this, i ) ); - } ); - } - - return this.each( function() { - var self = jQuery( this ), - contents = self.contents(); - - if ( contents.length ) { - contents.wrapAll( html ); - - } else { - self.append( html ); - } - } ); - }, - - wrap: function( html ) { - var htmlIsFunction = isFunction( html ); - - return this.each( function( i ) { - jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); - } ); - }, - - unwrap: function( selector ) { - this.parent( selector ).not( "body" ).each( function() { - jQuery( this ).replaceWith( this.childNodes ); - } ); - return this; - } -} ); - - -jQuery.expr.pseudos.hidden = function( elem ) { - return !jQuery.expr.pseudos.visible( elem ); -}; -jQuery.expr.pseudos.visible = function( elem ) { - return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); -}; - - - - -jQuery.ajaxSettings.xhr = function() { - try { - return new window.XMLHttpRequest(); - } catch ( e ) {} -}; - -var xhrSuccessStatus = { - - // File protocol always yields status code 0, assume 200 - 0: 200, - - // Support: IE <=9 only - // #1450: sometimes IE returns 1223 when it should be 204 - 1223: 204 - }, - xhrSupported = jQuery.ajaxSettings.xhr(); - -support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); -support.ajax = xhrSupported = !!xhrSupported; - -jQuery.ajaxTransport( function( options ) { - var callback, errorCallback; - - // Cross domain only allowed if supported through XMLHttpRequest - if ( support.cors || xhrSupported && !options.crossDomain ) { - return { - send: function( headers, complete ) { - var i, - xhr = options.xhr(); - - xhr.open( - options.type, - options.url, - options.async, - options.username, - options.password - ); - - // Apply custom fields if provided - if ( options.xhrFields ) { - for ( i in options.xhrFields ) { - xhr[ i ] = options.xhrFields[ i ]; - } - } - - // Override mime type if needed - if ( options.mimeType && xhr.overrideMimeType ) { - xhr.overrideMimeType( options.mimeType ); - } - - // X-Requested-With header - // For cross-domain requests, seeing as conditions for a preflight are - // akin to a jigsaw puzzle, we simply never set it to be sure. - // (it can always be set on a per-request basis or even using ajaxSetup) - // For same-domain requests, won't change header if already provided. - if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { - headers[ "X-Requested-With" ] = "XMLHttpRequest"; - } - - // Set headers - for ( i in headers ) { - xhr.setRequestHeader( i, headers[ i ] ); - } - - // Callback - callback = function( type ) { - return function() { - if ( callback ) { - callback = errorCallback = xhr.onload = - xhr.onerror = xhr.onabort = xhr.ontimeout = - xhr.onreadystatechange = null; - - if ( type === "abort" ) { - xhr.abort(); - } else if ( type === "error" ) { - - // Support: IE <=9 only - // On a manual native abort, IE9 throws - // errors on any property access that is not readyState - if ( typeof xhr.status !== "number" ) { - complete( 0, "error" ); - } else { - complete( - - // File: protocol always yields status 0; see #8605, #14207 - xhr.status, - xhr.statusText - ); - } - } else { - complete( - xhrSuccessStatus[ xhr.status ] || xhr.status, - xhr.statusText, - - // Support: IE <=9 only - // IE9 has no XHR2 but throws on binary (trac-11426) - // For XHR2 non-text, let the caller handle it (gh-2498) - ( xhr.responseType || "text" ) !== "text" || - typeof xhr.responseText !== "string" ? - { binary: xhr.response } : - { text: xhr.responseText }, - xhr.getAllResponseHeaders() - ); - } - } - }; - }; - - // Listen to events - xhr.onload = callback(); - errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); - - // Support: IE 9 only - // Use onreadystatechange to replace onabort - // to handle uncaught aborts - if ( xhr.onabort !== undefined ) { - xhr.onabort = errorCallback; - } else { - xhr.onreadystatechange = function() { - - // Check readyState before timeout as it changes - if ( xhr.readyState === 4 ) { - - // Allow onerror to be called first, - // but that will not handle a native abort - // Also, save errorCallback to a variable - // as xhr.onerror cannot be accessed - window.setTimeout( function() { - if ( callback ) { - errorCallback(); - } - } ); - } - }; - } - - // Create the abort callback - callback = callback( "abort" ); - - try { - - // Do send the request (this may raise an exception) - xhr.send( options.hasContent && options.data || null ); - } catch ( e ) { - - // #14683: Only rethrow if this hasn't been notified as an error yet - if ( callback ) { - throw e; - } - } - }, - - abort: function() { - if ( callback ) { - callback(); - } - } - }; - } -} ); - - - - -// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) -jQuery.ajaxPrefilter( function( s ) { - if ( s.crossDomain ) { - s.contents.script = false; - } -} ); - -// Install script dataType -jQuery.ajaxSetup( { - accepts: { - script: "text/javascript, application/javascript, " + - "application/ecmascript, application/x-ecmascript" - }, - contents: { - script: /\b(?:java|ecma)script\b/ - }, - converters: { - "text script": function( text ) { - jQuery.globalEval( text ); - return text; - } - } -} ); - -// Handle cache's special case and crossDomain -jQuery.ajaxPrefilter( "script", function( s ) { - if ( s.cache === undefined ) { - s.cache = false; - } - if ( s.crossDomain ) { - s.type = "GET"; - } -} ); - -// Bind script tag hack transport -jQuery.ajaxTransport( "script", function( s ) { - - // This transport only deals with cross domain or forced-by-attrs requests - if ( s.crossDomain || s.scriptAttrs ) { - var script, callback; - return { - send: function( _, complete ) { - script = jQuery( " - <% end %> - - - - - - NAV - <%= image_tag('navbar.png') %> - - -
      - <%= image_tag "logo.png", class: 'logo' %> - "> - <% if language_tabs.any? %> -
      - <% language_tabs.each do |lang| %> - <% if lang.is_a? Hash %> - <%= lang.values.first %> - <% else %> - <%= lang %> - <% end %> - <% end %> -
      - <% end %> - <% if current_page.data.search %> - -
        - <% end %> -
          - <% toc_data(page_content).each do |h1| %> -
        • - <%= h1[:content] %> - <% if h1[:children].length > 0 %> - - <% end %> -
        • - <% end %> -
        - <% if current_page.data.toc_footers %> - - <% end %> -
        -
        -
        -
        - <%= page_content %> -
        -
        - <% if language_tabs.any? %> -
        - <% language_tabs.each do |lang| %> - <% if lang.is_a? Hash %> - <%= lang.values.first %> - <% else %> - <%= lang %> - <% end %> - <% end %> -
        - <% end %> -
        -
        - - diff --git a/source/postman/Nobitex Gateway Testnet.postman_collection.json b/source/postman/Nobitex Gateway Testnet.postman_collection.json deleted file mode 100644 index 77b003c..0000000 --- a/source/postman/Nobitex Gateway Testnet.postman_collection.json +++ /dev/null @@ -1,252 +0,0 @@ -{ - "info": { - "_postman_id": "1c466724-e931-459b-b644-39d2e2b0addf", - "name": "Nobitex Gateway Testnet", - "description": "https://apidocs.nobitex.ir/gateway", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "token (testnet)", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"api\":\"DemoApiKey\",\n\t\"amount\":1000000,\n\t\"callbackURL\":\"http://localhost\",\n\t\"factorNumber\":\"10\",\n\t\"mobile\":\"09123456789\",\n\t\"description\":\"Test Payment with Nobitex\",\n\t\"currencies\":\"btc\"\n}" - }, - "url": { - "raw": "https://testnetapiv2.nobitex.ir/pg/send/", - "protocol": "https", - "host": [ - "testnetapi", - "nobitex", - "market" - ], - "path": [ - "pg", - "send", - "" - ] - } - }, - "response": [ - { - "name": "token (testnet)", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"api\":\"DemoApiKey\",\n\t\"amount\":1000000,\n\t\"callbackURL\":\"http://localhost\",\n\t\"factorNumber\":\"10\",\n\t\"mobile\":\"09123456789\",\n\t\"description\":\"Test Payment with Nobitex\",\n\t\"currencies\":\"btc\"\n}" - }, - "url": { - "raw": "https://testnetapiv2.nobitex.ir/pg/send/", - "protocol": "https", - "host": [ - "testnetapi", - "nobitex", - "market" - ], - "path": [ - "pg", - "send", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Server", - "value": "nginx/1.14.0 (Ubuntu)" - }, - { - "key": "Date", - "value": "Sat, 14 Sep 2019 11:00:56 GMT" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Content-Length", - "value": "66" - }, - { - "key": "Connection", - "value": "keep-alive" - }, - { - "key": "Vary", - "value": "Accept, Origin" - }, - { - "key": "Allow", - "value": "POST, OPTIONS" - }, - { - "key": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "key": "X-Frame-Options", - "value": "DENY" - }, - { - "key": "X-XSS-Protection", - "value": "1; mode=block" - }, - { - "key": "Referrer-Policy", - "value": "origin-when-cross-origin" - }, - { - "key": "X-Content-Type-Options", - "value": "nosniff" - } - ], - "cookie": [], - "body": "{\n \"status\": \"success\",\n \"token\": \"f6838d15fb024b0eb6d83e4c2a2028d3\"\n}" - } - ] - }, - { - "name": "verify payment (testnet)", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"api\":\"DemoApiKey\",\n\t\"token\":\"f50116d31d4a4d1ab93d1f2759f198bb\"\n}" - }, - "url": { - "raw": "https://testnetapiv2.nobitex.ir/pg/verify/", - "protocol": "https", - "host": [ - "testnetapi", - "nobitex", - "market" - ], - "path": [ - "pg", - "verify", - "" - ] - } - }, - "response": [ - { - "name": "verify payment (testnet)", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"api\":\"DemoApiKey\",\n\t\"token\":\"f50116d31d4a4d1ab93d1f2759f198bb\"\n}" - }, - "url": { - "raw": "https://testnetapiv2.nobitex.ir/pg/verify/", - "protocol": "https", - "host": [ - "testnetapi", - "nobitex", - "market" - ], - "path": [ - "pg", - "verify", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Server", - "value": "nginx/1.14.0 (Ubuntu)" - }, - { - "key": "Date", - "value": "Sat, 14 Sep 2019 11:35:51 GMT" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Content-Length", - "value": "200" - }, - { - "key": "Connection", - "value": "keep-alive" - }, - { - "key": "Vary", - "value": "Accept, Origin" - }, - { - "key": "Allow", - "value": "POST, OPTIONS" - }, - { - "key": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "key": "X-Frame-Options", - "value": "DENY" - }, - { - "key": "X-XSS-Protection", - "value": "1; mode=block" - }, - { - "key": "Referrer-Policy", - "value": "origin-when-cross-origin" - }, - { - "key": "X-Content-Type-Options", - "value": "nosniff" - } - ], - "cookie": [], - "body": "{\n \"status\": \"success\",\n \"amount\": 1000000,\n \"cryptoAmount\": 85516,\n \"txHash\": \"825d6613a6eef4566abf4ba7bae83618\",\n \"factorNumber\": \"10\",\n \"mobile\": \"09123456789\",\n \"description\": \"Test Payment with Nobitex\"\n}" - } - ] - } - ] -} diff --git a/source/postman/Nobitex Gateway.postman_collection.json b/source/postman/Nobitex Gateway.postman_collection.json deleted file mode 100644 index a5cebdd..0000000 --- a/source/postman/Nobitex Gateway.postman_collection.json +++ /dev/null @@ -1,251 +0,0 @@ -{ - "info": { - "_postman_id": "0c525a53-2c6a-48f5-8111-5ae3657f28aa", - "name": "Nobitex Gateway", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "token", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"api\":\"DemoApiKey\",\n\t\"amount\":1000000,\n\t\"callbackURL\":\"https://nobitex.ir\",\n\t\"factorNumber\":\"10\",\n\t\"mobile\":\"09123456789\",\n\t\"description\":\"Payment with Nobitex\",\n\t\"currencies\":\"btc\"\n}" - }, - "url": { - "raw": "https://apiv2.nobitex.ir/pg/send/", - "protocol": "https", - "host": [ - "api", - "nobitex", - "market" - ], - "path": [ - "pg", - "send", - "" - ] - } - }, - "response": [ - { - "name": "token", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"api\":\"DemoApiKey\",\n\t\"amount\":1000000,\n\t\"callbackURL\":\"https://nobitex.ir\",\n\t\"factorNumber\":\"10\",\n\t\"mobile\":\"09123456789\",\n\t\"description\":\"Payment with Nobitex\",\n\t\"currencies\":\"btc\"\n}" - }, - "url": { - "raw": "https://apiv2.nobitex.ir/pg/send/", - "protocol": "https", - "host": [ - "api", - "nobitex", - "market" - ], - "path": [ - "pg", - "send", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Server", - "value": "nginx/1.14.0 (Ubuntu)" - }, - { - "key": "Date", - "value": "Sat, 14 Sep 2019 11:00:56 GMT" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Content-Length", - "value": "66" - }, - { - "key": "Connection", - "value": "keep-alive" - }, - { - "key": "Vary", - "value": "Accept, Origin" - }, - { - "key": "Allow", - "value": "POST, OPTIONS" - }, - { - "key": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "key": "X-Frame-Options", - "value": "DENY" - }, - { - "key": "X-XSS-Protection", - "value": "1; mode=block" - }, - { - "key": "Referrer-Policy", - "value": "origin-when-cross-origin" - }, - { - "key": "X-Content-Type-Options", - "value": "nosniff" - } - ], - "cookie": [], - "body": "{\n \"status\": \"success\",\n \"token\": \"f6838d15fb024b0eb6d83e4c2a2028d3\"\n}" - } - ] - }, - { - "name": "verify payment", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"api\":\"DemoApiKey\",\n\t\"token\":\"f50116d31d4a4d1ab93d1f2759f198bb\"\n}" - }, - "url": { - "raw": "https://apiv2.nobitex.ir/pg/verify/", - "protocol": "https", - "host": [ - "api", - "nobitex", - "market" - ], - "path": [ - "pg", - "verify", - "" - ] - } - }, - "response": [ - { - "name": "verify payment", - "originalRequest": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"api\":\"DemoApiKey\",\n\t\"token\":\"f50116d31d4a4d1ab93d1f2759f198bb\"\n}" - }, - "url": { - "raw": "https://apiv2.nobitex.ir/pg/verify/", - "protocol": "https", - "host": [ - "api", - "nobitex", - "market" - ], - "path": [ - "pg", - "verify", - "" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Server", - "value": "nginx/1.14.0 (Ubuntu)" - }, - { - "key": "Date", - "value": "Sat, 14 Sep 2019 11:35:51 GMT" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "Content-Length", - "value": "200" - }, - { - "key": "Connection", - "value": "keep-alive" - }, - { - "key": "Vary", - "value": "Accept, Origin" - }, - { - "key": "Allow", - "value": "POST, OPTIONS" - }, - { - "key": "Strict-Transport-Security", - "value": "max-age=31536000; includeSubdomains" - }, - { - "key": "X-Frame-Options", - "value": "DENY" - }, - { - "key": "X-XSS-Protection", - "value": "1; mode=block" - }, - { - "key": "Referrer-Policy", - "value": "origin-when-cross-origin" - }, - { - "key": "X-Content-Type-Options", - "value": "nosniff" - } - ], - "cookie": [], - "body": "{\n \"status\": \"success\",\n \"amount\": 1000000,\n \"cryptoAmount\": 85516,\n \"txHash\": \"825d6613a6eef4566abf4ba7bae83618\",\n \"factorNumber\": \"10\",\n \"mobile\": \"09123456789\",\n \"description\": \"Test Payment with Nobitex\"\n}" - } - ] - } - ] -} diff --git a/source/stylesheets/_icon-font.scss b/source/stylesheets/_icon-font.scss deleted file mode 100644 index b599483..0000000 --- a/source/stylesheets/_icon-font.scss +++ /dev/null @@ -1,38 +0,0 @@ -@font-face { - font-family: 'slate'; - src:font-url('slate.eot?-syv14m'); - src:font-url('slate.eot?#iefix-syv14m') format('embedded-opentype'), - font-url('slate.woff2?-syv14m') format('woff2'), - font-url('slate.woff?-syv14m') format('woff'), - font-url('slate.ttf?-syv14m') format('truetype'), - font-url('slate.svg?-syv14m#slate') format('svg'); - font-weight: normal; - font-style: normal; -} - -%icon { - font-family: 'slate'; - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; -} - -%icon-exclamation-sign { - @extend %icon; - content: "\e600"; -} -%icon-info-sign { - @extend %icon; - content: "\e602"; -} -%icon-ok-sign { - @extend %icon; - content: "\e606"; -} -%icon-search { - @extend %icon; - content: "\e607"; -} diff --git a/source/stylesheets/_normalize.scss b/source/stylesheets/_normalize.scss deleted file mode 100644 index 46f646a..0000000 --- a/source/stylesheets/_normalize.scss +++ /dev/null @@ -1,427 +0,0 @@ -/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ - -/** - * 1. Set default font family to sans-serif. - * 2. Prevent iOS text size adjust after orientation change, without disabling - * user zoom. - */ - -html { - font-family: sans-serif; /* 1 */ - -ms-text-size-adjust: 100%; /* 2 */ - -webkit-text-size-adjust: 100%; /* 2 */ -} - -/** - * Remove default margin. - */ - -body { - margin: 0; -} - -/* HTML5 display definitions - ========================================================================== */ - -/** - * Correct `block` display not defined for any HTML5 element in IE 8/9. - * Correct `block` display not defined for `details` or `summary` in IE 10/11 - * and Firefox. - * Correct `block` display not defined for `main` in IE 11. - */ - -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -main, -menu, -nav, -section, -summary { - display: block; -} - -/** - * 1. Correct `inline-block` display not defined in IE 8/9. - * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. - */ - -audio, -canvas, -progress, -video { - display: inline-block; /* 1 */ - vertical-align: baseline; /* 2 */ -} - -/** - * Prevent modern browsers from displaying `audio` without controls. - * Remove excess height in iOS 5 devices. - */ - -audio:not([controls]) { - display: none; - height: 0; -} - -/** - * Address `[hidden]` styling not present in IE 8/9/10. - * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. - */ - -[hidden], -template { - display: none; -} - -/* Links - ========================================================================== */ - -/** - * Remove the gray background color from active links in IE 10. - */ - -a { - background-color: transparent; -} - -/** - * Improve readability when focused and also mouse hovered in all browsers. - */ - -a:active, -a:hover { - outline: 0; -} - -/* Text-level semantics - ========================================================================== */ - -/** - * Address styling not present in IE 8/9/10/11, Safari, and Chrome. - */ - -abbr[title] { - border-bottom: 1px dotted; -} - -/** - * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. - */ - -b, -strong { - font-weight: bold; -} - -/** - * Address styling not present in Safari and Chrome. - */ - -dfn { - font-style: italic; -} - -/** - * Address variable `h1` font-size and margin within `section` and `article` - * contexts in Firefox 4+, Safari, and Chrome. - */ - -h1 { - font-size: 2em; - margin: 0.67em 0; -} - -/** - * Address styling not present in IE 8/9. - */ - -mark { - background: #ff0; - color: #000; -} - -/** - * Address inconsistent and variable font size in all browsers. - */ - -small { - font-size: 80%; -} - -/** - * Prevent `sub` and `sup` affecting `line-height` in all browsers. - */ - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sup { - top: -0.5em; -} - -sub { - bottom: -0.25em; -} - -/* Embedded content - ========================================================================== */ - -/** - * Remove border when inside `a` element in IE 8/9/10. - */ - -img { - border: 0; -} - -/** - * Correct overflow not hidden in IE 9/10/11. - */ - -svg:not(:root) { - overflow: hidden; -} - -/* Grouping content - ========================================================================== */ - -/** - * Address margin not present in IE 8/9 and Safari. - */ - -figure { - margin: 1em 40px; -} - -/** - * Address differences between Firefox and other browsers. - */ - -hr { - -moz-box-sizing: content-box; - box-sizing: content-box; - height: 0; -} - -/** - * Contain overflow in all browsers. - */ - -pre { - overflow: auto; -} - -/** - * Address odd `em`-unit font size rendering in all browsers. - */ - -code, -kbd, -pre, -samp { - font-family: monospace, monospace; - font-size: 1em; -} - -/* Forms - ========================================================================== */ - -/** - * Known limitation: by default, Chrome and Safari on OS X allow very limited - * styling of `select`, unless a `border` property is set. - */ - -/** - * 1. Correct color not being inherited. - * Known issue: affects color of disabled elements. - * 2. Correct font properties not being inherited. - * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. - */ - -button, -input, -optgroup, -select, -textarea { - color: inherit; /* 1 */ - font: inherit; /* 2 */ - margin: 0; /* 3 */ -} - -/** - * Address `overflow` set to `hidden` in IE 8/9/10/11. - */ - -button { - overflow: visible; -} - -/** - * Address inconsistent `text-transform` inheritance for `button` and `select`. - * All other form control elements do not inherit `text-transform` values. - * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. - * Correct `select` style inheritance in Firefox. - */ - -button, -select { - text-transform: none; -} - -/** - * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` - * and `video` controls. - * 2. Correct inability to style clickable `input` types in iOS. - * 3. Improve usability and consistency of cursor style between image-type - * `input` and others. - */ - -button, -html input[type="button"], /* 1 */ -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; /* 2 */ - cursor: pointer; /* 3 */ -} - -/** - * Re-set default cursor for disabled elements. - */ - -button[disabled], -html input[disabled] { - cursor: default; -} - -/** - * Remove inner padding and border in Firefox 4+. - */ - -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} - -/** - * Address Firefox 4+ setting `line-height` on `input` using `!important` in - * the UA stylesheet. - */ - -input { - line-height: normal; -} - -/** - * It's recommended that you don't attempt to style these elements. - * Firefox's implementation doesn't respect box-sizing, padding, or width. - * - * 1. Address box sizing set to `content-box` in IE 8/9/10. - * 2. Remove excess padding in IE 8/9/10. - */ - -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; /* 1 */ - padding: 0; /* 2 */ -} - -/** - * Fix the cursor style for Chrome's increment/decrement buttons. For certain - * `font-size` values of the `input`, it causes the cursor style of the - * decrement button to change from `default` to `text`. - */ - -input[type="number"]::-webkit-inner-spin-button, -input[type="number"]::-webkit-outer-spin-button { - height: auto; -} - -/** - * 1. Address `appearance` set to `searchfield` in Safari and Chrome. - * 2. Address `box-sizing` set to `border-box` in Safari and Chrome - * (include `-moz` to future-proof). - */ - -input[type="search"] { - -webkit-appearance: textfield; /* 1 */ - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; /* 2 */ - box-sizing: content-box; -} - -/** - * Remove inner padding and search cancel button in Safari and Chrome on OS X. - * Safari (but not Chrome) clips the cancel button when the search input has - * padding (and `textfield` appearance). - */ - -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} - -/** - * Define consistent border, margin, and padding. - */ - -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} - -/** - * 1. Correct `color` not being inherited in IE 8/9/10/11. - * 2. Remove padding so people aren't caught out if they zero out fieldsets. - */ - -legend { - border: 0; /* 1 */ - padding: 0; /* 2 */ -} - -/** - * Remove default vertical scrollbar in IE 8/9/10/11. - */ - -textarea { - overflow: auto; -} - -/** - * Don't inherit the `font-weight` (applied by a rule above). - * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. - */ - -optgroup { - font-weight: bold; -} - -/* Tables - ========================================================================== */ - -/** - * Remove most spacing between table cells. - */ - -table { - border-collapse: collapse; - border-spacing: 0; -} - -td, -th { - padding: 0; -} diff --git a/source/stylesheets/_rtl.scss b/source/stylesheets/_rtl.scss deleted file mode 100644 index 759a8f7..0000000 --- a/source/stylesheets/_rtl.scss +++ /dev/null @@ -1,161 +0,0 @@ -:lang(fa) { -//////////////////////////////////////////////////////////////////////////////// -// RTL Styles Variables -//////////////////////////////////////////////////////////////////////////////// - -$default: auto; - -//////////////////////////////////////////////////////////////////////////////// -// TABLE OF CONTENTS -//////////////////////////////////////////////////////////////////////////////// - -#toc>ul>li>a>span { - float: left; -} - -.toc-wrapper { - transition: right 0.3s ease-in-out !important; - left: $default !important; - #{right}: 0; -} - -.toc-h2 { - padding-#{right}: $nav-padding + $nav-indent; -} - -#nav-button { - #{right}: 0; - transition: right 0.3s ease-in-out; - &.open { - right: $nav-width - } -} - -//////////////////////////////////////////////////////////////////////////////// -// PAGE LAYOUT AND CODE SAMPLE BACKGROUND -//////////////////////////////////////////////////////////////////////////////// -.page-wrapper { - margin-#{left}: $default !important; - margin-#{right}: $nav-width; - .dark-box { - #{right}: $default; - #{left}: 0; - } -} - -.lang-selector { - width: $default !important; - a { - float: right; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// CODE SAMPLE STYLES -//////////////////////////////////////////////////////////////////////////////// -.content { - &>h1, - &>h2, - &>h3, - &>h4, - &>h5, - &>h6, - &>p, - &>table, - &>ul, - &>ol, - &>aside, - &>dl { - margin-#{left}: $examples-width; - margin-#{right}: $default !important; - } - &>ul, - &>ol { - padding-#{right}: $main-padding + 15px; - } - table { - th, - td { - text-align: right; - } - } - dd { - margin-#{right}: 15px; - } - aside { - aside:before { - padding-#{left}: 0.5em; - } - .search-highlight { - background: linear-gradient(to top right, #F7E633 0%, #F1D32F 100%); - } - } - pre, - blockquote { - float: left !important; - clear: left !important; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// TYPOGRAPHY -//////////////////////////////////////////////////////////////////////////////// -@font-face { - font-family: 'IRANSans'; - src : url("../fonts/IRANSansFaNum/eot/IRANSansWeb(FaNum).eot"), url('../fonts/IRANSansFaNum/woff/IRANSansWeb(FaNum).woff') format('woff'), url('../fonts/IRANSansFaNum/ttf/IRANSansWeb(FaNum).ttf') format('truetype'), url("../fonts/IRANSansFaNum/woff2/IRANSansWeb(FaNum).woff2") format('woff2'); -} - -h1, -h2, -h3, -h4, -h5, -h6, -p, -aside, -td, -th, -li, -a, -table { - direction: rtl; - font-family: "Vazir", serif !important; -} - -.toc-wrapper { - text-align: right; - direction: rtl; - font-weight: 100 !important; -} - -td, th, .content table th, .content table td, li { - text-align: right !important; -} - -code { - direction: ltr; -} - - -//////////////////////////////////////////////////////////////////////////////// -// RESPONSIVE DESIGN -//////////////////////////////////////////////////////////////////////////////// -@media (max-width: $tablet-width) { - .toc-wrapper { - #{right}: -$nav-width; - &.open { - #{right}: 0; - } - } - .page-wrapper { - margin-#{right}: 0; - } -} - -@media (max-width: $phone-width) { - %left-col { - margin-#{left}: 0; - } -} - -} diff --git a/source/stylesheets/_variables.scss b/source/stylesheets/_variables.scss deleted file mode 100644 index 5d1bbf6..0000000 --- a/source/stylesheets/_variables.scss +++ /dev/null @@ -1,109 +0,0 @@ -/* -Copyright 2008-2013 Concur Technologies, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); you may -not use this file except in compliance with the License. You may obtain -a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. -*/ - - -//////////////////////////////////////////////////////////////////////////////// -// CUSTOMIZE SLATE -//////////////////////////////////////////////////////////////////////////////// -// Use these settings to help adjust the appearance of Slate - - -// BACKGROUND COLORS -//////////////////// -$nav-bg: #2E3336 !default; -$examples-bg: #2E3336 !default; -$code-bg: #1E2224 !default; -$code-annotation-bg: #191D1F !default; -$nav-subitem-bg: #1E2224 !default; -$nav-active-bg: #0F75D4 !default; -$nav-active-parent-bg: #1E2224 !default; // parent links of the current section -$lang-select-border: #000 !default; -$lang-select-bg: #1E2224 !default; -$lang-select-active-bg: $examples-bg !default; // feel free to change this to blue or something -$lang-select-pressed-bg: #111 !default; // color of language tab bg when mouse is pressed -$main-bg: #F3F7F9 !default; -$aside-notice-bg: #8fbcd4 !default; -$aside-warning-bg: #c97a7e !default; -$aside-success-bg: #6ac174 !default; -$search-notice-bg: #c97a7e !default; - - -// TEXT COLORS -//////////////////// -$main-text: #333 !default; // main content text color -$nav-text: #fff !default; -$nav-active-text: #fff !default; -$nav-active-parent-text: #fff !default; // parent links of the current section -$lang-select-text: #fff !default; // color of unselected language tab text -$lang-select-active-text: #fff !default; // color of selected language tab text -$lang-select-pressed-text: #fff !default; // color of language tab text when mouse is pressed - - -// SIZES -//////////////////// -$nav-width: 230px !default; // width of the navbar -$examples-width: 50% !default; // portion of the screen taken up by code examples -$logo-margin: 20px !default; // margin below logo -$main-padding: 28px !default; // padding to left and right of content & examples -$nav-padding: 15px !default; // padding to left and right of navbar -$nav-v-padding: 10px !default; // padding used vertically around search boxes and results -$nav-indent: 10px !default; // extra padding for ToC subitems -$code-annotation-padding: 13px !default; // padding inside code annotations -$h1-margin-bottom: 21px !default; // padding under the largest header tags -$tablet-width: 930px !default; // min width before reverting to tablet size -$phone-width: $tablet-width - $nav-width !default; // min width before reverting to mobile size - - -// FONTS -//////////////////// -$vazir-font-path:"../fonts/Vazir"; -@font-face { - font-family: 'Vazir'; - src : url("#{$vazir-font-path}/Vazir-Light-FD.eot"), url('#{$vazir-font-path}/Vazir-Light-FD.woff') format('woff'), url('#{$vazir-font-path}/Vazir-Light-FD.ttf') format('truetype'), url("#{$vazir-font-path}/Vazir-Light-FD.woff2") format('woff2'); -} - -%default-font { - font-family: "Vazir",-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; - font-size: 14px; -} - -%header-font { - @extend %default-font; - font-weight: bold; -} - -%code-font { - font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, serif; - font-size: 12px; - line-height: 1.5; -} - - -// OTHER -//////////////////// -$nav-footer-border-color: #666 !default; -$search-box-border-color: #666 !default; - - -//////////////////////////////////////////////////////////////////////////////// -// INTERNAL -//////////////////////////////////////////////////////////////////////////////// -// These settings are probably best left alone. - -%break-words { - word-break: break-all; - hyphens: auto; -} diff --git a/source/stylesheets/custom.css.scss b/source/stylesheets/custom.css.scss deleted file mode 100644 index 941faa3..0000000 --- a/source/stylesheets/custom.css.scss +++ /dev/null @@ -1,15 +0,0 @@ -@charset "utf-8"; -@import 'variables'; - -.badge { - font-size: 80%; - background-color: rgba(0,0,0,0.05); - padding: 0 3px; - border-radius: 4px; -} - -table td .long { - display: inline-block; - max-width: calc(25vw - 115px); - word-wrap: break-word; -} diff --git a/source/stylesheets/print.css.scss b/source/stylesheets/print.css.scss deleted file mode 100644 index aea88c3..0000000 --- a/source/stylesheets/print.css.scss +++ /dev/null @@ -1,153 +0,0 @@ -@charset "utf-8"; -@import 'normalize'; -@import 'variables'; -@import 'icon-font'; - -/* -Copyright 2008-2013 Concur Technologies, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); you may -not use this file except in compliance with the License. You may obtain -a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. -*/ - -$print-color: #999; -$print-color-light: #ccc; -$print-font-size: 12px; - -body { - @extend %default-font; -} - -.tocify, .toc-footer, .lang-selector, .search, #nav-button { - display: none; -} - -.tocify-wrapper>img { - margin: 0 auto; - display: block; -} - -.content { - font-size: 12px; - - pre, code { - @extend %code-font; - @extend %break-words; - border: 1px solid $print-color; - border-radius: 5px; - font-size: 0.8em; - } - - pre { - code { - border: 0; - } - } - - pre { - padding: 1.3em; - } - - code { - padding: 0.2em; - } - - table { - border: 1px solid $print-color; - tr { - border-bottom: 1px solid $print-color; - } - td,th { - padding: 0.7em; - } - } - - p { - line-height: 1.5; - } - - a { - text-decoration: none; - color: #000; - } - - h1 { - @extend %header-font; - font-size: 2.5em; - padding-top: 0.5em; - padding-bottom: 0.5em; - margin-top: 1em; - margin-bottom: $h1-margin-bottom; - border: 2px solid $print-color-light; - border-width: 2px 0; - text-align: center; - } - - h2 { - @extend %header-font; - font-size: 1.8em; - margin-top: 2em; - border-top: 2px solid $print-color-light; - padding-top: 0.8em; - } - - h1+h2, h1+div+h2 { - border-top: none; - padding-top: 0; - margin-top: 0; - } - - h3, h4 { - @extend %header-font; - font-size: 0.8em; - margin-top: 1.5em; - margin-bottom: 0.8em; - text-transform: uppercase; - } - - h5, h6 { - text-transform: uppercase; - } - - aside { - padding: 1em; - border: 1px solid $print-color-light; - border-radius: 5px; - margin-top: 1.5em; - margin-bottom: 1.5em; - line-height: 1.6; - } - - aside:before { - vertical-align: middle; - padding-right: 0.5em; - font-size: 14px; - } - - aside.notice:before { - @extend %icon-info-sign; - } - - aside.warning:before { - @extend %icon-exclamation-sign; - } - - aside.success:before { - @extend %icon-ok-sign; - } -} - -.copy-clipboard { - @media print { - display: none - } -} diff --git a/source/stylesheets/screen.css.scss b/source/stylesheets/screen.css.scss deleted file mode 100644 index 4b7592c..0000000 --- a/source/stylesheets/screen.css.scss +++ /dev/null @@ -1,634 +0,0 @@ -@charset "utf-8"; -@import 'normalize'; -@import 'variables'; -@import 'icon-font'; -@import 'rtl'; // uncomment to switch to RTL format - -/* -Copyright 2008-2013 Concur Technologies, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); you may -not use this file except in compliance with the License. You may obtain -a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. -*/ - -//////////////////////////////////////////////////////////////////////////////// -// GENERAL STUFF -//////////////////////////////////////////////////////////////////////////////// - -html, body { - color: $main-text; - padding: 0; - margin: 0; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - @extend %default-font; - background-color: $main-bg; - height: 100%; - -webkit-text-size-adjust: none; /* Never autoresize text */ -} - -//////////////////////////////////////////////////////////////////////////////// -// TABLE OF CONTENTS -//////////////////////////////////////////////////////////////////////////////// - -#toc > ul > li > a > span { - float: right; - background-color: #2484FF; - border-radius: 40px; - width: 20px; -} - -.toc-wrapper { - transition: left 0.3s ease-in-out; - - overflow-y: auto; - overflow-x: hidden; - position: fixed; - z-index: 30; - top: 0; - left: 0; - bottom: 0; - width: $nav-width; - background-color: $nav-bg; - font-size: 13px; - font-weight: bold; - - // language selector for mobile devices - .lang-selector { - display: none; - a { - padding-top: 0.5em; - padding-bottom: 0.5em; - } - } - - // This is the logo at the top of the ToC - .logo { - display: block; - max-width: 100%; - margin: $logo-margin; - width: 190px; - } - - &>.search { - position: relative; - - input { - background: $nav-bg; - border-width: 0 0 1px 0; - border-color: $search-box-border-color; - padding: 6px 0 6px 20px; - box-sizing: border-box; - margin: $nav-v-padding $nav-padding; - width: $nav-width - ($nav-padding*2); - outline: none; - color: $nav-text; - border-radius: 0; /* ios has a default border radius */ - } - - &:before { - position: absolute; - top: 17px; - left: $nav-padding; - color: $nav-text; - @extend %icon-search; - } - } - - .search-results { - margin-top: 0; - box-sizing: border-box; - height: 0; - overflow-y: auto; - overflow-x: hidden; - transition-property: height, margin; - transition-duration: 180ms; - transition-timing-function: ease-in-out; - background: $nav-subitem-bg; - &.visible { - height: 30%; - margin-bottom: 1em; - } - - li { - margin: 1em $nav-padding; - line-height: 1; - } - - a { - color: $nav-text; - text-decoration: none; - - &:hover { - text-decoration: underline; - } - } - } - - - // The Table of Contents is composed of multiple nested - // unordered lists. These styles remove the default - // styling of an unordered list because it is ugly. - ul, li { - list-style: none; - margin: 0; - padding: 0; - line-height: 28px; - } - - li { - color: $nav-text; - transition-property: background; - transition-timing-function: linear; - transition-duration: 200ms; - } - - // This is the currently selected ToC entry - .toc-link.active { - background-color: $nav-active-bg; - color: $nav-active-text; - } - - // this is parent links of the currently selected ToC entry - .toc-link.active-parent { - background-color: $nav-active-parent-bg; - color: $nav-active-parent-text; - } - - .toc-list-h2 { - display: none; - background-color: $nav-subitem-bg; - font-weight: 500; - } - - .toc-h2 { - padding-left: $nav-padding + $nav-indent; - font-size: 12px; - } - - .toc-footer { - padding: 1em 0; - margin-top: 1em; - border-top: 1px dashed $nav-footer-border-color; - - li,a { - color: $nav-text; - text-decoration: none; - } - - a:hover { - text-decoration: underline; - } - - li { - font-size: 0.8em; - line-height: 1.7; - text-decoration: none; - } - } -} - -.toc-link, .toc-footer li { - padding: 0 $nav-padding 0 $nav-padding; - display: block; - overflow-x: hidden; - white-space: nowrap; - text-overflow: ellipsis; - text-decoration: none; - color: $nav-text; - transition-property: background; - transition-timing-function: linear; - transition-duration: 130ms; -} - -// button to show navigation on mobile devices -#nav-button { - span { - display: block; - $side-pad: $main-padding / 2 - 8px; - padding: $side-pad $side-pad $side-pad; - background-color: rgba($main-bg, 0.7); - transform-origin: 0 0; - transform: rotate(-90deg) translate(-100%, 0); - border-radius: 0 0 0 5px; - } - padding: 0 1.5em 5em 0; // increase touch size area - display: none; - position: fixed; - top: 0; - left: 0; - z-index: 100; - color: #000; - text-decoration: none; - font-weight: bold; - opacity: 0.7; - line-height: 16px; - img { - height: 16px; - vertical-align: bottom; - } - - transition: left 0.3s ease-in-out; - - &:hover { opacity: 1; } - &.open {left: $nav-width} -} - - -//////////////////////////////////////////////////////////////////////////////// -// PAGE LAYOUT AND CODE SAMPLE BACKGROUND -//////////////////////////////////////////////////////////////////////////////// - -.page-wrapper { - margin-left: $nav-width; - position: relative; - z-index: 10; - background-color: $main-bg; - min-height: 100%; - - padding-bottom: 1px; // prevent margin overflow - - // The dark box is what gives the code samples their dark background. - // It sits essentially under the actual content block, which has a - // transparent background. - // I know, it's hackish, but it's the simplist way to make the left - // half of the content always this background color. - .dark-box { - width: $examples-width; - background-color: $examples-bg; - position: absolute; - right: 0; - top: 0; - bottom: 0; - } - - .lang-selector { - position: fixed; - z-index: 50; - border-bottom: 5px solid $lang-select-active-bg; - } -} - -.lang-selector { - display: flex; - background-color: $lang-select-bg; - width: 100%; - font-weight: bold; - overflow-x: auto; - a { - display: inline; - color: $lang-select-text; - text-decoration: none; - padding: 0 10px; - line-height: 30px; - outline: 0; - - &:active, &:focus { - background-color: $lang-select-pressed-bg; - color: $lang-select-pressed-text; - } - - &.active { - background-color: $lang-select-active-bg; - color: $lang-select-active-text; - } - } - - &:after { - content: ''; - clear: both; - display: block; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// CONTENT STYLES -//////////////////////////////////////////////////////////////////////////////// -// This is all the stuff with the light background in the left half of the page - -.content { - // fixes webkit rendering bug for some: see #538 - -webkit-transform: translateZ(0); - // to place content above the dark box - position: relative; - z-index: 30; - - &:after { - content: ''; - display: block; - clear: both; - } - - &>h1, &>h2, &>h3, &>h4, &>h5, &>h6, &>p, &>table, &>ul, &>ol, &>aside, &>dl { - margin-right: $examples-width; - padding: 0 $main-padding; - box-sizing: border-box; - display: block; - - @extend %left-col; - } - - &>ul, &>ol { - padding-left: $main-padding + 15px; - } - - // the div is the tocify hidden div for placeholding stuff - &>h1, &>h2, &>h2+div { - clear:both; - } - - h1 { - @extend %header-font; - font-size: 25px; - padding-top: 0.5em; - padding-bottom: 0.5em; - margin-bottom: $h1-margin-bottom; - margin-top: 2em; - border-top: 1px solid #ccc; - border-bottom: 1px solid #ccc; - background-color: #fdfdfd; - } - - h1:first-child, div:first-child + h1 { - border-top-width: 0; - margin-top: 0; - } - - h2 { - @extend %header-font; - font-size: 19px; - margin-top: 4em; - margin-bottom: 0; - border-top: 1px solid #ccc; - padding-top: 1.2em; - padding-bottom: 1.2em; - background-image: linear-gradient(to bottom, rgba(#fff, 0.2), rgba(#fff, 0)); - } - - // h2s right after h1s should bump right up - // against the h1s. - h1 + h2, h1 + div + h2 { - margin-top: $h1-margin-bottom * -1; - border-top: none; - } - - h3, h4, h5, h6 { - @extend %header-font; - font-size: 15px; - margin-top: 2.5em; - margin-bottom: 0.8em; - } - - h4, h5, h6 { - font-size: 10px; - } - - hr { - margin: 2em 0; - border-top: 2px solid $examples-bg; - border-bottom: 2px solid $main-bg; - } - - table { - margin-bottom: 1em; - overflow: visible; - th,td { - text-align: left; - vertical-align: top; - line-height: 1.6; - code { - white-space: nowrap; - } - } - - th { - padding: 5px 10px; - border-bottom: 1px solid #ccc; - vertical-align: bottom; - } - - td { - padding: 10px; - } - - tr:last-child { - border-bottom: 1px solid #ccc; - } - - tr:nth-child(odd)>td { - background-color: lighten($main-bg,4.2%); - } - - tr:nth-child(even)>td { - background-color: lighten($main-bg,2.4%); - } - } - - dt { - font-weight: bold; - } - - dd { - margin-left: 15px; - } - - p, li, dt, dd { - line-height: 1.6; - margin-top: 0; - } - - img { - max-width: 100%; - } - - code { - background-color: rgba(0,0,0,0.05); - padding: 3px; - border-radius: 3px; - @extend %break-words; - @extend %code-font; - } - - pre>code { - background-color: transparent; - padding: 0; - } - - aside { - padding-top: 1em; - padding-bottom: 1em; - margin-top: 1.5em; - margin-bottom: 1.5em; - background: $aside-notice-bg; - line-height: 1.6; - - &.warning { - background-color: $aside-warning-bg; - } - - &.success { - background-color: $aside-success-bg; - } - } - - aside:before { - vertical-align: middle; - padding-right: 0.5em; - font-size: 14px; - } - - aside.notice:before { - @extend %icon-info-sign; - } - - aside.warning:before { - @extend %icon-exclamation-sign; - } - - aside.success:before { - @extend %icon-ok-sign; - } - - .search-highlight { - padding: 2px; - margin: -3px; - border-radius: 4px; - border: 1px solid #F7E633; - background: linear-gradient(to top left, #F7E633 0%, #F1D32F 100%); - } -} - -//////////////////////////////////////////////////////////////////////////////// -// CODE SAMPLE STYLES -//////////////////////////////////////////////////////////////////////////////// -// This is all the stuff that appears in the right half of the page - -.content { - &>div.highlight { - clear:none; - } - - pre, blockquote { - background-color: $code-bg; - color: #fff; - - margin: 0; - width: $examples-width; - - float:right; - clear:right; - - box-sizing: border-box; - - @extend %right-col; - - &>p { margin: 0; } - - a { - color: #fff; - text-decoration: none; - border-bottom: dashed 1px #ccc; - } - } - - pre { - @extend %code-font; - padding-top: 2em; - padding-bottom: 2em; - padding: 2em $main-padding; - } - - blockquote { - &>p { - background-color: $code-annotation-bg; - padding: $code-annotation-padding 2em; - color: #eee; - } - } -} - -//////////////////////////////////////////////////////////////////////////////// -// RESPONSIVE DESIGN -//////////////////////////////////////////////////////////////////////////////// -// These are the styles for phones and tablets -// There are also a couple styles disperesed - -@media (max-width: $tablet-width) { - .toc-wrapper { - left: -$nav-width; - - &.open { - left: 0; - } - } - - .page-wrapper { - margin-left: 0; - } - - #nav-button { - display: block; - } - - .toc-link { - padding-top: 0.3em; - padding-bottom: 0.3em; - } -} - -@media (max-width: $phone-width) { - .dark-box { - display: none; - } - - %left-col { - margin-right: 0; - } - - .toc-wrapper .lang-selector { - display: block; - } - - .page-wrapper .lang-selector { - display: none; - } - - %right-col { - width: auto; - float: none; - } - - %right-col + %left-col { - margin-top: $main-padding; - } -} - -.highlight .c, .highlight .cm, .highlight .c1, .highlight .cs { - color: #909090; -} - -.highlight, .highlight .w { - background-color: $code-bg; -} - -.copy-clipboard { - float: right; - fill: #9DAAB6; - cursor: pointer; - opacity: 0.4; - height: 18px; - width: 18px; -} - -.copy-clipboard:hover { - opacity: 0.8; -} diff --git a/source/terms/index.html.md b/source/terms/index.html.md deleted file mode 100644 index 4ba40cc..0000000 --- a/source/terms/index.html.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: قوانین و شرایط استفاده از API نوبیتکس -lang: fa -toc_footers: - - مستندات API نوبیتکس - - سابقه تغییرات API - - سایت نوبیتکس ---- - -# قوانین و شرایط استفاده از API نوبیتکس - -## ملاحظات استفاده عمومی - -* تنها بخشی از API نوبیتکس که در مستندات ذکر شده باشند، API عمومی و قابل استفاده نوبیتکس به شمار می‌آیند. اگر endpoint یا فیلدی در مستندات ذکر نشده باشد، ممکن است بدون اطلاع قبلی دچار تغییر شود. -* ممکن است در طول زمان تغییراتی در API عمومی نوبیتکس رخ دهد. این تغییرات در صفحه -«[سابقه تغییرات API نوبیتکس](/changelog/)» - اطلاع‌رسانی خواهند شد. لازم است استفاده کنندگان به صورت منظم و هفتگی این صفحه را رصد نمایند و تغییرات لازم را در برنامه‌های خود اعمال نمایند. -* نوبیتکس تضمین سطح سرویس SLA برای API خود به عموم مشتریان ارائه نمی‌دهد و استفاده کنندگان از API باید تمهیدات لازم در خصوص تشخیص و واکنش به اختلالات احتمالی در سرویس را انجام دهند. نوبیتکس در قبال هیچ گونه شرایط یا تغییراتی در API که احتمالاً باعث ایجاد مشکل در کد نوشته شده توسط کاربران شود، نخواهد داشت. -* در صورت دریافت پاسخ مبنی بر استفاده نادرست از API، مانند خطای 429 یا سایر خطاهای ناشی از نرخ بالای درخواست‌ها یا ورودی نامعتبر، استفاده کننده ملزم است که واکنش مناسب را نسبت به خطا نشان داده و از تکرار اشتباه با بسامد بالا خودداری نماید. در صورت تشخیص استفاده نادرست و عدم واکنش مناسب به پیام‌های خطای دریافتی، ممکن است IP درخواست دهنده به صورت موقت یا دائمی در سرویس نوبیتکس مسدود شود. -* استفاده آگاهانه از API نوبیتکس جهت نفوذ یا حملات DDoS یا سایر اعمال مخرب خلاف شرایط استفاده نوبیتکس است و در صورت مشاهده حساب‌های کاربری دخیل در آن مسدود خواهند شد. - - -## ملاحظات برنامه‌نویسی - -* خروجی API نوبیتکس معمولاً در قالب JSON ارائه می‌شود. لازم به دقت است که ممکن است علاوه بر فیلدهایی که در مستندات برای خروجی ذکر شده‌اند، فیلدهای دیگری نیز در خروجی پاسخ وجود داشته باشند. پیشنهاد می‌شود که برنامه خود را به صورتی توسعه دهید که در صورت وجود فیلدهای دیگری علاوه بر فیلدهای مورد انتظار، دچار خطا نشود. - - -## ملاحظات مرتبط با سرویس کلادفلر - -* نوبیتکس از سرویس کلادفلر به عنوان CDN و واسط API استفاده می‌نماید. در صورتی که به هر دلیل کلادفلر ترافیک ارسالی شما را مشکوک یا مخرب تشخیص دهد ممکن است برخی یا تمام درخواست‌های شما را رد کند. مدیریت این شرایط به دلیل اهمیت سرویس کلادفلر جهت جلوگیری از حملات DDoS ضروری و خارج از کنترل نوبیتکس است و استفاده کنندگان از API ملزم هستند نکات عمومی Fair Use را لحاظ نمایند. -* امکان استفاده از API نوبیتکس هم از آی‌پی داخل و هم از آی‌پی خارج از کشور ممکن است و محدودیتی بابت استفاده از آی‌پی ایرانی روی درخواست‌ها اعمال نمی‌شود. -* اتصال تمامی کاربران عادی سایت و اپ و API نوبیتکس به واسطه سرویس کلادفلر با سرورهای نوبیتکس که در داخل ایران مستقر هستند، برقرار می‌شود و امکان ارائه کانال مستقیم‌تر ارتباطی وجود ندارد. کاربران می‌توانند در صورت نیاز به کاهش تاخیر ارتباطی، نسبت به حداقل‌سازی تاخیر ارتباطی خود تا سرورهای لبه کلادفلر اقدام نمایند. diff --git a/src/components/CustomSearch/hooks/useAutoFocusOnOpen.ts b/src/components/CustomSearch/hooks/useAutoFocusOnOpen.ts new file mode 100644 index 0000000..e737748 --- /dev/null +++ b/src/components/CustomSearch/hooks/useAutoFocusOnOpen.ts @@ -0,0 +1,13 @@ +import { useEffect, useRef } from 'react' + +export function useAutoFocusOnOpen(isOpen: boolean) { + const ref = useRef(null) + + useEffect(() => { + if (isOpen && ref.current) { + ref.current.focus() + } + }, [isOpen]) + + return ref +} \ No newline at end of file diff --git a/src/components/CustomSearch/hooks/useEscapeKey.ts b/src/components/CustomSearch/hooks/useEscapeKey.ts new file mode 100644 index 0000000..8c5112b --- /dev/null +++ b/src/components/CustomSearch/hooks/useEscapeKey.ts @@ -0,0 +1,20 @@ +import { useEffect } from 'react' + +export function useEscapeKey(onEscape: () => void, enabled: boolean = true) { + useEffect(() => { + if (!enabled) return + + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Escape') { + event.preventDefault() + onEscape() + } + } + + window.addEventListener('keydown', handleKeyDown) + + return () => { + window.removeEventListener('keydown', handleKeyDown) + } + }, [onEscape, enabled]) +} \ No newline at end of file diff --git a/src/components/CustomSearch/hooks/useOverlayClick.ts b/src/components/CustomSearch/hooks/useOverlayClick.ts new file mode 100644 index 0000000..373817a --- /dev/null +++ b/src/components/CustomSearch/hooks/useOverlayClick.ts @@ -0,0 +1,12 @@ +import React, { useCallback } from 'react' + +export function useOverlayClick(onClose: () => void) { + return useCallback( + (e: React.MouseEvent) => { + if (e.target === e.currentTarget) { + onClose() + } + }, + [onClose] + ) +} \ No newline at end of file diff --git a/src/components/CustomSearch/hooks/useSearchIndex.ts b/src/components/CustomSearch/hooks/useSearchIndex.ts new file mode 100644 index 0000000..ed665c6 --- /dev/null +++ b/src/components/CustomSearch/hooks/useSearchIndex.ts @@ -0,0 +1,19 @@ +import { usePluginData } from '@docusaurus/useGlobalData' + +export interface SearchEntry { + pageTitle: string + pageUrl: string + headingText: string + headingSlug: string + level: number + content: string + url: string +} + +export function useSearchIndex() { + const pluginData = usePluginData('docusaurus-plugin-custom-search') as { + searchIndex: SearchEntry[] + } + + return pluginData?.searchIndex || [] +} \ No newline at end of file diff --git a/src/components/CustomSearch/hooks/useSearchNavigation.ts b/src/components/CustomSearch/hooks/useSearchNavigation.ts new file mode 100644 index 0000000..c8b8fd3 --- /dev/null +++ b/src/components/CustomSearch/hooks/useSearchNavigation.ts @@ -0,0 +1,53 @@ +import { useCallback, useEffect, useRef, useState } from 'react' +import type { SearchEntry } from './useSearchIndex' + +interface UseSearchNavigationParams { + searchResults: SearchEntry[] + onSelectResult: (result: SearchEntry) => void +} + +export function useSearchNavigation({ + searchResults, + onSelectResult, +}: UseSearchNavigationParams) { + const [selectedIndex, setSelectedIndex] = useState(0) + const resultsRef = useRef(null) + + useEffect(() => { + setSelectedIndex(0) + }, [searchResults]) + + const handleKeyDown = useCallback( + (e: React.KeyboardEvent) => { + if (e.key === 'ArrowDown') { + e.preventDefault() + setSelectedIndex((prev) => + Math.min(prev + 1, searchResults.length - 1) + ) + } else if (e.key === 'ArrowUp') { + e.preventDefault() + setSelectedIndex((prev) => Math.max(prev - 1, 0)) + } else if (e.key === 'Enter' && searchResults.length > 0) { + e.preventDefault() + onSelectResult(searchResults[selectedIndex]) + } + }, + [searchResults, selectedIndex, onSelectResult] + ) + + useEffect(() => { + if (!resultsRef.current) return + const selectedElement = resultsRef.current.children[ + selectedIndex + ] as HTMLElement | undefined + + selectedElement?.scrollIntoView({ block: 'nearest', behavior: 'smooth' }) + }, [selectedIndex]) + + return { + selectedIndex, + setSelectedIndex, + handleKeyDown, + resultsRef, + } +} \ No newline at end of file diff --git a/src/components/CustomSearch/hooks/useSearchResults.ts b/src/components/CustomSearch/hooks/useSearchResults.ts new file mode 100644 index 0000000..a6425b4 --- /dev/null +++ b/src/components/CustomSearch/hooks/useSearchResults.ts @@ -0,0 +1,56 @@ +import { useEffect, useState } from 'react' +import type { SearchEntry } from './useSearchIndex' + +const MAX_RESULTS = 10 + +const normalizeText = (text: string): string => { + if (!text) return '' + + return text + .toLowerCase() + .replace(/[\u064A\u0649]/g, 'ی') + .replace(/\u0643/g, 'ک') + .replace(/[\u06C0\u06C1\u0629]/g, 'ه') + .replace(/[\u064B-\u065F\u0670\u06D6-\u06ED]/g, '') + .replace(/[^\p{L}\p{N}\s]+/gu, ' ') + .replace(/\s+/g, ' ') + .trim() +} + +const entryMatchesQuery = (entry: SearchEntry, rawQuery: string): boolean => { + const normalizedQuery = normalizeText(rawQuery) + if (!normalizedQuery) return false + + const queryTokens = normalizedQuery.split(' ').filter(Boolean) + if (!queryTokens.length) return false + + const haystack = normalizeText( + `${entry.pageTitle} ${entry.headingText} ${entry.content ?? ''}` + ) + + return queryTokens.every((q) => haystack.includes(q)) +} + +export function useSearchResults( + searchQuery: string, + searchIndex: SearchEntry[] +) { + const [searchResults, setSearchResults] = useState([]) + + useEffect(() => { + const trimmed = searchQuery.trim() + + if (!trimmed) { + setSearchResults([]) + return + } + + const results = searchIndex.filter((entry) => + entryMatchesQuery(entry, trimmed) + ) + + setSearchResults(results.slice(0, MAX_RESULTS)) + }, [searchQuery, searchIndex]) + + return searchResults +} \ No newline at end of file diff --git a/src/components/CustomSearch/index.tsx b/src/components/CustomSearch/index.tsx new file mode 100644 index 0000000..1242505 --- /dev/null +++ b/src/components/CustomSearch/index.tsx @@ -0,0 +1,118 @@ +import React, { useState, useCallback } from 'react' +import { useHistory } from '@docusaurus/router' +import { useEscapeKey } from './hooks/useEscapeKey' +import { useAutoFocusOnOpen } from './hooks/useAutoFocusOnOpen' +import { useSearchIndex, SearchEntry } from './hooks/useSearchIndex' +import { useSearchResults } from './hooks/useSearchResults' +import { useSearchNavigation } from './hooks/useSearchNavigation' +import { useOverlayClick } from './hooks/useOverlayClick' + +interface CustomSearchProps { + isOpen: boolean + onClose: () => void +} + +const KEYBOARD_SHORTCUTS = [ + { keys: ['↑', '↓'], label: 'برای پیمایش' }, + { keys: ['Enter'], label: 'برای انتخاب' }, + { keys: ['Esc'], label: 'برای بستن' }, +] as const + +export default function CustomSearch({ isOpen, onClose }: CustomSearchProps) { + const [searchQuery, setSearchQuery] = useState('') + const history = useHistory() + + useEscapeKey(onClose, isOpen) + const inputRef = useAutoFocusOnOpen(isOpen) + const searchIndex = useSearchIndex() + const searchResults = useSearchResults(searchQuery, searchIndex) + const handleSelectResult = useCallback( + (result: SearchEntry) => { + history.push(result.url) + onClose() + setSearchQuery('') + }, + [history, onClose] + ) + const { + selectedIndex, + setSelectedIndex, + handleKeyDown, + resultsRef, + } = useSearchNavigation({ + searchResults, + onSelectResult: handleSelectResult, + }) + + const handleOverlayClick = useOverlayClick(onClose) + + if (!isOpen) return null + + return ( +
        +
        +
        + setSearchQuery(e.target.value)} + onKeyDown={handleKeyDown} + dir="rtl" + /> + +
        + + {searchQuery && ( +
        + {searchResults.length > 0 ? ( + searchResults.map((result, index) => ( +
        handleSelectResult(result)} + onMouseEnter={() => setSelectedIndex(index)} + > +
        + {result.pageTitle} +
        +
        + {result.headingText} +
        +
        {result.url}
        +
        + )) + ) : ( +
        + نتیجه‌ای یافت نشد +
        + )} +
        + )} + +
        +
        + {KEYBOARD_SHORTCUTS.map(({ keys, label }) => ( + + {keys.map((key) => ( + {key} + ))}{' '} + {label} + + ))} +
        +
        +
        +
        + ) +} \ No newline at end of file diff --git a/src/css/styles.css b/src/css/styles.css new file mode 100644 index 0000000..4ff63a7 --- /dev/null +++ b/src/css/styles.css @@ -0,0 +1,675 @@ +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 100; + src: url('../../static/fonts/vazirmatn-fd-100.woff2'); +} + +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 200; + src: url('../../static/fonts/vazirmatn-fd-200.woff2'); +} + +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 300; + src: url('../../static/fonts/vazirmatn-fd-300.woff2'); +} + +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 400; + src: url('../../static/fonts/vazirmatn-fd-400.woff2'); +} + +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 500; + src: url('../../static/fonts/vazirmatn-fd-500.woff2'); +} + +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 600; + src: url('../../static/fonts/vazirmatn-fd-600.woff2'); +} + +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 700; + src: url('../../static/fonts/vazirmatn-fd-700.woff2'); +} + +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 800; + src: url('../../static/fonts/vazirmatn-fd-800.woff2'); +} + +@font-face { + font-family: 'vazirmatn'; + font-style: normal; + font-weight: 900; + src: url('../../static/fonts/vazirmatn-fd-900.woff2'); +} + +.font-vazir { + font-family: 'vazirmatn', 'roboto-regular', 'Roboto', 'Helvetica', 'Arial', sans-serif; +} + +:root { + --ifm-color-primary: #754EC6; + --ifm-color-primary-dark: #754EC6; + --ifm-color-primary-darker: #754EC6; + --ifm-color-primary-darkest: #754EC6; + --ifm-color-primary-light: #754EC6; + --ifm-color-primary-lighter: #754EC6; + --ifm-color-primary-lightest: #754EC6; + --ifm-code-background: #FFFFFF; + --ifm-menu-color-background-hover: rgba(111, 129, 148, 0.08); + --ifm-navbar-background-color: #FFFFFF; + --docsearch-modal-background: #FFFFFF; + --docsearch-searchbox-background: rgba(111, 129, 148, 0.08); + --ifm-pre-background: #FFFFFF; + --ifm-card-background-color: #FFFFFF; + --ifm-font-family-base: 'vazirmatn', 'roboto-regular', 'Roboto', 'Helvetica', 'Arial', sans-serif; + --text-primary: #000000; + --bg-neutral-default-rest: rgba(111, 129, 148, 0.08); + --theme-bg: #F7FAFC; + --theme-bg-reverse: #000000; + --bg-surface-2: #F0F3F7; + --bg-surface-2-reversed: #15191C; + --br-primary-default-rest: #8F6ED4; +} + +[data-theme='dark'] { + --ifm-color-primary: #966BED; + --ifm-color-primary-dark: #966BED; + --ifm-color-primary-darker: #966BED; + --ifm-color-primary-darkest: #966BED; + --ifm-color-primary-light: #966BED; + --ifm-color-primary-lighter: #966BED; + --ifm-color-primary-lightest: #966BED; + --ifm-code-background: #15191C; + --ifm-navbar-background-color: #101214; + --docsearch-modal-background: #101214; + --docsearch-searchbox-background: rgba(97, 117, 138, 0.24); + --ifm-pre-background: #101214; + --ifm-card-background-color: #101214; + --ifm-menu-color-background-hover: rgba(97,117,138,0.24); + --text-primary: #FFFFFF; + --bg-neutral-default-rest: rgba(97, 117, 138, 0.24); + --theme-bg: #000000; + --theme-bg-reverse: #F7FAFC; + --bg-surface-2: #15191C; + --bg-surface-2-reversed: #F0F3F7; + --br-primary-default-rest: #825BD3; + +} + +[class^="docRoot_"], +[class*=" docRoot_"] { + background: #F7FAFC; +} + +[data-theme='dark'] [class^="docRoot_"], +[data-theme='dark'] [class*=" docRoot_"] { + background: #000000; +} + +[class^="pagination-nav__link"], +[class*=" pagination-nav__link"] { + background: #F7FAFC; + border-radius: 6px; + border: 1px solid rgba(111, 129, 148, 0.16); +} + +[data-theme='dark'] [class^="pagination-nav__link"], +[data-theme='dark'] [class*=" pagination-nav__link"] { + background: #000000; + border: 1px solid rgba(97, 117, 138, 0.32); +} + +.DocSearch-Button { + @media (min-width: 769px) { + display: flex; + width: 183px; + border-radius: 6px; + + .DocSearch-Button-Keys { + display: none; + } + } + border: 1px solid rgba(97, 117, 138, 0.32); + background: rgba(97, 117, 138, 0.24); +} + +[data-theme='dark'] .DocSearch-Button { + border: 1px solid rgba(111, 129, 148, 0.16); + background: rgba(111, 129, 148, 0.08); +} + +.theme-layout-navbar-right { + gap: 12px; +} + +.navbar__link { + svg { + display: none; + } +} + +.DocSearch-Footer { + .DocSearch-Logo { + display: none; + } +} + +.custom-footer { + @media (max-width: 769px) { + display: none; + } + + display: flex; + height: 48px; + padding: 8px 12px 8px 24px; + justify-content: space-between; + align-items: center; + align-self: stretch; + background: #FFFFFF; + + p { + text-align: right; + + font-family: 'vazirmatn', 'roboto-regular', 'Roboto', 'Helvetica', 'Arial', sans-serif; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: 16px; + margin-bottom: 0; + } + + div { + display: flex; + gap: 16px; + + button { + text-align: center; + font-family: 'vazirmatn', 'roboto-regular', 'Roboto', 'Helvetica', 'Arial', sans-serif; + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: 16px; + + display: inline-flex; + height: 32px; + min-height: 32px; + max-height: 32px; + padding: 0 8px; + justify-content: center; + align-items: center; + gap: 0; + background: transparent; + border-radius: 6px; + border: 1px solid transparent; + + &:hover { + cursor: pointer; + background: rgba(97, 117, 138, 0.32); + } + } + } +} + +[data-theme='dark'] .custom-footer { + background: #101214; +} + +.custom-search-button { + cursor: pointer; + padding: 0 12px 0 16px; + display: flex; + justify-content: flex-start; + align-items: center; + gap: 8px; + align-self: stretch; + border-radius: 6px; + border: 1px solid rgba(97, 117, 138, 0.32); + background: var(--bg-neutral-default-rest); + width: 180px; + height: 40px; +} + +.custom-search-icon { + display: inline-flex; + align-items: center; + justify-content: center; + font-size: 16px; +} + +.custom-search-text { + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: 20px; + font-family: 'vazirmatn', 'roboto-regular', 'Roboto', 'Helvetica', 'Arial', sans-serif; +} + +@media (max-width: 769px) { + .menu__list { + .custom-search-button { + display: none; + } + + svg { + display: none; + } + } + .custom-search-button { + width: 40px; + height: 40px; + padding: 0; + border-radius: 50%; + justify-content: center; + gap: 0; + } + + .custom-search-text { + display: none; + } +} + +.openapi-explorer__details-outer-container { + direction: rtl; +} + +.openapi-explorer__request-header-container { + direction: rtl; +} + +.openapi-security__details { + direction: rtl; +} + +.openapi-tabs__code-container { + direction: rtl; +} + +.openapi-explorer__response-container { + direction: rtl; +} + +.theme-layout-main { + background: var(--theme-bg); +} + +.openapi-explorer__floating-btn { + button { + margin-right: 400px; + position-area: y-end; + place-self: anchor-center; + text-align: center; + font-family: 'vazirmatn', 'roboto-regular', 'Roboto', 'Helvetica', 'Arial', sans-serif; + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: 16px; + + display: inline-flex; + height: 26px; + min-height: 32px; + max-height: 32px; + padding: 0 8px; + justify-content: center; + align-items: center; + gap: 0; + background: var(--theme-bg-reverse); + border-radius: 6px; + border: 1px solid transparent; + + &:hover { + cursor: pointer; + } + } +} + +.openapi-explorer__select-input { + margin-top: 0 !important; + background-image: none !important; +} + +.tabs-container { + direction: rtl; +} + +.openapi-markdown__details { + direction: rtl; +} + +.openapi-schema__name { + padding: 0 10px; +} + +.custom-search-overlay { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.75); + display: flex; + align-items: flex-start; + justify-content: center; + z-index: 9999; + padding-top: 10vh; + animation: fadeIn 0.2s ease-in; +} + +@keyframes fadeIn { + from { + opacity: 0; + } + to { + opacity: 1; + } +} + +.custom-search-modal { + background: #F7FAFC; + border-radius: 12px; + box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); + width: 90%; + max-width: 640px; + max-height: 70vh; + display: flex; + flex-direction: column; + animation: slideDown 0.2s ease-out; + border: 1px solid var(--ifm-color-emphasis-200); +} + +@keyframes slideDown { + from { + transform: translateY(-20px); + opacity: 0; + } + to { + transform: translateY(0); + opacity: 1; + } +} + +.custom-search-header { + display: flex; + align-items: center; + padding: 16px; + border-bottom: 1px solid var(--ifm-color-emphasis-200); + gap: 12px; +} + +.custom-search-input { + flex: 1; + border: none; + background: transparent; + font-size: 18px; + outline: none; + color: var(--ifm-font-color-base); + font-family: var(--ifm-font-family-base); + direction: rtl; + text-align: right; +} + +.custom-search-input::placeholder { + color: var(--ifm-color-emphasis-500); +} + +.custom-search-close { + background: transparent; + border: none; + font-size: 24px; + color: var(--ifm-color-emphasis-600); + cursor: pointer; + padding: 4px 8px; + border-radius: 4px; + transition: all 0.2s; + line-height: 1; +} + +.custom-search-close:hover { + background: var(--ifm-color-emphasis-200); + color: var(--ifm-font-color-base); +} + +.custom-search-results { + overflow-y: auto; + max-height: 50vh; + padding: 8px; +} + +.custom-search-result-item { + padding: 12px 16px; + cursor: pointer; + border-radius: 8px; + margin-bottom: 4px; + transition: all 0.15s; + border: 1px solid transparent; + direction: rtl; + text-align: right; +} + +.custom-search-result-item:hover, +.custom-search-result-item.selected { + background: var(--ifm-color-emphasis-100); + border-color: var(--ifm-color-primary); +} + +.custom-search-result-item.selected { + background: var(--ifm-color-primary-lightest); +} + +.result-page-title { + font-size: 12px; + color: var(--text-primray); + margin-bottom: 4px; + font-weight: 500; +} + +.result-heading-text { + font-size: 16px; + color: var(--ifm-font-color-base); + font-weight: 600; + margin-bottom: 4px; + line-height: 1.4; +} + +.result-url { + font-size: 12px; + color: var(--text-primary); + opacity: 0.8; + font-family: monospace; + direction: ltr; + text-align: left; +} + +.custom-search-no-results { + padding: 40px 20px; + text-align: center; + color: var(--ifm-color-emphasis-600); + font-size: 16px; + direction: rtl; +} + +.custom-search-footer { + border-top: 1px solid var(--ifm-color-emphasis-200); + padding: 12px 16px; +} + +.custom-search-shortcuts { + display: flex; + justify-content: space-between; + gap: 16px; + font-size: 13px; + color: var(--ifm-color-emphasis-600); + flex-wrap: wrap; + direction: rtl; +} + +.custom-search-shortcuts span { + display: flex; + align-items: center; + gap: 6px; +} + +.custom-search-shortcuts kbd { + background: var(--ifm-card-background-color); + border: 1px solid var(--ifm-color-emphasis-300); + border-radius: 4px; + padding: 2px 6px; + font-family: monospace; + font-size: 12px; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); +} + +[data-theme='dark'] .custom-search-modal { + box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8); + background: #000000; +} + +[data-theme='dark'] .custom-search-close:hover { + background: var(--ifm-color-emphasis-300); +} + +[data-theme='dark'] .custom-search-result-item:hover, +[data-theme='dark'] .custom-search-result-item.selected { + background: var(--ifm-color-emphasis-200); +} + +[data-theme='dark'] .custom-search-result-item.selected { + background: var(--ifm-color-primary-dark); +} + +.custom-search-results::-webkit-scrollbar { + width: 8px; +} + +.custom-search-results::-webkit-scrollbar-track { + background: var(--ifm-color-emphasis-100); + border-radius: 4px; +} + +.custom-search-results::-webkit-scrollbar-thumb { + background: var(--ifm-color-emphasis-400); + border-radius: 4px; +} + +.custom-search-results::-webkit-scrollbar-thumb:hover { + background: var(--ifm-color-emphasis-600); +} + +@media (max-width: 768px) { + .custom-search-modal { + width: 95%; + max-height: 80vh; + } + + .custom-search-shortcuts { + font-size: 11px; + } + + .custom-search-input { + font-size: 16px; + } +} + +.openapi-explorer__code-block-btn-group { + position-area: y-start; + margin-left: -350px; +} + +[class^="collapsibleContent_"], +[class*="collapsibleContent_"] { + ul { + padding: 0; + } +} +.openapi__heading { + margin: 24px 0 40px 0 !important; +} + +.openapi__method-endpoint { + display: flex; + align-items: center; + /* max-width: 100%; */ + width: 100%; + direction: rtl; + padding: 0.65rem; + border: 1px solid var(--ifm-toc-border-color); + gap: 16px; +} + +.openapi-schema__type { + padding-right: 12px; + padding-left: 0; +} + +.openapi-schema__required { + display: inline-flex; + align-items: center; + font-size: 10.5px; + font-weight: bold; + text-transform: uppercase; + color: var(--openapi-required); + margin-right: 1%; + background-color: transparent; +} + +.tabs.openapi-tabs__code-list-container.openapi-tabs__code-container-inner { + padding-right: 0; + padding-left: 0; + gap: 12px; + + li { + margin: 0; + } +} + +.openapi-tabs__schema-list-container.openapi-tabs__schema { + padding-right: 0; + padding-left: 0; + gap: 12px; + + li { + margin: 0; + } +} + +.openapi-tabs__mime-container { + ul { + padding-right: 0; + padding-left: 0; + } +} + +.openapi-tabs__code-item { + &:hover { + border: 1px solid var(--bg-surface-2-reversed); + } +} + +.openapi-tabs__code-item.active { + border-radius: 3px; + background: var(--bg-surface-2); + border: 1px solid var(--br-primary-default-rest); + box-shadow: none; + + &:hover { + border: 1px solid var(--br-primary-default-rest); + } +} \ No newline at end of file diff --git a/src/css/styles.module.css b/src/css/styles.module.css new file mode 100644 index 0000000..d1a89ba --- /dev/null +++ b/src/css/styles.module.css @@ -0,0 +1,5 @@ +/** + * CSS files with the .module.css suffix will be treated as CSS modules + * and scoped locally. + */ + diff --git a/source/changelog/index.html.md b/src/pages/changelog.md similarity index 73% rename from source/changelog/index.html.md rename to src/pages/changelog.md index 590a3d1..fa74d75 100644 --- a/source/changelog/index.html.md +++ b/src/pages/changelog.md @@ -2,9 +2,9 @@ title: سابقه تغییرات API نوبیتکس lang: fa toc_footers: - - مستندات API نوبیتکس - - شرایط استفاده از API - - سایت نوبیتکس + - "مستندات API نوبیتکس" + - "شرایط استفاده از API" + - "سایت نوبیتکس" --- # سابقه تغییرات API نوبیتکس @@ -64,17 +64,17 @@ toc_footers: * **بهبود خروجی اردربوک:** تعداد سفارش‌های بازگردانده شده در هر سمت اردربوک از ۱۶ به ۲۴ سفارش افزایش یافته است. همین طور امکان استفاده از نماد `all` برای دریافت یکجای تمامی اردربوک‌ها فراهم شده است. به طور کلی نیز سرعت به‌روزرسانی اردربوک بهبود یافته است. # سایر تغییرات API -## تغییرات آذر 1401 +## تغییرات آذر 1401 * افزودن امکان فیلتر لیست سفارشات با یک آی دی مبدا * افزودن امکان جستجوی نماد روی چارت UDF -* افزودن امکان ثبت و دریافت لیست [بازارهای مورد علاقه](/#favorite_market) +* افزودن امکان ثبت و دریافت لیست [بازارهای مورد علاقه](#favorite_market) -## تغییرات آبان 1401 +## تغییرات آبان 1401 -* افزوده شدن کارمزد واریز شناسه دار جیبیت به پاسخ endpoint تنظیمات: [v2/options](/#options) +* افزوده شدن کارمزد واریز شناسه دار جیبیت به پاسخ endpoint تنظیمات: [v2/options](#options) -## تغییرات مهر 1401 +## تغییرات مهر 1401 * افزوده شدن امکان ثبت و دریافت آنتی‌فیشینگ کد @@ -86,29 +86,28 @@ toc_footers: ## تغییرات آبان ۱۴۰۰ * افزودن پارامتر hasNext به پاسخ endpoint های زیر: - - /users/transactions-history + - /users/transactions-history * افزودن کد خطا به endpoint های زیر: -message | code endpoint -------- | ---- -msgUnfilledForm | ValidationError /users/wallets/deposit/bank -msgBankAmountLow | AmountTooLow -msgBankAmountHigh | AmountTooHigh -CoinDepositLimitation | CoinDepositLimitation /users/wallets/generate-address -ExchangeRequiredTag | ExchangeRequiredTag /users/wallets/withdraw -msgInvalid2FA | Invalid2FA -WithdrawAmountLimitation | WithdrawAmountLimitation -Insufficient Balance | InsufficientBalance -msgWithdrawLimitReached | WithdrawLimitReached -msgAmountTooLow | AmountTooLow -msgAmountTooHigh | AmountTooHigh -WithdrawAmountLimitation | WithdrawAmountLimitation /users/wallets/withdraw-confirm -Insufficient Balance | InsufficientBalance -Withdraw is not cancelable | NotCancelable /users/wallets/withdraw-cancel -CoinDepositLimitation | CoinDepositLimitation /users/wallets/invoice/generate -CoinDepositDisabled | CoinDepositDisabled - +| message | code | endpoint | +|-----------------------|--------------------|---------------------------------| +| msgUnfilledForm | ValidationError | /users/wallets/deposit/bank | +| msgBankAmountLow | AmountTooLow | /users/wallets/deposit/bank | +| msgBankAmountHigh | AmountTooHigh | /users/wallets/deposit/bank | +| CoinDepositLimitation | CoinDepositLimitation | /users/wallets/generate-address | +| ExchangeRequiredTag | ExchangeRequiredTag | /users/wallets/withdraw | +| msgInvalid2FA | Invalid2FA | /users/wallets/withdraw | +| WithdrawAmountLimitation | WithdrawAmountLimitation | /users/wallets/withdraw | +| Insufficient Balance | InsufficientBalance | /users/wallets/withdraw | +| msgWithdrawLimitReached | WithdrawLimitReached | /users/wallets/withdraw | +| msgAmountTooLow | AmountTooLow | /users/wallets/withdraw-confirm | +| msgAmountTooHigh | AmountTooHigh | /users/wallets/withdraw-confirm | +| WithdrawAmountLimitation | WithdrawAmountLimitation | /users/wallets/withdraw-confirm | +| Insufficient Balance | InsufficientBalance | /users/wallets/withdraw-confirm | +| Withdraw is not cancelable | NotCancelable | /users/wallets/withdraw-cancel | +| CoinDepositLimitation | CoinDepositLimitation | /users/wallets/invoice/generate | +| CoinDepositDisabled | CoinDepositDisabled | /users/wallets/invoice/generate | # مستندات جدید @@ -138,8 +137,7 @@ CoinDepositDisabled | CoinDepositDisabled * ایجاد صورت‌حساب واریز (/users/wallets/invoice/generate) * لیست نوتیفیکیشن‌ها (/notifications/list) - ## تغییرات مهر ۱۴۰۳ * حذف پارامتر availableBalance از پاسخ endpoint های زیر: - - /liquidity-pools/list + - /liquidity-pools/list \ No newline at end of file diff --git a/src/pages/download.mdx b/src/pages/download.mdx new file mode 100644 index 0000000..5ac28b2 --- /dev/null +++ b/src/pages/download.mdx @@ -0,0 +1,64 @@ +--- +title: دانلود فایل‌ها +description: Download OpenAPI (Swagger) YAML files +--- + +## دانلود فایل‌های OpenAPI + + \ No newline at end of file diff --git a/source/includes/_faq.md b/src/pages/faq.md similarity index 100% rename from source/includes/_faq.md rename to src/pages/faq.md diff --git a/source/includes/_general_notes.md b/src/pages/general_notes.md similarity index 100% rename from source/includes/_general_notes.md rename to src/pages/general_notes.md diff --git a/src/pages/index.module.css b/src/pages/index.module.css new file mode 100644 index 0000000..d1a89ba --- /dev/null +++ b/src/pages/index.module.css @@ -0,0 +1,5 @@ +/** + * CSS files with the .module.css suffix will be treated as CSS modules + * and scoped locally. + */ + diff --git a/src/theme/Footer/index.tsx b/src/theme/Footer/index.tsx new file mode 100644 index 0000000..a15acfd --- /dev/null +++ b/src/theme/Footer/index.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import clsx from 'clsx'; +import '../../css/styles.css'; + +export default function Footer() { + const currentYear = new Date().getFullYear() + + return ( +
        +
        + + +
        +

        + Copyright © 2016 - {currentYear} Nobitex Ltd. All rights reserved +

        +
        + ); +} diff --git a/src/theme/NavbarItem/ComponentTypes.tsx b/src/theme/NavbarItem/ComponentTypes.tsx new file mode 100644 index 0000000..77b69a0 --- /dev/null +++ b/src/theme/NavbarItem/ComponentTypes.tsx @@ -0,0 +1,7 @@ +import ComponentTypes from '@theme-original/NavbarItem/ComponentTypes'; +import SearchNavbarItem from './SearchNavbarItem'; + +export default { + ...ComponentTypes, + 'custom-searchNavbarItem': SearchNavbarItem, +}; diff --git a/src/theme/NavbarItem/SearchNavbarItem.tsx b/src/theme/NavbarItem/SearchNavbarItem.tsx new file mode 100644 index 0000000..95d141c --- /dev/null +++ b/src/theme/NavbarItem/SearchNavbarItem.tsx @@ -0,0 +1,24 @@ +import React, {useState} from 'react'; +import CustomSearch from "@site/src/components/CustomSearch"; + +export default function SearchNavbarItem() { + const [searchOpen, setSearchOpen] = useState(false) + + return ( + <> + + setSearchOpen(false)} + /> + + ); +} diff --git a/src/theme/Root.tsx b/src/theme/Root.tsx new file mode 100644 index 0000000..e2273b1 --- /dev/null +++ b/src/theme/Root.tsx @@ -0,0 +1,75 @@ +import React, { useState, useEffect } from 'react' +import CustomSearch from '@site/src/components/CustomSearch' + +export default function Root({ children }: { children: React.ReactNode }) { + const [isSearchOpen, setIsSearchOpen] = useState(false) + + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent) => { + if ((event.ctrlKey || event.metaKey) && event.key === 'k') { + event.preventDefault() + setIsSearchOpen(true) + } + if (event.key === 'Escape' && isSearchOpen) { + event.preventDefault() + setIsSearchOpen(false) + } + } + + document.addEventListener('keydown', handleKeyDown) + + return () => { + document.removeEventListener('keydown', handleKeyDown) + } + }, [isSearchOpen]) + + useEffect(() => { + const templates = [ + { + id: 'market-symbols', + value: + 'BTCIRT, ETHIRT, LTCIRT, USDTIRT, XRPIRT, BCHIRT, BNBIRT, EOSIRT, XLMIRT, ETCIRT, TRXIRT, DOGEIRT, UNIIRT, DAIIRT, LINKIRT, DOTIRT, AAVEIRT, ADAIRT, SHIBIRT, FTMIRT, MATICIRT, AXSIRT, MANAIRT, SANDIRT, AVAXIRT, MKRIRT, GMTIRT, USDCIRT, BTCUSDT, ETHUSDT, LTCUSDT, XRPUSDT, BCHUSDT, BNBUSDT, EOSUSDT, XLMUSDT, ETCUSDT, TRXUSDT, PMNUSDT, DOGEUSDT, UNIUSDT, DAIUSDT, LINKUSDT, DOTUSDT, AAVEUSDT, ADAUSDT, SHIBUSDT, FTMUSDT, MATICUSDT, AXSUSDT, MANAUSDT, SANDUSDT, AVAXUSDT, MKRUSDT, GMTUSDT, USDCUSDT, CHZIRT, GRTIRT, CRVIRT, BANDUSDT, COMPUSDT, EGLDIRT, HBARUSDT, GALIRT, HBARIRT, WBTCUSDT, IMXIRT, WBTCIRT, ONEIRT, GLMUSDT, ENSIRT, 1M_BTTIRT, SUSHIIRT, LDOIRT, ATOMUSDT, ZROIRT, STORJIRT, ANTIRT, AEVOUSDT, 100K_FLOKIIRT, RSRUSDT, API3USDT, GLMIRT, XMRIRT, ENSUSDT, OMIRT, RDNTIRT, MAGICUSDT, TIRT, ATOMIRT, NOTIRT, CVXIRT, XTZIRT, FILIRT, UMAIRT, 1B_BABYDOGEIRT, BANDIRT, SSVIRT, DAOIRT, BLURIRT, ONEUSDT, EGALAUSDT, GMXIRT, XTZUSDT, FLOWUSDT, GALUSDT, WIRT, CVCUSDT, NMRUSDT, SKLIRT, SNTIRT, BATUSDT, TRBUSDT, NMRIRT, RDNTUSDT, API3IRT, CVCIRT, WLDIRT, YFIUSDT, SOLIRT, TUSDT, QNTUSDT, IMXUSDT, AEVOIRT, GMXUSDT, ETHFIUSDT, QNTIRT, GRTUSDT, WLDUSDT, FETIRT, AGIXIRT, NOTUSDT, LPTIRT, SLPIRT, MEMEUSDT, SOLUSDT, BALUSDT, DAOUSDT, COMPIRT, MEMEIRT, TONUSDT, BATIRT, SNXIRT, TRBIRT, 1INCHUSDT, OMUSDT, RSRIRT, RNDRIRT, SLPUSDT, SSVUSDT, RNDRUSDT, AGLDIRT, NEARUSDT, WOOUSDT, YFIIRT, MDTIRT, CRVUSDT, MDTUSDT, EGLDUSDT, LRCIRT, LPTUSDT, BICOUSDT, 1M_PEPEIRT, BICOIRT, MAGICIRT, ETHFIIRT, ANTUSDT, 1INCHIRT, APEUSDT, 1M_NFTIRT, ARBIRT, LRCUSDT, WUSDT, BLURUSDT, CELRUSDT, DYDXIRT, CVXUSDT, BALIRT, TONIRT, 100K_FLOKIUSDT, JSTUSDT, ZROUSDT, ARBUSDT, APTIRT, 1M_NFTUSDT, CELRIRT, UMAUSDT, SKLUSDT, ZRXUSDT, AGLDUSDT, ALGOIRT, NEARIRT, APTUSDT, ZRXIRT, SUSHIUSDT, FETUSDT, ALGOUSDT, 1M_PEPEUSDT, MASKIRT, EGALAIRT, FLOWIRT, 1B_BABYDOGEUSDT, MASKUSDT, 1M_BTTUSDT, STORJUSDT, XMRUSDT, OMGIRT, SNTUSDT, APEIRT, FILUSDT, ENJUSDT, OMGUSDT, WOOIRT, CHZUSDT, ENJIRT, DYDXUSDT, AGIXUSDT, JSTIRT, LDOUSDT, SNXUSDT' + }, + { + id: 'currency-symbols', + value: + 'rls, btc, eth, ltc, usdt, xrp, bch, bnb, eos, xlm, etc, trx, pmn, doge, uni, dai, link, dot, aave, ada, shib, ftm, matic, axs, mana, sand, avax, mkr, gmt, atom, uma, w, rsr, wld, 1m_nft, flow, agld, ton, mask, snt, agix, algo, ssv, band, omg, comp, zrx, rdnt, imx, 1inch, mdt, sushi, bico, gmx, zro, bal, dao, gal, not, nmr, xmr, enj, apt, lrc, dydx, grt, near, cvx, 100k_floki, fil, sol, ldo, crv, aevo, qnt, om, woo, storj, ant, 1m_btt, magic, ape, rndr, hbar, lpt, glm, blur, wbtc, meme, ethfi, egala, arb, fet, skl, cvc, snx, jst, ens, trb, chz, xtz, api3, slp, t, bat, 1b_babydoge, celr, yfi, egld, one, 1m_pepe, usdc', + }, + { + id: 'network-symbols', + value: + 'FIAT_MONEY, ETH, BSC, ADA, ALGO, APT, ARB, BCH, BNB, BTC, BTCLN, DOGE, DOT, EOS, ETC, LTC, PMN, TRX, OMNI, ZTRX, XLM, XMR, XRP, ATOM, EGLD, FIL, FLR, FLOW, FTM, MATIC, AVAX, HBAR, NEAR, TON, SOL, XTZ, ONE', + }, + { + id: 'tag-required-networks', + value: 'BNB, EOS, PMN, XLM, XRP', + }, + ] + + const updateElements = () => { + templates.forEach((tpl) => { + document.querySelectorAll(`.${tpl.id}`).forEach((el) => { + el.textContent = tpl.value + }) + }) + } + + setTimeout(updateElements, 300) + + window.addEventListener('docusaurus.routeDidUpdate', updateElements) + + return () => { + window.removeEventListener('docusaurus.routeDidUpdate', updateElements) + } + }, []) + + return ( + <> + {children} + setIsSearchOpen(false)} + /> + + ) +} diff --git a/static/fonts/vazirmatn-fd-100.woff2 b/static/fonts/vazirmatn-fd-100.woff2 new file mode 100644 index 0000000..71f1766 Binary files /dev/null and b/static/fonts/vazirmatn-fd-100.woff2 differ diff --git a/static/fonts/vazirmatn-fd-200.woff2 b/static/fonts/vazirmatn-fd-200.woff2 new file mode 100644 index 0000000..ccc24b8 Binary files /dev/null and b/static/fonts/vazirmatn-fd-200.woff2 differ diff --git a/static/fonts/vazirmatn-fd-300.woff2 b/static/fonts/vazirmatn-fd-300.woff2 new file mode 100644 index 0000000..d66c383 Binary files /dev/null and b/static/fonts/vazirmatn-fd-300.woff2 differ diff --git a/static/fonts/vazirmatn-fd-400.woff2 b/static/fonts/vazirmatn-fd-400.woff2 new file mode 100644 index 0000000..d996eb7 Binary files /dev/null and b/static/fonts/vazirmatn-fd-400.woff2 differ diff --git a/static/fonts/vazirmatn-fd-500.woff2 b/static/fonts/vazirmatn-fd-500.woff2 new file mode 100644 index 0000000..7c8d464 Binary files /dev/null and b/static/fonts/vazirmatn-fd-500.woff2 differ diff --git a/static/fonts/vazirmatn-fd-600.woff2 b/static/fonts/vazirmatn-fd-600.woff2 new file mode 100644 index 0000000..155c212 Binary files /dev/null and b/static/fonts/vazirmatn-fd-600.woff2 differ diff --git a/static/fonts/vazirmatn-fd-700.woff2 b/static/fonts/vazirmatn-fd-700.woff2 new file mode 100644 index 0000000..1a35db5 Binary files /dev/null and b/static/fonts/vazirmatn-fd-700.woff2 differ diff --git a/static/fonts/vazirmatn-fd-800.woff2 b/static/fonts/vazirmatn-fd-800.woff2 new file mode 100644 index 0000000..699a1f4 Binary files /dev/null and b/static/fonts/vazirmatn-fd-800.woff2 differ diff --git a/static/fonts/vazirmatn-fd-900.woff2 b/static/fonts/vazirmatn-fd-900.woff2 new file mode 100644 index 0000000..5038f6b Binary files /dev/null and b/static/fonts/vazirmatn-fd-900.woff2 differ diff --git a/static/img/favicon.ico b/static/img/favicon.ico new file mode 100644 index 0000000..7eafaf7 Binary files /dev/null and b/static/img/favicon.ico differ diff --git a/static/img/logo-dark.svg b/static/img/logo-dark.svg new file mode 100644 index 0000000..8be7e88 --- /dev/null +++ b/static/img/logo-dark.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/img/logo-light.svg b/static/img/logo-light.svg new file mode 100644 index 0000000..e8a5762 --- /dev/null +++ b/static/img/logo-light.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/images/logo.png b/static/img/logo.png similarity index 100% rename from source/images/logo.png rename to static/img/logo.png diff --git a/static/img/nobitex-logo.svg b/static/img/nobitex-logo.svg new file mode 100644 index 0000000..c9bc812 --- /dev/null +++ b/static/img/nobitex-logo.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/static/img/search-icon.svg b/static/img/search-icon.svg new file mode 100644 index 0000000..b57b0e4 --- /dev/null +++ b/static/img/search-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0c7e88e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@docusaurus/tsconfig", + "compilerOptions": { + "baseUrl": "./docusaurus" + }, + "exclude": [ + "docusaurus/.docusaurus", "build"] +}