Class: Convore::Group

Inherits:
Base
  • Object
show all
Defined in:
lib/convore/group.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

find, from_json, get_class, #method_missing

Constructor Details

#initialize(username, password) ⇒ Group

Returns a new instance of Group.



8
9
10
11
# File 'lib/convore/group.rb', line 8

def initialize(username, password)
	@username = username
	@password = password
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Convore::Base

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/convore/group.rb', line 6

def password
  @password
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/convore/group.rb', line 6

def username
  @username
end

Class Method Details

.apiObject



98
99
100
# File 'lib/convore/group.rb', line 98

def self.api
	'group'
end

Instance Method Details

#create_group(hash) ⇒ Object

Create a new group.



19
20
21
22
23
24
25
26
# File 'lib/convore/group.rb', line 19

def create_group(hash)
	RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/create.json",
		{:name => hash[:name],
		 :kind => hash[:kind],
		 #from here down optional
		 :description => hash[:description],
		 :slug => hash[:slug]}
end

#create_topic(group_id, hash) ⇒ Object

Create a new topic



84
85
86
87
88
89
# File 'lib/convore/group.rb', line 84

def create_topic(group_id, hash)
	if group_id.integer?
		RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/topics/create.json",
		{:name => hash[:name]}
	end
end

#get_group_info(group_id) ⇒ Object

Get detailed information about the group



29
30
31
32
33
# File 'lib/convore/group.rb', line 29

def get_group_info(group_id)
	if group_id.integer?
		RestClient.get "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}.json"
	end
end

#get_group_members(group_id, *hash) ⇒ Object

Get the group members



36
37
38
39
40
41
42
43
# File 'lib/convore/group.rb', line 36

def get_group_members(group_id, *hash)
	if group_id.integer?
		RestClient.get "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/members.json",
		#from here down optional
		#{:filter => hash[:admin]}
		hash[0]
	end
end

#get_groupsObject

Get a list of the current user’s groups



14
15
16
# File 'lib/convore/group.rb', line 14

def get_groups
	RestClient.get "https://#{@username}:#{@password}@convore.com/api/groups.json"
end

#get_latest_topics(group_id, *hash) ⇒ Object

Get the latest topics in a group



74
75
76
77
78
79
80
81
# File 'lib/convore/group.rb', line 74

def get_latest_topics(group_id, *hash)
	if group_id.integer?
		RestClient.get "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/topics.json",
		#from here down optional (pagination)
		#{:until_id => hash[:until_id]}
		hash[0]
	end
end

#get_online_members(group_id) ⇒ Object

Get group members online now



67
68
69
70
71
# File 'lib/convore/group.rb', line 67

def get_online_members(group_id)
	if group_id.integer?
		RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/online.json", {}
	end
end

#join_private_group(group_id) ⇒ Object

Requests to join a private group



53
54
55
56
57
# File 'lib/convore/group.rb', line 53

def join_private_group(group_id)
	if group_id.integer?
		RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/request.json", ()
	end
end

#join_public_group(group_id) ⇒ Object

Join a public group



46
47
48
49
50
# File 'lib/convore/group.rb', line 46

def join_public_group(group_id)
	if group_id.integer?
		RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/join.json", {}
	end
end

#leave_group(group_id) ⇒ Object

Leave a group



60
61
62
63
64
# File 'lib/convore/group.rb', line 60

def leave_group(group_id)
	if group_id.integer?
		RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/leave.json", {}
	end
end

#mark_all_read(group_id) ⇒ Object

Mark all messages in the group as read



92
93
94
95
96
# File 'lib/convore/group.rb', line 92

def mark_all_read(group_id)
	if group_id.integer?
		RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/mark_read.json", {}
	end
end