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

#pragma once

#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// 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; }

#include <string>
#include <optional>
#include "AppleAuthFullName.hpp"
#include "AppleRealUserStatus.hpp"

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (AppleAuthCredential).
   */
  struct AppleAuthCredential final {
  public:
    std::string user     SWIFT_PRIVATE;
    std::optional<std::string> state     SWIFT_PRIVATE;
    std::optional<std::string> identityToken     SWIFT_PRIVATE;
    std::optional<std::string> authorizationCode     SWIFT_PRIVATE;
    std::optional<std::string> email     SWIFT_PRIVATE;
    std::optional<AppleAuthFullName> fullName     SWIFT_PRIVATE;
    AppleRealUserStatus realUserStatus     SWIFT_PRIVATE;

  public:
    AppleAuthCredential() = default;
    explicit AppleAuthCredential(std::string user, std::optional<std::string> state, std::optional<std::string> identityToken, std::optional<std::string> authorizationCode, std::optional<std::string> email, std::optional<AppleAuthFullName> fullName, AppleRealUserStatus realUserStatus): user(user), state(state), identityToken(identityToken), authorizationCode(authorizationCode), email(email), fullName(fullName), realUserStatus(realUserStatus) {}

  public:
    friend bool operator==(const AppleAuthCredential& lhs, const AppleAuthCredential& rhs) = default;
  };

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ AppleAuthCredential <> JS AppleAuthCredential (object)
  template <>
  struct JSIConverter<margelo::nitro::one::AppleAuthCredential> final {
    static inline margelo::nitro::one::AppleAuthCredential fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::AppleAuthCredential(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "user"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "identityToken"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authorizationCode"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "email"))),
        JSIConverter<std::optional<margelo::nitro::one::AppleAuthFullName>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fullName"))),
        JSIConverter<margelo::nitro::one::AppleRealUserStatus>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "realUserStatus")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::AppleAuthCredential& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "user"), JSIConverter<std::string>::toJSI(runtime, arg.user));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.state));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "identityToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.identityToken));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "authorizationCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.authorizationCode));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "email"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.email));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "fullName"), JSIConverter<std::optional<margelo::nitro::one::AppleAuthFullName>>::toJSI(runtime, arg.fullName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "realUserStatus"), JSIConverter<margelo::nitro::one::AppleRealUserStatus>::toJSI(runtime, arg.realUserStatus));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "user")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "identityToken")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authorizationCode")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "email")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::one::AppleAuthFullName>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fullName")))) return false;
      if (!JSIConverter<margelo::nitro::one::AppleRealUserStatus>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "realUserStatus")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
