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

#pragma once

#include "HybridOneAppleAuthSpec.hpp"

// Forward declaration of `HybridOneAppleAuthSpec_cxx` to properly resolve imports.
namespace One { class HybridOneAppleAuthSpec_cxx; }

// Forward declaration of `AppleAuthResult` to properly resolve imports.
namespace margelo::nitro::one { struct AppleAuthResult; }
// Forward declaration of `AppleAuthResultType` to properly resolve imports.
namespace margelo::nitro::one { enum class AppleAuthResultType; }
// Forward declaration of `AppleAuthCredential` to properly resolve imports.
namespace margelo::nitro::one { struct AppleAuthCredential; }
// Forward declaration of `AppleAuthFullName` to properly resolve imports.
namespace margelo::nitro::one { struct AppleAuthFullName; }
// Forward declaration of `AppleRealUserStatus` to properly resolve imports.
namespace margelo::nitro::one { enum class AppleRealUserStatus; }
// Forward declaration of `AppleAuthSignInOptions` to properly resolve imports.
namespace margelo::nitro::one { struct AppleAuthSignInOptions; }
// Forward declaration of `AppleAuthScope` to properly resolve imports.
namespace margelo::nitro::one { enum class AppleAuthScope; }
// Forward declaration of `AppleCredentialState` to properly resolve imports.
namespace margelo::nitro::one { enum class AppleCredentialState; }

#include "AppleAuthResult.hpp"
#include <NitroModules/Promise.hpp>
#include "AppleAuthResultType.hpp"
#include "AppleAuthCredential.hpp"
#include <optional>
#include <string>
#include "AppleAuthFullName.hpp"
#include "AppleRealUserStatus.hpp"
#include "AppleAuthSignInOptions.hpp"
#include "AppleAuthScope.hpp"
#include <vector>
#include "AppleCredentialState.hpp"

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

namespace margelo::nitro::one {

  /**
   * The C++ part of HybridOneAppleAuthSpec_cxx.swift.
   *
   * HybridOneAppleAuthSpecSwift (C++) accesses HybridOneAppleAuthSpec_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, HybridOneAppleAuthSpec_cxx can directly inherit from the C++ class HybridOneAppleAuthSpec
   * to simplify the whole structure and memory management.
   */
  class HybridOneAppleAuthSpecSwift: public virtual HybridOneAppleAuthSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridOneAppleAuthSpecSwift(const One::HybridOneAppleAuthSpec_cxx& swiftPart):
      HybridObject(HybridOneAppleAuthSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline One::HybridOneAppleAuthSpec_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<HybridOneAppleAuthSpecSwift>(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 bool isAvailable() override {
      auto __result = _swiftPart.isAvailable();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<AppleAuthResult>> signIn(const AppleAuthSignInOptions& options) override {
      auto __result = _swiftPart.signIn(std::forward<decltype(options)>(options));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<AppleCredentialState>> getCredentialState(const std::string& user) override {
      auto __result = _swiftPart.getCredentialState(user);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    One::HybridOneAppleAuthSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::one
