<% if cls.type == 'object' -%>

class <%= cls.generated_class_name %>
  # @private
  class Representation < Google::Apis::Core::JsonRepresentation
<%   if api.features && api.features.include?('dataWrapper') -%>
    self.representation_wrap = lambda { |args| :data if args[:unwrap] == <%= cls.generated_type %> }
<%   end -%>
<%   if cls.variant -%>
    def from_hash(hash, *args)
      case hash['<%= cls.variant.discriminant %>']
<%     for v in cls.variant.map -%>
<%   ref = api.schemas[v._ref] %>
      when '<%= v.type_value %>'
        <%= ref.generated_type %>::Representation.new(<%= ref.generated_type %>.new).from_hash(hash, *args)
<%     end -%>
      end
    end

    def to_hash(*args)
      case represented
<%     for v in cls.variant.map -%>
<%   ref = api.schemas[v._ref] %>
      when <%= ref.generated_type %>
        <%= ref.generated_type %>::Representation.new(represented).to_hash(*args)
<%     end -%>
      end
    end
<%   else -%>
<%     for property in cls.properties.values -%>
<%       if property.type == 'hash' -%>
    hash :<%= property.generated_name %>, as: '<%= property.name %>'<%= include('representation_type', :lead => ', ', :type => property.additional_properties, :api => api) %>
<%       elsif property.type == 'array' -%>
    collection :<%= property.generated_name %>, as: '<%= property.name %>'<%= include('representation_type', :lead => ', ', :type => property.items, :api => api) %>
<%       else -%>
    property :<%= property.generated_name %>,<% if property.format == 'byte' %> :base64 => true,<%end%> as: '<%= property.name %>'<%= include('representation_type', :lead => ', ', :type => property, :api => api) %>
<%       end -%>
<%     end -%>
<%   end -%>
  end
<%   for child_class in cls.properties.values -%>
<%     if child_class._ref.nil? -%>
<%= indent(include('representation', :cls => child_class, :api => api), 2) -%>
<%     end -%>
<%   end -%>
end
<% elsif cls.items && cls.items._ref.nil? -%>
<%= include('representation', :cls => cls.items, :api => api) -%>
<% elsif cls.additional_properties && cls.additional_properties._ref.nil? -%>
<%= include('representation', :cls => cls.additional_properties, :api => api) -%>
<% end -%>
