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

module Svix
  class SubscribeIn
    attr_accessor :endpoint
    attr_accessor :sink

    ALL_FIELD ||= ["endpoint", "sink"].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::SubscribeIn` 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::SubscribeIn")
        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["endpoint"] = Svix::EndpointIn.deserialize(attributes["endpoint"]) if attributes["endpoint"]
      attrs["sink"] = Svix::AutoConfigSinkType.deserialize(attributes["sink"]) if attributes["sink"]
      new(attrs)
    end

    def serialize
      out = Hash.new
      out["endpoint"] = Svix::serialize_schema_ref(@endpoint) if @endpoint
      out["sink"] = Svix::serialize_schema_ref(@sink) if @sink
      out
    end

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