Sha256: 12ddcb3cc76035b05453613bdc7435aecacdbdd39f87e54e6d297be1fe6d44e4

Contents?: true

Size: 1.66 KB

Versions: 4

Compression:

Stored size: 1.66 KB

Contents

module Coop
  class Group < APIObject
    # Public: The base for all status API calls
    #
    # Examples
    #
    #   self.statuses
    #   # => #<Coop::Status @group_id=12345>
    #
    # Returns a Coop::Status instance with the group_id set
    def statuses
      Status.new({ group_id: self.id })
    end
    
    # Public: Post a status update to a group
    #
    # message - The text for the status update
    #
    # Examples
    #
    #   Group.new({ id: 12345 }).post! "Is this computer?"
    #   # => "/statuses/123456"
    #
    # Returns String of new status' URL
    def post!(message)
      Status.new({ group_id: self.id }).post!(message)
    end
    
    # Public: Post a status update to a group as Cobot
    #
    # message - The text for the status update
    # api_key - The API key needed to post as Cobot
    #
    # Examples
    #
    #   Group.new({ id: 12345 }).post_as_cobot! "YES, THIS IS COMPUTER", "THISISMYSECRETKEY"
    #   # => "/statuses/123456"
    #
    # Returns String of new status' URL
    def post_as_cobot!(message, api_key)
      Status.new({ group_id: self.id }).post_as_cobot!(message, api_key)
    end
    
    # Public: The base for all agenda API calls
    #
    # Examples
    #
    #   self.statuses
    #   # => #<Coop::Agenda @group_id=12345>
    #
    # Returns a Coop::Agenda instance with the group_id set
    def agenda
      Agenda.new({ group_id: self.id })
    end
    
    # Public: The base for all user API calls
    #
    # Examples
    #
    #   self.users
    #   # => #<Coop::User @group_id=12345>
    #
    # Returns a Coop::User instance with the group_id set
    def users
      User.new({ group_id: self.id }).all
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
coop-1.1.1 lib/coop/api_object/group.rb
coop-1.1.0 lib/coop/api_object/group.rb
coop-1.0.1 lib/coop/api_object/group.rb
coop-1.0.0 lib/coop/api_object/group.rb