///
/// NitroGoogleUserInfo.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



#include <string>
#include <optional>

namespace margelo::nitro::nitrogooglesso {

  /**
   * A struct which can be represented as a JavaScript object (NitroGoogleUserInfo).
   */
  struct NitroGoogleUserInfo final {
  public:
    std::string email     SWIFT_PRIVATE;
    std::string idToken     SWIFT_PRIVATE;
    std::optional<std::string> givenName     SWIFT_PRIVATE;
    std::optional<std::string> familyName     SWIFT_PRIVATE;
    std::optional<std::string> phoneNumber     SWIFT_PRIVATE;
    std::optional<std::string> displayName     SWIFT_PRIVATE;
    std::optional<std::string> profilePictureUri     SWIFT_PRIVATE;

  public:
    NitroGoogleUserInfo() = default;
    explicit NitroGoogleUserInfo(std::string email, std::string idToken, std::optional<std::string> givenName, std::optional<std::string> familyName, std::optional<std::string> phoneNumber, std::optional<std::string> displayName, std::optional<std::string> profilePictureUri): email(email), idToken(idToken), givenName(givenName), familyName(familyName), phoneNumber(phoneNumber), displayName(displayName), profilePictureUri(profilePictureUri) {}

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

} // namespace margelo::nitro::nitrogooglesso

namespace margelo::nitro {

  // C++ NitroGoogleUserInfo <> JS NitroGoogleUserInfo (object)
  template <>
  struct JSIConverter<margelo::nitro::nitrogooglesso::NitroGoogleUserInfo> final {
    static inline margelo::nitro::nitrogooglesso::NitroGoogleUserInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::nitrogooglesso::NitroGoogleUserInfo(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "email"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "givenName"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "familyName"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "phoneNumber"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "profilePictureUri")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogooglesso::NitroGoogleUserInfo& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "email"), JSIConverter<std::string>::toJSI(runtime, arg.email));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "idToken"), JSIConverter<std::string>::toJSI(runtime, arg.idToken));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "givenName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.givenName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "familyName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.familyName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "phoneNumber"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.phoneNumber));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "displayName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.displayName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "profilePictureUri"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.profilePictureUri));
      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, "email")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "givenName")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "familyName")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "phoneNumber")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "profilePictureUri")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
