├── .github ├── FUNDING.yml └── workflows │ ├── macos.yml │ ├── ubuntu.yml │ └── windows.yml ├── .gitignore ├── .gitmodules ├── .idea ├── .gitignore ├── .name └── misc.xml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── VKAPIConfig.cmake.in ├── examples ├── 1 │ ├── CMakeLists.txt │ └── main.cpp ├── 2 │ ├── CMakeLists.txt │ └── main.cpp └── CMakeLists.txt ├── include ├── BotBase.hpp ├── ClientBase.hpp ├── Config.hpp.in ├── Defines.hpp ├── Exceptions.hpp ├── Optional.hpp ├── Request.hpp ├── UserBase.hpp ├── Utilities.hpp └── nlohmann │ └── json.hpp └── src ├── BotBase.cpp ├── ClientBase.cpp ├── Request.cpp ├── UserBase.cpp └── Utilities.cpp /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | custom: ['paypal.me/qucals'] 4 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: MacOS 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - develop 8 | pull_request: 9 | branches: [ master ] 10 | 11 | env: 12 | BUILD_TYPE: Release 13 | CMAKE_BUILD_DIR: ${{ github.workspace }}/build/ 14 | 15 | jobs: 16 | build: 17 | name: Deploy on MacOS 18 | runs-on: macos-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v2 22 | with: 23 | submodules: true 24 | 25 | - name: Install deps 26 | run: | 27 | brew update 28 | brew install curl 29 | 30 | - name: Configure VKAPI Library CMake 31 | run: cmake -B ${{ env.CMAKE_BUILD_DIR }} -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} 32 | 33 | - name: Build VKAPI Library 34 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --config ${{ env.BUILD_TYPE }} 35 | 36 | - name: Install VKAPI Library 37 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --target install --config ${{ env.BUILD_TYPE }} 38 | 39 | # Configure, Build and Install WE - With Examples 40 | - name: Configure VKAPI Library CMake WE 41 | run: cmake -B ${{ env.CMAKE_BUILD_DIR }} -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} 42 | 43 | - name: Build VKAPI Library WE 44 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --config ${{ env.BUILD_TYPE }} 45 | 46 | - name: Install VKAPI Library WE 47 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --target install --config ${{ env.BUILD_TYPE }} 48 | 49 | - name: Test 50 | working-directory: ${{ env.CMAKE_BUILD_DIR }} 51 | # Execute tests defined by the CMake configuration. 52 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 53 | run: ctest -C ${{ env.BUILD_TYPE }} 54 | 55 | 56 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - develop 8 | pull_request: 9 | branches: [ master ] 10 | 11 | env: 12 | BUILD_TYPE: Release 13 | CMAKE_BUILD_DIR: ${{ github.workspace }}/build/ 14 | 15 | jobs: 16 | build: 17 | name: Deploy on Ubuntu 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v2 22 | with: 23 | submodules: true 24 | 25 | - name: Install deps 26 | run: | 27 | sudo apt update 28 | sudo apt upgrade 29 | sudo apt install curl 30 | sudo apt-get install libcurl4-openssl-dev 31 | 32 | - name: Configure VKAPI Library CMake 33 | run: cmake -B ${{ env.CMAKE_BUILD_DIR }} -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} 34 | 35 | - name: Build VKAPI Library 36 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --config ${{ env.BUILD_TYPE }} 37 | 38 | - name: Install VKAPI Library 39 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --target install --config ${{ env.BUILD_TYPE }} 40 | 41 | # Configure, Build and Install WE - With Examples 42 | - name: Configure VKAPI Library CMake WE 43 | run: cmake -B ${{ env.CMAKE_BUILD_DIR }} -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} 44 | 45 | - name: Build VKAPI Library WE 46 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --config ${{ env.BUILD_TYPE }} 47 | 48 | - name: Install VKAPI Library WE 49 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --target install --config ${{ env.BUILD_TYPE }} 50 | 51 | - name: Test 52 | working-directory: ${{ env.CMAKE_BUILD_DIR }} 53 | # Execute tests defined by the CMake configuration. 54 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 55 | run: ctest -C ${{ env.BUILD_TYPE }} 56 | 57 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: Windows 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - develop 8 | pull_request: 9 | branches: [ master ] 10 | 11 | env: 12 | BUILD_TYPE: Release 13 | CMAKE_BUILD_DIR: ${{ github.workspace }}/build 14 | 15 | jobs: 16 | build: 17 | name: Deploy on Windows 18 | runs-on: windows-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v2 22 | with: 23 | submodules: true 24 | 25 | - name: Install deps 26 | uses: crazy-max/ghaction-chocolatey@v1 27 | with: 28 | args: install curl 29 | 30 | - name: Configure VKAPI Library CMake 31 | run: | 32 | cd ${{ github.workspace }} 33 | mkdir build 34 | cmake -B ${{ env.CMAKE_BUILD_DIR }} -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} 35 | 36 | - name: Build VKAPI Library 37 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --config ${{ env.BUILD_TYPE }} 38 | 39 | - name: Install VKAPI Library 40 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --target install --config ${{ env.BUILD_TYPE }} 41 | 42 | # Configure, Build and Install WE - With Examples 43 | - name: Configure VKAPI Library CMake WE 44 | run: cmake -B ${{ env.CMAKE_BUILD_DIR }} -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} 45 | 46 | - name: Build VKAPI Library WE 47 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --config ${{ env.BUILD_TYPE }} 48 | 49 | - name: Install VKAPI Library WE 50 | run: cmake --build ${{ env.CMAKE_BUILD_DIR }} --target install --config ${{ env.BUILD_TYPE }} 51 | 52 | - name: Test 53 | working-directory: ${{ env.CMAKE_BUILD_DIR }} 54 | # Execute tests defined by the CMake configuration. 55 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 56 | run: ctest -C ${{ env.BUILD_TYPE }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ##### Windows 2 | # Windows thumbnail cache files 3 | Thumbs.db 4 | Thumbs.db:encryptable 5 | ehthumbs.db 6 | ehthumbs_vista.db 7 | 8 | # Dump file 9 | *.stackdump 10 | 11 | # Folder config file 12 | [Dd]esktop.ini 13 | 14 | # Recycle Bin used on file shares 15 | $RECYCLE.BIN/ 16 | 17 | # Windows Installer files 18 | *.cab 19 | *.msi 20 | *.msix 21 | *.msm 22 | *.msp 23 | 24 | # Windows shortcuts 25 | *.lnk 26 | 27 | ##### Linux 28 | *~ 29 | 30 | # temporary files which can be created if a process still has a handle open of a deleted file 31 | .fuse_hidden* 32 | 33 | # KDE directory preferences 34 | .directory 35 | 36 | # Linux trash folder which might appear on any partition or disk 37 | .Trash-* 38 | 39 | # .nfs files are created when an open file is removed but is still being accessed 40 | .nfs* 41 | 42 | ##### MacOS 43 | # General 44 | .DS_Store 45 | .AppleDouble 46 | .LSOverride 47 | 48 | # Icon must end with two \r 49 | Icon 50 | 51 | # Thumbnails 52 | ._* 53 | 54 | # Files that might appear in the root of a volume 55 | .DocumentRevisions-V100 56 | .fseventsd 57 | .Spotlight-V100 58 | .TemporaryItems 59 | .Trashes 60 | .VolumeIcon.icns 61 | .com.apple.timemachine.donotpresent 62 | 63 | # Directories potentially created on remote AFP share 64 | .AppleDB 65 | .AppleDesktop 66 | Network Trash Folder 67 | Temporary Items 68 | .apdisk 69 | 70 | ##### Android 71 | # Built application files 72 | *.apk 73 | *.ap_ 74 | *.aab 75 | 76 | # Files for the ART/Dalvik VM 77 | *.dex 78 | 79 | # Java class files 80 | *.class 81 | 82 | # Generated files 83 | bin/ 84 | gen/ 85 | out/ 86 | # Uncomment the following line in case you need and you don't have the release build type files in your app 87 | # release/ 88 | 89 | # Gradle files 90 | .gradle/ 91 | build/ 92 | 93 | # Local configuration file (sdk path, etc) 94 | local.properties 95 | 96 | # Proguard folder generated by Eclipse 97 | proguard/ 98 | 99 | # Log Files 100 | *.log 101 | 102 | # Android Studio Navigation editor temp files 103 | .navigation/ 104 | 105 | # Android Studio captures folder 106 | captures/ 107 | 108 | # IntelliJ 109 | *.iml 110 | .idea/ 111 | .idea/workspace.xml 112 | .idea/tasks.xml 113 | .idea/gradle.xml 114 | .idea/assetWizardSettings.xml 115 | .idea/dictionaries 116 | .idea/libraries 117 | # Android Studio 3 in .gitignore file. 118 | .idea/caches 119 | .idea/modules.xml 120 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 121 | .idea/navEditor.xml 122 | 123 | # Keystore files 124 | # Uncomment the following lines if you do not want to check your keystore files in. 125 | #*.jks 126 | #*.keystore 127 | 128 | # External native build folder generated in Android Studio 2.2 and later 129 | .externalNativeBuild 130 | 131 | # Google Services (e.g. APIs or Firebase) 132 | # google-services.json 133 | 134 | # Freeline 135 | freeline.py 136 | freeline/ 137 | freeline_project_description.json 138 | 139 | # fastlane 140 | fastlane/report.xml 141 | fastlane/Preview.html 142 | fastlane/screenshots 143 | fastlane/test_output 144 | fastlane/readme.md 145 | 146 | # Version control 147 | vcs.xml 148 | 149 | # lint 150 | lint/intermediates/ 151 | lint/generated/ 152 | lint/outputs/ 153 | lint/tmp/ 154 | # lint/reports/ 155 | 156 | ##### Backup 157 | *.bak 158 | *.gho 159 | *.ori 160 | *.orig 161 | *.tmp 162 | 163 | ##### GPG 164 | secring.* 165 | 166 | ##### Dropbox 167 | # Dropbox settings and caches 168 | .dropbox 169 | .dropbox.attr 170 | .dropbox.cache 171 | 172 | ##### SynopsysVCS 173 | # Waveform formats 174 | *.vcd 175 | *.vpd 176 | *.evcd 177 | *.fsdb 178 | 179 | # Default name of the simulation executable. A different name can be 180 | # specified with this switch (the associated daidir database name is 181 | # also taken from here): -o / 182 | simv 183 | 184 | # Generated for Verilog and VHDL top configs 185 | simv.daidir/ 186 | simv.db.dir/ 187 | 188 | # Infrastructure necessary to co-simulate SystemC models with 189 | # Verilog/VHDL models. An alternate directory may be specified with this 190 | # switch: -Mdir= 191 | csrc/ 192 | 193 | # Log file - the following switch allows to specify the file that will be 194 | # used to write all messages from simulation: -l 195 | *.log 196 | 197 | # Coverage results (generated with urg) and database location. The 198 | # following switch can also be used: urg -dir .vdb 199 | simv.vdb/ 200 | urgReport/ 201 | 202 | # DVE and UCLI related files. 203 | DVEfiles/ 204 | ucli.key 205 | 206 | # When the design is elaborated for DirectC, the following file is created 207 | # with declarations for C/C++ functions. 208 | vc_hdrs.h 209 | 210 | ##### SVN 211 | .svn/ 212 | 213 | ##### Mercurial 214 | .hg/ 215 | .hgignore 216 | .hgsigs 217 | .hgsub 218 | .hgsubstate 219 | .hgtags 220 | 221 | ##### Bazaar 222 | .bzr/ 223 | .bzrignore 224 | 225 | ##### CVS 226 | /CVS/* 227 | **/CVS/* 228 | .cvsignore 229 | */.cvsignore 230 | 231 | ##### TortoiseGit 232 | # Project-level settings 233 | /.tgitconfig 234 | 235 | ##### PuTTY 236 | # Private key 237 | *.ppk 238 | 239 | ##### Vim 240 | # Swap 241 | [._]*.s[a-v][a-z] 242 | !*.svg # comment out if you don't need vector files 243 | [._]*.sw[a-p] 244 | [._]s[a-rt-v][a-z] 245 | [._]ss[a-gi-z] 246 | [._]sw[a-p] 247 | 248 | # Session 249 | Session.vim 250 | Sessionx.vim 251 | 252 | # Temporary 253 | .netrwhist 254 | *~ 255 | # Auto-generated tag files 256 | tags 257 | # Persistent undo 258 | [._]*.un~ 259 | 260 | ##### Emacs 261 | # -*- mode: gitignore; -*- 262 | *~ 263 | \#*\# 264 | /.emacs.desktop 265 | /.emacs.desktop.lock 266 | *.elc 267 | auto-save-list 268 | tramp 269 | .\#* 270 | 271 | # Org-mode 272 | .org-id-locations 273 | *_archive 274 | 275 | # flymake-mode 276 | *_flymake.* 277 | 278 | # eshell files 279 | /eshell/history 280 | /eshell/lastdir 281 | 282 | # elpa packages 283 | /elpa/ 284 | 285 | # reftex files 286 | *.rel 287 | 288 | # AUCTeX auto folder 289 | /auto/ 290 | 291 | # cask packages 292 | .cask/ 293 | dist/ 294 | 295 | # Flycheck 296 | flycheck_*.el 297 | 298 | # server auth directory 299 | /server/ 300 | 301 | # projectiles files 302 | .projectile 303 | 304 | # directory configuration 305 | .dir-locals.el 306 | 307 | # network security 308 | /network-security.data 309 | 310 | ##### SublimeText 311 | # Cache files for Sublime Text 312 | *.tmlanguage.cache 313 | *.tmPreferences.cache 314 | *.stTheme.cache 315 | 316 | # Workspace files are user-specific 317 | *.sublime-workspace 318 | 319 | # Project files should be checked into the repository, unless a significant 320 | # proportion of contributors will probably not be using Sublime Text 321 | # *.sublime-project 322 | 323 | # SFTP configuration file 324 | sftp-config.json 325 | sftp-config-alt*.json 326 | 327 | # Package control specific files 328 | Package Control.last-run 329 | Package Control.ca-list 330 | Package Control.ca-bundle 331 | Package Control.system-ca-bundle 332 | Package Control.cache/ 333 | Package Control.ca-certs/ 334 | Package Control.merged-ca-bundle 335 | Package Control.user-ca-bundle 336 | oscrypto-ca-bundle.crt 337 | bh_unicode_properties.cache 338 | 339 | # Sublime-github package stores a github token in this file 340 | # https://packagecontrol.io/packages/sublime-github 341 | GitHub.sublime-settings 342 | 343 | ##### Notepad++ 344 | # Notepad++ backups # 345 | *.bak 346 | 347 | ##### TextMate 348 | *.tmproj 349 | *.tmproject 350 | tmtags 351 | 352 | ##### VisualStudioCode 353 | .vscode/* 354 | !.vscode/settings.json 355 | !.vscode/tasks.json 356 | !.vscode/launch.json 357 | !.vscode/extensions.json 358 | *.code-workspace 359 | 360 | # Local History for Visual Studio Code 361 | .history/ 362 | 363 | ##### NetBeans 364 | **/nbproject/private/ 365 | **/nbproject/Makefile-*.mk 366 | **/nbproject/Package-*.bash 367 | build/ 368 | nbbuild/ 369 | dist/ 370 | nbdist/ 371 | .nb-gradle/ 372 | 373 | ##### JetBrains 374 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 375 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 376 | 377 | # User-specific stuff 378 | .idea/**/workspace.xml 379 | .idea/**/tasks.xml 380 | .idea/**/usage.statistics.xml 381 | .idea/**/dictionaries 382 | .idea/**/shelf 383 | 384 | # Generated files 385 | .idea/**/contentModel.xml 386 | 387 | # Sensitive or high-churn files 388 | .idea/**/dataSources/ 389 | .idea/**/dataSources.ids 390 | .idea/**/dataSources.local.xml 391 | .idea/**/sqlDataSources.xml 392 | .idea/**/dynamic.xml 393 | .idea/**/uiDesigner.xml 394 | .idea/**/dbnavigator.xml 395 | 396 | # Gradle 397 | .idea/**/gradle.xml 398 | .idea/**/libraries 399 | 400 | # Gradle and Maven with auto-import 401 | # When using Gradle or Maven with auto-import, you should exclude module files, 402 | # since they will be recreated, and may cause churn. Uncomment if using 403 | # auto-import. 404 | # .idea/artifacts 405 | # .idea/compiler.xml 406 | # .idea/jarRepositories.xml 407 | # .idea/modules.xml 408 | # .idea/*.iml 409 | # .idea/modules 410 | # *.iml 411 | # *.ipr 412 | 413 | # CMake 414 | cmake-build-*/ 415 | build/* 416 | lib/* 417 | bin/* 418 | 419 | # Mongo Explorer plugin 420 | .idea/**/mongoSettings.xml 421 | 422 | # File-based project format 423 | *.iws 424 | 425 | # IntelliJ 426 | out/ 427 | 428 | # mpeltonen/sbt-idea plugin 429 | .idea_modules/ 430 | 431 | # JIRA plugin 432 | atlassian-ide-plugin.xml 433 | 434 | # Cursive Clojure plugin 435 | .idea/replstate.xml 436 | 437 | # Crashlytics plugin (for Android Studio and IntelliJ) 438 | com_crashlytics_export_strings.xml 439 | crashlytics.properties 440 | crashlytics-build.properties 441 | fabric.properties 442 | 443 | # Editor-based Rest Client 444 | .idea/httpRequests 445 | 446 | # Android studio 3.1+ serialized cache file 447 | .idea/caches/build_file_checksums.ser 448 | 449 | ##### Eclipse 450 | .metadata 451 | bin/ 452 | tmp/ 453 | *.tmp 454 | *.bak 455 | *.swp 456 | *~.nib 457 | local.properties 458 | .settings/ 459 | .loadpath 460 | .recommenders 461 | 462 | # External tool builders 463 | .externalToolBuilders/ 464 | 465 | # Locally stored "Eclipse launch configurations" 466 | *.launch 467 | 468 | # PyDev specific (Python IDE for Eclipse) 469 | *.pydevproject 470 | 471 | # CDT-specific (C/C++ Development Tooling) 472 | .cproject 473 | 474 | # CDT- autotools 475 | .autotools 476 | 477 | # Java annotation processor (APT) 478 | .factorypath 479 | 480 | # PDT-specific (PHP Development Tools) 481 | .buildpath 482 | 483 | # sbteclipse plugin 484 | .target 485 | 486 | # Tern plugin 487 | .tern-project 488 | 489 | # TeXlipse plugin 490 | .texlipse 491 | 492 | # STS (Spring Tool Suite) 493 | .springBeans 494 | 495 | # Code Recommenders 496 | .recommenders/ 497 | 498 | # Annotation Processing 499 | .apt_generated/ 500 | .apt_generated_test/ 501 | 502 | # Scala IDE specific (Scala & Java development for Eclipse) 503 | .cache-main 504 | .scala_dependencies 505 | .worksheet 506 | 507 | # Uncomment this line if you wish to ignore the project description file. 508 | # Typically, this file would be tracked if it contains build/dependency configurations: 509 | #.project 510 | 511 | ##### Qt 512 | # C++ objects and libs 513 | *.slo 514 | *.lo 515 | *.o 516 | *.a 517 | *.la 518 | *.lai 519 | *.so 520 | *.so.* 521 | *.dll 522 | *.dylib 523 | 524 | # Qt-es 525 | object_script.*.Release 526 | object_script.*.Debug 527 | *_plugin_import.cpp 528 | /.qmake.cache 529 | /.qmake.stash 530 | *.pro.user 531 | *.pro.user.* 532 | *.qbs.user 533 | *.qbs.user.* 534 | *.moc 535 | moc_*.cpp 536 | moc_*.h 537 | qrc_*.cpp 538 | ui_*.h 539 | *.qmlc 540 | *.jsc 541 | Makefile* 542 | *build-* 543 | *.qm 544 | *.prl 545 | 546 | # Qt unit tests 547 | target_wrapper.* 548 | 549 | # QtCreator 550 | *.autosave 551 | 552 | # QtCreator Qml 553 | *.qmlproject.user 554 | *.qmlproject.user.* 555 | 556 | # QtCreator CMake 557 | CMakeLists.txt.user* 558 | 559 | # QtCreator 4.8< compilation database 560 | compile_commands.json 561 | 562 | # QtCreator local machine specific files for imported projects 563 | *creator.user* 564 | 565 | ##### VisualStudio 566 | ##### VisualStudio 567 | ## Ignore Visual Studio temporary files, build results, and 568 | ## files generated by popular Visual Studio add-ons. 569 | ## 570 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 571 | 572 | # User-specific files 573 | *.rsuser 574 | *.suo 575 | *.user 576 | *.userosscache 577 | *.sln.docstates 578 | 579 | # User-specific files (MonoDevelop/Xamarin Studio) 580 | *.userprefs 581 | 582 | # Mono auto generated files 583 | mono_crash.* 584 | 585 | # Build results 586 | [Dd]ebug/ 587 | [Dd]ebugPublic/ 588 | [Rr]elease/ 589 | [Rr]eleases/ 590 | x64/ 591 | x86/ 592 | [Ww][Ii][Nn]32/ 593 | [Aa][Rr][Mm]/ 594 | [Aa][Rr][Mm]64/ 595 | bld/ 596 | [Bb]in/ 597 | [Oo]bj/ 598 | [Ll]og/ 599 | [Ll]ogs/ 600 | 601 | # Visual Studio 2015/2017 cache/options directory 602 | .vs/ 603 | # Uncomment if you have tasks that create the project's static files in wwwroot 604 | #wwwroot/ 605 | 606 | # Visual Studio 2017 auto generated files 607 | Generated\ Files/ 608 | 609 | # MSTest test Results 610 | [Tt]est[Rr]esult*/ 611 | [Bb]uild[Ll]og.* 612 | 613 | # NUnit 614 | *.VisualState.xml 615 | TestResult.xml 616 | nunit-*.xml 617 | 618 | # Build Results of an ATL Project 619 | [Dd]ebugPS/ 620 | [Rr]eleasePS/ 621 | dlldata.c 622 | 623 | # Benchmark Results 624 | BenchmarkDotNet.Artifacts/ 625 | 626 | # .NET Core 627 | project.lock.json 628 | project.fragment.lock.json 629 | artifacts/ 630 | 631 | # ASP.NET Scaffolding 632 | ScaffoldingReadMe.txt 633 | 634 | # StyleCop 635 | StyleCopReport.xml 636 | 637 | # Files built by Visual Studio 638 | *_i.c 639 | *_p.c 640 | *_h.h 641 | *.ilk 642 | *.meta 643 | *.obj 644 | *.iobj 645 | *.pch 646 | *.pdb 647 | *.ipdb 648 | *.pgc 649 | *.pgd 650 | *.rsp 651 | *.sbr 652 | *.tlb 653 | *.tli 654 | *.tlh 655 | *.tmp 656 | *.tmp_proj 657 | *_wpftmp.csproj 658 | *.log 659 | *.vspscc 660 | *.vssscc 661 | .builds 662 | *.pidb 663 | *.svclog 664 | *.scc 665 | 666 | # Chutzpah Test files 667 | _Chutzpah* 668 | 669 | # Visual C++ cache files 670 | ipch/ 671 | *.aps 672 | *.ncb 673 | *.opendb 674 | *.opensdf 675 | *.sdf 676 | *.cachefile 677 | *.VC.db 678 | *.VC.VC.opendb 679 | 680 | # Visual Studio profiler 681 | *.psess 682 | *.vsp 683 | *.vspx 684 | *.sap 685 | 686 | # Visual Studio Trace Files 687 | *.e2e 688 | 689 | # TFS 2012 Local Workspace 690 | $tf/ 691 | 692 | # Guidance Automation Toolkit 693 | *.gpState 694 | 695 | # ReSharper is a .NET coding add-in 696 | _ReSharper*/ 697 | *.[Rr]e[Ss]harper 698 | *.DotSettings.user 699 | 700 | # TeamCity is a build add-in 701 | _TeamCity* 702 | 703 | # DotCover is a Code Coverage Tool 704 | *.dotCover 705 | 706 | # AxoCover is a Code Coverage Tool 707 | .axoCover/* 708 | !.axoCover/settings.json 709 | 710 | # Coverlet is a free, cross platform Code Coverage Tool 711 | coverage*[.json, .xml, .info] 712 | 713 | # Visual Studio code coverage results 714 | *.coverage 715 | *.coveragexml 716 | 717 | # NCrunch 718 | _NCrunch_* 719 | .*crunch*.local.xml 720 | nCrunchTemp_* 721 | 722 | # MightyMoose 723 | *.mm.* 724 | AutoTest.Net/ 725 | 726 | # Web workbench (sass) 727 | .sass-cache/ 728 | 729 | # Installshield output folder 730 | [Ee]xpress/ 731 | 732 | # DocProject is a documentation generator add-in 733 | DocProject/buildhelp/ 734 | DocProject/Help/*.HxT 735 | DocProject/Help/*.HxC 736 | DocProject/Help/*.hhc 737 | DocProject/Help/*.hhk 738 | DocProject/Help/*.hhp 739 | DocProject/Help/Html2 740 | DocProject/Help/html 741 | 742 | # Click-Once directory 743 | publish/ 744 | 745 | # Publish Web Output 746 | *.[Pp]ublish.xml 747 | *.azurePubxml 748 | # Note: Comment the next line if you want to checkin your web deploy settings, 749 | # but database connection strings (with potential passwords) will be unencrypted 750 | *.pubxml 751 | *.publishproj 752 | 753 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 754 | # checkin your Azure Web App publish settings, but sensitive information contained 755 | # in these scripts will be unencrypted 756 | PublishScripts/ 757 | 758 | # NuGet Packages 759 | *.nupkg 760 | # NuGet Symbol Packages 761 | *.snupkg 762 | # The packages folder can be ignored because of Package Restore 763 | **/[Pp]ackages/* 764 | # except build/, which is used as an MSBuild target. 765 | !**/[Pp]ackages/build/ 766 | # Uncomment if necessary however generally it will be regenerated when needed 767 | #!**/[Pp]ackages/repositories.config 768 | # NuGet v3's project.json files produces more ignorable files 769 | *.nuget.props 770 | *.nuget.targets 771 | 772 | # Microsoft Azure Build Output 773 | csx/ 774 | *.build.csdef 775 | 776 | # Microsoft Azure Emulator 777 | ecf/ 778 | rcf/ 779 | 780 | # Windows Store app package directories and files 781 | AppPackages/ 782 | BundleArtifacts/ 783 | Package.StoreAssociation.xml 784 | _pkginfo.txt 785 | *.appx 786 | *.appxbundle 787 | *.appxupload 788 | 789 | # Visual Studio cache files 790 | # files ending in .cache can be ignored 791 | *.[Cc]ache 792 | # but keep track of directories ending in .cache 793 | !?*.[Cc]ache/ 794 | 795 | # Others 796 | ClientBin/ 797 | ~$* 798 | *~ 799 | *.dbmdl 800 | *.dbproj.schemaview 801 | *.jfm 802 | *.pfx 803 | *.publishsettings 804 | orleans.codegen.cs 805 | 806 | # Including strong name files can present a security risk 807 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 808 | #*.snk 809 | 810 | # Since there are multiple workflows, uncomment next line to ignore bower_components 811 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 812 | #bower_components/ 813 | 814 | # RIA/Silverlight projects 815 | Generated_Code/ 816 | 817 | # Backup & report files from converting an old project file 818 | # to a newer Visual Studio version. Backup files are not needed, 819 | # because we have git ;-) 820 | _UpgradeReport_Files/ 821 | Backup*/ 822 | UpgradeLog*.XML 823 | UpgradeLog*.htm 824 | ServiceFabricBackup/ 825 | *.rptproj.bak 826 | 827 | # SQL Server files 828 | *.mdf 829 | *.ldf 830 | *.ndf 831 | 832 | # Business Intelligence projects 833 | *.rdl.data 834 | *.bim.layout 835 | *.bim_*.settings 836 | *.rptproj.rsuser 837 | *- [Bb]ackup.rdl 838 | *- [Bb]ackup ([0-9]).rdl 839 | *- [Bb]ackup ([0-9][0-9]).rdl 840 | 841 | # Microsoft Fakes 842 | FakesAssemblies/ 843 | 844 | # GhostDoc plugin setting file 845 | *.GhostDoc.xml 846 | 847 | # Node.js Tools for Visual Studio 848 | .ntvs_analysis.dat 849 | node_modules/ 850 | 851 | # Visual Studio 6 build log 852 | *.plg 853 | 854 | # Visual Studio 6 workspace options file 855 | *.opt 856 | 857 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 858 | *.vbw 859 | 860 | # Visual Studio LightSwitch build output 861 | **/*.HTMLClient/GeneratedArtifacts 862 | **/*.DesktopClient/GeneratedArtifacts 863 | **/*.DesktopClient/ModelManifest.xml 864 | **/*.Server/GeneratedArtifacts 865 | **/*.Server/ModelManifest.xml 866 | _Pvt_Extensions 867 | 868 | # Paket dependency manager 869 | .paket/paket.exe 870 | paket-files/ 871 | 872 | # FAKE - F# Make 873 | .fake/ 874 | 875 | # CodeRush personal settings 876 | .cr/personal 877 | 878 | # Python Tools for Visual Studio (PTVS) 879 | __pycache__/ 880 | *.pyc 881 | 882 | # Cake - Uncomment if you are using it 883 | # tools/** 884 | # !tools/packages.config 885 | 886 | # Tabs Studio 887 | *.tss 888 | 889 | # Telerik's JustMock configuration file 890 | *.jmconfig 891 | 892 | # BizTalk build output 893 | *.btp.cs 894 | *.btm.cs 895 | *.odx.cs 896 | *.xsd.cs 897 | 898 | # OpenCover UI analysis results 899 | OpenCover/ 900 | 901 | # Azure Stream Analytics local run output 902 | ASALocalRun/ 903 | 904 | # MSBuild Binary and Structured Log 905 | *.binlog 906 | 907 | # NVidia Nsight GPU debugger configuration file 908 | *.nvuser 909 | 910 | # MFractors (Xamarin productivity tool) working folder 911 | .mfractor/ 912 | 913 | # Local History for Visual Studio 914 | .localhistory/ 915 | 916 | # BeatPulse healthcheck temp database 917 | healthchecksdb 918 | 919 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 920 | MigrationBackup/ 921 | 922 | # Ionide (cross platform F# VS Code tools) working folder 923 | .ionide/ 924 | 925 | # Fody - auto-generated XML schema 926 | FodyWeavers.xsd 927 | 928 | ##### Gradle 929 | .gradle 930 | **/build/ 931 | !src/**/build/ 932 | 933 | # Ignore Gradle GUI config 934 | gradle-app.setting 935 | 936 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 937 | !gradle-wrapper.jar 938 | 939 | # Cache of project 940 | .gradletasknamecache 941 | 942 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 943 | # gradle/wrapper/gradle-wrapper.properties 944 | 945 | ##### C++ 946 | # Prerequisites 947 | *.d 948 | 949 | # Compiled Object files 950 | *.slo 951 | *.lo 952 | *.o 953 | *.obj 954 | 955 | # Precompiled Headers 956 | *.gch 957 | *.pch 958 | 959 | # Compiled Dynamic libraries 960 | *.so 961 | *.dylib 962 | *.dll 963 | 964 | # Fortran module files 965 | *.mod 966 | *.smod 967 | 968 | # Compiled Static libraries 969 | *.lai 970 | *.la 971 | *.a 972 | *.lib 973 | 974 | # Executables 975 | *.exe 976 | *.out 977 | *.app 978 | 979 | ##### C 980 | # Prerequisites 981 | *.d 982 | 983 | # Object files 984 | *.o 985 | *.ko 986 | *.obj 987 | *.elf 988 | 989 | # Linker output 990 | *.ilk 991 | *.map 992 | *.exp 993 | 994 | # Precompiled Headers 995 | *.gch 996 | *.pch 997 | 998 | # Libraries 999 | *.lib 1000 | *.a 1001 | *.la 1002 | *.lo 1003 | 1004 | # Shared objects (inc. Windows DLLs) 1005 | *.dll 1006 | *.so 1007 | *.so.* 1008 | *.dylib 1009 | 1010 | # Executables 1011 | *.exe 1012 | *.out 1013 | *.app 1014 | *.i*86 1015 | *.x86_64 1016 | *.hex 1017 | 1018 | # Debug files 1019 | *.dSYM/ 1020 | *.su 1021 | *.idb 1022 | *.pdb 1023 | 1024 | # Kernel Module Compile Results 1025 | *.mod* 1026 | *.cmd 1027 | .tmp_versions/ 1028 | modules.order 1029 | Module.symvers 1030 | Mkfile.old 1031 | dkms.conf 1032 | 1033 | # VS code 1034 | *.vscode/ 1035 | 1036 | # CURL 1037 | ./include/curl/* 1038 | 1039 | # JSON 1040 | ./include/nlohmann/* 1041 | 1042 | # VKAPI 1043 | include/Config.hpp 1044 | src/main.cpp -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qucals/VK-API/975b9f687fd58b680fc50b01a7d4f3d75e6a62c2/.gitmodules -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | VKAPI -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | set(PROJECT_NAME VKAPI) 3 | project(${PROJECT_NAME} LANGUAGES CXX) 4 | 5 | include(CMakePackageConfigHelpers) 6 | include(GNUInstallDirs) 7 | 8 | set(VKAPI_MAJOR_VERSION 0) 9 | set(VKAPI_MINOR_VERSION 0) 10 | set(VKAPI_PATCH_VERSION 5) 11 | set(VKAPI_VERSION_STRING "${VKAPI_MAJOR_VERSION}.${VKAPI_MINOR_VERSION}.${VKAPI_PATCH_VERSION}") 12 | 13 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/Config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/Config.hpp @ONLY) 14 | 15 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 16 | 17 | if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 18 | set(MACOSX TRUE) 19 | endif() 20 | 21 | set(NLOHMANN_JSON_PATH "${PROJECT_SOURCE_DIR}/include") 22 | set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}) 23 | 24 | option(BUILD_LIBRARY "Determines that, as a result, we get" ON) 25 | option(BUILD_EXAMPLES "Determines whether examples should be performed" ON) 26 | 27 | file(GLOB TARGET_SRC "./src/*.cpp") 28 | file(GLOB TARGET_HEADERS "./include/*.hpp") 29 | 30 | if(BUILD_LIBRARY) 31 | add_library(${PROJECT_NAME} STATIC ${TARGET_SRC} ${TARGET_HEADERS}) 32 | else() 33 | if(UNIX) 34 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") 35 | endif() 36 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcurl") 37 | add_executable(${PROJECT_NAME} ${TARGET_SRC} ${TARGET_HEADERS}) 38 | endif() 39 | 40 | target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_INSTALL_INCLUDEDIR}) 41 | 42 | # Include json 43 | target_link_directories(${PROJECT_NAME} PUBLIC ${NLOHMANN_JSON_PATH}) 44 | 45 | # Link curl 46 | if(UNIX) 47 | find_package(CURL REQUIRED) 48 | target_link_directories(${PROJECT_NAME} PUBLIC ${CURL_INCLUDE_DIR}) 49 | else() 50 | include(FindPkgConfig) 51 | # find_package(CURL REQUIRED) 52 | pkg_check_modules(CURL libcurl REQUIRED) 53 | endif() 54 | 55 | target_link_libraries(${PROJECT_NAME} PUBLIC CURL::libcurl) 56 | 57 | set_target_properties( 58 | ${PROJECT_NAME} PROPERTIES 59 | CXX_STANDARD 14 60 | CXX_STANDARD_REQUIRED on 61 | ) 62 | 63 | configure_package_config_file( 64 | VKAPIConfig.cmake.in 65 | "${CMAKE_CURRENT_BINARY_DIR}/VKAPIConfig.cmake" 66 | INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VKAPI.cmake 67 | ) 68 | 69 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/VKAPIConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/) 70 | 71 | install(TARGETS ${PROJECT_NAME} EXPORT VKAPITargets) 72 | install(EXPORT VKAPITargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ NAMESPACE VKAPI::) 73 | 74 | install(FILES ${TARGET_HEADERS} DESTINATION ${CMAKE_INSTALL_BINDIR}/include/vkapi) 75 | 76 | if(BUILD_EXAMPLES) 77 | add_subdirectory(examples) 78 | endif() -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

VK API Library

6 | 7 |
8 | 9 | [![Status](https://img.shields.io/badge/status-active-success.svg)]() 10 | [![CodeFactor](https://www.codefactor.io/repository/github/qucals/VK-API/badge/master)](https://www.codefactor.io/repository/github/qucals/VK-API/overview/master) 11 |
12 | [![Workflow](https://github.com/qucals/VK-API/actions/workflows/macos.yml/badge.svg)]() 13 | [![Workflow](https://github.com/qucals/VK-API/actions/workflows/ubuntu.yml/badge.svg)]() 14 | [![Workflow](https://github.com/qucals/VK-API/actions/workflows/windows.yml/badge.svg)]() 15 |
16 | [![GitHub Issues](https://img.shields.io/github/issues/qucals/VK-API.svg)](https://github.com/qucals/VK-API/issues) 17 | [![GitHub Pull Requests](https://img.shields.io/github/issues-pr/qucals/VK-API.svg)](https://github.com/qucals/VK-API/pulls) 18 | [![License](https://img.shields.io/github/license/qucals/VK-API)](/LICENSE) 19 | 20 |
21 | 22 | --- 23 | 24 |

The easiest C++ library to use for working with the VK API. 25 |
26 |

27 | 28 | ## 📝 Table of Contents 29 | 30 | - [About](#about) 31 | - [Getting Started](#getting_started) 32 | - [Deployment](#deployment) 33 | - [Usage](#usage) 34 | - [Built Using](#built_using) 35 | - [Authors](#authors) 36 | 37 | ## 🧐 About
38 | 39 | This is a library for easy work with the VK API. It contains all the standard queries that are defined by VK. This makes it easier to access LongPollServer VK. 40 | 41 | ## 🏁 Getting Started 42 | 43 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [deployment](#deployment) for notes on how to deploy the project on a live system. 44 | 45 | Steps : 46 | 1. Copy this repository to your computer; 47 | 2. Open terminal in a directory where you copied the repository; 48 | 3. Change a main directory: `cd build`; 49 | 4. Enter the following command with your replacements: `cmake ..`; 50 | 5. Build the project by the next command: `cmake --build .`. 51 | 52 | ### Prerequisites 53 | 54 | The library using 2 additional dependencies: 55 | 1. [curlpp](https://www.curlpp.org/) - A library for working with requests; 56 | 2. [json](https://github.com/nlohmann/json) - A library for working with json. 57 | 58 | Note that you also can install it by `vcpkg` on Windows. 59 | 60 | ### Installing 61 | 62 | For connection this library to yours you need to follow the next steps: 63 | 1. Copy this repository to your computer; 64 | 2. Open terminal in a directory where you copied the repository; 65 | 3. Change a main directory: `cd build`; 66 | 4. Enter the following command with your replacements: `cmake ..`; 67 | 5. Build and install the project by the next command: `cmake --build . --target install --config Release`; 68 | 6. If building and install is ended successfully you can see there are `include` and `lib`'s directories in `install`'s directory. 69 | 70 | After the above steps you will have a static library and include's files that you can connection to your project. 71 | 72 | ## 🎈 Usage 73 | 74 | There are two base examples. 75 | 76 | Authorization for Bot: 77 | 78 | ```CXX 79 | #include "Bot.hpp" 80 | 81 | int main(int argc, const char** argv) 82 | { 83 | std::string access_token = "your_token_there"; 84 | std::string group_id = "your_group_id_there"; 85 | 86 | vk::base::bot::Bot bot(group_id); 87 | 88 | if (bot.Auth(access_token) == true) { 89 | // The further behaviour 90 | } else { 91 | // The further behaviour 92 | } 93 | 94 | return 0; 95 | } 96 | ``` 97 | 98 | Authorization for User: 99 | 100 | ```CXX 101 | #include "User.hpp" 102 | 103 | int main(int argc, const char** argv) 104 | { 105 | std::string app_id = "your_app_id_there"; 106 | std::string app_secure_key = "your_app_secure_key_there"; 107 | std::string login = "your_login_there"; 108 | std::string password = "your_password_there"; 109 | std::string access_token = "your_access_token_there"; 110 | 111 | vk::base::user::User user(app_id, app_secure_key); 112 | 113 | if(user.Auth(login, password) == true) { 114 | // The further behaviour 115 | } else { 116 | // The further behaviour 117 | } 118 | 119 | // or 120 | 121 | if (user.Auth(access_token) == true) { 122 | // The further behaviour 123 | } else { 124 | // The further behaviour 125 | } 126 | 127 | return 0; 128 | } 129 | ``` 130 | 131 | There are other examples of using this library in the `examples` directory. 132 | 133 | ## 🚀 Deployment 134 | 135 | ### CMake 136 | 137 | If you use CMake you make use the `find_package` instruction. 138 | After [installing](#installing) the project you can find vkapiConfig.cmake in the `lib/cmake` directory. For connection this library to your project you need to add the following code to your cmake file: 139 | ```CMake 140 | set(CMAKE_CXX_FLAGS " -lcurl") 141 | set(VKAPI_DIR *path_to_vkapiconfig.cmake*) 142 | find_package(VKAPI CONFIG REQUIRED) 143 | target_link_libraries(${PROJECT_NAME} VKAPI::VKAPI) 144 | ``` 145 | Replace: 146 | `*path_to_vkapiconfig.cmake*` to the path to directory `lib/cmake`; 147 | 148 | ### Others 149 | 150 | If you use another building system you need to connection include's files and lib file which is located `bin\include` and `lib` directories. 151 | 152 | ## ⛏️ Built Using 153 | 154 | - [CMake](https://cmake.org/) - Cross-platform family of tools designed to build 155 | 156 | ## ✍️ Authors 157 | 158 | - [@qucals](https://github.com/qucals) - Idea & Initial work 159 | -------------------------------------------------------------------------------- /VKAPIConfig.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | find_dependency(CURL REQUIRED) 3 | 4 | @PACKAGE_INIT@ 5 | 6 | include(${CMAKE_CURRENT_LIST_DIR}/VKAPITargets.cmake) -------------------------------------------------------------------------------- /examples/1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | set(PROJECT_NAME Example1) 3 | project(${PROJECT_NAME} LANGUAGES CXX) 4 | 5 | if(UNIX) 6 | set(CMAKE_CXX_FLAGS "-L/usr/local/lib/ -L/usr/lib/ ${CMAKE_CXX_FLAGS} -pthread") 7 | endif() 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcurl") 9 | 10 | set(VKAPI_DIR ../../lib/cmake) 11 | find_package(VKAPI CONFIG REQUIRED) 12 | 13 | add_executable(${PROJECT_NAME} main.cpp) 14 | target_link_libraries(${PROJECT_NAME} VKAPI::VKAPI) 15 | 16 | set_target_properties( 17 | ${PROJECT_NAME} PROPERTIES 18 | CXX_STANDARD 14 19 | CXX_STANDARD_REQUIRED on 20 | ) -------------------------------------------------------------------------------- /examples/1/main.cpp: -------------------------------------------------------------------------------- 1 | #include "BotBase.hpp" 2 | 3 | int main(int argc, const char** argv) 4 | { 5 | std::string access_token = "your_token_there"; 6 | std::string group_id = "your_group_id_there"; 7 | 8 | vk::base::bot::BotBase bot(group_id); 9 | 10 | std::cout << "I'm created vk::BotBase!" << std::endl; 11 | std::cout << "The address is: " << &bot << std::endl; 12 | try { 13 | if (bot.Auth(access_token) == true) { 14 | std::cout << "Auth is ended successfully" << std::endl; 15 | } else { 16 | std::cout << "Auth is failed!" << std::endl; 17 | } 18 | } catch (std::exception ex) { 19 | std::cout << ex.what() << std::endl; 20 | } 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /examples/2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | set(PROJECT_NAME Example2) 3 | project(${PROJECT_NAME} LANGUAGES CXX) 4 | 5 | if(UNIX) 6 | set(CMAKE_CXX_FLAGS "-L/usr/local/lib/ -L/usr/lib/ ${CMAKE_CXX_FLAGS} -pthread") 7 | endif() 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcurl") 9 | 10 | set(VKAPI_DIR ../../lib/cmake) 11 | find_package(VKAPI CONFIG REQUIRED) 12 | 13 | add_executable(${PROJECT_NAME} main.cpp) 14 | target_link_libraries(${PROJECT_NAME} VKAPI::VKAPI) 15 | 16 | set_target_properties( 17 | ${PROJECT_NAME} PROPERTIES 18 | CXX_STANDARD 14 19 | CXX_STANDARD_REQUIRED on 20 | ) -------------------------------------------------------------------------------- /examples/2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "UserBase.hpp" 2 | 3 | int main(int argc, const char** argv) 4 | { 5 | std::string app_id = "your_app_id_there"; 6 | std::string app_secure_key = "your_app_secure_key_there"; 7 | std::string login = "your_login_there"; 8 | std::string password = "your_password_there"; 9 | std::string access_token = "your_access_token_there"; 10 | 11 | vk::base::user::UserBase user(app_id, app_secure_key); 12 | try { 13 | if (user.Auth(login, password) == true) { 14 | // The further behaviour 15 | } else { 16 | // The further behaviour 17 | } 18 | 19 | // or 20 | 21 | if (user.Auth(access_token) == true) { 22 | // The further behaviour 23 | } else { 24 | // The further behaviour 25 | } 26 | } catch (std::exception ex) { 27 | std::cout << ex.what() << std::endl; 28 | } 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(VKAPI_TESTS LANGUAGES CXX) 3 | 4 | set(VKAPI_MAJOR_VERSION 0) 5 | set(VKAPI_MINOR_VERSION 0) 6 | set(VKAPI_PATCH_VERSION 5) 7 | 8 | set(MODULES 1 2) 9 | 10 | foreach(MODULE ${MODULES}) 11 | add_subdirectory(${MODULE}) 12 | endforeach() -------------------------------------------------------------------------------- /include/BotBase.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains the class for working with vkbot. 3 | * @file BotBase.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_BOTBASE_HPP 9 | #define VKAPI_BOTBASE_HPP 10 | 11 | #include "ClientBase.hpp" 12 | 13 | namespace vk 14 | { 15 | 16 | namespace base 17 | { 18 | 19 | namespace bot 20 | { 21 | 22 | constexpr const char* DEFAULT_TIME_WAIT = "25"; 23 | 24 | /** 25 | * @brief The class for working from bots by Long Poll Server. 26 | */ 27 | class BotBase : public ClientBase 28 | { 29 | public: 30 | // There are bot methods, but not all. 31 | // Description about below methods you can find at https://vk.com/dev/methods 32 | enum class METHODS 33 | { 34 | DELETE_COMMENT, 35 | RESTORE_COMMENT, 36 | ADD_ADDRESS, 37 | DELETE_ADDRESS, 38 | DISABLE_ONLINE, 39 | EDIT_ADDRESS, 40 | ENABLE_ONLINE, 41 | GET_BANNED, 42 | GET_LONG_POLL_SERVER, 43 | GET_LONG_POLL_SETTINGS, 44 | GET_MEMBERS, 45 | GET_ONLINE_STATUS, 46 | GET_TOKEN_PERMISSIONS, 47 | IS_MEMBER, 48 | SET_LONG_POLL_SETTINGS, 49 | SET_SETTINGS, 50 | CREATE_CHAT, 51 | DELETE_MESSAGE, 52 | DELETE_CHAT_PHOTO, 53 | DELETE_CONVERSATION, 54 | EDIT_MESSAGE, 55 | EDIT_CHAT, 56 | GET_BY_CONVERSATION_MESSAGE_ID, 57 | GET_BY_MESSAGE_ID, 58 | GET_CONVERSATION_MEMBERS, 59 | GET_CONVERSATIONS, 60 | GET_CONVERSATION_BY_ID, 61 | GET_HISTORY, 62 | GET_INVITE_LINK, 63 | PIN_MESSAGE, 64 | REMOVE_CHAT_USER, 65 | RESTORE_MESSAGE, 66 | SEARCH_MESSAGE, 67 | SEND_MESSAGE, 68 | UNPIN_MESSAGE, 69 | GET_USER, 70 | CLOSE_COMMENTS, 71 | CREATE_COMMENT, 72 | OPEN_COMMENTS, 73 | }; 74 | 75 | // The standard events which the server can return. 76 | enum class EVENTS 77 | { 78 | MESSAGE_NEW, 79 | MESSAGE_REPLY, 80 | MESSAGE_ALLOW, 81 | MESSAGE_DENY, 82 | PHOTO_NEW, 83 | AUDIO_NEW, 84 | VIDEO_NEW, 85 | WALL_REPLY_NEW, 86 | WALL_REPLY_EDIT, 87 | WALL_REPLY_DELETE, 88 | WALL_POST_NEW, 89 | WALL_REPOST, 90 | BOARD_POST_NEW, 91 | BOARD_POST_EDIT, 92 | BOARD_POST_DELETE, 93 | BOARD_POST_RESTORE, 94 | PHOTO_COMMENT_NEW, 95 | PHOTO_COMMENT_EDIT, 96 | PHOTO_COMMENT_DELETE, 97 | PHOTO_COMMENT_RESTORE, 98 | VIDEO_COMMENT_NEW, 99 | VIDEO_COMMENT_EDIT, 100 | VIDEO_COMMENT_DELETE, 101 | VIDEO_COMMENT_RESTORE, 102 | MARKET_COMMENT_NEW, 103 | MARKET_COMMENT_EDIT, 104 | MARKET_COMMENT_DELETE, 105 | MARKET_COMMENT_RESTORE, 106 | POLL_VOTE_NEW, 107 | GROUP_JOIN, 108 | GROUP_LEAVE, 109 | USER_BLOCK, 110 | USER_UNBLOCK, 111 | GROUP_CHANGE_SETTINGS, 112 | GROUP_CHANGE_PHOTO, 113 | GROUP_OFFICERS_EDIT, 114 | UNKNOWN 115 | }; 116 | 117 | struct Event 118 | { 119 | JsonType parameters; 120 | EVENTS type; 121 | 122 | Event(const EVENTS _type, JsonType _parameters) 123 | : parameters(_VKAPI_MOVE(_parameters)) 124 | , type(_type) 125 | {} 126 | }; 127 | 128 | public: 129 | /** 130 | * @param groupId: the id of the bot's group. 131 | * 132 | * @param timeWait: 133 | * The time of waiting for any event. 134 | * Default: DEFAULT_TIME_WAIT ("25"). 135 | */ 136 | _VKAPI_EXPLICIT BotBase(std::string groupId, std::string timeWait = DEFAULT_TIME_WAIT); 137 | 138 | ~BotBase() = default; 139 | 140 | /** 141 | * @brief The authorization function by the access token. 142 | * 143 | * @param accessToken: the access token. 144 | * 145 | * @retval 'true' if authorization is successfully and 'false' in another case. 146 | */ 147 | bool Auth(const std::string& accessToken) _VKAPI_FINAL; 148 | 149 | /** 150 | * @brief The function of waiting for any event after authorization. 151 | * 152 | * @retval If the event has happened the function returns the description about it. 153 | */ 154 | Event WaitForEvent(); 155 | 156 | /** 157 | * @brief The function of converting an enum's method to a string (URL). 158 | * 159 | * @param method: the enum's method. 160 | * 161 | * @retval a string (URL) of this method. 162 | */ 163 | _VKAPI_COMPLEXITY_FUNCTION 164 | _VKAPI_STATIC std::string MethodToString(METHODS method); 165 | 166 | /** 167 | * @brief The function of sending any request to the VK server. 168 | * 169 | * @param method: the enum's method. 170 | * @param parametersData: the data of parameters for your request. 171 | * 172 | * @retval the answer of your request in JsonType. 173 | */ 174 | JsonType SendRequest(METHODS method, const JsonType& parametersData); 175 | 176 | /** 177 | * @brief The function of sending any request to the VK server. 178 | * 179 | * @param method: your method in str format. 180 | * @param parametersData: the data of parameters for your request. 181 | * 182 | * @retval the answer of your request in JsonType. 183 | */ 184 | JsonType SendRequest(const std::string& method, const JsonType& parametersData) _VKAPI_OVERRIDE; 185 | 186 | #ifdef __CPLUSPLUS_OVER_11 187 | 188 | /** 189 | * @brief The function witch calls private function for sending a request in asynchronous mode. 190 | * 191 | * @param method: the enum's method. 192 | * @param parametersData: the data of parameters for your request. 193 | * 194 | * @retval the answer of your request in JsonType. 195 | */ 196 | auto SendRequestAsync(METHODS method, const JsonType& parametersData) -> std::future; 197 | 198 | /** 199 | * @brief The function witch calls private function for sending a request in asynchronous mode. 200 | * 201 | * @param method: your method in str format. 202 | * @param parametersData: the data of parameters for your request. 203 | * 204 | * @retval the answer of your request in JsonType. 205 | */ 206 | auto SendRequestAsync(const std::string& method, const JsonType& parametersData) -> std::future; 207 | 208 | #endif // __CPLUSPLUS_OVER_11 209 | 210 | protected: 211 | /** 212 | * @brief 213 | * Checking the data of parameters on validation. 214 | * If the following items won't be found the function will add it. 215 | * 216 | * @param parametersData: the data for checking validation. 217 | * 218 | * @retval the correctly data of parameters in JsonType. 219 | */ 220 | JsonType CheckValidationParameters(const JsonType& parametersData) _VKAPI_OVERRIDE; 221 | 222 | /** 223 | * @brief Get the type of events by string. 224 | * 225 | * @param typeEvent: the event in str. 226 | * 227 | * @retval the type of event in enum (EVENTS). 228 | */ 229 | _VKAPI_COMPLEXITY_FUNCTION 230 | _VKAPI_STATIC EVENTS GetTypeEvent(const std::string& typeEvent); 231 | 232 | private: 233 | 234 | #ifdef __CPLUSPLUS_OVER_11 235 | /** 236 | * @brief The static function of sending any request to the VK server. 237 | * 238 | * @param botHandle: a pointer to your handle of BotBase. 239 | * @param method: the enum's method. 240 | * @param parametersData: the data of parameters for your request. 241 | * 242 | * @retval the answer of your request in JsonType. 243 | */ 244 | _VKAPI_STATIC JsonType 245 | SendRequestAsyncByMethod_(BotBase* botHandle, METHODS method, const JsonType& parametersData); 246 | 247 | /** 248 | * @brief The static function of sending any request to the VK server. 249 | * 250 | * @param botHandle: a pointer to your handle of BotBase. 251 | * @param method: your method in str format. 252 | * @param parametersData: the data of parameters for your request. 253 | * 254 | * @retval the answer of your request in JsonType. 255 | */ 256 | _VKAPI_STATIC JsonType 257 | SendRequestAsyncByStr_(BotBase* botHandle, const std::string& method, const JsonType& parametersData); 258 | 259 | #endif // #ifdef __CPLUSPLUS_OVER_11 260 | 261 | private: 262 | const std::string m_groupId; 263 | std::string m_accessToken; 264 | 265 | JsonType m_previousEvent; 266 | 267 | std::string m_secretKey; 268 | std::string m_serverUrl; 269 | std::string m_timeStamp; 270 | 271 | std::string m_timeWait; 272 | }; 273 | 274 | } // namespace bot 275 | 276 | } // namespace base 277 | 278 | } // namespace vk 279 | 280 | #endif // VKAPI_BOTBASE_HPP 281 | -------------------------------------------------------------------------------- /include/ClientBase.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains general objects for working with VK API. 3 | * @file ClientBase.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_CLIENTBASE_HPP 9 | #define VKAPI_CLIENTBASE_HPP 10 | 11 | #include "Config.hpp" 12 | 13 | #include "Request.hpp" // Request 14 | #include "Utilities.hpp" // ConvertStrToUrlCode 15 | #include "Exceptions.hpp" // already_connected, not_connected, empty_argument 16 | #include "Defines.hpp" 17 | 18 | #ifdef __VKAPI_VERSION_ADDED_OPTIONAL 19 | #if __VKAPI_COMPILED_VERSION >= __VKAPI_VERSION_ADDED_OPTIONAL 20 | #include "Optional.hpp" 21 | #endif // __VKAPI_COMPILED_VERSION >= __VKAPI_VERSION_ADDED_OPTIONAL 22 | #endif // __VKAPI_VERSION_ADDED_OPTIONAL 23 | 24 | #include // cout, endl 25 | #include // rand 26 | #include // set 27 | #include // string 28 | #include // begin, end 29 | 30 | #ifdef __CPLUSPLUS_OVER_11 31 | #include // async, future 32 | #endif // __CPLUSPLUS_OVER_11 33 | 34 | #include "nlohmann/json.hpp" // nlohmann::json 35 | 36 | namespace vk 37 | { 38 | 39 | namespace base 40 | { 41 | 42 | #ifndef VKAPI_OPTIONAL_HPP 43 | typedef nlohmann::json JsonType; 44 | 45 | typedef long long int IdType; 46 | typedef unsigned long long UIdType; 47 | typedef bool IndicatorType; 48 | #endif // VKAPI_OPTIONAL_HPP 49 | 50 | #define VKAPI_INVALID_REQUEST "invalid_request" 51 | #define VKAPI_NEED_CAPTCHA "need_captcha" 52 | 53 | constexpr const char* VKAPI_API_URL = "https://api.vk.com/method/"; 54 | constexpr const char* VKAPI_AUTH_URL = "https://oauth.vk.com/token?"; 55 | constexpr const char* VKAPI_OAUTH_URL = "https://oauth.vk.com/authorize?"; 56 | constexpr const char* VKAPI_OAUTH_URL_SECOND = "https://oauth.vk.com/access_token?"; 57 | constexpr const char* VKAPI_API_VERSION = "5.120"; 58 | 59 | // The types of error which the VK server can return. 60 | // You can see the description of these on https://vk.com/dev/errors 61 | enum class VK_REQUEST_ERROR_TYPES : uint16_t 62 | { 63 | UNKNOWN_ERROR = 1, 64 | APP_IS_DISABLED = 2, 65 | UNKNOWN_METHOD = 3, 66 | INVALID_SIGNATURE = 4, 67 | AUTHORIZATION_FAILED = 5, 68 | TOO_MANY_REQUESTS = 6, 69 | NO_PERMISSIONS = 7, 70 | INVALID_REQUEST = 8, 71 | TOO_MANY_SIMILAR_ACTIONS = 9, 72 | INTERNAL_SERVER_ERROR = 10, 73 | TEST_MODE = 11, 74 | NEED_CAPTCHA = 14, 75 | ACCESS_DENIED = 15, 76 | NEED_HTTPS = 16, 77 | USER_VALIDATION_REQUIRED = 17, 78 | PAGE_DELETE_OR_BLOCKED = 18, 79 | ACTION_PROHIBITED_FOR_NON_STANDALONE_APP = 20, 80 | ACTION_FOR_ONLY_STANDOLE_OR_OPEN_APP = 21, 81 | METHOD_DISABLED = 23, 82 | COMMUNITY_ACCESS_TOKEN_INVALID = 27, 83 | APP_ACCESS_TOKEN_INVALID = 28, 84 | LIMIT_CALLING_REACHED = 29, 85 | PROFILE_IS_PRIVATE = 30, 86 | PARAMETER_OMITTED_OR_INVALID = 100, 87 | INVALID_APP_ID = 101, 88 | INVALID_USER_ID = 113, 89 | INVALID_TIMESTAMP = 150, 90 | ACCESS_ALBUM_PROHIBITED = 200, 91 | ACCESS_AUDIO_PROHIBITED = 201, 92 | ACCESS_TO_GROUP_PROHIBITED = 203, 93 | ALBUM_IS_FULL = 300, 94 | RECAPTCHA_NEEDED = 3300, 95 | PHONE_VALIDATION_NEEDED = 3301, 96 | PASSWORD_VALIDATION_NEEDED = 3302, 97 | OPT_APP_VALIDATION_NEEDED = 3303, 98 | EMAIL_CONFIRMATION_NEEDED = 3304, 99 | ASSERT_VOTES = 3305, 100 | TOKEN_EXTENSION_REQUIRED = 3609, 101 | USER_IS_DEACTIVATED = 3610, 102 | SERVICE_IS_DEACTIVATED_FOR_USER = 3611, 103 | OTHERS = 0 104 | }; 105 | 106 | // The base-parent class for UserBase & BotBase classes. 107 | // It has a standard function of Auth and some functions with working with URL scope. 108 | class ClientBase 109 | { 110 | public: 111 | ClientBase(); 112 | 113 | /** 114 | * @brief The function of authorization by access token. 115 | * 116 | * @note 117 | * ClientBase hasn't the own realization of auth's function because of 118 | * implementation for user and bot auths is differently. 119 | * 120 | * @param accessToken: the access token 121 | */ 122 | _VKAPI_VIRTUAL bool Auth(const std::string& accessToken) = 0; 123 | 124 | /** 125 | * @brief Add a scope to the main scope's list. 126 | * 127 | * @param scope: your scope. 128 | */ 129 | _VKAPI_VIRTUAL void AddScope(std::string scope); 130 | 131 | /** 132 | * @brief Add a list of scopes to the main scope's list. 133 | * 134 | * @param scopeList: your list of scopes. 135 | */ 136 | _VKAPI_VIRTUAL void AddScope(std::initializer_list scopeList); 137 | 138 | /** 139 | * @brief Clear the main scope's list. 140 | */ 141 | _VKAPI_VIRTUAL void ClearScope(); 142 | 143 | /** 144 | * @brief Generate a 32 bits random number. 145 | * 146 | * @note For example, it is used in the messaging request to the VK server. 147 | * 148 | * @retval a 32 bits random number. 149 | */ 150 | _VKAPI_STATIC uint32_t GetRandomId(); 151 | 152 | /** 153 | * @brief Indicates that you are connected to long poll. 154 | * 155 | * @return the connection indicator. 156 | */ 157 | _VKAPI_VIRTUAL bool IsAuthorized() const 158 | { return m_connectedToLongPoll; } 159 | 160 | /** 161 | * @brief The function sends any request to the VK serve. 162 | * 163 | * @param method: the method in str format. 164 | * @param parametersData: the data of parameters for the request. 165 | * 166 | * @retval the answer of the request in JsonType format. 167 | */ 168 | _VKAPI_VIRTUAL JsonType SendRequest(const std::string& method, const JsonType& parametersData) = 0; 169 | 170 | ClientBase& operator=(const ClientBase&) = delete; 171 | 172 | protected: 173 | /** 174 | * @brief Convert parameters data to URL format. 175 | * 176 | * @param parametersData: your parameters data which need to convert to URL format. 177 | * 178 | * @retval a string with parameters in URL format. 179 | */ 180 | _VKAPI_VIRTUAL std::string ConvertParametersDataToURL(const JsonType& parametersData); 181 | 182 | /** 183 | * @brief Check validation parameters on having items like access_token and others. 184 | * 185 | * @note If the data of parameters won't have necessary parameters the function will add it. 186 | * 187 | * @param parametersData: the data of parameters that you want to check. 188 | * 189 | * @retval the correctly data of parameters. 190 | */ 191 | _VKAPI_VIRTUAL JsonType CheckValidationParameters(const JsonType& parametersData) = 0; 192 | 193 | /** 194 | * @brief Get the error type by a string. 195 | * 196 | * @param errorStr: the error in string format. 197 | * 198 | * @retval the type of the error in enum format (VK_REQUEST_ERROR_TYPES). 199 | */ 200 | _VKAPI_STATIC VK_REQUEST_ERROR_TYPES GetRequestErrorType(const std::string& errorStr); 201 | 202 | protected: 203 | std::set m_scope; 204 | 205 | bool m_connectedToLongPoll; 206 | }; 207 | 208 | } // namespace base 209 | 210 | } // namespace vk 211 | 212 | #endif // VKAPI_CLIENTBASE_HPP 213 | -------------------------------------------------------------------------------- /include/Config.hpp.in: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains information about the project's version. 3 | * @file Config.hpp 4 | * @author qucals 5 | * @version @VKAPI_MAJOR_VERSION@.@VKAPI_MINOR_VERSION@.@VKAPI_PATCH_VERSION@ 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_CONFIG_HPP_IN 9 | #define VKAPI_CONFIG_HPP_IN 10 | 11 | namespace vk 12 | { 13 | 14 | /** 15 | * @brief Information the version of VKAPI in use. 16 | * 17 | * Represents the library's version as three levels: major revision 18 | * (increments with massive changes, additions, and enhancements), 19 | * minor revision (increments with backwards-compatible changes to the 20 | * major revision), and patchlevel (increments with fixes to the minor 21 | * revision). 22 | */ 23 | typedef struct __vkapi_version 24 | { 25 | short major; 26 | short minor; 27 | short patch; 28 | } __vkapi_version; 29 | 30 | #define __VKAPI_MAJOR_VERSION @VKAPI_MAJOR_VERSION@ 31 | #define __VKAPI_MINOR_VERSION @VKAPI_MINOR_VERSION@ 32 | #define __VKAPI_PATCH_VERSION @VKAPI_PATCH_VERSION@ 33 | 34 | #ifndef __VKAPI_MAJOR_VERSION 35 | #define __VKAPI_MAJOR_VERSION 0 36 | #endif // __VKAPI_MAJOR_VERSION 37 | 38 | #ifndef __VKAPI_MINOR_VERSION 39 | #define __VKAPI_MINOR_VERSION 0 40 | #endif // __VKAPI_MINOR_VERSION 41 | 42 | #ifndef __VKAPI_PATCH_VERSION 43 | #define __VKAPI_PATCH_VERSION 0 44 | #endif // __VKAPI_PATCH_VERSION 45 | 46 | /** 47 | * @brief Macro to determine VKAPI version program was compiled against. 48 | * 49 | * This macro fills in a __vkapi_version structure with the version of the 50 | * library you compiled against. This is determined by what header the 51 | * compiler uses. Note that if you dynamically linked the library, you might 52 | * have a slightly newer or older version at runtime. That version can be 53 | * determined with GUCpp_GetVersion(), which, unlike GUCpp_VERSION(), 54 | * is not a macro. 55 | * 56 | * @param x A pointer to a __vkapi_version struct to initialize. 57 | */ 58 | #define __VKAPI_VERSION(x) \ 59 | { \ 60 | (x)->major = __VKAPI_MAJOR_VERSION; \ 61 | (x)->minor = __VKAPI_MINOR_VERSION; \ 62 | (x)->patch = __VKAPI_PATCH_VERSION; \ 63 | } 64 | 65 | /** 66 | * This macro turns the version numbers into a numeric value: 67 | * @verbatim 68 | (1,2,3) -> (1203) 69 | @endverbatim 70 | * 71 | * This assumes that there will never be more than 100 patchlevels. 72 | */ 73 | #define __VKAPI_VERSION_NUM(X, Y, Z) \ 74 | ((X) * 1000 + (Y) * 100 + (Z)) 75 | 76 | /** 77 | * This is the version number macro for the current GUCpp version. 78 | */ 79 | #define __VKAPI_COMPILED_VERSION \ 80 | __VKAPI_VERSION_NUM(__VKAPI_MAJOR_VERSION, __VKAPI_MINOR_VERSION, __VKAPI_PATCH_VERSION) 81 | 82 | /** 83 | * This macro will evaluate to true if compiled with VKAPI at least X.Y.Z. 84 | */ 85 | #define __VKAPI_VERSION_ATLEAST(X, Y, Z) \ 86 | (__VKAPI_COMPILED_VERSION >= __VKAPI_VERSION_NUM(X, Y, Z)) 87 | 88 | } // namespace vk 89 | 90 | #endif // VKAPI_CONFIG_HPP_IN 91 | -------------------------------------------------------------------------------- /include/Defines.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains general defines about the language. 3 | * @file Defines.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_DEFINES_HPP 9 | #define VKAPI_DEFINES_HPP 10 | 11 | #include "Config.hpp" 12 | 13 | #ifndef _VKAPI_NO_IMPL 14 | #define _VKAPI_NO_IMPL 15 | #endif // _VKAPI_NO_IMPL 16 | 17 | #ifndef _VKAPI_STATIC 18 | #define _VKAPI_STATIC static 19 | #endif // _VKAPI_STATIC 20 | 21 | #if (__cplusplus >= 201103L) 22 | #define __CPLUSPLUS_OVER_11 23 | #endif // (__cplusplus >= 201103L) 24 | 25 | #if (__cplusplus >= 201402L) 26 | #define __CPLUSPLUS_OVER_14 27 | #endif // ((__cplusplus >= 201402L)) 28 | 29 | #if (__cplusplus >= 201703L) 30 | #define __CPLUSPLUS_OVER_17 31 | #endif // (__cplusplus >= 201703L) 32 | 33 | #if (__cplusplus >= 202002L) 34 | #define __CPLUSPLUS_OVER_20 35 | #endif // (__cplusplus >= 202002L) 36 | 37 | #ifdef __CPLUSPLUS_OVER_11 38 | #ifndef _VKAPI_OVERRIDE 39 | #define _VKAPI_OVERRIDE override 40 | #endif // _VKAPI_OVERRIDE 41 | 42 | #ifndef _VKAPI_FINAL 43 | #define _VKAPI_FINAL final 44 | #endif // _VKAPI_FINAL 45 | 46 | #ifndef _VKAPI_NOEXCEPT 47 | #define _VKAPI_NOEXCEPT noexcept 48 | #endif // _VKAPI_NOEXCEPT 49 | 50 | #ifndef _VKAPI_EXPLICIT 51 | #define _VKAPI_EXPLICIT explicit 52 | #endif // _VKAPI_EXPLICIT 53 | 54 | #ifndef _VKAPI_MOVE 55 | #include 56 | #define _VKAPI_MOVE(x) std::move(x) 57 | #endif // _VKAPI_MOVE(x) 58 | #else 59 | #ifndef _VKAPI_OVERRIDE 60 | #define _VKAPI_OVERRIDE 61 | #endif // _VKAPI_OVERRIDE 62 | 63 | #ifndef _VKAPI_FINAL 64 | #define _VKAPI_FINAL 65 | #endif // _VKAPI_FINAL 66 | 67 | #ifndef _VKAPI_NOEXCEPT 68 | #define _VKAPI_NOEXCEPT 69 | #endif // _VKAPI_NOEXCEPT 70 | 71 | #ifndef _VKAPI_EXPLICIT 72 | #define _VKAPI_EXPLICIT 73 | #endif // _VKAPI_EXPLICIT 74 | 75 | #ifndef _VKAPI_MOVE 76 | #define _VKAPI_MOVE(x) x 77 | #endif // _VKAPI_MOVE 78 | #endif 79 | 80 | #ifndef _VKAPI_VIRTUAL 81 | #define _VKAPI_VIRTUAL virtual 82 | #endif // _VKAPI_VIRTUAL 83 | 84 | #ifndef _VKAPI_INLINE 85 | #define _VKAPI_INLINE inline 86 | #endif // _VKAPI_INLINE 87 | 88 | #ifndef _VKAPI_UNUSED 89 | #define _VKAPI_UNUSED(x) (void)(x) 90 | #endif // _VKAPI_UNUSED 91 | 92 | #if defined(_MSC_VER) 93 | #define __DISABLE_WARNING_PUSH __pragma(warning(push)) 94 | #define __DISABLE_WARNING_POP __pragma(warning(pop)) 95 | #define __DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber)) 96 | #elif defined(__GNUC__) || defined(__clang__) 97 | #define __DO_PRAGMA(X) _Pragma(#X) 98 | #define __DISABLE_WARNING_PUSH __DO_PRAGMA("GCC diagnostic push") 99 | #define __DISABLE_WARNING_POP __DO_PRAGMA("GCC diagnostic pop") 100 | #define __DISABLE_WARNING(warningName) __DO_PRAGMA("GCC diagnostic ignored \"#warningName\"") 101 | #else 102 | #define __DISABLE_WARNING_PUSH 103 | #define __DISABLE_WARNING_POP 104 | #define __DISABLE_WARNING 105 | #endif 106 | 107 | #ifndef __VKAPI_VERSION_ADDED_OPTIONAL 108 | #define __VKAPI_VERSION_ADDED_OPTIONAL __VKAPI_VERSION_NUM(0, 0, 7) 109 | #endif // __VKAPI_VERSION_ADDED_OPTIONAL 110 | 111 | // TODO(#14): Write defines for disable complexity warnings 112 | #define _VKAPI_COMPLEXITY_FUNCTION 113 | 114 | #endif //VKAPI_DEFINES_HPP 115 | -------------------------------------------------------------------------------- /include/Exceptions.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains exceptions and information about them of this library. 3 | * @file Exceptions.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_EXCEPTIONS_HPP 9 | #define VKAPI_EXCEPTIONS_HPP 10 | 11 | #include 12 | #include 13 | 14 | #include "Defines.hpp" 15 | 16 | namespace vk 17 | { 18 | 19 | namespace ex 20 | { 21 | 22 | class BaseException : _VKAPI_VIRTUAL public std::exception 23 | { 24 | protected: 25 | std::string m_errorMessage; 26 | 27 | public: 28 | _VKAPI_EXPLICIT BaseException(std::string msg) 29 | : m_errorMessage(_VKAPI_MOVE(msg)) 30 | {} 31 | 32 | ~BaseException() _VKAPI_NOEXCEPT _VKAPI_OVERRIDE = default; 33 | 34 | const char* what() const _VKAPI_NOEXCEPT _VKAPI_OVERRIDE 35 | { 36 | return m_errorMessage.c_str(); 37 | } 38 | }; 39 | 40 | class AlreadyConnectedException : _VKAPI_VIRTUAL public BaseException 41 | { 42 | public: 43 | explicit AlreadyConnectedException() 44 | : BaseException("The client is already connected to Long Poll Server!") 45 | {} 46 | }; 47 | 48 | class NotConnectedException : _VKAPI_VIRTUAL public BaseException 49 | { 50 | public: 51 | explicit NotConnectedException() 52 | : BaseException("The client is not already connected to Long Poll Server!") 53 | {} 54 | }; 55 | 56 | class EmptyArgumentException : _VKAPI_VIRTUAL public BaseException 57 | { 58 | public: 59 | explicit EmptyArgumentException() 60 | : BaseException("The size of argument's symbols cannot equal zero!") 61 | {} 62 | }; 63 | 64 | class RequestError : _VKAPI_VIRTUAL public BaseException 65 | { 66 | public: 67 | explicit RequestError() 68 | : BaseException("Request returned unknown errors!") 69 | {} 70 | }; 71 | 72 | } // namespace ex 73 | 74 | } // namespace vk 75 | 76 | #endif // VKAPI_EXCEPTIONS_HPP 77 | -------------------------------------------------------------------------------- /include/Optional.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Describes optional class. 3 | * @file Optional.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_OPTIONAL_HPP 9 | #define VKAPI_OPTIONAL_HPP 10 | 11 | #include 12 | 13 | #include "Defines.hpp" 14 | #include "nlohmann/json.hpp" 15 | 16 | namespace vk 17 | { 18 | 19 | namespace base 20 | { 21 | 22 | #if defined(__CPLUSPLUS_OVER_17) 23 | 24 | #include 25 | 26 | template 27 | class Optional : public std::optional 28 | {}; 29 | 30 | #else 31 | 32 | template 33 | class BasicOptional 34 | { 35 | public: 36 | #if defined(__CPLUSPLUS_OVER_11) 37 | typedef _Type&& _RValue_Type; 38 | typedef const _Type& _ConstRef_Type; 39 | #else 40 | typedef const _Type& _RValue_Type; 41 | typedef const _Type& _ConstRef_Type; 42 | #endif // defined(__CPLUSPLUS_OVER_14) 43 | 44 | BasicOptional() 45 | : m_isSet(false) 46 | {} 47 | 48 | _VKAPI_EXPLICIT BasicOptional(_RValue_Type val) 49 | : m_val(_VKAPI_MOVE(val)) 50 | , m_isSet(true) 51 | {} 52 | 53 | void Set(_ConstRef_Type val) 54 | { 55 | m_val = val; 56 | m_isSet = true; 57 | } 58 | 59 | const _Type& Get() const& _VKAPI_NOEXCEPT 60 | { return m_val; } 61 | 62 | void Clear() 63 | { 64 | m_val = _Type(); 65 | m_isSet = false; 66 | } 67 | 68 | bool Empty() 69 | { return !m_isSet; } 70 | 71 | BasicOptional& operator=(_ConstRef_Type val) 72 | { 73 | m_val = val; 74 | m_isSet = true; 75 | return *this; 76 | } 77 | 78 | _VKAPI_EXPLICIT operator _Type() const 79 | { 80 | return m_val; 81 | } 82 | 83 | bool operator==(const bool& val) const 84 | { return m_isSet == val; } 85 | 86 | private: 87 | _Type m_val; 88 | bool m_isSet; 89 | }; 90 | 91 | template 92 | class Optional : public BasicOptional 93 | {}; 94 | 95 | #endif // defined(__CPLUSPLUS_OVER_17) 96 | 97 | typedef long long int IdType; 98 | typedef unsigned long long UIdType; 99 | typedef bool IndicatorType; 100 | 101 | typedef nlohmann::json JsonType; 102 | 103 | typedef Optional Opt_IdType; 104 | typedef Optional Opt_UIdType; 105 | typedef Optional Opt_StrType; 106 | typedef Optional Opt_FloatType; 107 | typedef Optional Opt_JsonType; 108 | typedef Optional&> Opt_IdArrayType; 109 | typedef Optional Opt_IndicatorType; 110 | 111 | } // namespace base 112 | 113 | } // namespace vk 114 | 115 | #endif //VKAPI_OPTIONAL_HPP 116 | -------------------------------------------------------------------------------- /include/Request.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Describes the class for working with CURL. 3 | * @file Request.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_REQUEST_HPP 9 | #define VKAPI_REQUEST_HPP 10 | 11 | #include "Defines.hpp" 12 | #include "Utilities.hpp" // ConvertStrToUrlCode 13 | 14 | #include // curl 15 | #include // string 16 | 17 | namespace vk 18 | { 19 | 20 | namespace base 21 | { 22 | 23 | constexpr long APPLY_CURLOPT = 1L; 24 | constexpr long NO_APPLY_CURLOPT = 0L; 25 | constexpr long MAXREGIDS = 50L; 26 | constexpr const char* USERAGENT = "VKAPI Client"; 27 | 28 | /** 29 | * @brief The class for working with request. 30 | */ 31 | class Request 32 | { 33 | public: 34 | Request() = delete; 35 | ~Request() = delete; 36 | 37 | Request& operator=(const Request&) = delete; 38 | 39 | /** 40 | * @brief Sending your request to the VK server. 41 | * 42 | * @param url: the request in url format. 43 | * @param postData: the additional parameters which need to add to the request. 44 | * 45 | * @retval an answer in a string. 46 | */ 47 | _VKAPI_STATIC std::string Send(const std::string& url, 48 | const std::string& postData); 49 | 50 | protected: 51 | _VKAPI_STATIC std::size_t CurlWriteData(char* ptr, size_t size, 52 | size_t nmemb, std::string* data); 53 | }; 54 | 55 | } // namespace base 56 | 57 | } // namespace vk 58 | 59 | #endif // VKAPI_REQUEST_HPP 60 | -------------------------------------------------------------------------------- /include/UserBase.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Describes the class for working with VK account. 3 | * @file UserBase.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_USERBASE_HPP 9 | #define VKAPI_USERBASE_HPP 10 | 11 | #include "ClientBase.hpp" 12 | 13 | namespace vk 14 | { 15 | 16 | namespace base 17 | { 18 | 19 | namespace user 20 | { 21 | 22 | /** 23 | * @brief The class for working from users by Long Poll Server. 24 | */ 25 | class UserBase : public ClientBase 26 | { 27 | public: 28 | // There are user's methods, but not all. 29 | // Description about below methods you can find at https://vk.com/dev/methods 30 | enum class METHODS 31 | { 32 | ACCOUNT_BAN, 33 | ACCOUNT_CHANGE_PASSWORD, 34 | ACCOUNT_GET_ACTIVE_OFFERS, 35 | ACCOUNT_GET_APP_PERMISSIONS, 36 | ACCOUNT_GET_BANNED, 37 | ACCOUNT_GET_COUNTERS, 38 | ACCOUNT_GET_INFO, 39 | ACCOUNT_GET_PROFILE_INFO, 40 | ACCOUNT_GET_PUSH_SETTINGS, 41 | ACCOUNT_REGISTER_DEVICE, 42 | ACCOUNT_SAVE_PROFILE_INFO, 43 | ACCOUNT_SET_INFO, 44 | ACCOUNT_SET_PUSH_SETTINGS, 45 | ACCOUNT_UNBAN, 46 | ACCOUNT_UNREGISTER_DEVICE, 47 | BOARD_ADD_TOPIC, 48 | BOARD_CLOSE_TOPIC, 49 | BOARD_CREATE_COMMENT, 50 | BOARD_DELETE_COMMENT, 51 | BOARD_DELETE_TOPIC, 52 | BOARD_EDIT_COMMENT, 53 | BOARD_EDIT_TOPIC, 54 | BOARD_FIX_TOPIC, 55 | BOARD_GET_COMMENTS, 56 | BOARD_GET_TOPICS, 57 | BOARD_OPEN_TOPIC, 58 | BOARD_RESTORE_COMMENT, 59 | BOARD_UNFIX_TOPIC, 60 | DATABASE_GET_CHAIRS, 61 | DATABASE_GET_CITIES, 62 | DATABASE_GET_CITIES_BY_ID, 63 | DATABASE_GET_COUNTRIES, 64 | DATABASE_GET_FACULTIES, 65 | DATABASE_GET_METRO_STATIONS, 66 | DATABASE_GET_REGIONS, 67 | DATABASE_GET_SCHOOL_CLASSES, 68 | DATABASE_GET_SCHOOLS, 69 | DATABASE_GET_UNIVERSITIES, 70 | DOCS_ADD, 71 | DOCS_DELETE, 72 | DOCS_EDIT, 73 | DOCS_GET, 74 | DOCS_GET_BY_ID, 75 | DOCS_GET_MESSAGES_UPLOAD_SERVER, 76 | DOCS_GET_TYPES, 77 | DOCS_GET_UPLOAD_SERVER, 78 | DOCS_GET_WALL_UPLOAD_SERVER, 79 | DOCS_SAVE, 80 | DOCS_SEARCH, 81 | EXECUTE, 82 | FAVE_ADD_ARTICLE, 83 | FAVE_ADD_LINK, 84 | FAVE_ADD_PAGE, 85 | FAVE_ADD_POST, 86 | FAVE_ADD_PRODUCT, 87 | FAVE_ADD_TAG, 88 | FAVE_ADD_VIDEO, 89 | FAVE_EDIT_TAG, 90 | FAVE_GET, 91 | FAVE_GET_PAGES, 92 | FAVE_GET_TAGS, 93 | FAVE_MARK_SEEN, 94 | FAVE_REMOVE_ARTICLE, 95 | FAVE_REMOVE_LINK, 96 | FAVE_REMOVE_PAGE, 97 | FAVE_REMOVE_POST, 98 | FAVE_REMOVE_PRODUCT, 99 | FAVE_REMOVE_TAG, 100 | FAVE_REMOVE_VIDEO, 101 | FAVE_REORDER_TAGS, 102 | FAVE_SET_PAGE_TAGS, 103 | FAVE_SET_TAGS, 104 | FAVE_TRACK_PAGE_INTERACTION, 105 | FRIENDS_ADD, 106 | FRIENDS_ADD_LIST, 107 | FRIENDS_ARE_FRIENDS, 108 | FRIENDS_DELETE, 109 | FRIENDS_DELETE_ALL_REQUESTS, 110 | FRIENDS_DELETE_LIST, 111 | FRIENDS_EDIT, 112 | FRIENDS_EDIT_LIST, 113 | FRIENDS_GET, 114 | FRIENDS_GET_APP_USERS, 115 | FRIENDS_GET_BY_PHONES, 116 | FRIENDS_GET_LISTS, 117 | FRIENDS_GET_MUTUAL, 118 | FRIENDS_GET_ONLINE, 119 | FRIENDS_GET_RECENT, 120 | FRIENDS_GET_REQUESTS, 121 | FRIENDS_GET_SUGGESTIONS, 122 | FRIENDS_SEARCH, 123 | GIFTS_GET, 124 | GROUPS_ADD_ADDRESS, 125 | GROUPS_ADD_CALLBACK_SERVER, 126 | GROUPS_ADD_LINK, 127 | GROUPS_APPROVE_REQUEST, 128 | GROUPS_BAN, 129 | GROUPS_CREATE, 130 | GROUPS_DELETE_ADDRESS, 131 | GROUPS_DELETE_CALLBACK_SERVER, 132 | GROUPS_DELETE_LINK, 133 | GROUPS_DISABLE_ONLINE, 134 | GROUPS_EDIT, 135 | GROUPS_EDIT_ADDRESS, 136 | GROUPS_EDIT_CALLBACK_SERVER, 137 | GROUPS_EDIT_LINK, 138 | GROUPS_EDIT_MANAGER, 139 | GROUPS_ENABLE_ONLINE, 140 | GROUPS_GET, 141 | GROUPS_GET_ADDRESSES, 142 | GROUPS_GET_BANNED, 143 | GROUPS_GET_BY_ID, 144 | GROUPS_GET_CALLBACK_CONFIRMATION_CODE, 145 | GROUPS_GET_CALLBACK_SERVER, 146 | GROUPS_GET_CALLBACK_SETTINGS, 147 | GROUPS_GET_CATALOG, 148 | GROUPS_GET_CATALOG_INFO, 149 | GROUPS_GET_INVITED_USERS, 150 | GROUPS_GET_INVITIES, 151 | GROUPS_GET_LONG_POLL_SERVER, 152 | GROUPS_GET_LONG_POLL_SETTINGS, 153 | GROUPS_GET_MEMBERS, 154 | GROUPS_GET_ONLINE_STATUS, 155 | GROUPS_GET_REQUESTS, 156 | GROUPS_GET_SETTINGS, 157 | GROUPS_GET_TAG_LIST, 158 | GROUPS_GET_TOKEN_PERMISSIONS, 159 | GROUPS_INVITE, 160 | GROUPS_IS_MEMBER, 161 | GROUPS_JOIN, 162 | GROUPS_LEAVE, 163 | GROUPS_REMOVE_USER, 164 | GROUPS_REORDER_LINK, 165 | GROUPS_SEARCH, 166 | GROUPS_SET_CALLBACK_SETTINGS, 167 | GROUPS_SET_LONG_POLL_SETTINGS, 168 | GROUPS_SET_SETTINGS, 169 | GROUPS_SET_USER_NOTE, 170 | GROUPS_TAG_ADD, 171 | GROUPS_TAG_BIND, 172 | GROUPS_TAG_DELETE, 173 | GROUPS_TAG_UPDATE, 174 | GROUPS_UNBAN, 175 | LEADFORMS_CREATE, 176 | LEADFORMS_DELETE, 177 | LEADFORMS_GET, 178 | LEADFORMS_GET_LEADS, 179 | LEADFORMS_GET_UPLOAD_URL, 180 | LEADFORMS_LIST, 181 | LEADFORMS_UPDATE, 182 | LIKES_ADD, 183 | LIKES_DELETE, 184 | LIKES_GET_LIST, 185 | LIKES_IS_LIKED, 186 | MARKET_ADD, 187 | MARKET_ADD_ALBUM, 188 | MARKET_ADD_TO_ALBUM, 189 | MARKET_CREATE_COMMENT, 190 | MARKET_DELETE, 191 | MARKET_DELETE_ALBUM, 192 | MARKET_DELETE_COMMENT, 193 | MARKET_EDIT, 194 | MARKET_EDIT_ALBUM, 195 | MARKET_EDIT_COMMENT, 196 | MARKET_EDIT_ORDER, 197 | MARKET_GET, 198 | MARKET_GET_ALBUM_BY_ID, 199 | MARKET_GET_ALBUMS, 200 | MARKET_GET_BY_ID, 201 | MARKET_GET_CATEGORIES, 202 | MARKET_GET_COMMENTS, 203 | MARKET_GET_GROUP_ORDERS, 204 | MARKET_GET_ORDER_BY_ID, 205 | MARKET_GET_ORDER_ITEMS, 206 | MARKET_GET_ORDERS, 207 | MARKET_REMOVE_FROM_ALBUM, 208 | MARKET_REORDER_ALBUMS, 209 | MARKET_REORDER_ITEMS, 210 | MARKET_REPORT, 211 | MARKET_REPORT_COMMENT, 212 | MARKET_RESTORE, 213 | MARKET_RESTORE_COMMENT, 214 | MARKET_SEARCH, 215 | MESSAGES_ADD_CHAT_USER, 216 | MESSAGES_ALLOW_MESSAGES_FROM_GROUP, 217 | MESSAGES_CREATE_CHAT, 218 | MESSAGES_DELETE, 219 | MESSAGES_DELETE_CHAT_PHOTO, 220 | MESSAGES_DELETE_CONVERSATION, 221 | MESSAGES_DENY_MESSAGES_FROM_GROUP, 222 | MESSAGES_EDIT, 223 | MESSAGES_EDIT_CHAT, 224 | MESSAGES_GET_BY_CONVERSATION_MESSAGE_ID, 225 | MESSAGES_GET_BY_ID, 226 | MESSAGES_GET_CHAT, 227 | MESSAGES_GET_CHAT_PREVIEW, 228 | MESSAGES_GET_CONVERSATIONS, 229 | MESSAGES_GET_CONVERSATION_BY_ID, 230 | MESSAGES_GET_HISTORY, 231 | MESSAGES_GET_HISTORY_ATTACHMENTS, 232 | MESSAGES_GET_IMPORTANT_MESSAGES, 233 | MESSAGES_GET_INVITE_LINK, 234 | MESSAGES_GET_LAST_ACTIVITY, 235 | MESSAGES_GET_LONG_POLL_HISTORY, 236 | MESSAGES_GET_LONG_POLL_SERVER, 237 | MESSAGES_IS_MESSAGES_FROM_GROUP_ALLOWED, 238 | MESSAGES_JOIN_CHAT_BY_INVITE_LINK, 239 | MESSAGES_MARK_AS_ANSWERED_CONVERSATION, 240 | MESSAGES_MARK_AS_IMPORTANT, 241 | MESSAGES_MARK_AS_IMPORTANT_CONVERSATION, 242 | MESSAGES_MARK_AS_READ, 243 | MESSAGES_PIN, 244 | MESSAGES_REMOVE_CHAT_USER, 245 | MESSAGES_RESTORE, 246 | MESSAGES_SEARCH, 247 | MESSAGES_SEARCH_CONVERSATIONS, 248 | MESSAGES_SEND, 249 | MESSAGES_SEND_MESSAGE_EVENT_ANSWER, 250 | MESSAGES_SET_ACTIVITY, 251 | MESSAGES_SET_CHAT_PHOTO, 252 | MESSAGES_UNPIN, 253 | NEWSFEED_ADD_BAN, 254 | NEWSFEED_DELETE_BAN, 255 | NEWSFEED_DELETE_LIST, 256 | NEWSFEED_GET, 257 | NEWSFEED_GET_BANNED, 258 | NEWSFEED_GET_COMMENTS, 259 | NEWSFEED_GET_LISTS, 260 | NEWSFEED_GET_MENTIONS, 261 | NEWSFEED_GET_RECOMMENDED, 262 | NEWSFEED_GET_SUGGESTED_SOURCES, 263 | NEWSFEED_IGNORE_ITEM, 264 | NEWSFEED_SAVE_LIST, 265 | NEWSFEED_SEARCH, 266 | NEWSFEED_UNIGNORED_ITEM, 267 | NEWSFEED_UNSUBSCRIBE, 268 | NOTES_ADD, 269 | NOTES_CREATE_COMMENT, 270 | NOTES_DELETE, 271 | NOTES_DELETE_COMMENT, 272 | NOTES_EDIT, 273 | NOTES_EDIT_COMMENT, 274 | NOTES_GET, 275 | NOTES_GET_BY_ID, 276 | NOTES_GET_COMMENTS, 277 | NOTES_RESTORE_COMMENTS, 278 | NOTIFICATIONS_GET, 279 | NOTIFICATIONS_MARK_AS_VIEWED, 280 | PAGES_GET, 281 | PAGES_GET_HISTORY, 282 | PAGES_GET_TITLES, 283 | PAGES_GET_VERSION, 284 | PAGES_PARSE_WIKI, 285 | PAGES_SAVE, 286 | PAGES_SAVE_ACCESS, 287 | PHOTOS_CONFIRM_TAG, 288 | PHOTOS_COPY, 289 | PHOTOS_CREATE_ALBUM, 290 | PHOTOS_CREATE_COMMENT, 291 | PHOTOS_DELETE, 292 | PHOTOS_DELETE_ALBUM, 293 | PHOTOS_DELETE_COMMENT, 294 | PHOTOS_EDIT, 295 | PHOTOS_EDIT_ALBUM, 296 | PHOTOS_EDIT_COMMENT, 297 | PHOTOS_GET, 298 | PHOTOS_GET_ALBUM, 299 | PHOTOS_GET_ALBUMS_COUNT, 300 | PHOTOS_GET_ALL, 301 | PHOTOS_GET_ALL_COMMENTS, 302 | PHOTOS_GET_BY_ID, 303 | PHOTOS_GET_CHAT_UPLOAD_SERVER, 304 | PHOTOS_GET_COMMENTS, 305 | PHOTOS_GET_MARKET_ALBUM_UPLOAD_SERVER, 306 | PHOTOS_GET_MARKET_UPLOAD_SERVER, 307 | PHOTOS_GET_MESSAGES_UPLOAD_SERVER, 308 | PHOTOS_GET_NEW_TAGS, 309 | PHOTOS_GET_OWNER_COVER_PHOTO_UPLOAD_SERVER, 310 | PHOTOS_GET_OWNER_PHOTO_UPLOAD_SERVER, 311 | PHOTOS_GET_TAGS, 312 | PHOTOS_GET_UPLOAD_SERVER, 313 | PHOTOS_GET_USER_PHOTOS, 314 | PHOTOS_GET_WALL_UPLOAD_SERVER, 315 | PHOTOS_MAKE_COVER, 316 | PHOTOS_MOVE, 317 | PHOTOS_PUT_TAG, 318 | PHOTOS_REMOVE_TAG, 319 | PHOTOS_REORDER_ALBUMS, 320 | PHOTOS_REODER_PHOTOS, 321 | PHOTOS_REPORT, 322 | PHOTOS_REPORT_COMMENT, 323 | PHOTOS_RESTORE, 324 | PHOTOS_RESTORE_COMMENT, 325 | PHOTOS_SAVE, 326 | PHOTOS_SAVE_MARKET_ALBUM_PHOTO, 327 | PHOTOS_SAVE_MARKET_PHOTO, 328 | PHOTOS_SAVE_MESSAGES_PHOTO, 329 | PHOTOS_SAVE_OWNER_COVER_PHOTO, 330 | PHOTOS_SAVE_OWNER_PHOTO, 331 | PHOTOS_SAVE_WALL_PHOTO, 332 | PHOTOS_SEARCH, 333 | POLLS_ADD_VOTE, 334 | POLLS_CREATE, 335 | POLLS_DELETE_VOTE, 336 | POLLS_EDIT, 337 | POLLS_GET_BACKGROUNDS, 338 | POLLS_GET_BY_ID, 339 | POLLS_GET_PHOTO_UPLOAD_SERVER, 340 | POLLS_GET_VOTES, 341 | POLLS_SAVE_PHOTO, 342 | PRETTYCARDS_CREATE, 343 | PRETTYCARDS_DELETE, 344 | PRETTYCARDS_EDIT, 345 | PRETTYCARDS_GET, 346 | PRETTYCARDS_GET_BY_ID, 347 | PRETTYCARDS_GET_UPLOAD_URL, 348 | SEARCH_GET_HINTS, 349 | STATS_GET, 350 | STATS_GET_POST_REACH, 351 | STATS_TRACK_VISITOR, 352 | STATUS_GET, 353 | STATUS_SET, 354 | STORIES_BAN_OWNER, 355 | STORIES_DELETE, 356 | STORIES_GET, 357 | STORIES_GET_BANNED, 358 | STORIES_GET_BY_ID, 359 | STORIES_GET_PHOTO_UPLOAD_SERVER, 360 | STORIES_GET_REPLIES, 361 | STORIES_GET_STATS, 362 | STORIES_GET_VIDEO_UPLOAD_SERVER, 363 | STORIES_GET_VIEWERS, 364 | STORIES_HIDE_ALL_REPLIES, 365 | STORIES_HIDE_REPLY, 366 | STORIES_SAVE, 367 | STORIES_SEARCH, 368 | STORIES_UNBAN_OWNER, 369 | USERS_GET, 370 | USERS_GET_FOLLOWERS, 371 | USERS_GET_SUBSCRIPTIONS, 372 | USERS_REPORT, 373 | USERS_SEARCH, 374 | UTILS_CHECK_LINK, 375 | VIDEO_ADD, 376 | VIDEO_ADD_ALBUM, 377 | VIDEO_ADD_TO_ALBUM, 378 | VIDEO_CREATE_COMMENT, 379 | VIDEO_DELETE, 380 | VIDEO_DELETE_ALBUM, 381 | VIDEO_DELETE_COMMENT, 382 | VIDEO_EDIT, 383 | VIDEO_EDIT_ALBUM, 384 | VIDEO_EDIT_COMMENT, 385 | VIDEO_GET, 386 | VIDEO_GET_ALBUM_BY_ID, 387 | VIDEO_GET_ALBUMS, 388 | VIDEO_GET_ALBUMS_BY_VIDEO, 389 | VIDEO_GET_COMMENTS, 390 | VIDEO_REMOVE_FROM_ALBUMS, 391 | VIDEO_REORDER_ALBUMS, 392 | VIDEO_REORDER_VIDEOS, 393 | VIDEO_REPORT, 394 | VIDEO_REPORT_COMMENT, 395 | VIDEO_RESTORE, 396 | VIDEO_RESTORE_COMMENT, 397 | VIDEO_SAVE, 398 | VIDEO_SEARCH, 399 | WALL_CHECK_COPYRIGHT_LINK, 400 | WALL_CLOSE_COMMENTS, 401 | WALL_CREATE_COMMENT, 402 | WALL_DELETE, 403 | WALL_DELETE_COMMENT, 404 | WALL_EDIT, 405 | WALL_EDIT_ADS_STEALTH, 406 | WALL_EDIT_COMMENT, 407 | WALL_GET, 408 | WALL_GET_BY_ID, 409 | WALL_GET_COMMENT, 410 | WALL_GET_REPOSTS, 411 | WALL_OPEN_COMMENTS, 412 | WALL_PIN, 413 | WALL_POST, 414 | WALL_POST_ADS_STEALTH, 415 | WALL_REPORT_COMMENT, 416 | WALL_REPORT_POST, 417 | WALL_REPOST, 418 | WALL_RESTORE, 419 | WALL_RESTORE_COMMENT, 420 | WALL_SEARCH, 421 | WALL_UNPIN, 422 | }; 423 | 424 | // There are types' messages which the VK server can return during authorization. 425 | enum class VALIDATION_TYPES 426 | { 427 | TWOFA_SMS, 428 | TWOFA_APP, 429 | UNKNOWN 430 | }; 431 | 432 | public: 433 | /** 434 | * @param appId: the id of the application. 435 | * @param appSecureKey: the secure key of the application. 436 | */ 437 | UserBase(std::string appId, std::string appSecureKey); 438 | 439 | ~UserBase() = default; 440 | 441 | /** 442 | * @brief The authorization function by login and password. 443 | * 444 | * @param login: your login. 445 | * @param password: your password. 446 | * 447 | * @retval 'true' if auth is successfully and 'false' in another case. 448 | */ 449 | _VKAPI_VIRTUAL bool Auth(std::string& login, std::string& password); 450 | 451 | /** 452 | * @brief The authorization function by access token. 453 | * 454 | * @param accessToken: your access token. 455 | * 456 | * @retval 'true' if auth is successfully and 'false' in another case. 457 | */ 458 | bool Auth(const std::string& accessToken) _VKAPI_FINAL; 459 | 460 | /** 461 | * @brief The function of sending any request to the VK server. 462 | * 463 | * @param method: the enum's method. 464 | * @param parametersData: the data of parameters for the request. 465 | * 466 | * @retval the answer of the request in JsonType format. 467 | */ 468 | JsonType SendRequest(METHODS method, const JsonType& parametersData); 469 | 470 | /** 471 | * @brief The function sends any request to the VK serve. 472 | * 473 | * @param method: the method in str format. 474 | * @param parametersData: the data of parameters for the request. 475 | * 476 | * @retval the answer of the request in JsonType format. 477 | */ 478 | JsonType SendRequest(const std::string& method, const JsonType& parametersData) _VKAPI_OVERRIDE; 479 | 480 | /** 481 | * @brief The function of converting an enum's method to a string (URL). 482 | * 483 | * @param method: enum's method. 484 | * 485 | * @retval a string of this method in URL format. 486 | */ 487 | _VKAPI_COMPLEXITY_FUNCTION 488 | _VKAPI_STATIC std::string MethodToString(METHODS method); 489 | 490 | /** 491 | * @brief Get the validation type for auth by its description in string format. 492 | * 493 | * @param descriptionType: the description of the type. 494 | * 495 | * @retval the validation type in enum format (VALIDATION_TYPES). 496 | */ 497 | _VKAPI_STATIC VALIDATION_TYPES GetValidationType(const std::string& descriptionType); 498 | 499 | UserBase& operator=(const UserBase&) = delete; 500 | 501 | protected: 502 | /** 503 | * @brief Checking validation parameters on having items like access_token and others. 504 | * 505 | * @note If the data of parameters won't have the function will add it. 506 | * 507 | * @param parametersData: the data of parameters that you want to check. 508 | * 509 | * @retval the correctly data of parameters. 510 | */ 511 | JsonType CheckValidationParameters(const JsonType& parametersData) _VKAPI_OVERRIDE; 512 | 513 | /** 514 | * @brief Get the URL to the captcha. 515 | * 516 | * @param parametersData: the parameters data which was sent in the previous request. 517 | * @param answerData: the answer which was received in the previous request. 518 | * 519 | * @retval the URL to the captcha. 520 | */ 521 | _VKAPI_STATIC std::string GetURLCaptcha(JsonType& parametersData, const JsonType& answerData); 522 | 523 | private: 524 | const std::string m_appId; 525 | const std::string m_appSecureKey; 526 | 527 | std::string m_accessToken; 528 | std::string m_userId; 529 | }; 530 | 531 | } // namespace user 532 | 533 | } // namespace base 534 | 535 | } // namespace vk 536 | 537 | #endif // VKAPI_USERBASE_HPP 538 | -------------------------------------------------------------------------------- /include/Utilities.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains additional functions for working with the library. 3 | * @file Utilities.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #ifndef VKAPI_UTILITIES_HPP 9 | #define VKAPI_UTILITIES_HPP 10 | 11 | #include "Defines.hpp" 12 | 13 | #include // string 14 | #include // curl 15 | 16 | #ifndef __CPLUSPLUS_OVER_11 17 | #include 18 | #endif // __CPLUSPLUS_OVER_11 19 | 20 | namespace vk 21 | { 22 | 23 | namespace utilities 24 | { 25 | 26 | std::string ConvertStrToUrlCode(const std::string& str); 27 | 28 | std::string ToString(int val); 29 | std::string ToString(unsigned val); 30 | std::string ToString(long val); 31 | std::string ToString(unsigned long val); 32 | std::string ToString(long long val); 33 | std::string ToString(unsigned long long val); 34 | std::string ToString(float val); 35 | std::string ToString(double val); 36 | std::string ToString(long double val); 37 | 38 | } // namespace utilities 39 | 40 | } // namespace vk 41 | 42 | #endif // VKAPI_UTILITIES_HPP 43 | -------------------------------------------------------------------------------- /src/BotBase.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains the class for working with vkbot. 3 | * @file BotBase.cpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #include "BotBase.hpp" 9 | 10 | namespace vk 11 | { 12 | 13 | namespace base 14 | { 15 | 16 | namespace bot 17 | { 18 | 19 | BotBase::BotBase(std::string groupId, std::string timeWait) 20 | : m_groupId(_VKAPI_MOVE(groupId)) 21 | , m_timeWait(_VKAPI_MOVE(timeWait)) 22 | {} 23 | 24 | bool BotBase::Auth(const std::string& accessToken) 25 | { 26 | if (IsAuthorized()) { throw ex::AlreadyConnectedException(); } 27 | if (accessToken.empty()) { throw ex::EmptyArgumentException(); } 28 | 29 | m_accessToken = accessToken; 30 | 31 | JsonType parametersData = { 32 | { "access_token", m_accessToken }, 33 | { "group_id", m_groupId }, 34 | { "v", VKAPI_API_VERSION } 35 | }; 36 | 37 | const std::string method = MethodToString(METHODS::GET_LONG_POLL_SERVER); 38 | const std::string url = VKAPI_API_URL + method; 39 | JsonType response = JsonType::parse(Request::Send(url, ConvertParametersDataToURL(parametersData))); 40 | 41 | if (response.find("error") != response.end()) { 42 | throw ex::RequestError(); 43 | // TODO (#12): Add error handling when BotBase::Auth failed 44 | } else { 45 | JsonType answerDataStr = response["response"]; 46 | 47 | m_secretKey = answerDataStr["key"].get(); 48 | m_serverUrl = answerDataStr["server"].get(); 49 | m_timeStamp = answerDataStr["ts"].get(); 50 | 51 | m_connectedToLongPoll = true; 52 | } 53 | 54 | return m_connectedToLongPoll; 55 | } 56 | 57 | BotBase::Event BotBase::WaitForEvent() 58 | { 59 | if (!IsAuthorized()) { throw ex::NotConnectedException(); } 60 | 61 | JsonType parametersData = { 62 | { "key", m_secretKey }, 63 | { "ts", m_timeStamp }, 64 | { "wait", m_timeWait } 65 | }; 66 | 67 | std::string url = m_serverUrl + "?act=a_check&"; 68 | JsonType response = JsonType::parse(Request::Send(url, ConvertParametersDataToURL(parametersData))); 69 | 70 | if (response.find("ts") != response.end()) { 71 | m_timeStamp = response.at("ts").get(); 72 | } 73 | 74 | JsonType updates = response.at("updates")[0]; 75 | std::string eventStr = updates.at("type").get(); 76 | 77 | return Event(GetTypeEvent(eventStr), updates); 78 | } 79 | 80 | _VKAPI_COMPLEXITY_FUNCTION 81 | std::string BotBase::MethodToString(const METHODS method) 82 | { 83 | switch (method) { 84 | case METHODS::DELETE_COMMENT: 85 | return "board.deleteComment"; 86 | case METHODS::RESTORE_COMMENT: 87 | return "board.restoreComment"; 88 | case METHODS::ADD_ADDRESS: 89 | return "groups.addAddress"; 90 | case METHODS::DELETE_ADDRESS: 91 | return "groups.deleteAddress"; 92 | case METHODS::DISABLE_ONLINE: 93 | return "groups.disableOnline"; 94 | case METHODS::EDIT_ADDRESS: 95 | return "groups.editAddress"; 96 | case METHODS::ENABLE_ONLINE: 97 | return "groups.enableOnline"; 98 | case METHODS::GET_BANNED: 99 | return "groups.getBanned"; 100 | case METHODS::GET_LONG_POLL_SERVER: 101 | return "groups.getLongPollServer"; 102 | case METHODS::GET_LONG_POLL_SETTINGS: 103 | return "groups.getLongPollSettings"; 104 | case METHODS::GET_MEMBERS: 105 | return "groups.getMembers"; 106 | case METHODS::GET_ONLINE_STATUS: 107 | return "groups.getOnlineStatus"; 108 | case METHODS::GET_TOKEN_PERMISSIONS: 109 | return "groups.getTokenPermissions"; 110 | case METHODS::IS_MEMBER: 111 | return "groups.isMember"; 112 | case METHODS::SET_LONG_POLL_SETTINGS: 113 | return "groups.setLongPollSettings"; 114 | case METHODS::SET_SETTINGS: 115 | return "groups.setSettings"; 116 | case METHODS::CREATE_CHAT: 117 | return "messages.createChat"; 118 | case METHODS::DELETE_MESSAGE: 119 | return "messages.delete"; 120 | case METHODS::DELETE_CHAT_PHOTO: 121 | return "messages.deleteChatPhoto"; 122 | case METHODS::DELETE_CONVERSATION: 123 | return "messages.deleteConversation"; 124 | case METHODS::EDIT_MESSAGE: 125 | return "messages.edit"; 126 | case METHODS::EDIT_CHAT: 127 | return "messages.editChat"; 128 | case METHODS::GET_BY_CONVERSATION_MESSAGE_ID: 129 | return "messages.getByConversationMessageId"; 130 | case METHODS::GET_BY_MESSAGE_ID: 131 | return "messages.getById"; 132 | case METHODS::GET_CONVERSATION_MEMBERS: 133 | return "messages.getConversationMembers"; 134 | case METHODS::GET_CONVERSATIONS: 135 | return "messages.getConversations"; 136 | case METHODS::GET_CONVERSATION_BY_ID: 137 | return "messages.getConversationById"; 138 | case METHODS::GET_HISTORY: 139 | return "messages.getHistory"; 140 | case METHODS::GET_INVITE_LINK: 141 | return "messages.getInviteLink"; 142 | case METHODS::PIN_MESSAGE: 143 | return "messages.pin"; 144 | case METHODS::REMOVE_CHAT_USER: 145 | return "messages.removeChatUser"; 146 | case METHODS::RESTORE_MESSAGE: 147 | return "messages.restore"; 148 | case METHODS::SEARCH_MESSAGE: 149 | return "messages.search"; 150 | case METHODS::SEND_MESSAGE: 151 | return "messages.send"; 152 | case METHODS::UNPIN_MESSAGE: 153 | return "messages.unpin"; 154 | case METHODS::GET_USER: 155 | return "users.get"; 156 | case METHODS::CLOSE_COMMENTS: 157 | return "wall.closeComments"; 158 | case METHODS::CREATE_COMMENT: 159 | return "wall.createComment"; 160 | case METHODS::OPEN_COMMENTS: 161 | return "wall.openComments"; 162 | } 163 | 164 | return ""; 165 | } 166 | 167 | JsonType BotBase::SendRequest(METHODS method, const JsonType& parametersData) 168 | { 169 | if (!IsAuthorized()) { throw ex::NotConnectedException(); } 170 | 171 | std::string methodStr = MethodToString(method); 172 | std::string url = VKAPI_API_URL + methodStr; 173 | 174 | JsonType pData = CheckValidationParameters(parametersData); 175 | JsonType response = JsonType::parse(Request::Send(url, ConvertParametersDataToURL(pData))); 176 | 177 | return response; 178 | } 179 | 180 | JsonType BotBase::SendRequest(const std::string& method, const JsonType& parametersData) 181 | { 182 | if (!IsAuthorized()) { throw ex::NotConnectedException(); } 183 | if (method.empty()) { throw ex::EmptyArgumentException(); } 184 | 185 | std::string url = VKAPI_API_URL + method; 186 | 187 | JsonType pData = CheckValidationParameters(parametersData); 188 | JsonType response = JsonType::parse(Request::Send(url, ConvertParametersDataToURL(pData))); 189 | 190 | return response; 191 | } 192 | 193 | #ifdef __CPLUSPLUS_OVER_11 194 | 195 | auto BotBase::SendRequestAsync(METHODS method, const JsonType& parametersData) -> std::future 196 | { return std::async(BotBase::SendRequestAsyncByMethod_, this, method, parametersData); } 197 | 198 | auto BotBase::SendRequestAsync(const std::string& method, const JsonType& parametersData) -> std::future 199 | { return std::async(BotBase::SendRequestAsyncByStr_, this, method, parametersData); } 200 | 201 | JsonType BotBase::SendRequestAsyncByMethod_(BotBase* botHandle, METHODS method, const JsonType& parametersData) 202 | { 203 | assert(botHandle == nullptr); 204 | if (!botHandle->IsAuthorized()) { throw ex::NotConnectedException(); } 205 | 206 | std::string methodStr = BotBase::MethodToString(method); 207 | std::string url = VKAPI_API_URL + methodStr; 208 | 209 | JsonType pData = botHandle->CheckValidationParameters(parametersData); 210 | JsonType response = JsonType::parse(Request::Send(url, botHandle->ConvertParametersDataToURL(pData))); 211 | 212 | return response; 213 | } 214 | 215 | JsonType BotBase::SendRequestAsyncByStr_(BotBase* botHandle, const std::string& method, const JsonType& parametersData) 216 | { 217 | assert(botHandle == nullptr); 218 | if (!botHandle->IsAuthorized()) { throw ex::NotConnectedException(); } 219 | if (method.empty()) { throw ex::EmptyArgumentException(); } 220 | 221 | std::string url = VKAPI_API_URL + method; 222 | 223 | JsonType pData = botHandle->CheckValidationParameters(parametersData); 224 | JsonType response = JsonType::parse(Request::Send(url, botHandle->ConvertParametersDataToURL(pData))); 225 | 226 | return response; 227 | } 228 | 229 | #endif // __CPLUSPLUS_OVER_11 230 | 231 | JsonType BotBase::CheckValidationParameters(const JsonType& parametersData) 232 | { 233 | JsonType cParametersData = parametersData; 234 | 235 | if (cParametersData.find("access_token") == cParametersData.end()) { 236 | cParametersData.push_back({ "access_token", m_accessToken }); 237 | } 238 | 239 | if (cParametersData.find("group_id") == cParametersData.end()) { 240 | cParametersData.push_back({ "group_id", m_groupId }); 241 | } 242 | 243 | if (cParametersData.find("v") == cParametersData.end()) { 244 | cParametersData.push_back({ "v", VKAPI_API_VERSION }); 245 | } 246 | 247 | return cParametersData; 248 | } 249 | 250 | _VKAPI_COMPLEXITY_FUNCTION 251 | BotBase::EVENTS BotBase::GetTypeEvent(const std::string& typeEvent) 252 | { 253 | if (typeEvent == "message_new") { 254 | return EVENTS::MESSAGE_NEW; 255 | } else if (typeEvent == "message_reply") { 256 | return EVENTS::MESSAGE_REPLY; 257 | } else if (typeEvent == "message_allow") { 258 | return EVENTS::MESSAGE_ALLOW; 259 | } else if (typeEvent == "message_deny") { 260 | return EVENTS::MESSAGE_DENY; 261 | } else if (typeEvent == "photo_new") { 262 | return EVENTS::PHOTO_NEW; 263 | } else if (typeEvent == "audio_new") { 264 | return EVENTS::AUDIO_NEW; 265 | } else if (typeEvent == "video_new") { 266 | return EVENTS::VIDEO_NEW; 267 | } else if (typeEvent == "wall_reply_new") { 268 | return EVENTS::WALL_REPLY_NEW; 269 | } else if (typeEvent == "wall_reply_edit") { 270 | return EVENTS::WALL_REPLY_EDIT; 271 | } else if (typeEvent == "wall_reply_delete") { 272 | return EVENTS::WALL_REPLY_DELETE; 273 | } else if (typeEvent == "wall_post_new") { 274 | return EVENTS::WALL_POST_NEW; 275 | } else if (typeEvent == "wall_repost") { 276 | return EVENTS::WALL_REPOST; 277 | } else if (typeEvent == "board_post_new") { 278 | return EVENTS::BOARD_POST_NEW; 279 | } else if (typeEvent == "board_post_edit") { 280 | return EVENTS::BOARD_POST_EDIT; 281 | } else if (typeEvent == "board_post_delete") { 282 | return EVENTS::BOARD_POST_DELETE; 283 | } else if (typeEvent == "board_post_restore") { 284 | return EVENTS::BOARD_POST_RESTORE; 285 | } else if (typeEvent == "photo_comment_new") { 286 | return EVENTS::PHOTO_COMMENT_NEW; 287 | } else if (typeEvent == "photo_comment_edit") { 288 | return EVENTS::PHOTO_COMMENT_EDIT; 289 | } else if (typeEvent == "photo_comment_delete") { 290 | return EVENTS::PHOTO_COMMENT_DELETE; 291 | } else if (typeEvent == "photo_comment_restore") { 292 | return EVENTS::PHOTO_COMMENT_RESTORE; 293 | } else if (typeEvent == "video_comment_new") { 294 | return EVENTS::VIDEO_COMMENT_NEW; 295 | } else if (typeEvent == "video_comment_edit") { 296 | return EVENTS::VIDEO_COMMENT_EDIT; 297 | } else if (typeEvent == "video_comment_delete") { 298 | return EVENTS::VIDEO_COMMENT_DELETE; 299 | } else if (typeEvent == "video_comment_restore") { 300 | return EVENTS::VIDEO_COMMENT_RESTORE; 301 | } else if (typeEvent == "market_comment_new") { 302 | return EVENTS::MARKET_COMMENT_NEW; 303 | } else if (typeEvent == "market_comment_edit") { 304 | return EVENTS::MARKET_COMMENT_EDIT; 305 | } else if (typeEvent == "market_comment_delete") { 306 | return EVENTS::MARKET_COMMENT_DELETE; 307 | } else if (typeEvent == "market_comment_restore") { 308 | return EVENTS::MARKET_COMMENT_RESTORE; 309 | } else if (typeEvent == "poll_vote_new") { 310 | return EVENTS::POLL_VOTE_NEW; 311 | } else if (typeEvent == "group_join") { 312 | return EVENTS::GROUP_JOIN; 313 | } else if (typeEvent == "group_leave") { 314 | return EVENTS::GROUP_LEAVE; 315 | } else if (typeEvent == "user_block") { 316 | return EVENTS::USER_BLOCK; 317 | } else if (typeEvent == "user_unblock") { 318 | return EVENTS::USER_UNBLOCK; 319 | } else if (typeEvent == "group_change_settings") { 320 | return EVENTS::GROUP_CHANGE_SETTINGS; 321 | } else if (typeEvent == "group_change_photo") { 322 | return EVENTS::GROUP_CHANGE_PHOTO; 323 | } else if (typeEvent == "group_officers_edit") { 324 | return EVENTS::GROUP_OFFICERS_EDIT; 325 | } else { 326 | return EVENTS::UNKNOWN; 327 | } 328 | } 329 | 330 | } // namespace bot 331 | 332 | } // namespace base 333 | 334 | } // namespace vk -------------------------------------------------------------------------------- /src/ClientBase.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains general objects for working with VK API. 3 | * @file ClientBase.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #include "ClientBase.hpp" 9 | 10 | namespace vk 11 | { 12 | 13 | namespace base 14 | { 15 | 16 | ClientBase::ClientBase() 17 | : m_connectedToLongPoll(false) 18 | {} 19 | 20 | void ClientBase::AddScope(std::string scope) 21 | { m_scope.insert(_VKAPI_MOVE(scope)); } 22 | 23 | void ClientBase::AddScope(std::initializer_list scopeList) 24 | { 25 | #ifdef __CPLUSPLUS_OVER_11 26 | for (const auto& scope : scopeList) { m_scope.insert(_VKAPI_MOVE(scope)); } 27 | #else 28 | for (std::initializer_list::iterator iter = scopeList.begin(); 29 | iter != scopeList.end(); 30 | ++iter) { 31 | m_scope.insert(_VKAPI_MOVE(*iter)); 32 | } 33 | #endif // __CPLUSPLUS_OVER_11 34 | } 35 | 36 | void ClientBase::ClearScope() 37 | { m_scope.clear(); } 38 | 39 | std::string ClientBase::ConvertParametersDataToURL(const JsonType& parametersData) 40 | { 41 | std::string result; 42 | 43 | #ifdef __CPLUSPLUS_OVER_11 44 | // TODO(#16): Rewrite below function with using std::accumulate 45 | for (const auto& parameter : parametersData.items()) { 46 | result += parameter.key() + "=" + 47 | utilities::ConvertStrToUrlCode(parameter.value().get()) + "&"; 48 | } 49 | #else 50 | for (JsonType::iterator iter = parametersData.begin(); 51 | iter != parametersData.end(); 52 | ++iter) { 53 | result += iter->key() + "=" + 54 | utilities::ConvertStrToUrlCode(iter->value().get()) + "&"; 55 | } 56 | #endif // __CPLUSPLUS_OVER_11 57 | 58 | return result; 59 | } 60 | 61 | uint32_t ClientBase::GetRandomId() 62 | { 63 | #ifdef __CPLUSPLUS_OVER_11 64 | std::random_device rd; 65 | std::uniform_int_distribution dist(10000); 66 | return dist(rd); 67 | #else 68 | uint32_t number = 999999 + (long int) ((double) rand() / (double) RAND_MAX * (LONG_MAX - 999999 + 1)); 69 | return number; 70 | #endif // __CPLUSPLUS_OVER_11 71 | } 72 | 73 | VK_REQUEST_ERROR_TYPES ClientBase::GetRequestErrorType(const std::string& errorStr) 74 | { 75 | using VK_ERROR = VK_REQUEST_ERROR_TYPES; 76 | 77 | // TODO (#13): Add all VK_ERRORS 78 | if (errorStr == VKAPI_INVALID_REQUEST) { 79 | return VK_ERROR::INVALID_REQUEST; 80 | } else if (errorStr == VKAPI_NEED_CAPTCHA) { 81 | return VK_ERROR::NEED_CAPTCHA; 82 | } else { 83 | return VK_ERROR::UNKNOWN_ERROR; 84 | } 85 | } 86 | 87 | } // namespace base 88 | 89 | } // namespace vk -------------------------------------------------------------------------------- /src/Request.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Describes the class for working with CURL. 3 | * @file Request.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #include "Request.hpp" 9 | 10 | namespace vk 11 | { 12 | 13 | namespace base 14 | { 15 | 16 | std::string Request::Send(const std::string& url, const std::string& postData) 17 | { 18 | CURL* curl = curl_easy_init(); 19 | 20 | if (curl) { 21 | std::string errorBuf; 22 | std::string callbackBuf; 23 | 24 | errorBuf.resize(CURL_ERROR_SIZE); 25 | 26 | curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuf.c_str()); 27 | curl_easy_setopt(curl, CURLOPT_USERAGENT, USERAGENT); 28 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, NO_APPLY_CURLOPT); 29 | curl_easy_setopt(curl, CURLOPT_HTTPGET, NO_APPLY_CURLOPT); 30 | curl_easy_setopt(curl, CURLOPT_MAXREDIRS, MAXREGIDS); 31 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); 32 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, Request::CurlWriteData); 33 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &callbackBuf); 34 | 35 | if (!postData.empty()) { 36 | curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str()); 37 | } 38 | 39 | CURLcode result = curl_easy_perform(curl); 40 | 41 | curl_easy_cleanup(curl); 42 | 43 | if (result == CURLE_OK) { 44 | return callbackBuf; 45 | } else { 46 | return errorBuf; 47 | } 48 | } 49 | 50 | return postData; 51 | } 52 | 53 | 54 | 55 | std::size_t Request::CurlWriteData(char* ptr, size_t size, 56 | size_t nmemb, std::string* data) 57 | { 58 | if (data) { 59 | data->append(ptr, size * nmemb); 60 | return size * nmemb; 61 | } 62 | 63 | return 0; 64 | } 65 | 66 | } // namespace base 67 | 68 | } // namespace vk -------------------------------------------------------------------------------- /src/UserBase.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Describes the class for working with VK account. 3 | * @file UserBase.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #include "UserBase.hpp" 9 | 10 | namespace vk 11 | { 12 | 13 | namespace base 14 | { 15 | 16 | namespace user 17 | { 18 | 19 | UserBase::UserBase(std::string appId, std::string appSecureKey) 20 | : ClientBase() 21 | , m_appId(_VKAPI_MOVE(appId)) 22 | , m_appSecureKey(_VKAPI_MOVE(appSecureKey)) 23 | { 24 | if (m_appId.empty() || m_appSecureKey.empty()) { throw ex::EmptyArgumentException(); } 25 | } 26 | 27 | bool UserBase::Auth(std::string& login, std::string& password) 28 | { 29 | if (login.empty() || password.empty()) { throw ex::EmptyArgumentException(); } 30 | if (IsAuthorized()) { m_connectedToLongPoll = false; } 31 | 32 | std::string scope; 33 | 34 | if (!m_scope.empty()) { 35 | #ifdef __CPLUSPLUS_OVER_11 36 | scope = std::accumulate(std::begin(m_scope), std::end(m_scope), std::string(), 37 | [](const std::string& temp, const std::string& item) 38 | { return temp + "," + item; }); 39 | #else 40 | for (std::set::iterator iter = m_scope.begin(); 41 | iter != m_scope.end(); 42 | ++iter) { 43 | scope += "," + i; 44 | } 45 | #endif // __CPLUSPLUS_OVER_11 46 | scope = scope.substr(0, scope.size() - 1); 47 | } 48 | 49 | JsonType parametersData = { 50 | { "client_id", m_appId }, 51 | { "grant_type", "password" }, 52 | { "client_secret", m_appSecureKey }, 53 | { "scope", scope }, 54 | { "username", login }, 55 | { "password", password } 56 | }; 57 | 58 | JsonType response = JsonType::parse(Request::Send(VKAPI_AUTH_URL, 59 | ConvertParametersDataToURL(parametersData))); 60 | 61 | try { 62 | if (response.find("error") != response.end()) { 63 | std::string errorTypeStr = response["error"].get(); 64 | VK_REQUEST_ERROR_TYPES errorType = GetRequestErrorType(errorTypeStr); 65 | 66 | if (errorType == VK_REQUEST_ERROR_TYPES::NEED_CAPTCHA) { 67 | std::cout << GetURLCaptcha(parametersData, response); 68 | 69 | std::string captchaKey; 70 | std::cin >> captchaKey; 71 | 72 | parametersData.push_back({ "captcha_key", captchaKey }); 73 | std::string answer = Request::Send(VKAPI_AUTH_URL, ConvertParametersDataToURL(parametersData)); 74 | 75 | // TODO (#11): Add further processing 76 | } 77 | 78 | VALIDATION_TYPES validationType = GetValidationType(response.at("validation_type")); 79 | 80 | if (validationType == VALIDATION_TYPES::TWOFA_SMS || 81 | validationType == VALIDATION_TYPES::TWOFA_APP) { 82 | parametersData.push_back({ "2fa_supported", "1" }); 83 | 84 | if (validationType == VALIDATION_TYPES::TWOFA_SMS) { 85 | parametersData.push_back({ "force_sms", "1" }); 86 | } else { 87 | parametersData.push_back({ "2fa_app", "1" }); 88 | } 89 | 90 | Request::Send(response.at("redirect_url").get(), ""); 91 | Request::Send(VKAPI_AUTH_URL, ConvertParametersDataToURL(parametersData)); 92 | 93 | std::cout << "Enter code: "; 94 | 95 | std::string code; 96 | std::cin >> code; 97 | 98 | parametersData.push_back({ "code", code }); 99 | response = JsonType::parse(Request::Send(VKAPI_AUTH_URL, ConvertParametersDataToURL(parametersData))); 100 | 101 | m_accessToken = response.at("access_token").get(); 102 | m_userId = response.at("user_id").get(); 103 | m_connectedToLongPoll = true; 104 | } 105 | } else { 106 | m_accessToken = response.at("access_token").get(); 107 | m_userId = response.at("user_id").get(); 108 | m_connectedToLongPoll = true; 109 | } 110 | } catch (JsonType::exception& exc) { 111 | std::cerr << "exception message: " << exc.what() << std::endl; 112 | std::cerr << "exception id: " << exc.id << std::endl; 113 | } 114 | 115 | return m_connectedToLongPoll; 116 | } 117 | 118 | bool UserBase::Auth(const std::string& accessToken) 119 | { 120 | if (accessToken.empty()) { throw ex::EmptyArgumentException(); } 121 | if (IsAuthorized()) { m_connectedToLongPoll = false; } 122 | 123 | JsonType parametersData = { 124 | { "access_token", accessToken }, 125 | { "v", VKAPI_API_VERSION } 126 | }; 127 | 128 | const std::string method = MethodToString(METHODS::USERS_GET); 129 | const std::string url = VKAPI_API_URL + method; 130 | 131 | JsonType response = JsonType::parse(Request::Send(url, ConvertParametersDataToURL(parametersData))); 132 | 133 | try { 134 | if (response.find("error") != response.end()) { 135 | #ifdef __CPLUSPLUS_OVER_11 136 | for (const auto& data : response.at("response").items()) { 137 | m_userId = data.value().at("id").get(); 138 | } 139 | #else 140 | JsonType __response = response.at("response").items(); 141 | for (JsonType::iterator iter = __response.begin(); 142 | iter != __response.end(); 143 | ++iter) { 144 | m_userId = iter->value().at("id").get(); 145 | } 146 | #endif // __CPLUSPLUS_OVER_11 147 | m_accessToken = accessToken; 148 | m_connectedToLongPoll = true; 149 | } else { 150 | m_userId.clear(); 151 | m_accessToken.clear(); 152 | m_connectedToLongPoll = false; 153 | } 154 | } catch (JsonType::exception& exc) { 155 | std::cerr << "exception message: " << exc.what() << std::endl; 156 | std::cerr << "exception id: " << exc.id << std::endl; 157 | } 158 | 159 | return m_connectedToLongPoll; 160 | } 161 | 162 | JsonType UserBase::CheckValidationParameters(const JsonType& parametersData) 163 | { 164 | JsonType cParametersData = parametersData; 165 | 166 | if (cParametersData.find("access_token") == cParametersData.end()) { 167 | cParametersData.push_back({ "access_token", m_accessToken }); 168 | } 169 | 170 | if (cParametersData.find("v") == cParametersData.end()) { 171 | cParametersData.push_back({ "v", VKAPI_API_VERSION }); 172 | } 173 | 174 | return cParametersData; 175 | } 176 | 177 | std::string UserBase::GetURLCaptcha(JsonType& parametersData, const JsonType& response) 178 | { 179 | parametersData.push_back( 180 | { "captcha_sid", response.at("captcha_sid").get() }); 181 | return response.at("captcha_img").get(); 182 | } 183 | 184 | UserBase::VALIDATION_TYPES UserBase::GetValidationType(const std::string& descriptionType) 185 | { 186 | if (descriptionType == "2fa_sms") { 187 | return VALIDATION_TYPES::TWOFA_SMS; 188 | } else if (descriptionType == "2fa_app") { 189 | return VALIDATION_TYPES::TWOFA_APP; 190 | } else { 191 | return VALIDATION_TYPES::UNKNOWN; 192 | } 193 | } 194 | 195 | JsonType UserBase::SendRequest(METHODS method, const JsonType& parametersData) 196 | { 197 | if (!IsAuthorized()) { throw ex::NotConnectedException(); } 198 | 199 | std::string methodStr = MethodToString(method); 200 | std::string url = VKAPI_API_URL + methodStr; 201 | 202 | JsonType pData = CheckValidationParameters(parametersData); 203 | JsonType response = JsonType::parse(Request::Send(url, ConvertParametersDataToURL(pData))); 204 | 205 | return response; 206 | } 207 | 208 | JsonType UserBase::SendRequest(const std::string& method, const JsonType& parametersData) 209 | { 210 | if (!IsAuthorized()) { throw ex::NotConnectedException(); } 211 | if (method.empty()) { throw ex::EmptyArgumentException(); } 212 | 213 | std::string url = VKAPI_API_URL + method; 214 | 215 | JsonType pData = CheckValidationParameters(parametersData); 216 | JsonType response = JsonType::parse(Request::Send(url, ConvertParametersDataToURL(pData))); 217 | 218 | return response; 219 | } 220 | 221 | _VKAPI_COMPLEXITY_FUNCTION 222 | std::string UserBase::MethodToString(METHODS method) 223 | { 224 | switch (method) { 225 | case METHODS::ACCOUNT_BAN: 226 | return "account.Ban"; 227 | case METHODS::ACCOUNT_CHANGE_PASSWORD: 228 | return "account.changePassword"; 229 | case METHODS::ACCOUNT_GET_ACTIVE_OFFERS: 230 | return "account.getActiveOffers"; 231 | case METHODS::ACCOUNT_GET_APP_PERMISSIONS: 232 | return "account.getAppPermissions"; 233 | case METHODS::ACCOUNT_GET_BANNED: 234 | return "account.getBanned"; 235 | case METHODS::ACCOUNT_GET_COUNTERS: 236 | return "account.getCounters"; 237 | case METHODS::ACCOUNT_GET_INFO: 238 | return "account.getInfo"; 239 | case METHODS::ACCOUNT_GET_PROFILE_INFO: 240 | return "account.getProfileInfo"; 241 | case METHODS::ACCOUNT_GET_PUSH_SETTINGS: 242 | return "account.getPushSettings"; 243 | case METHODS::ACCOUNT_REGISTER_DEVICE: 244 | return "account.registerDevice"; 245 | case METHODS::ACCOUNT_SAVE_PROFILE_INFO: 246 | return "account.saveProfileInfo"; 247 | case METHODS::ACCOUNT_SET_INFO: 248 | return "account.setInfo"; 249 | case METHODS::ACCOUNT_SET_PUSH_SETTINGS: 250 | return "account.setPushSettings"; 251 | case METHODS::ACCOUNT_UNBAN: 252 | return "account.unban"; 253 | case METHODS::ACCOUNT_UNREGISTER_DEVICE: 254 | return "account.unregisterDevice"; 255 | case METHODS::BOARD_ADD_TOPIC: 256 | return "board.addTopic"; 257 | case METHODS::BOARD_CLOSE_TOPIC: 258 | return "board.closeTopic"; 259 | case METHODS::BOARD_CREATE_COMMENT: 260 | return "board.createComment"; 261 | case METHODS::BOARD_DELETE_COMMENT: 262 | return "board.deleteComment"; 263 | case METHODS::BOARD_DELETE_TOPIC: 264 | return "board.deleteTopic"; 265 | case METHODS::BOARD_EDIT_COMMENT: 266 | return "board.editComment"; 267 | case METHODS::BOARD_EDIT_TOPIC: 268 | return "board.editTopic"; 269 | case METHODS::BOARD_FIX_TOPIC: 270 | return "board.fixTopic"; 271 | case METHODS::BOARD_GET_COMMENTS: 272 | return "board.getComments"; 273 | case METHODS::BOARD_GET_TOPICS: 274 | return "board.getTopics"; 275 | case METHODS::BOARD_OPEN_TOPIC: 276 | return "board.openTopic"; 277 | case METHODS::BOARD_RESTORE_COMMENT: 278 | return "board.restoreComment"; 279 | case METHODS::BOARD_UNFIX_TOPIC: 280 | return "board.unfixTopic"; 281 | case METHODS::DATABASE_GET_CHAIRS: 282 | return "database.getChairs"; 283 | case METHODS::DATABASE_GET_CITIES: 284 | return "database.getCities"; 285 | case METHODS::DATABASE_GET_CITIES_BY_ID: 286 | return "database.getCitiesById"; 287 | case METHODS::DATABASE_GET_COUNTRIES: 288 | return "database.getCounties"; 289 | case METHODS::DATABASE_GET_FACULTIES: 290 | return "database.getFaculties"; 291 | case METHODS::DATABASE_GET_METRO_STATIONS: 292 | return "database.getMetroStations"; 293 | case METHODS::DATABASE_GET_REGIONS: 294 | return "database.getRegions"; 295 | case METHODS::DATABASE_GET_SCHOOL_CLASSES: 296 | return "database.getSchoolClasses"; 297 | case METHODS::DATABASE_GET_SCHOOLS: 298 | return "database.getSchools"; 299 | case METHODS::DATABASE_GET_UNIVERSITIES: 300 | return "database.getUniversities"; 301 | case METHODS::DOCS_ADD: 302 | return "docs.add"; 303 | case METHODS::DOCS_DELETE: 304 | return "docs.delete"; 305 | case METHODS::DOCS_EDIT: 306 | return "docs.edit"; 307 | case METHODS::DOCS_GET: 308 | return "docs.get"; 309 | case METHODS::DOCS_GET_BY_ID: 310 | return "docs.getById"; 311 | case METHODS::DOCS_GET_MESSAGES_UPLOAD_SERVER: 312 | return "docs.getMessagesUploadServer"; 313 | case METHODS::DOCS_GET_TYPES: 314 | return "docs.getTypes"; 315 | case METHODS::DOCS_GET_UPLOAD_SERVER: 316 | return "docs.getUploadServer"; 317 | case METHODS::DOCS_GET_WALL_UPLOAD_SERVER: 318 | return "docs.getWallUploadServer"; 319 | case METHODS::DOCS_SAVE: 320 | return "docs.save"; 321 | case METHODS::DOCS_SEARCH: 322 | return "docs.search"; 323 | case METHODS::EXECUTE: 324 | return "execute"; 325 | case METHODS::FAVE_ADD_ARTICLE: 326 | return "fave.addArticle"; 327 | case METHODS::FAVE_ADD_LINK: 328 | return "fave.addLink"; 329 | case METHODS::FAVE_ADD_PAGE: 330 | return "fave.addPage"; 331 | case METHODS::FAVE_ADD_POST: 332 | return "fave.addPost"; 333 | case METHODS::FAVE_ADD_PRODUCT: 334 | return "fave.addProduct"; 335 | case METHODS::FAVE_ADD_TAG: 336 | return "fave.addTag"; 337 | case METHODS::FAVE_ADD_VIDEO: 338 | return "fave.addVideo"; 339 | case METHODS::FAVE_EDIT_TAG: 340 | return "fave.editTag"; 341 | case METHODS::FAVE_GET: 342 | return "fave.get"; 343 | case METHODS::FAVE_GET_PAGES: 344 | return "fave.getPages"; 345 | case METHODS::FAVE_GET_TAGS: 346 | return "fave.getTags"; 347 | case METHODS::FAVE_MARK_SEEN: 348 | return "fave.markSeen"; 349 | case METHODS::FAVE_REMOVE_ARTICLE: 350 | return "fave.removeArticle"; 351 | case METHODS::FAVE_REMOVE_LINK: 352 | return "fave.removeLink"; 353 | case METHODS::FAVE_REMOVE_PAGE: 354 | return "fave.removePage"; 355 | case METHODS::FAVE_REMOVE_POST: 356 | return "fave.removePost"; 357 | case METHODS::FAVE_REMOVE_PRODUCT: 358 | return "fave.removeProduct"; 359 | case METHODS::FAVE_REMOVE_TAG: 360 | return "fave.removeTag"; 361 | case METHODS::FAVE_REMOVE_VIDEO: 362 | return "fave.removeVideo"; 363 | case METHODS::FAVE_REORDER_TAGS: 364 | return "fave.reorderTags"; 365 | case METHODS::FAVE_SET_PAGE_TAGS: 366 | return "fave.setPageTags"; 367 | case METHODS::FAVE_SET_TAGS: 368 | return "fave.setTags"; 369 | case METHODS::FAVE_TRACK_PAGE_INTERACTION: 370 | return "fave.trackPageInteraction"; 371 | case METHODS::FRIENDS_ADD: 372 | return "friends.add"; 373 | case METHODS::FRIENDS_ADD_LIST: 374 | return "friends.addList"; 375 | case METHODS::FRIENDS_ARE_FRIENDS: 376 | return "friends.areFriends"; 377 | case METHODS::FRIENDS_DELETE: 378 | return "friends.delete"; 379 | case METHODS::FRIENDS_DELETE_ALL_REQUESTS: 380 | return "friends.deleteAllRequests"; 381 | case METHODS::FRIENDS_DELETE_LIST: 382 | return "friends.deleteList"; 383 | case METHODS::FRIENDS_EDIT: 384 | return "friends.edit"; 385 | case METHODS::FRIENDS_EDIT_LIST: 386 | return "friends.editList"; 387 | case METHODS::FRIENDS_GET: 388 | return "friends.get"; 389 | case METHODS::FRIENDS_GET_APP_USERS: 390 | return "friends.getAppUsers"; 391 | case METHODS::FRIENDS_GET_BY_PHONES: 392 | return "friends.getByPhones"; 393 | case METHODS::FRIENDS_GET_LISTS: 394 | return "friends.getLists"; 395 | case METHODS::FRIENDS_GET_MUTUAL: 396 | return "friends.getMutual"; 397 | case METHODS::FRIENDS_GET_ONLINE: 398 | return "friends.getOnline"; 399 | case METHODS::FRIENDS_GET_RECENT: 400 | return "friends.getRecent"; 401 | case METHODS::FRIENDS_GET_REQUESTS: 402 | return "friends.getRequests"; 403 | case METHODS::FRIENDS_GET_SUGGESTIONS: 404 | return "friends.getSuggestions"; 405 | case METHODS::FRIENDS_SEARCH: 406 | return "friends.search"; 407 | case METHODS::GIFTS_GET: 408 | return "gifts.get"; 409 | case METHODS::GROUPS_ADD_ADDRESS: 410 | return "groups.addAddress"; 411 | case METHODS::GROUPS_ADD_CALLBACK_SERVER: 412 | return "groups.addCallbackServer"; 413 | case METHODS::GROUPS_ADD_LINK: 414 | return "groups.addLink"; 415 | case METHODS::GROUPS_APPROVE_REQUEST: 416 | return "groups.approveRequest"; 417 | case METHODS::GROUPS_BAN: 418 | return "groups.ban"; 419 | case METHODS::GROUPS_CREATE: 420 | return "groups.create"; 421 | case METHODS::GROUPS_DELETE_ADDRESS: 422 | return "groups.deleteAddress"; 423 | case METHODS::GROUPS_DELETE_CALLBACK_SERVER: 424 | return "groups.deleteCallbackServer"; 425 | case METHODS::GROUPS_DELETE_LINK: 426 | return "groups.deleteLink"; 427 | case METHODS::GROUPS_DISABLE_ONLINE: 428 | return "groups.disableOnline"; 429 | case METHODS::GROUPS_EDIT: 430 | return "groups.edit"; 431 | case METHODS::GROUPS_EDIT_ADDRESS: 432 | return "groups.editAddress"; 433 | case METHODS::GROUPS_EDIT_CALLBACK_SERVER: 434 | return "groups.editCallbackServer"; 435 | case METHODS::GROUPS_EDIT_LINK: 436 | return "groups.editLink"; 437 | case METHODS::GROUPS_EDIT_MANAGER: 438 | return "groups.editManager"; 439 | case METHODS::GROUPS_ENABLE_ONLINE: 440 | return "groups.enableOnline"; 441 | case METHODS::GROUPS_GET: 442 | return "groups.get"; 443 | case METHODS::GROUPS_GET_ADDRESSES: 444 | return "groups.getAddresses"; 445 | case METHODS::GROUPS_GET_BANNED: 446 | return "groups.getBanned"; 447 | case METHODS::GROUPS_GET_BY_ID: 448 | return "groups.getById"; 449 | case METHODS::GROUPS_GET_CALLBACK_CONFIRMATION_CODE: 450 | return "groups.getCallbackConfirmationCode"; 451 | case METHODS::GROUPS_GET_CALLBACK_SERVER: 452 | return "groups.getCallbackServer"; 453 | case METHODS::GROUPS_GET_CALLBACK_SETTINGS: 454 | return "groups.getCallbackSettings"; 455 | case METHODS::GROUPS_GET_CATALOG: 456 | return "groups.getCatalog"; 457 | case METHODS::GROUPS_GET_CATALOG_INFO: 458 | return "groups.getCatalogInfo"; 459 | case METHODS::GROUPS_GET_INVITED_USERS: 460 | return "groups.getInvitedUsers"; 461 | case METHODS::GROUPS_GET_INVITIES: 462 | return "groups.getInvities"; 463 | case METHODS::GROUPS_GET_LONG_POLL_SERVER: 464 | return "groups.getLongPollServer"; 465 | case METHODS::GROUPS_GET_LONG_POLL_SETTINGS: 466 | return "groups.getLongPollSettings"; 467 | case METHODS::GROUPS_GET_MEMBERS: 468 | return "groups.getMembers"; 469 | case METHODS::GROUPS_GET_ONLINE_STATUS: 470 | return "groups.getOnlineStatus"; 471 | case METHODS::GROUPS_GET_REQUESTS: 472 | return "groups.getRequests"; 473 | case METHODS::GROUPS_GET_SETTINGS: 474 | return "groups.getSettings"; 475 | case METHODS::GROUPS_GET_TAG_LIST: 476 | return "groups.getTagList"; 477 | case METHODS::GROUPS_GET_TOKEN_PERMISSIONS: 478 | return "groups.getTokenPermissions"; 479 | case METHODS::GROUPS_INVITE: 480 | return "groups.invite"; 481 | case METHODS::GROUPS_IS_MEMBER: 482 | return "groups.isMember"; 483 | case METHODS::GROUPS_JOIN: 484 | return "groups.join"; 485 | case METHODS::GROUPS_LEAVE: 486 | return "groups.leave"; 487 | case METHODS::GROUPS_REMOVE_USER: 488 | return "groups.removeUser"; 489 | case METHODS::GROUPS_REORDER_LINK: 490 | return "groups.reorderLink"; 491 | case METHODS::GROUPS_SEARCH: 492 | return "groups.search"; 493 | case METHODS::GROUPS_SET_CALLBACK_SETTINGS: 494 | return "groups.setCallbackSettings"; 495 | case METHODS::GROUPS_SET_LONG_POLL_SETTINGS: 496 | return "groups.setLongPollSettings"; 497 | case METHODS::GROUPS_SET_SETTINGS: 498 | return "groups.setSettings"; 499 | case METHODS::GROUPS_SET_USER_NOTE: 500 | return "groups.setUserNote"; 501 | case METHODS::GROUPS_TAG_ADD: 502 | return "groups.tagAdd"; 503 | case METHODS::GROUPS_TAG_BIND: 504 | return "groups.tagBind"; 505 | case METHODS::GROUPS_TAG_DELETE: 506 | return "groups.tagDelete"; 507 | case METHODS::GROUPS_TAG_UPDATE: 508 | return "groups.tagUpdate"; 509 | case METHODS::GROUPS_UNBAN: 510 | return "groups.unban"; 511 | case METHODS::LEADFORMS_CREATE: 512 | return "leadForms.create"; 513 | case METHODS::LEADFORMS_DELETE: 514 | return "leadForms.delete"; 515 | case METHODS::LEADFORMS_GET: 516 | return "leadForms.get"; 517 | case METHODS::LEADFORMS_GET_LEADS: 518 | return "leadForms.getLeads"; 519 | case METHODS::LEADFORMS_GET_UPLOAD_URL: 520 | return "leadForms.getUploadURL"; 521 | case METHODS::LEADFORMS_LIST: 522 | return "leadForms.list"; 523 | case METHODS::LEADFORMS_UPDATE: 524 | return "leadForms.update"; 525 | case METHODS::LIKES_ADD: 526 | return "likes.add"; 527 | case METHODS::LIKES_DELETE: 528 | return "likes.delete"; 529 | case METHODS::LIKES_GET_LIST: 530 | return "likes.getList"; 531 | case METHODS::LIKES_IS_LIKED: 532 | return "likes.isLiked"; 533 | case METHODS::MARKET_ADD: 534 | return "market.add"; 535 | case METHODS::MARKET_ADD_ALBUM: 536 | return "market.addAlbum"; 537 | case METHODS::MARKET_ADD_TO_ALBUM: 538 | return "market.addToAlbum"; 539 | case METHODS::MARKET_CREATE_COMMENT: 540 | return "market.createComment"; 541 | case METHODS::MARKET_DELETE: 542 | return "market.delete"; 543 | case METHODS::MARKET_DELETE_ALBUM: 544 | return "market.deleteAlbum"; 545 | case METHODS::MARKET_DELETE_COMMENT: 546 | return "market.deleteComment"; 547 | case METHODS::MARKET_EDIT: 548 | return "market.edit"; 549 | case METHODS::MARKET_EDIT_ALBUM: 550 | return "market.editAlbum"; 551 | case METHODS::MARKET_EDIT_COMMENT: 552 | return "market.editComment"; 553 | case METHODS::MARKET_EDIT_ORDER: 554 | return "market.editOrder"; 555 | case METHODS::MARKET_GET: 556 | return "market.get"; 557 | case METHODS::MARKET_GET_ALBUM_BY_ID: 558 | return "market.getAlbumById"; 559 | case METHODS::MARKET_GET_ALBUMS: 560 | return "market.getAlbums"; 561 | case METHODS::MARKET_GET_BY_ID: 562 | return "market.getById"; 563 | case METHODS::MARKET_GET_CATEGORIES: 564 | return "market.getCategories"; 565 | case METHODS::MARKET_GET_COMMENTS: 566 | return "market.getComments"; 567 | case METHODS::MARKET_GET_GROUP_ORDERS: 568 | return "market.getGroupOrders"; 569 | case METHODS::MARKET_GET_ORDER_BY_ID: 570 | return "market.getOrderById"; 571 | case METHODS::MARKET_GET_ORDER_ITEMS: 572 | return "market.getOrderItems"; 573 | case METHODS::MARKET_GET_ORDERS: 574 | return "market.getOrders"; 575 | case METHODS::MARKET_REMOVE_FROM_ALBUM: 576 | return "market.removeFromAlbum"; 577 | case METHODS::MARKET_REORDER_ALBUMS: 578 | return "market.reorderAlbums"; 579 | case METHODS::MARKET_REORDER_ITEMS: 580 | return "market.reorderItems"; 581 | case METHODS::MARKET_REPORT: 582 | return "market.report"; 583 | case METHODS::MARKET_REPORT_COMMENT: 584 | return "market.reportComment"; 585 | case METHODS::MARKET_RESTORE: 586 | return "market.restore"; 587 | case METHODS::MARKET_RESTORE_COMMENT: 588 | return "market.restoreComment"; 589 | case METHODS::MARKET_SEARCH: 590 | return "market.search"; 591 | case METHODS::MESSAGES_ADD_CHAT_USER: 592 | return "messages.addChatUser"; 593 | case METHODS::MESSAGES_ALLOW_MESSAGES_FROM_GROUP: 594 | return "messages.allowMessagesFromGroup"; 595 | case METHODS::MESSAGES_CREATE_CHAT: 596 | return "messages.createChat"; 597 | case METHODS::MESSAGES_DELETE: 598 | return "messages.delete"; 599 | case METHODS::MESSAGES_DELETE_CHAT_PHOTO: 600 | return "messages.deleteChatPhoto"; 601 | case METHODS::MESSAGES_DELETE_CONVERSATION: 602 | return "messages.deleteConversation"; 603 | case METHODS::MESSAGES_DENY_MESSAGES_FROM_GROUP: 604 | return "messages.denyMessagesFromGroup"; 605 | case METHODS::MESSAGES_EDIT: 606 | return "messages.edit"; 607 | case METHODS::MESSAGES_EDIT_CHAT: 608 | return "messages.editChat"; 609 | case METHODS::MESSAGES_GET_BY_CONVERSATION_MESSAGE_ID: 610 | return "messages.getByConversationMessageId"; 611 | case METHODS::MESSAGES_GET_BY_ID: 612 | return "messages.getById"; 613 | case METHODS::MESSAGES_GET_CHAT: 614 | return "messages.getChat"; 615 | case METHODS::MESSAGES_GET_CHAT_PREVIEW: 616 | return "messages.getChatPreview"; 617 | case METHODS::MESSAGES_GET_CONVERSATIONS: 618 | return "messages.getConversations"; 619 | case METHODS::MESSAGES_GET_CONVERSATION_BY_ID: 620 | return "messages.getConversationById"; 621 | case METHODS::MESSAGES_GET_HISTORY: 622 | return "messages.getHistory"; 623 | case METHODS::MESSAGES_GET_HISTORY_ATTACHMENTS: 624 | return "messages.getHistoryAttachments"; 625 | case METHODS::MESSAGES_GET_IMPORTANT_MESSAGES: 626 | return "messages.getImportantMessages"; 627 | case METHODS::MESSAGES_GET_INVITE_LINK: 628 | return "messages.getInviteLink"; 629 | case METHODS::MESSAGES_GET_LAST_ACTIVITY: 630 | return "messages.getLastActivity"; 631 | case METHODS::MESSAGES_GET_LONG_POLL_HISTORY: 632 | return "messages.getLongPollHistory"; 633 | case METHODS::MESSAGES_GET_LONG_POLL_SERVER: 634 | return "messages.getLongPollServer"; 635 | case METHODS::MESSAGES_IS_MESSAGES_FROM_GROUP_ALLOWED: 636 | return "messages.isMessagesFromGroupAllowed"; 637 | case METHODS::MESSAGES_JOIN_CHAT_BY_INVITE_LINK: 638 | return "messages.joinChatByInviteLink"; 639 | case METHODS::MESSAGES_MARK_AS_ANSWERED_CONVERSATION: 640 | return "messages.markAsAnsweredConversation"; 641 | case METHODS::MESSAGES_MARK_AS_IMPORTANT: 642 | return "messages.markAsImportant"; 643 | case METHODS::MESSAGES_MARK_AS_IMPORTANT_CONVERSATION: 644 | return "messages.markAsImportantConversation"; 645 | case METHODS::MESSAGES_MARK_AS_READ: 646 | return "messages.markAsRead"; 647 | case METHODS::MESSAGES_PIN: 648 | return "messages.pin"; 649 | case METHODS::MESSAGES_REMOVE_CHAT_USER: 650 | return "messages.removeChatUser"; 651 | case METHODS::MESSAGES_RESTORE: 652 | return "messages.restore"; 653 | case METHODS::MESSAGES_SEARCH: 654 | return "messages.search"; 655 | case METHODS::MESSAGES_SEARCH_CONVERSATIONS: 656 | return "messages.searchConversations"; 657 | case METHODS::MESSAGES_SEND: 658 | return "messages.send"; 659 | case METHODS::MESSAGES_SEND_MESSAGE_EVENT_ANSWER: 660 | return "messages.sendMessageEventAnswer"; 661 | case METHODS::MESSAGES_SET_ACTIVITY: 662 | return "messages.setActivity"; 663 | case METHODS::MESSAGES_SET_CHAT_PHOTO: 664 | return "messages.setChatPhoto"; 665 | case METHODS::MESSAGES_UNPIN: 666 | return "messages.unpin"; 667 | case METHODS::NEWSFEED_ADD_BAN: 668 | return "newsfeed.addBan"; 669 | case METHODS::NEWSFEED_DELETE_BAN: 670 | return "newsfeed.deleteBan"; 671 | case METHODS::NEWSFEED_DELETE_LIST: 672 | return "newsfeed.deleteList"; 673 | case METHODS::NEWSFEED_GET: 674 | return "newsfeed.get"; 675 | case METHODS::NEWSFEED_GET_BANNED: 676 | return "newsfeed.getBanned"; 677 | case METHODS::NEWSFEED_GET_COMMENTS: 678 | return "newsfeed.getComments"; 679 | case METHODS::NEWSFEED_GET_LISTS: 680 | return "newsfeed.getLists"; 681 | case METHODS::NEWSFEED_GET_MENTIONS: 682 | return "newsfeed.getMentions"; 683 | case METHODS::NEWSFEED_GET_RECOMMENDED: 684 | return "newsfeed.getRecommended"; 685 | case METHODS::NEWSFEED_GET_SUGGESTED_SOURCES: 686 | return "newsfeed.getSuggestedSources"; 687 | case METHODS::NEWSFEED_IGNORE_ITEM: 688 | return "newsfeed.ignoreItem"; 689 | case METHODS::NEWSFEED_SAVE_LIST: 690 | return "newsfeed.saveList"; 691 | case METHODS::NEWSFEED_SEARCH: 692 | return "newsfeed.search"; 693 | case METHODS::NEWSFEED_UNIGNORED_ITEM: 694 | return "newsfeed.unignoredItem"; 695 | case METHODS::NEWSFEED_UNSUBSCRIBE: 696 | return "newsfeed.unsubscribe"; 697 | case METHODS::NOTES_ADD: 698 | return "notes.add"; 699 | case METHODS::NOTES_CREATE_COMMENT: 700 | return "notes.createComment"; 701 | case METHODS::NOTES_DELETE: 702 | return "notes.delete"; 703 | case METHODS::NOTES_DELETE_COMMENT: 704 | return "notes.deleteComment"; 705 | case METHODS::NOTES_EDIT: 706 | return "notes.edit"; 707 | case METHODS::NOTES_EDIT_COMMENT: 708 | return "notes.editComment"; 709 | case METHODS::NOTES_GET: 710 | return "notes.get"; 711 | case METHODS::NOTES_GET_BY_ID: 712 | return "notes.getById"; 713 | case METHODS::NOTES_GET_COMMENTS: 714 | return "notes.getComments"; 715 | case METHODS::NOTES_RESTORE_COMMENTS: 716 | return "notes.restoreComments"; 717 | case METHODS::NOTIFICATIONS_GET: 718 | return "notifications.get"; 719 | case METHODS::NOTIFICATIONS_MARK_AS_VIEWED: 720 | return "notifications.markAsViewed"; 721 | case METHODS::PAGES_GET: 722 | return "pages.get"; 723 | case METHODS::PAGES_GET_HISTORY: 724 | return "pages.getHistory"; 725 | case METHODS::PAGES_GET_TITLES: 726 | return "pages.getTitles"; 727 | case METHODS::PAGES_GET_VERSION: 728 | return "pages.getVersion"; 729 | case METHODS::PAGES_PARSE_WIKI: 730 | return "pages.parseWiki"; 731 | case METHODS::PAGES_SAVE: 732 | return "pages.save"; 733 | case METHODS::PAGES_SAVE_ACCESS: 734 | return "pages.saveAccess"; 735 | case METHODS::PHOTOS_CONFIRM_TAG: 736 | return "photos.confirmTag"; 737 | case METHODS::PHOTOS_COPY: 738 | return "photos.copy"; 739 | case METHODS::PHOTOS_CREATE_ALBUM: 740 | return "photos.createAlbum"; 741 | case METHODS::PHOTOS_CREATE_COMMENT: 742 | return "photos.createComment"; 743 | case METHODS::PHOTOS_DELETE: 744 | return "photos.delete"; 745 | case METHODS::PHOTOS_DELETE_ALBUM: 746 | return "photos.deleteAlbum"; 747 | case METHODS::PHOTOS_DELETE_COMMENT: 748 | return "photos.deleteComment"; 749 | case METHODS::PHOTOS_EDIT: 750 | return "photos.edit"; 751 | case METHODS::PHOTOS_EDIT_ALBUM: 752 | return "photos.editAlbum"; 753 | case METHODS::PHOTOS_EDIT_COMMENT: 754 | return "photos.editComment"; 755 | case METHODS::PHOTOS_GET: 756 | return "photos.get"; 757 | case METHODS::PHOTOS_GET_ALBUM: 758 | return "photos.getAlbum"; 759 | case METHODS::PHOTOS_GET_ALBUMS_COUNT: 760 | return "photos.getAlbumsCount"; 761 | case METHODS::PHOTOS_GET_ALL: 762 | return "photos.getAll"; 763 | case METHODS::PHOTOS_GET_ALL_COMMENTS: 764 | return "photos.getAllComments"; 765 | case METHODS::PHOTOS_GET_BY_ID: 766 | return "photos.getById"; 767 | case METHODS::PHOTOS_GET_CHAT_UPLOAD_SERVER: 768 | return "photos.getChatUploadServer"; 769 | case METHODS::PHOTOS_GET_COMMENTS: 770 | return "photos.getComments"; 771 | case METHODS::PHOTOS_GET_MARKET_ALBUM_UPLOAD_SERVER: 772 | return "photos.getMarketAlbumUploadServer"; 773 | case METHODS::PHOTOS_GET_MARKET_UPLOAD_SERVER: 774 | return "photos.getMarketUploadServer"; 775 | case METHODS::PHOTOS_GET_MESSAGES_UPLOAD_SERVER: 776 | return "photos.getMessagesUploadServer"; 777 | case METHODS::PHOTOS_GET_NEW_TAGS: 778 | return "photos.getNewTags"; 779 | case METHODS::PHOTOS_GET_OWNER_COVER_PHOTO_UPLOAD_SERVER: 780 | return "photos.getOnwerCoverPhotoUploadServer"; 781 | case METHODS::PHOTOS_GET_OWNER_PHOTO_UPLOAD_SERVER: 782 | return "photos.getOnwerPhotoUploadServer"; 783 | case METHODS::PHOTOS_GET_TAGS: 784 | return "photos.getTags"; 785 | case METHODS::PHOTOS_GET_UPLOAD_SERVER: 786 | return "photos.getUploadServer"; 787 | case METHODS::PHOTOS_GET_USER_PHOTOS: 788 | return "photos.getUserPhotos"; 789 | case METHODS::PHOTOS_GET_WALL_UPLOAD_SERVER: 790 | return "photos.getWallUploadServer"; 791 | case METHODS::PHOTOS_MAKE_COVER: 792 | return "photos.makeCover"; 793 | case METHODS::PHOTOS_MOVE: 794 | return "photos.move"; 795 | case METHODS::PHOTOS_PUT_TAG: 796 | return "photos.putTag"; 797 | case METHODS::PHOTOS_REMOVE_TAG: 798 | return "photos.removeTag"; 799 | case METHODS::PHOTOS_REORDER_ALBUMS: 800 | return "photos.reorderAlbums"; 801 | case METHODS::PHOTOS_REODER_PHOTOS: 802 | return "photos.reorderPhotos"; 803 | case METHODS::PHOTOS_REPORT: 804 | return "photos.report"; 805 | case METHODS::PHOTOS_REPORT_COMMENT: 806 | return "photos.reportComment"; 807 | case METHODS::PHOTOS_RESTORE: 808 | return "photos.restore"; 809 | case METHODS::PHOTOS_RESTORE_COMMENT: 810 | return "photos.restoreComment"; 811 | case METHODS::PHOTOS_SAVE: 812 | return "photos.save"; 813 | case METHODS::PHOTOS_SAVE_MARKET_ALBUM_PHOTO: 814 | return "photos.saveMarketAlbumPhoto"; 815 | case METHODS::PHOTOS_SAVE_MARKET_PHOTO: 816 | return "photos.saveMarketPhoto"; 817 | case METHODS::PHOTOS_SAVE_MESSAGES_PHOTO: 818 | return "photos.saveMessagesPhoto"; 819 | case METHODS::PHOTOS_SAVE_OWNER_COVER_PHOTO: 820 | return "photos.saveOnwerCoverPhoto"; 821 | case METHODS::PHOTOS_SAVE_OWNER_PHOTO: 822 | return "photos.saveOwnerPhoto"; 823 | case METHODS::PHOTOS_SAVE_WALL_PHOTO: 824 | return "photos.saveWallPhoto"; 825 | case METHODS::PHOTOS_SEARCH: 826 | return "photos.search"; 827 | case METHODS::POLLS_ADD_VOTE: 828 | return "polls.addVote"; 829 | case METHODS::POLLS_CREATE: 830 | return "polls.create"; 831 | case METHODS::POLLS_DELETE_VOTE: 832 | return "polls.deleteVote"; 833 | case METHODS::POLLS_EDIT: 834 | return "polls.edit"; 835 | case METHODS::POLLS_GET_BACKGROUNDS: 836 | return "polls.getBackgrounds"; 837 | case METHODS::POLLS_GET_BY_ID: 838 | return "polls.getById"; 839 | case METHODS::POLLS_GET_PHOTO_UPLOAD_SERVER: 840 | return "polls.getPhotoUploadServer"; 841 | case METHODS::POLLS_GET_VOTES: 842 | return "polls.getVotes"; 843 | case METHODS::POLLS_SAVE_PHOTO: 844 | return "polls.savePhoto"; 845 | case METHODS::PRETTYCARDS_CREATE: 846 | return "prettycards.create"; 847 | case METHODS::PRETTYCARDS_DELETE: 848 | return "prettycards.delete"; 849 | case METHODS::PRETTYCARDS_EDIT: 850 | return "prettycards.edit"; 851 | case METHODS::PRETTYCARDS_GET: 852 | return "prettycards.get"; 853 | case METHODS::PRETTYCARDS_GET_BY_ID: 854 | return "prettycards.getById"; 855 | case METHODS::PRETTYCARDS_GET_UPLOAD_URL: 856 | return "prettycards.getUploadURL"; 857 | case METHODS::SEARCH_GET_HINTS: 858 | return "prettycards.getHints"; 859 | case METHODS::STATS_GET: 860 | return "stats.get"; 861 | case METHODS::STATS_GET_POST_REACH: 862 | return "stats.getPostReach"; 863 | case METHODS::STATS_TRACK_VISITOR: 864 | return "stats.trackVisitor"; 865 | case METHODS::STATUS_GET: 866 | return "status.get"; 867 | case METHODS::STATUS_SET: 868 | return "status.set"; 869 | case METHODS::STORIES_BAN_OWNER: 870 | return "stories.banOnwer"; 871 | case METHODS::STORIES_DELETE: 872 | return "stories.delete"; 873 | case METHODS::STORIES_GET: 874 | return "stories.get"; 875 | case METHODS::STORIES_GET_BANNED: 876 | return "stories.getBanned"; 877 | case METHODS::STORIES_GET_BY_ID: 878 | return "stories.getById"; 879 | case METHODS::STORIES_GET_PHOTO_UPLOAD_SERVER: 880 | return "stories.getPhotoUploadServer"; 881 | case METHODS::STORIES_GET_REPLIES: 882 | return "stories.getReplies"; 883 | case METHODS::STORIES_GET_STATS: 884 | return "stories.getStats"; 885 | case METHODS::STORIES_GET_VIDEO_UPLOAD_SERVER: 886 | return "stories.getVideoUploadServer"; 887 | case METHODS::STORIES_GET_VIEWERS: 888 | return "stories.getViewers"; 889 | case METHODS::STORIES_HIDE_ALL_REPLIES: 890 | return "stories.hideAllReplies"; 891 | case METHODS::STORIES_HIDE_REPLY: 892 | return "stories.hideReply"; 893 | case METHODS::STORIES_SAVE: 894 | return "stories.save"; 895 | case METHODS::STORIES_SEARCH: 896 | return "stories.search"; 897 | case METHODS::STORIES_UNBAN_OWNER: 898 | return "stories.unbanOwner"; 899 | case METHODS::USERS_GET: 900 | return "users.get"; 901 | case METHODS::USERS_GET_FOLLOWERS: 902 | return "users.getFollowers"; 903 | case METHODS::USERS_GET_SUBSCRIPTIONS: 904 | return "users.getSubscriptions"; 905 | case METHODS::USERS_REPORT: 906 | return "users.report"; 907 | case METHODS::USERS_SEARCH: 908 | return "users.search"; 909 | case METHODS::UTILS_CHECK_LINK: 910 | return "utils.checkLink"; 911 | case METHODS::VIDEO_ADD: 912 | return "video.add"; 913 | case METHODS::VIDEO_ADD_ALBUM: 914 | return "video.addAlbum"; 915 | case METHODS::VIDEO_ADD_TO_ALBUM: 916 | return "video.addToAlbum"; 917 | case METHODS::VIDEO_CREATE_COMMENT: 918 | return "video.createComment"; 919 | case METHODS::VIDEO_DELETE: 920 | return "video.delete"; 921 | case METHODS::VIDEO_DELETE_ALBUM: 922 | return "video.deleteAlbum"; 923 | case METHODS::VIDEO_DELETE_COMMENT: 924 | return "video.deleteComment"; 925 | case METHODS::VIDEO_EDIT: 926 | return "video.edit"; 927 | case METHODS::VIDEO_EDIT_ALBUM: 928 | return "video.editAlbum"; 929 | case METHODS::VIDEO_EDIT_COMMENT: 930 | return "video.editComment"; 931 | case METHODS::VIDEO_GET: 932 | return "video.get"; 933 | case METHODS::VIDEO_GET_ALBUM_BY_ID: 934 | return "video.getAlbumById"; 935 | case METHODS::VIDEO_GET_ALBUMS: 936 | return "video.getAlbums"; 937 | case METHODS::VIDEO_GET_ALBUMS_BY_VIDEO: 938 | return "video.getAlbumsByVideo"; 939 | case METHODS::VIDEO_GET_COMMENTS: 940 | return "video.getComments"; 941 | case METHODS::VIDEO_REMOVE_FROM_ALBUMS: 942 | return "video.removeFromAlbums"; 943 | case METHODS::VIDEO_REORDER_ALBUMS: 944 | return "video.reorderAlbums"; 945 | case METHODS::VIDEO_REORDER_VIDEOS: 946 | return "video.reorderVideos"; 947 | case METHODS::VIDEO_REPORT: 948 | return "video.report"; 949 | case METHODS::VIDEO_REPORT_COMMENT: 950 | return "video.reportComment"; 951 | case METHODS::VIDEO_RESTORE: 952 | return "video.restore"; 953 | case METHODS::VIDEO_RESTORE_COMMENT: 954 | return "video.restoreComment"; 955 | case METHODS::VIDEO_SAVE: 956 | return "video.save"; 957 | case METHODS::VIDEO_SEARCH: 958 | return "video.search"; 959 | case METHODS::WALL_CHECK_COPYRIGHT_LINK: 960 | return "wall.checkCopyrightLink"; 961 | case METHODS::WALL_CLOSE_COMMENTS: 962 | return "wall.closeComments"; 963 | case METHODS::WALL_CREATE_COMMENT: 964 | return "wall.createComment"; 965 | case METHODS::WALL_DELETE: 966 | return "wall.delete"; 967 | case METHODS::WALL_DELETE_COMMENT: 968 | return "wall.deleteComment"; 969 | case METHODS::WALL_EDIT: 970 | return "wall.edit"; 971 | case METHODS::WALL_EDIT_ADS_STEALTH: 972 | return "wall.editAbsStealth"; 973 | case METHODS::WALL_EDIT_COMMENT: 974 | return "wall.editComment"; 975 | case METHODS::WALL_GET: 976 | return "wall.get"; 977 | case METHODS::WALL_GET_BY_ID: 978 | return "wall.getById"; 979 | case METHODS::WALL_GET_COMMENT: 980 | return "wall.getComment"; 981 | case METHODS::WALL_GET_REPOSTS: 982 | return "wall.getReposts"; 983 | case METHODS::WALL_OPEN_COMMENTS: 984 | return "wall.openComments"; 985 | case METHODS::WALL_PIN: 986 | return "wall.pin"; 987 | case METHODS::WALL_POST: 988 | return "wall.post"; 989 | case METHODS::WALL_POST_ADS_STEALTH: 990 | return "wall.postAbsStealth"; 991 | case METHODS::WALL_REPORT_COMMENT: 992 | return "wall.reportComment"; 993 | case METHODS::WALL_REPORT_POST: 994 | return "wall.reportPost"; 995 | case METHODS::WALL_REPOST: 996 | return "wall.repost"; 997 | case METHODS::WALL_RESTORE: 998 | return "wall.restore"; 999 | case METHODS::WALL_RESTORE_COMMENT: 1000 | return "wall.restoreComment"; 1001 | case METHODS::WALL_SEARCH: 1002 | return "wall.search"; 1003 | case METHODS::WALL_UNPIN: 1004 | return "wall.unpin"; 1005 | } 1006 | 1007 | return ""; 1008 | } 1009 | 1010 | } // namespace user 1011 | 1012 | } // namespace base 1013 | 1014 | } // namespace vk -------------------------------------------------------------------------------- /src/Utilities.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains additional functions for working with the library. 3 | * @file Utilities.hpp 4 | * @author qucals 5 | * @version 0.0.7 24/08/21 6 | */ 7 | 8 | #include "Utilities.hpp" 9 | 10 | namespace vk 11 | { 12 | 13 | namespace utilities 14 | { 15 | 16 | std::string ConvertStrToUrlCode(const std::string& str) 17 | { 18 | std::string temp(str); 19 | CURL* curl = curl_easy_init(); 20 | 21 | if (curl) { 22 | char* output = curl_easy_escape(curl, str.c_str(), static_cast(str.length())); 23 | 24 | if (output) { 25 | temp = output; 26 | curl_free(output); 27 | } 28 | } 29 | return temp; 30 | } 31 | 32 | std::string ToString(int val) 33 | { 34 | #ifdef __CPLUSPLUS_OVER_11 35 | return std::to_string(val); 36 | #else 37 | std::ostringstream ostr; 38 | ostr << val; 39 | std::string str = ostr.str(); 40 | return str; 41 | #endif 42 | } 43 | 44 | std::string ToString(unsigned val) 45 | { 46 | #ifdef __CPLUSPLUS_OVER_11 47 | return std::to_string(val); 48 | #else 49 | std::ostringstream ostr; 50 | ostr << val; 51 | std::string str = ostr.str(); 52 | return str; 53 | #endif 54 | } 55 | 56 | std::string ToString(long val) 57 | { 58 | #ifdef __CPLUSPLUS_OVER_11 59 | return std::to_string(val); 60 | #else 61 | std::ostringstream ostr; 62 | ostr << val; 63 | std::string str = ostr.str(); 64 | return str; 65 | #endif 66 | } 67 | 68 | std::string ToString(unsigned long val) 69 | { 70 | #ifdef __CPLUSPLUS_OVER_11 71 | return std::to_string(val); 72 | #else 73 | std::ostringstream ostr; 74 | ostr << val; 75 | std::string str = ostr.str(); 76 | return str; 77 | #endif 78 | } 79 | 80 | std::string ToString(long long val) 81 | { 82 | #ifdef __CPLUSPLUS_OVER_11 83 | return std::to_string(val); 84 | #else 85 | std::ostringstream ostr; 86 | ostr << val; 87 | std::string str = ostr.str(); 88 | return str; 89 | #endif 90 | } 91 | 92 | std::string ToString(unsigned long long val) 93 | { 94 | #ifdef __CPLUSPLUS_OVER_11 95 | return std::to_string(val); 96 | #else 97 | std::ostringstream ostr; 98 | ostr << val; 99 | std::string str = ostr.str(); 100 | return str; 101 | #endif 102 | } 103 | 104 | std::string ToString(float val) 105 | { 106 | #ifdef __CPLUSPLUS_OVER_11 107 | return std::to_string(val); 108 | #else 109 | std::ostringstream ostr; 110 | ostr << val; 111 | std::string str = ostr.str(); 112 | return str; 113 | #endif 114 | } 115 | 116 | std::string ToString(double val) 117 | { 118 | #ifdef __CPLUSPLUS_OVER_11 119 | return std::to_string(val); 120 | #else 121 | std::ostringstream ostr; 122 | ostr << val; 123 | std::string str = ostr.str(); 124 | return str; 125 | #endif 126 | } 127 | 128 | std::string ToString(long double val) 129 | { 130 | #ifdef __CPLUSPLUS_OVER_11 131 | return std::to_string(val); 132 | #else 133 | std::ostringstream ostr; 134 | ostr << val; 135 | std::string str = ostr.str(); 136 | return str; 137 | #endif 138 | } 139 | 140 | } // namespace utilities 141 | 142 | } // namespace vk 143 | --------------------------------------------------------------------------------