# frozen_string_literal: true
# This file is @generated
require "json"

module Svix
  class EventTypePatch
    attr_accessor :description
    attr_accessor :archived
    attr_accessor :deprecated
    attr_accessor :schemas
    attr_accessor :feature_flags
    # The event type group's name
    attr_accessor :group_name

    ALL_FIELD ||= ["description", "archived", "deprecated", "schemas", "feature_flags", "group_name"].freeze
    private_constant :ALL_FIELD

    def initialize(attributes = {})
      unless attributes.is_a?(Hash)
        fail(ArgumentError, "The input argument (attributes) must be a hash in `Svix::EventTypePatch` new method")
      end

      attributes.each do |k, v|
        unless ALL_FIELD.include?(k.to_s)
          fail(ArgumentError, "The field #{k} is not part of Svix::EventTypePatch")
        end

        instance_variable_set("@#{k}", v)
        instance_variable_set("@__#{k}_is_defined", true)
      end
    end

    def self.deserialize(attributes = {})
      attributes = attributes.transform_keys(&:to_s)
      attrs = Hash.new
      attrs["description"] = attributes["description"]
      attrs["archived"] = attributes["archived"]
      attrs["deprecated"] = attributes["deprecated"]
      attrs["schemas"] = attributes["schemas"]
      attrs["feature_flags"] = attributes["featureFlags"]
      attrs["group_name"] = attributes["groupName"]
      new(attrs)
    end

    def serialize
      out = Hash.new
      out["description"] = Svix::serialize_primitive(@description) if @description
      out["archived"] = Svix::serialize_primitive(@archived) unless @archived.nil?
      out["deprecated"] = Svix::serialize_primitive(@deprecated) unless @deprecated.nil?
      out["schemas"] = Svix::serialize_primitive(@schemas) if @__schemas_is_defined
      out["featureFlags"] = Svix::serialize_primitive(@feature_flags) if @__feature_flags_is_defined
      out["groupName"] = Svix::serialize_primitive(@group_name) if @__group_name_is_defined
      out
    end

    # Serializes the object to a json string
    # @return String
    def to_json
      JSON.dump(serialize)
    end
  end
end
