///
/// ContactInfo.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 `ContactPostalAddress` to properly resolve imports.
namespace margelo::nitro::one { struct ContactPostalAddress; }

#include <string>
#include <vector>
#include "ContactPostalAddress.hpp"

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (ContactInfo).
   */
  struct ContactInfo final {
  public:
    std::string identifier     SWIFT_PRIVATE;
    std::string givenName     SWIFT_PRIVATE;
    std::string familyName     SWIFT_PRIVATE;
    std::vector<std::string> phoneNumbers     SWIFT_PRIVATE;
    std::vector<std::string> emailAddresses     SWIFT_PRIVATE;
    std::vector<ContactPostalAddress> postalAddresses     SWIFT_PRIVATE;

  public:
    ContactInfo() = default;
    explicit ContactInfo(std::string identifier, std::string givenName, std::string familyName, std::vector<std::string> phoneNumbers, std::vector<std::string> emailAddresses, std::vector<ContactPostalAddress> postalAddresses): identifier(identifier), givenName(givenName), familyName(familyName), phoneNumbers(phoneNumbers), emailAddresses(emailAddresses), postalAddresses(postalAddresses) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ ContactInfo <> JS ContactInfo (object)
  template <>
  struct JSIConverter<margelo::nitro::one::ContactInfo> final {
    static inline margelo::nitro::one::ContactInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::ContactInfo(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "identifier"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "givenName"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "familyName"))),
        JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "phoneNumbers"))),
        JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "emailAddresses"))),
        JSIConverter<std::vector<margelo::nitro::one::ContactPostalAddress>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "postalAddresses")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::ContactInfo& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "identifier"), JSIConverter<std::string>::toJSI(runtime, arg.identifier));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "givenName"), JSIConverter<std::string>::toJSI(runtime, arg.givenName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "familyName"), JSIConverter<std::string>::toJSI(runtime, arg.familyName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "phoneNumbers"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.phoneNumbers));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "emailAddresses"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.emailAddresses));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "postalAddresses"), JSIConverter<std::vector<margelo::nitro::one::ContactPostalAddress>>::toJSI(runtime, arg.postalAddresses));
      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, "identifier")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "givenName")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "familyName")))) return false;
      if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "phoneNumbers")))) return false;
      if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "emailAddresses")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::one::ContactPostalAddress>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "postalAddresses")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
