# #Eligibility
#
# Reference for developers
#
# OpenAPI spec version: v3
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
# Swagger Codegen version: 2.4.17
#

require 'date'

module ChangeHealthcare
  module Eligibility
    module SwaggerClient
      class PlanDateInformation
        attr_accessor :added, :admission, :benefit, :benefit_begin, :benefit_end, :certification, :cobra_begin, :cobra_end, :completion, :coordination_of_benefits, :date_of_death, :date_of_last_update, :discharge, :effective_date_of_change, :eligibility, :eligibility_begin, :eligibility_end, :enrollment, :issue, :latest_visit_or_consultation, :period_end, :period_start, :plan, :plan_begin, :plan_end, :policy_effective, :policy_expiration, :premium_paid_to_date_begin, :premium_paid_to_date_end, :primary_care_provider, :service, :status

        # Attribute mapping from ruby-style variable name to JSON key.
        def self.attribute_map
          {
            'added': :added,
            'admission': :admission,
            'benefit': :benefit,
            'benefit_begin': :benefitBegin,
            'benefit_end': :benefitEnd,
            'certification': :certification,
            'cobra_begin': :cobraBegin,
            'cobra_end': :cobraEnd,
            'completion': :completion,
            'coordination_of_benefits': :coordinationOfBenefits,
            'date_of_death': :dateOfDeath,
            'date_of_last_update': :dateOfLastUpdate,
            'discharge': :discharge,
            'effective_date_of_change': :effectiveDateOfChange,
            'eligibility': :eligibility,
            'eligibility_begin': :eligibilityBegin,
            'eligibility_end': :eligibilityEnd,
            'enrollment': :enrollment,
            'issue': :issue,
            'latest_visit_or_consultation': :latestVisitOrConsultation,
            'period_end': :periodEnd,
            'period_start': :periodStart,
            'plan': :plan,
            'plan_begin': :planBegin,
            'plan_end': :planEnd,
            'policy_effective': :policyEffective,
            'policy_expiration': :policyExpiration,
            'premium_paid_to_date_begin': :premiumPaidToDateBegin,
            'premium_paid_to_date_end': :premiumPaidToDateEnd,
            'primary_care_provider': :primaryCareProvider,
            'service': :service,
            'status': :status
          }
        end

        # Attribute type mapping.
        def self.swagger_types
          {
            'added': :String,
            'admission': :String,
            'benefit': :String,
            'benefit_begin': :String,
            'benefit_end': :String,
            'certification': :String,
            'cobra_begin': :String,
            'cobra_end': :String,
            'completion': :String,
            'coordination_of_benefits': :String,
            'date_of_death': :String,
            'date_of_last_update': :String,
            'discharge': :String,
            'effective_date_of_change': :String,
            'eligibility': :String,
            'eligibility_begin': :String,
            'eligibility_end': :String,
            'enrollment': :String,
            'issue': :String,
            'latest_visit_or_consultation': :String,
            'period_end': :String,
            'period_start': :String,
            'plan': :String,
            'plan_begin': :String,
            'plan_end': :String,
            'policy_effective': :String,
            'policy_expiration': :String,
            'premium_paid_to_date_begin': :String,
            'premium_paid_to_date_end': :String,
            'primary_care_provider': :String,
            'service': :String,
            'status': :String
          }
        end

        # Initializes the object
        # @param [Hash] attributes Model attributes in the form of hash
        def initialize(attributes = {})
          return unless attributes.is_a?(Hash)

          # convert string to symbol for hash key
          attributes = attributes.transform_keys(&:to_sym)

          self.added = attributes[:added] if attributes.key?(:added)

          self.admission = attributes[:admission] if attributes.key?(:admission)

          self.benefit = attributes[:benefit] if attributes.key?(:benefit)

          self.benefit_begin = attributes[:benefitBegin] if attributes.key?(:benefitBegin)

          self.benefit_end = attributes[:benefitEnd] if attributes.key?(:benefitEnd)

          self.certification = attributes[:certification] if attributes.key?(:certification)

          self.cobra_begin = attributes[:cobraBegin] if attributes.key?(:cobraBegin)

          self.cobra_end = attributes[:cobraEnd] if attributes.key?(:cobraEnd)

          self.completion = attributes[:completion] if attributes.key?(:completion)

          self.coordination_of_benefits = attributes[:coordinationOfBenefits] if attributes.key?(:coordinationOfBenefits)

          self.date_of_death = attributes[:dateOfDeath] if attributes.key?(:dateOfDeath)

          self.date_of_last_update = attributes[:dateOfLastUpdate] if attributes.key?(:dateOfLastUpdate)

          self.discharge = attributes[:discharge] if attributes.key?(:discharge)

          self.effective_date_of_change = attributes[:effectiveDateOfChange] if attributes.key?(:effectiveDateOfChange)

          self.eligibility = attributes[:eligibility] if attributes.key?(:eligibility)

          self.eligibility_begin = attributes[:eligibilityBegin] if attributes.key?(:eligibilityBegin)

          self.eligibility_end = attributes[:eligibilityEnd] if attributes.key?(:eligibilityEnd)

          self.enrollment = attributes[:enrollment] if attributes.key?(:enrollment)

          self.issue = attributes[:issue] if attributes.key?(:issue)

          self.latest_visit_or_consultation = attributes[:latestVisitOrConsultation] if attributes.key?(:latestVisitOrConsultation)

          self.period_end = attributes[:periodEnd] if attributes.key?(:periodEnd)

          self.period_start = attributes[:periodStart] if attributes.key?(:periodStart)

          self.plan = attributes[:plan] if attributes.key?(:plan)

          self.plan_begin = attributes[:planBegin] if attributes.key?(:planBegin)

          self.plan_end = attributes[:planEnd] if attributes.key?(:planEnd)

          self.policy_effective = attributes[:policyEffective] if attributes.key?(:policyEffective)

          self.policy_expiration = attributes[:policyExpiration] if attributes.key?(:policyExpiration)

          self.premium_paid_to_date_begin = attributes[:premiumPaidToDateBegin] if attributes.key?(:premiumPaidToDateBegin)

          self.premium_paid_to_date_end = attributes[:premiumPaidToDateEnd] if attributes.key?(:premiumPaidToDateEnd)

          self.primary_care_provider = attributes[:primaryCareProvider] if attributes.key?(:primaryCareProvider)

          self.service = attributes[:service] if attributes.key?(:service)

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

        # Show invalid properties with the reasons. Usually used together with valid?
        # @return Array for valid properties with the reasons
        def list_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?
          true
        end

        # Checks equality by comparing each attribute.
        # @param [Object] Object to be compared
        def ==(o)
          return true if equal?(o)

          self.class == o.class &&
            added == o.added &&
            admission == o.admission &&
            benefit == o.benefit &&
            benefit_begin == o.benefit_begin &&
            benefit_end == o.benefit_end &&
            certification == o.certification &&
            cobra_begin == o.cobra_begin &&
            cobra_end == o.cobra_end &&
            completion == o.completion &&
            coordination_of_benefits == o.coordination_of_benefits &&
            date_of_death == o.date_of_death &&
            date_of_last_update == o.date_of_last_update &&
            discharge == o.discharge &&
            effective_date_of_change == o.effective_date_of_change &&
            eligibility == o.eligibility &&
            eligibility_begin == o.eligibility_begin &&
            eligibility_end == o.eligibility_end &&
            enrollment == o.enrollment &&
            issue == o.issue &&
            latest_visit_or_consultation == o.latest_visit_or_consultation &&
            period_end == o.period_end &&
            period_start == o.period_start &&
            plan == o.plan &&
            plan_begin == o.plan_begin &&
            plan_end == o.plan_end &&
            policy_effective == o.policy_effective &&
            policy_expiration == o.policy_expiration &&
            premium_paid_to_date_begin == o.premium_paid_to_date_begin &&
            premium_paid_to_date_end == o.premium_paid_to_date_end &&
            primary_care_provider == o.primary_care_provider &&
            service == o.service &&
            status == o.status
        end

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

        # Calculates hash code according to all attributes.
        # @return [Fixnum] Hash code
        def hash
          [added, admission, benefit, benefit_begin, benefit_end, certification, cobra_begin, cobra_end, completion, coordination_of_benefits, date_of_death, date_of_last_update, discharge, effective_date_of_change, eligibility, eligibility_begin, eligibility_end, enrollment, issue, latest_visit_or_consultation, period_end, period_start, plan, plan_begin, plan_end, policy_effective, policy_expiration, premium_paid_to_date_begin, premium_paid_to_date_end, primary_care_provider, service, status].hash
        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)

          self.class.swagger_types.each_pair do |key, type|
            if 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)
                send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
              end
            elsif !attributes[self.class.attribute_map[key]].nil?
              send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
            end # or else data not found in attributes(hash), not an issue as the data can be optional
          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 :DateTime
            DateTime.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
            temp_model = SwaggerClient.const_get(type).new
            temp_model.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 = send(attr)
            next if value.nil?

            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