Revision control
- /**
- * OpenAPI Petstore
- * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
- *
- * The version of the OpenAPI document: 1.0.0
- *
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
- * https://openapi-generator.tech
- * Do not edit the class manually.
- */
-
- #include <QFile>
- #include <QJsonArray>
- #include <QJsonDocument>
- #include <QJsonObject>
- #include <QVariantMap>
- #include <QDebug>
-
- #include "OAIPetApiHandler.h"
- #include "OAIPetApiRequest.h"
-
- namespace OpenAPI {
-
- OAIPetApiHandler::OAIPetApiHandler(){
-
- }
-
- OAIPetApiHandler::~OAIPetApiHandler(){
-
- }
-
- void OAIPetApiHandler::addPet(OAIPet body, bool passed) {
- if (passed)
- m_pets.insert(body.getId(), body);
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
-
- reqObj->addPetResponse(body, passed);
- }
- }
- void OAIPetApiHandler::deletePet(qint64 pet_id, QString api_key, bool passed) {
- Q_UNUSED(api_key);
- if (passed)
- m_pets.remove(pet_id);
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
-
- reqObj->deletePetResponse(passed);
- }
- }
- void OAIPetApiHandler::findPetsByAgeAndPatience(QList<qint32> pet_data) {
-
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
- QList<OAIPet> res;
- if (pet_data.size() % 2 == 0) {
- while (pet_data.size() >= 2) {
- int age = pet_data.takeAt(0);
- int patience = pet_data.takeAt(0);
- for (auto pet: m_pets) {
- if (pet.getAge() == age
- && pet.getPatience() == patience) {
- res.append(pet);
- }
- }
- }
- }
-
- reqObj->findPetsByAgeAndPatienceResponse(res.size() > 0, res);
- }
- }
- void OAIPetApiHandler::findPetsByStatus(QList<QString> status) {
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
- QList<OAIPet> res;
- for (auto it = m_pets.constBegin(); it != m_pets.constEnd(); ++it) {
- const auto &pets = it.value();
- if (status.contains(pets.getStatus()))
- res.append(pets);
- }
- reqObj->findPetsByStatusResponse(res);
- }
- }
- void OAIPetApiHandler::findPetsByTags(QList<QString> tags) {
- Q_UNUSED(tags);
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
- QList<OAIPet> res;
- reqObj->findPetsByTagsResponse(res);
- }
- }
- void OAIPetApiHandler::findPetsImageById(qint64 petId) {
- auto iter = m_pets.find(petId);
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
- bool found = iter != m_pets.constEnd();
- QFile file(":/qt-logo.png");
- QByteArray bArray;
- if (file.exists()) {
- if (file.open(QIODevice::ReadOnly))
- bArray = file.readAll();
- file.close();
- } else {
- qWarning() << "Error opening file 'qt-logo.png'";
- }
- reqObj->findPetsImageByIdResponse(found, bArray.toBase64());
- }
- }
- void OAIPetApiHandler::getJsonFile(qint64 pet_id) {
- Q_UNUSED(pet_id);
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
- OAIHttpFileElement res;
- res.setFileName(":/response.json");
- res.setMimeType("json");
- res.setRequestFileName("response.json");
- reqObj->getJsonFileResponse(res);
- }
- }
- void OAIPetApiHandler::getPetById(qint64 pet_id) {
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
- reqObj->getPetByIdResponse(m_pets.value(pet_id));
- }
- }
- void OAIPetApiHandler::updatePet(OAIPet body) {
- m_pets.insert(body.getId(), body);
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
- reqObj->updatePetResponse(body);
- }
- }
- void OAIPetApiHandler::updatePetWithForm(qint64 pet_id, QString name, QString status) {
- Q_UNUSED(pet_id);
- Q_UNUSED(name);
- Q_UNUSED(status);
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
-
- reqObj->updatePetWithFormResponse();
- }
- }
- void OAIPetApiHandler::uploadFile(qint64 pet_id, QString additional_metadata, OAIHttpFileElement file) {
- Q_UNUSED(pet_id);
- Q_UNUSED(additional_metadata);
- Q_UNUSED(file);
- auto reqObj = qobject_cast<OAIPetApiRequest*>(sender());
- if( reqObj != nullptr )
- {
- OAIApiResponse res;
- reqObj->uploadFileResponse(res);
- }
- }
-
-
- }