#include "ofd.h" #include "../settings.h" #include "../utils/utils.h" #include #include #include #include #include OFD::OFD() {} OFD::OFD(std::string path) { this->module = OFDModule(path); }; std::vector OFD::search_ofds() { std::vector result{}; std::string path = std::string(std::getenv("HOME")) + "/" + OFDS_MODULES_DIR; std::filesystem::directory_entry modules_dir(path); if (!modules_dir.exists()) { std::filesystem::create_directories(path); std::cout << "No modules directory found. Created one at " << path << std::endl; std::cout << "Please, download modules to that directory from my git." << std::endl; } for (auto file : std::filesystem::directory_iterator(path)) { result.push_back(file.path()); } return result; } void OFD::set_module(std::string path) { this->module = OFDModule(path); } std::string OFD::get_check_data(std::string fn, std::string fd, std::string fp) { //curl 'https://ofd.beeline.ru/api/ofdcheck/checkf?fn=7281440701327430&fp=2518183888&fd=25955&format=4' \ -H 'Accept: application/json, text/plain, */*' \ -H 'Accept-Language: en-US,en;q=0.9,eo;q=0.8,ru;q=0.7' \ -H 'Authorization: bearer null' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'DNT: 1' \ -H 'Referer: https://ofd.beeline.ru/check-order?fn=7281440701327430&fp=2518183888&fd=25955' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Sec-Fetch-Site: same-origin' \ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36' \ -H 'sec-ch-ua: "Chromium";v="127", "Not)A;Brand";v="99"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "Linux"' cpr::Response r = cpr::Get(cpr::Url{to_utf8(module.get_url())}, cpr::Parameters{{"fn", fn}, {"fd", fd}, {"fp", fp}}); std::cout << r.text << std::endl; return r.text; }