///
/// HybridNitroOtaSpecSwift.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#include "HybridNitroOtaSpec.hpp"

// Forward declaration of `HybridNitroOtaSpec_cxx` to properly resolve imports.
namespace NitroOta { class HybridNitroOtaSpec_cxx; }



#include <NitroModules/Promise.hpp>
#include <string>
#include <NitroModules/Null.hpp>
#include <functional>
#include <variant>
#include <optional>

#include "NitroOta-Swift-Cxx-Umbrella.hpp"

namespace margelo::nitro::nitroota {

  /**
   * The C++ part of HybridNitroOtaSpec_cxx.swift.
   *
   * HybridNitroOtaSpecSwift (C++) accesses HybridNitroOtaSpec_cxx (Swift), and might
   * contain some additional bridging code for C++ <> Swift interop.
   *
   * Since this obviously introduces an overhead, I hope at some point in
   * the future, HybridNitroOtaSpec_cxx can directly inherit from the C++ class HybridNitroOtaSpec
   * to simplify the whole structure and memory management.
   */
  class HybridNitroOtaSpecSwift: public virtual HybridNitroOtaSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridNitroOtaSpecSwift(const NitroOta::HybridNitroOtaSpec_cxx& swiftPart):
      HybridObject(HybridNitroOtaSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline NitroOta::HybridNitroOtaSpec_cxx& getSwiftPart() noexcept {
      return _swiftPart;
    }

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    bool equals(const std::shared_ptr<HybridObject>& other) override {
      if (auto otherCast = std::dynamic_pointer_cast<HybridNitroOtaSpecSwift>(other)) {
        return _swiftPart.equals(otherCast->_swiftPart);
      }
      return false;
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline std::shared_ptr<Promise<bool>> checkForUpdates(const std::string& versionCheckUrl) override {
      auto __result = _swiftPart.checkForUpdates(versionCheckUrl);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> downloadZipFromUrl(const std::string& downloadUrl, const std::optional<std::variant<nitro::NullType, std::function<void(double /* received */, double /* total */)>>>& onProgress, const std::optional<std::variant<nitro::NullType, std::string>>& bundleFilePath) override {
      auto __result = _swiftPart.downloadZipFromUrl(downloadUrl, onProgress, bundleFilePath);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::variant<nitro::NullType, std::string> getStoredOtaVersion() override {
      auto __result = _swiftPart.getStoredOtaVersion();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::variant<nitro::NullType, std::string> getStoredUnzippedPath() override {
      auto __result = _swiftPart.getStoredUnzippedPath();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void reloadApp() override {
      auto __result = _swiftPart.reloadApp();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void scheduleBackgroundOTACheck(const std::string& versionCheckUrl, const std::optional<std::variant<nitro::NullType, std::string>>& downloadUrl, double interval) override {
      auto __result = _swiftPart.scheduleBackgroundOTACheck(versionCheckUrl, downloadUrl, std::forward<decltype(interval)>(interval));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::shared_ptr<Promise<bool>> rollbackToPreviousBundle() override {
      auto __result = _swiftPart.rollbackToPreviousBundle();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void confirmBundle() override {
      auto __result = _swiftPart.confirmBundle();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::shared_ptr<Promise<std::string>> getBlacklistedVersions() override {
      auto __result = _swiftPart.getBlacklistedVersions();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> getRollbackHistory() override {
      auto __result = _swiftPart.getRollbackHistory();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> markCurrentBundleAsBad(const std::string& reason) override {
      auto __result = _swiftPart.markCurrentBundleAsBad(reason);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double getNotifiedRollbackCount() override {
      auto __result = _swiftPart.getNotifiedRollbackCount();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void acknowledgeRollbackHistory() override {
      auto __result = _swiftPart.acknowledgeRollbackHistory();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    NitroOta::HybridNitroOtaSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::nitroota
