Sha256: b0cb838664cfac50af0c1c2312b5e8b182277bc9d7af2b1dfd2bee026b166f13

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 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]
            options_string << "occurred_since_date=#{options[:occurred_since]}"
          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
pivotal-tracker-0.1.0 lib/pivotal-tracker/activity.rb
pivotal-tracker-0.0.9.1 lib/pivotal-tracker/activity.rb