=begin
#CMS Domains

#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

The version of the OpenAPI document: v3

Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1

=end

require 'date'
require 'time'

module Hubspot
  module Cms
    module Domains
      class Domain
        # Whether the domain is used for CMS landing pages.
        attr_accessor :is_used_for_landing_page

        attr_accessor :primary_blog_post

        attr_accessor :primary_knowledge

        attr_accessor :created

        attr_accessor :secondary_to_domain

        attr_accessor :manually_marked_as_resolving

        # Whether the domain is used for CMS knowledge pages.
        attr_accessor :is_used_for_knowledge

        # Whether the domain is used for CMS blog posts.
        attr_accessor :is_used_for_blog_post

        # Whether the domain is used for CMS site pages.
        attr_accessor :is_used_for_site_page

        # Whether the DNS for this domain is optimally configured for use with HubSpot.
        attr_accessor :is_resolving

        attr_accessor :is_ssl_enabled

        # Whether the domain is used for CMS email web pages.
        attr_accessor :is_used_for_email

        # The actual domain or sub-domain. e.g. www.hubspot.com
        attr_accessor :domain

        attr_accessor :primary_site_page

        attr_accessor :primary_landing_page

        # The unique ID of this domain.
        attr_accessor :id

        attr_accessor :correct_cname

        attr_accessor :is_ssl_only

        attr_accessor :updated

        attr_accessor :primary_email

        # Attribute mapping from ruby-style variable name to JSON key.
        def self.attribute_map
          {
            :'is_used_for_landing_page' => :'isUsedForLandingPage',
            :'primary_blog_post' => :'primaryBlogPost',
            :'primary_knowledge' => :'primaryKnowledge',
            :'created' => :'created',
            :'secondary_to_domain' => :'secondaryToDomain',
            :'manually_marked_as_resolving' => :'manuallyMarkedAsResolving',
            :'is_used_for_knowledge' => :'isUsedForKnowledge',
            :'is_used_for_blog_post' => :'isUsedForBlogPost',
            :'is_used_for_site_page' => :'isUsedForSitePage',
            :'is_resolving' => :'isResolving',
            :'is_ssl_enabled' => :'isSslEnabled',
            :'is_used_for_email' => :'isUsedForEmail',
            :'domain' => :'domain',
            :'primary_site_page' => :'primarySitePage',
            :'primary_landing_page' => :'primaryLandingPage',
            :'id' => :'id',
            :'correct_cname' => :'correctCname',
            :'is_ssl_only' => :'isSslOnly',
            :'updated' => :'updated',
            :'primary_email' => :'primaryEmail'
          }
        end

        # Returns all the JSON keys this model knows about
        def self.acceptable_attributes
          attribute_map.values
        end

        # Attribute type mapping.
        def self.openapi_types
          {
            :'is_used_for_landing_page' => :'Boolean',
            :'primary_blog_post' => :'Boolean',
            :'primary_knowledge' => :'Boolean',
            :'created' => :'Time',
            :'secondary_to_domain' => :'String',
            :'manually_marked_as_resolving' => :'Boolean',
            :'is_used_for_knowledge' => :'Boolean',
            :'is_used_for_blog_post' => :'Boolean',
            :'is_used_for_site_page' => :'Boolean',
            :'is_resolving' => :'Boolean',
            :'is_ssl_enabled' => :'Boolean',
            :'is_used_for_email' => :'Boolean',
            :'domain' => :'String',
            :'primary_site_page' => :'Boolean',
            :'primary_landing_page' => :'Boolean',
            :'id' => :'String',
            :'correct_cname' => :'String',
            :'is_ssl_only' => :'Boolean',
            :'updated' => :'Time',
            :'primary_email' => :'Boolean'
          }
        end

        # List of attributes with nullable: true
        def self.openapi_nullable
          Set.new([
          ])
        end

        # Initializes the object
        # @param [Hash] attributes Model attributes in the form of hash
        def initialize(attributes = {})
          if (!attributes.is_a?(Hash))
            fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Cms::Domains::Domain` initialize method"
          end

          # check to see if the attribute exists and convert string to symbol for hash key
          attributes = attributes.each_with_object({}) { |(k, v), h|
            if (!self.class.attribute_map.key?(k.to_sym))
              fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Cms::Domains::Domain`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
            end
            h[k.to_sym] = v
          }

          if attributes.key?(:'is_used_for_landing_page')
            self.is_used_for_landing_page = attributes[:'is_used_for_landing_page']
          end

          if attributes.key?(:'primary_blog_post')
            self.primary_blog_post = attributes[:'primary_blog_post']
          end

          if attributes.key?(:'primary_knowledge')
            self.primary_knowledge = attributes[:'primary_knowledge']
          end

          if attributes.key?(:'created')
            self.created = attributes[:'created']
          end

          if attributes.key?(:'secondary_to_domain')
            self.secondary_to_domain = attributes[:'secondary_to_domain']
          end

          if attributes.key?(:'manually_marked_as_resolving')
            self.manually_marked_as_resolving = attributes[:'manually_marked_as_resolving']
          end

          if attributes.key?(:'is_used_for_knowledge')
            self.is_used_for_knowledge = attributes[:'is_used_for_knowledge']
          end

          if attributes.key?(:'is_used_for_blog_post')
            self.is_used_for_blog_post = attributes[:'is_used_for_blog_post']
          end

          if attributes.key?(:'is_used_for_site_page')
            self.is_used_for_site_page = attributes[:'is_used_for_site_page']
          end

          if attributes.key?(:'is_resolving')
            self.is_resolving = attributes[:'is_resolving']
          end

          if attributes.key?(:'is_ssl_enabled')
            self.is_ssl_enabled = attributes[:'is_ssl_enabled']
          end

          if attributes.key?(:'is_used_for_email')
            self.is_used_for_email = attributes[:'is_used_for_email']
          end

          if attributes.key?(:'domain')
            self.domain = attributes[:'domain']
          end

          if attributes.key?(:'primary_site_page')
            self.primary_site_page = attributes[:'primary_site_page']
          end

          if attributes.key?(:'primary_landing_page')
            self.primary_landing_page = attributes[:'primary_landing_page']
          end

          if attributes.key?(:'id')
            self.id = attributes[:'id']
          end

          if attributes.key?(:'correct_cname')
            self.correct_cname = attributes[:'correct_cname']
          end

          if attributes.key?(:'is_ssl_only')
            self.is_ssl_only = attributes[:'is_ssl_only']
          end

          if attributes.key?(:'updated')
            self.updated = attributes[:'updated']
          end

          if attributes.key?(:'primary_email')
            self.primary_email = attributes[:'primary_email']
          end
        end

        # Show invalid properties with the reasons. Usually used together with valid?
        # @return Array for valid properties with the reasons
        def list_invalid_properties
          invalid_properties = Array.new
          if @is_used_for_landing_page.nil?
            invalid_properties.push('invalid value for "is_used_for_landing_page", is_used_for_landing_page cannot be nil.')
          end

          if @is_used_for_knowledge.nil?
            invalid_properties.push('invalid value for "is_used_for_knowledge", is_used_for_knowledge cannot be nil.')
          end

          if @is_used_for_blog_post.nil?
            invalid_properties.push('invalid value for "is_used_for_blog_post", is_used_for_blog_post cannot be nil.')
          end

          if @is_used_for_site_page.nil?
            invalid_properties.push('invalid value for "is_used_for_site_page", is_used_for_site_page cannot be nil.')
          end

          if @is_resolving.nil?
            invalid_properties.push('invalid value for "is_resolving", is_resolving cannot be nil.')
          end

          if @is_used_for_email.nil?
            invalid_properties.push('invalid value for "is_used_for_email", is_used_for_email cannot be nil.')
          end

          if @domain.nil?
            invalid_properties.push('invalid value for "domain", domain cannot be nil.')
          end

          if @id.nil?
            invalid_properties.push('invalid value for "id", id cannot be nil.')
          end

          invalid_properties
        end

        # Check to see if the all the properties in the model are valid
        # @return true if the model is valid
        def valid?
          return false if @is_used_for_landing_page.nil?
          return false if @is_used_for_knowledge.nil?
          return false if @is_used_for_blog_post.nil?
          return false if @is_used_for_site_page.nil?
          return false if @is_resolving.nil?
          return false if @is_used_for_email.nil?
          return false if @domain.nil?
          return false if @id.nil?
          true
        end

        # Checks equality by comparing each attribute.
        # @param [Object] Object to be compared
        def ==(o)
          return true if self.equal?(o)
          self.class == o.class &&
              is_used_for_landing_page == o.is_used_for_landing_page &&
              primary_blog_post == o.primary_blog_post &&
              primary_knowledge == o.primary_knowledge &&
              created == o.created &&
              secondary_to_domain == o.secondary_to_domain &&
              manually_marked_as_resolving == o.manually_marked_as_resolving &&
              is_used_for_knowledge == o.is_used_for_knowledge &&
              is_used_for_blog_post == o.is_used_for_blog_post &&
              is_used_for_site_page == o.is_used_for_site_page &&
              is_resolving == o.is_resolving &&
              is_ssl_enabled == o.is_ssl_enabled &&
              is_used_for_email == o.is_used_for_email &&
              domain == o.domain &&
              primary_site_page == o.primary_site_page &&
              primary_landing_page == o.primary_landing_page &&
              id == o.id &&
              correct_cname == o.correct_cname &&
              is_ssl_only == o.is_ssl_only &&
              updated == o.updated &&
              primary_email == o.primary_email
        end

        # @see the `==` method
        # @param [Object] Object to be compared
        def eql?(o)
          self == o
        end

        # Calculates hash code according to all attributes.
        # @return [Integer] Hash code
        def hash
          [is_used_for_landing_page, primary_blog_post, primary_knowledge, created, secondary_to_domain, manually_marked_as_resolving, is_used_for_knowledge, is_used_for_blog_post, is_used_for_site_page, is_resolving, is_ssl_enabled, is_used_for_email, domain, primary_site_page, primary_landing_page, id, correct_cname, is_ssl_only, updated, primary_email].hash
        end

        # Builds the object from hash
        # @param [Hash] attributes Model attributes in the form of hash
        # @return [Object] Returns the model itself
        def self.build_from_hash(attributes)
          new.build_from_hash(attributes)
        end

        # Builds the object from hash
        # @param [Hash] attributes Model attributes in the form of hash
        # @return [Object] Returns the model itself
        def build_from_hash(attributes)
          return nil unless attributes.is_a?(Hash)
          attributes = attributes.transform_keys(&:to_sym)
          self.class.openapi_types.each_pair do |key, type|
            if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
              self.send("#{key}=", nil)
            elsif type =~ /\AArray<(.*)>/i
              # check to ensure the input is an array given that the attribute
              # is documented as an array but the input is not
              if attributes[self.class.attribute_map[key]].is_a?(Array)
                self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
              end
            elsif !attributes[self.class.attribute_map[key]].nil?
              self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
            end
          end

          self
        end

        # Deserializes the data based on type
        # @param string type Data type
        # @param string value Value to be deserialized
        # @return [Object] Deserialized data
        def _deserialize(type, value)
          case type.to_sym
          when :Time
            Time.parse(value)
          when :Date
            Date.parse(value)
          when :String
            value.to_s
          when :Integer
            value.to_i
          when :Float
            value.to_f
          when :Boolean
            if value.to_s =~ /\A(true|t|yes|y|1)\z/i
              true
            else
              false
            end
          when :Object
            # generic object (usually a Hash), return directly
            value
          when /\AArray<(?<inner_type>.+)>\z/
            inner_type = Regexp.last_match[:inner_type]
            value.map { |v| _deserialize(inner_type, v) }
          when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
            k_type = Regexp.last_match[:k_type]
            v_type = Regexp.last_match[:v_type]
            {}.tap do |hash|
              value.each do |k, v|
                hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
              end
            end
          else # model
            # models (e.g. Pet) or oneOf
            klass = Hubspot::Cms::Domains.const_get(type)
            klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
          end
        end

        # Returns the string representation of the object
        # @return [String] String presentation of the object
        def to_s
          to_hash.to_s
        end

        # to_body is an alias to to_hash (backward compatibility)
        # @return [Hash] Returns the object in the form of hash
        def to_body
          to_hash
        end

        # Returns the object in the form of hash
        # @return [Hash] Returns the object in the form of hash
        def to_hash
          hash = {}
          self.class.attribute_map.each_pair do |attr, param|
            value = self.send(attr)
            if value.nil?
              is_nullable = self.class.openapi_nullable.include?(attr)
              next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
            end

            hash[param] = _to_hash(value)
          end
          hash
        end

        # Outputs non-array value in the form of hash
        # For object, use to_hash. Otherwise, just return the value
        # @param [Object] value Any valid value
        # @return [Hash] Returns the value in the form of hash
        def _to_hash(value)
          if value.is_a?(Array)
            value.compact.map { |v| _to_hash(v) }
          elsif value.is_a?(Hash)
            {}.tap do |hash|
              value.each { |k, v| hash[k] = _to_hash(v) }
            end
          elsif value.respond_to? :to_hash
            value.to_hash
          else
            value
          end
        end

      end

    end
  end
end
