Sha256: 285ea139b27fc8455adbf8d747d835d4e8e39bcfce0fa1280f0b001d74e08f1d

Contents?: true

Size: 1.4 KB

Versions: 21

Compression:

Stored size: 1.4 KB

Contents

module GoogleApps
  module Atom
    class MessageAttributes
      def initialize
        @document = Atom::XML::Document.new
        set_header
      end
      
      def add_property(prop)
        property = Atom::XML::Node.new 'apps:mailItemProperty'
        property['value'] = prop

        @document.root << property
      end

      def add_label(name)
        label = Atom::XML::Node.new 'apps:label'
        label['labelName'] = name

        @document.root << label
      end

      def to_s
        @document.to_s
      end

      private

      def set_header
        @document.root = Atom::XML::Node.new 'atom:entry' # API Docs show just entry here

        Atom::XML::Namespace.new(@document.root, 'atom', 'http://www.w3.org/2005/Atom') # API Docs show this as just xmlns
        Atom::XML::Namespace.new(@document.root, 'apps', 'http://schemas.google.com/apps/2006')

        @document.root << category
        @document.root << content
      end

      def category
        header = Atom::XML::Node.new 'category'
        header['scheme'] = 'http://schemas.google.com/g/2005#kind'
        header['term'] = 'http://schemas.google.com/apps/2006#mailItem'

        header
      end

      def content
        header = Atom::XML::Node.new 'atom:content'
        Atom::XML::Namespace.new(header, 'atom', 'http://www.w3.org/2005/Atom')
        header['type'] = 'message/rfc822'

        header
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
google_apps-0.4.9 lib/google_apps/atom/message_attributes.rb
google_apps-0.4.8.1 lib/google_apps/atom/message_attributes.rb
google_apps-0.4.8 lib/google_apps/atom/message_attributes.rb
google_apps-0.4.6 lib/google_apps/atom/message_attributes.rb
google_apps-0.4.5 lib/google_apps/atom/message_attributes.rb
google_apps-0.4.2 lib/google_apps/atom/message_attributes.rb
google_apps-0.4.1 lib/google_apps/atom/message_attributes.rb
google_apps-0.4 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.12 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.11 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.10 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.9 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.8 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.7 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.6 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.5 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.4 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.3 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.2 lib/google_apps/atom/message_attributes.rb
google_apps-0.3.1 lib/google_apps/atom/message_attributes.rb