=begin
#Ahello REST API documentation

#На данной странице вы можете выполнять запросы к API, для этого необходимо указать 'appId', который  был передан вам сотрудниками тех. поддержки в поле api_key. Укажите также PartnerUserId (это CRM Id пользователя или его email ), partnerUserId передается в заголовке запроса. Важно!!! ApiKeys-аутентификация c указанием только ключа appId в ближайшее время будет работать только для данной страницы документации. Для реальных сценариев интеграции необходимо использовать HMAC-аутентификацию. В ближайшее время появится раздел помощи по основным вопросам работы с API

OpenAPI spec version: v1
Contact: petrunin@action-media.ru
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.16

=end

require 'date'

module AktionClient
  class EndPhoneCallModel
    attr_accessor :activity_id

    attr_accessor :new_owner_id

    attr_accessor :new_owner_bussiness_unit_id

    attr_accessor :new_owner_name

    attr_accessor :actual_start

    attr_accessor :call_reason_id

    attr_accessor :call_result_id

    attr_accessor :call_refusal_id

    attr_accessor :contact_face_id

    attr_accessor :phonenumber

    attr_accessor :next_call_date

    attr_accessor :annotation

    attr_accessor :regarding_object_id

    attr_accessor :regarding_object_id_name

    attr_accessor :campaign_id

    attr_accessor :customer_id

    attr_accessor :customer_id_type

    attr_accessor :customer_id_name

    attr_accessor :summaryt_table_event_id

    attr_accessor :primary_phone_call_id

    attr_accessor :activity_serial_nr

    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'activity_id' => :'activityId',
        :'new_owner_id' => :'newOwnerId',
        :'new_owner_bussiness_unit_id' => :'newOwnerBussinessUnitId',
        :'new_owner_name' => :'newOwnerName',
        :'actual_start' => :'actualStart',
        :'call_reason_id' => :'callReasonId',
        :'call_result_id' => :'callResultId',
        :'call_refusal_id' => :'callRefusalId',
        :'contact_face_id' => :'contactFaceId',
        :'phonenumber' => :'phonenumber',
        :'next_call_date' => :'nextCallDate',
        :'annotation' => :'annotation',
        :'regarding_object_id' => :'regardingObjectId',
        :'regarding_object_id_name' => :'regardingObjectIdName',
        :'campaign_id' => :'campaignId',
        :'customer_id' => :'customerId',
        :'customer_id_type' => :'customerIdType',
        :'customer_id_name' => :'customerIdName',
        :'summaryt_table_event_id' => :'summarytTableEventId',
        :'primary_phone_call_id' => :'primaryPhoneCallId',
        :'activity_serial_nr' => :'activitySerialNr'
      }
    end

    # Attribute type mapping.
    def self.swagger_types
      {
        :'activity_id' => :'String',
        :'new_owner_id' => :'String',
        :'new_owner_bussiness_unit_id' => :'String',
        :'new_owner_name' => :'String',
        :'actual_start' => :'DateTime',
        :'call_reason_id' => :'String',
        :'call_result_id' => :'String',
        :'call_refusal_id' => :'String',
        :'contact_face_id' => :'String',
        :'phonenumber' => :'String',
        :'next_call_date' => :'DateTime',
        :'annotation' => :'String',
        :'regarding_object_id' => :'String',
        :'regarding_object_id_name' => :'String',
        :'campaign_id' => :'String',
        :'customer_id' => :'String',
        :'customer_id_type' => :'String',
        :'customer_id_name' => :'String',
        :'summaryt_table_event_id' => :'Integer',
        :'primary_phone_call_id' => :'String',
        :'activity_serial_nr' => :'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.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

      if attributes.has_key?(:'activityId')
        self.activity_id = attributes[:'activityId']
      end

      if attributes.has_key?(:'newOwnerId')
        self.new_owner_id = attributes[:'newOwnerId']
      end

      if attributes.has_key?(:'newOwnerBussinessUnitId')
        self.new_owner_bussiness_unit_id = attributes[:'newOwnerBussinessUnitId']
      end

      if attributes.has_key?(:'newOwnerName')
        self.new_owner_name = attributes[:'newOwnerName']
      end

      if attributes.has_key?(:'actualStart')
        self.actual_start = attributes[:'actualStart']
      end

      if attributes.has_key?(:'callReasonId')
        self.call_reason_id = attributes[:'callReasonId']
      end

      if attributes.has_key?(:'callResultId')
        self.call_result_id = attributes[:'callResultId']
      end

      if attributes.has_key?(:'callRefusalId')
        self.call_refusal_id = attributes[:'callRefusalId']
      end

      if attributes.has_key?(:'contactFaceId')
        self.contact_face_id = attributes[:'contactFaceId']
      end

      if attributes.has_key?(:'phonenumber')
        self.phonenumber = attributes[:'phonenumber']
      end

      if attributes.has_key?(:'nextCallDate')
        self.next_call_date = attributes[:'nextCallDate']
      end

      if attributes.has_key?(:'annotation')
        self.annotation = attributes[:'annotation']
      end

      if attributes.has_key?(:'regardingObjectId')
        self.regarding_object_id = attributes[:'regardingObjectId']
      end

      if attributes.has_key?(:'regardingObjectIdName')
        self.regarding_object_id_name = attributes[:'regardingObjectIdName']
      end

      if attributes.has_key?(:'campaignId')
        self.campaign_id = attributes[:'campaignId']
      end

      if attributes.has_key?(:'customerId')
        self.customer_id = attributes[:'customerId']
      end

      if attributes.has_key?(:'customerIdType')
        self.customer_id_type = attributes[:'customerIdType']
      end

      if attributes.has_key?(:'customerIdName')
        self.customer_id_name = attributes[:'customerIdName']
      end

      if attributes.has_key?(:'summarytTableEventId')
        self.summaryt_table_event_id = attributes[:'summarytTableEventId']
      end

      if attributes.has_key?(:'primaryPhoneCallId')
        self.primary_phone_call_id = attributes[:'primaryPhoneCallId']
      end

      if attributes.has_key?(:'activitySerialNr')
        self.activity_serial_nr = attributes[:'activitySerialNr']
      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
      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 self.equal?(o)
      self.class == o.class &&
          activity_id == o.activity_id &&
          new_owner_id == o.new_owner_id &&
          new_owner_bussiness_unit_id == o.new_owner_bussiness_unit_id &&
          new_owner_name == o.new_owner_name &&
          actual_start == o.actual_start &&
          call_reason_id == o.call_reason_id &&
          call_result_id == o.call_result_id &&
          call_refusal_id == o.call_refusal_id &&
          contact_face_id == o.contact_face_id &&
          phonenumber == o.phonenumber &&
          next_call_date == o.next_call_date &&
          annotation == o.annotation &&
          regarding_object_id == o.regarding_object_id &&
          regarding_object_id_name == o.regarding_object_id_name &&
          campaign_id == o.campaign_id &&
          customer_id == o.customer_id &&
          customer_id_type == o.customer_id_type &&
          customer_id_name == o.customer_id_name &&
          summaryt_table_event_id == o.summaryt_table_event_id &&
          primary_phone_call_id == o.primary_phone_call_id &&
          activity_serial_nr == o.activity_serial_nr
    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
      [activity_id, new_owner_id, new_owner_bussiness_unit_id, new_owner_name, actual_start, call_reason_id, call_result_id, call_refusal_id, contact_face_id, phonenumber, next_call_date, annotation, regarding_object_id, regarding_object_id_name, campaign_id, customer_id, customer_id_type, customer_id_name, summaryt_table_event_id, primary_phone_call_id, activity_serial_nr].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)
            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 # 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 = AktionClient.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 = self.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
