Sha256: ee43cacd25c35b9077e10595ac2cb28ba46219202102c962059df5657acf1346

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

module PivotalTracker
  class Activity
    include HappyMapper
    class << self
      def all(project=nil, options={})
        params = self.encode_options(options)
        if project
          parse(Client.connection["/projects/#{project.id}/activities#{params}"].get)
        else
          parse(Client.connection["/activities#{params}"].get)
        end
      end

      protected

        def encode_options(options)
          return nil if !options.is_a?(Hash) || options.empty?

          options_string = []
          options_string << "limit=#{options.delete(:limit)}" if options[:limit]
          options_string << "newer_than_version=#{options.delete(:newer_than_version)}" if options[:newer_than_version]

          if options[:occurred_since]
            options_string << "occurred_since_date=\"#{options[:occurred_since].utc}\""
          elsif options[:occurred_since_date]
            #NOTE currently forces UTC as the timezone
            options_string << "occurred_since_date=#{URI.escape options[:occurred_since_date].strftime("%Y/%m/%d %H:%M:%S UTC")}"
          end

          return "?#{options_string.join('&')}"
        end

    end

    element :id, Integer
    element :version, Integer
    element :event_type, String
    element :occurred_at, DateTime
    element :author, String
    element :project_id, Integer
    element :description, String

    has_many :stories, Story

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tsenart-pivotal-tracker-0.5.0 lib/pivotal-tracker/activity.rb
tsenart-pivotal-tracker-0.4.0 lib/pivotal-tracker/activity.rb