=begin
#Docusign eSignature REST API

#The Docusign eSignature REST API provides you with a powerful, convenient, and simple Web services API for interacting with Docusign.

OpenAPI spec version: v2.1
Contact: devcenter@docusign.com
Generated by: https://github.com/swagger-api/swagger-codegen.git

=end

require 'date'

module DocuSign_eSign
  # This group tab is used to place radio buttons on a document. The `radios` property contains a list of [`radio`](/docs/esign-rest-api/reference/envelopes/enveloperecipienttabs/) objects  associated with the group. Only one radio button can be selected in a group. 
  class RadioGroup
    # For conditional fields this is the TabLabel of the parent tab that controls this tab's visibility.
    attr_accessor :conditional_parent_label

    # Metadata that indicates whether the `conditionalParentLabel` property is editable.
    attr_accessor :conditional_parent_label_metadata

    # For conditional fields, this is the value of the parent tab that controls the tab's visibility.  If the parent tab is a Checkbox, Radio button, Optional Signature, or Optional Initial use \"on\" as the value to show that the parent tab is active. 
    attr_accessor :conditional_parent_value

    # Metadata that indicates whether the `conditionalParentValue` property is editable.
    attr_accessor :conditional_parent_value_metadata

    # Specifies the document ID number that the tab is placed on. This must refer to an existing Document's ID attribute.
    attr_accessor :document_id

    # Metadata that indicates whether the `documentId` property is editable.
    attr_accessor :document_id_metadata

    # The name of the group.
    attr_accessor :group_name

    # Metadata that indicates whether the `groupName` property is editable.
    attr_accessor :group_name_metadata

    # The initial value of the tab when it was sent to the recipient. 
    attr_accessor :original_value

    # Metadata that indicates whether the `originalValue` property is editable.
    attr_accessor :original_value_metadata

    # Specifies the locations and status for radio buttons that are grouped together.
    attr_accessor :radios

    # Unique for the recipient. It is used by the tab element to indicate which recipient is to sign the Document.
    attr_accessor :recipient_id

    # 
    attr_accessor :recipient_id_guid

    # Metadata that indicates whether the `recipientIdGuid` property is editable.
    attr_accessor :recipient_id_guid_metadata

    # Metadata that indicates whether the `recipientId` property is editable.
    attr_accessor :recipient_id_metadata

    # When set to **true** and shared is true, information must be entered in this field to complete the envelope. 
    attr_accessor :require_all

    # Metadata that indicates whether the `requireAll` property is editable.
    attr_accessor :require_all_metadata

    # Optional element for field markup. When set to **true**, the signer is required to initial when they modify a shared field.
    attr_accessor :require_initial_on_shared_change

    # Metadata that indicates whether the `requireInitialOnSharedChange` property is editable.
    attr_accessor :require_initial_on_shared_change_metadata

    # When set to **true**, this custom tab is shared.
    attr_accessor :shared

    # Metadata that indicates whether the `shared` property is editable.
    attr_accessor :shared_metadata

    # 
    attr_accessor :share_to_recipients

    # Reserved for DocuSign.
    attr_accessor :share_to_recipients_metadata

    # 
    attr_accessor :tab_type

    # Metadata that indicates whether the `tabType` property is editable.
    attr_accessor :tab_type_metadata

    # When set to **true**, the sender cannot change any attributes of the recipient. Used only when working with template recipients. 
    attr_accessor :template_locked

    # Metadata that indicates whether the `templateLocked` property is editable.
    attr_accessor :template_locked_metadata

    # When set to **true**, the sender may not remove the recipient. Used only when working with template recipients.
    attr_accessor :template_required

    # Metadata that indicates whether the `templateRequired` property is editable.
    attr_accessor :template_required_metadata

    # 
    attr_accessor :tooltip

    # Metadata that indicates whether the `tooltip` property is editable.
    attr_accessor :tooltip_metadata

    # Specifies the value of the tab. 
    attr_accessor :value

    # Metadata that indicates whether the `value` property is editable.
    attr_accessor :value_metadata

    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'conditional_parent_label' => :'conditionalParentLabel',
        :'conditional_parent_label_metadata' => :'conditionalParentLabelMetadata',
        :'conditional_parent_value' => :'conditionalParentValue',
        :'conditional_parent_value_metadata' => :'conditionalParentValueMetadata',
        :'document_id' => :'documentId',
        :'document_id_metadata' => :'documentIdMetadata',
        :'group_name' => :'groupName',
        :'group_name_metadata' => :'groupNameMetadata',
        :'original_value' => :'originalValue',
        :'original_value_metadata' => :'originalValueMetadata',
        :'radios' => :'radios',
        :'recipient_id' => :'recipientId',
        :'recipient_id_guid' => :'recipientIdGuid',
        :'recipient_id_guid_metadata' => :'recipientIdGuidMetadata',
        :'recipient_id_metadata' => :'recipientIdMetadata',
        :'require_all' => :'requireAll',
        :'require_all_metadata' => :'requireAllMetadata',
        :'require_initial_on_shared_change' => :'requireInitialOnSharedChange',
        :'require_initial_on_shared_change_metadata' => :'requireInitialOnSharedChangeMetadata',
        :'shared' => :'shared',
        :'shared_metadata' => :'sharedMetadata',
        :'share_to_recipients' => :'shareToRecipients',
        :'share_to_recipients_metadata' => :'shareToRecipientsMetadata',
        :'tab_type' => :'tabType',
        :'tab_type_metadata' => :'tabTypeMetadata',
        :'template_locked' => :'templateLocked',
        :'template_locked_metadata' => :'templateLockedMetadata',
        :'template_required' => :'templateRequired',
        :'template_required_metadata' => :'templateRequiredMetadata',
        :'tooltip' => :'tooltip',
        :'tooltip_metadata' => :'tooltipMetadata',
        :'value' => :'value',
        :'value_metadata' => :'valueMetadata'
      }
    end

    # Attribute type mapping.
    def self.swagger_types
      {
        :'conditional_parent_label' => :'String',
        :'conditional_parent_label_metadata' => :'PropertyMetadata',
        :'conditional_parent_value' => :'String',
        :'conditional_parent_value_metadata' => :'PropertyMetadata',
        :'document_id' => :'String',
        :'document_id_metadata' => :'PropertyMetadata',
        :'group_name' => :'String',
        :'group_name_metadata' => :'PropertyMetadata',
        :'original_value' => :'String',
        :'original_value_metadata' => :'PropertyMetadata',
        :'radios' => :'Array<Radio>',
        :'recipient_id' => :'String',
        :'recipient_id_guid' => :'String',
        :'recipient_id_guid_metadata' => :'PropertyMetadata',
        :'recipient_id_metadata' => :'PropertyMetadata',
        :'require_all' => :'String',
        :'require_all_metadata' => :'PropertyMetadata',
        :'require_initial_on_shared_change' => :'String',
        :'require_initial_on_shared_change_metadata' => :'PropertyMetadata',
        :'shared' => :'String',
        :'shared_metadata' => :'PropertyMetadata',
        :'share_to_recipients' => :'String',
        :'share_to_recipients_metadata' => :'PropertyMetadata',
        :'tab_type' => :'String',
        :'tab_type_metadata' => :'PropertyMetadata',
        :'template_locked' => :'String',
        :'template_locked_metadata' => :'PropertyMetadata',
        :'template_required' => :'String',
        :'template_required_metadata' => :'PropertyMetadata',
        :'tooltip' => :'String',
        :'tooltip_metadata' => :'PropertyMetadata',
        :'value' => :'String',
        :'value_metadata' => :'PropertyMetadata'
      }
    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?(:'conditionalParentLabel')
        self.conditional_parent_label = attributes[:'conditionalParentLabel']
      end

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

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

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

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

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

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

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

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

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

      if attributes.has_key?(:'radios')
        if (value = attributes[:'radios']).is_a?(Array)
          self.radios = value
        end
      end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if attributes.has_key?(:'valueMetadata')
        self.value_metadata = attributes[:'valueMetadata']
      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 &&
          conditional_parent_label == o.conditional_parent_label &&
          conditional_parent_label_metadata == o.conditional_parent_label_metadata &&
          conditional_parent_value == o.conditional_parent_value &&
          conditional_parent_value_metadata == o.conditional_parent_value_metadata &&
          document_id == o.document_id &&
          document_id_metadata == o.document_id_metadata &&
          group_name == o.group_name &&
          group_name_metadata == o.group_name_metadata &&
          original_value == o.original_value &&
          original_value_metadata == o.original_value_metadata &&
          radios == o.radios &&
          recipient_id == o.recipient_id &&
          recipient_id_guid == o.recipient_id_guid &&
          recipient_id_guid_metadata == o.recipient_id_guid_metadata &&
          recipient_id_metadata == o.recipient_id_metadata &&
          require_all == o.require_all &&
          require_all_metadata == o.require_all_metadata &&
          require_initial_on_shared_change == o.require_initial_on_shared_change &&
          require_initial_on_shared_change_metadata == o.require_initial_on_shared_change_metadata &&
          shared == o.shared &&
          shared_metadata == o.shared_metadata &&
          share_to_recipients == o.share_to_recipients &&
          share_to_recipients_metadata == o.share_to_recipients_metadata &&
          tab_type == o.tab_type &&
          tab_type_metadata == o.tab_type_metadata &&
          template_locked == o.template_locked &&
          template_locked_metadata == o.template_locked_metadata &&
          template_required == o.template_required &&
          template_required_metadata == o.template_required_metadata &&
          tooltip == o.tooltip &&
          tooltip_metadata == o.tooltip_metadata &&
          value == o.value &&
          value_metadata == o.value_metadata
    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
      [conditional_parent_label, conditional_parent_label_metadata, conditional_parent_value, conditional_parent_value_metadata, document_id, document_id_metadata, group_name, group_name_metadata, original_value, original_value_metadata, radios, recipient_id, recipient_id_guid, recipient_id_guid_metadata, recipient_id_metadata, require_all, require_all_metadata, require_initial_on_shared_change, require_initial_on_shared_change_metadata, shared, shared_metadata, share_to_recipients, share_to_recipients_metadata, tab_type, tab_type_metadata, template_locked, template_locked_metadata, template_required, template_required_metadata, tooltip, tooltip_metadata, value, value_metadata].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 = DocuSign_eSign.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
