teamlab 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/lib/teamlab.rb +61 -0
- data/lib/teamlab/Config.rb +37 -0
- data/lib/teamlab/Modules/Calendar.rb +98 -0
- data/lib/teamlab/Modules/Community.rb +248 -0
- data/lib/teamlab/Modules/Crm.rb +773 -0
- data/lib/teamlab/Modules/Files.rb +193 -0
- data/lib/teamlab/Modules/Group.rb +49 -0
- data/lib/teamlab/Modules/Mail.rb +30 -0
- data/lib/teamlab/Modules/People.rb +97 -0
- data/lib/teamlab/Modules/Project.rb +437 -0
- data/lib/teamlab/Modules/Settings.rb +53 -0
- data/lib/teamlab/Request.rb +61 -0
- data/lib/teamlab/Response.rb +14 -0
- data/lib/teamlab/version.rb +3 -0
- data/spec/lib/Teamlab_spec.rb +1745 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/http_data.rb +149 -0
- data/teamlab.gemspec +28 -0
- metadata +168 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 rzagudaev
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Teamlab
|
2
|
+
|
3
|
+
Ruby Framework to interact with TeamLab API 2.0
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'teamlab'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install teamlab
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
First of all, you should configure your enviroment by commands
|
22
|
+
|
23
|
+
$ Teamlab.configure do |config|
|
24
|
+
$ config.server = 'example.teamlab.com'
|
25
|
+
$ config.username = 'foo'
|
26
|
+
$ config.password = 'bar'
|
27
|
+
$ end
|
28
|
+
|
29
|
+
and then call methods you need:
|
30
|
+
|
31
|
+
$ Teamlab.people.get_people
|
32
|
+
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/teamlab.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative 'teamlab/version'
|
2
|
+
require_relative 'teamlab/Config'
|
3
|
+
require_relative 'teamlab/Request'
|
4
|
+
require_relative 'teamlab/Response'
|
5
|
+
require_relative 'teamlab/Modules/People'
|
6
|
+
require_relative 'teamlab/Modules/Group'
|
7
|
+
require_relative 'teamlab/Modules/Settings'
|
8
|
+
require_relative 'teamlab/Modules/Files'
|
9
|
+
require_relative 'teamlab/Modules/Project'
|
10
|
+
require_relative 'teamlab/Modules/Crm'
|
11
|
+
require_relative 'teamlab/Modules/Community'
|
12
|
+
require_relative 'teamlab/Modules/Calendar'
|
13
|
+
require_relative 'teamlab/Modules/Mail'
|
14
|
+
|
15
|
+
module Teamlab
|
16
|
+
|
17
|
+
def self.people
|
18
|
+
Teamlab.config.api_additive = 'people'
|
19
|
+
@people ||= Teamlab::People.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.group
|
23
|
+
Teamlab.config.api_additive = 'group'
|
24
|
+
@group ||= Teamlab::Group.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.settings
|
28
|
+
Teamlab.config.api_additive = 'settings'
|
29
|
+
@settings ||= Teamlab::Settings.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.files
|
33
|
+
Teamlab.config.api_additive = 'files'
|
34
|
+
@files ||= Teamlab::Files.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.project
|
38
|
+
Teamlab.config.api_additive = 'project'
|
39
|
+
@project ||= Teamlab::Project.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.crm
|
43
|
+
Teamlab.config.api_additive = 'crm'
|
44
|
+
@crm ||= Teamlab::Crm.new
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.community
|
48
|
+
Teamlab.config.api_additive = 'community'
|
49
|
+
@community ||= Teamlab::Community.new
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.calendar
|
53
|
+
Teamlab.config.api_additive = 'calendar'
|
54
|
+
@calendar ||= Teamlab::Calendar.new
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.mail
|
58
|
+
Teamlab.config.api_additive = 'mail'
|
59
|
+
@mail ||= Teamlab::Mail.new
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'active_support/configurable'
|
3
|
+
require_relative 'Request'
|
4
|
+
|
5
|
+
module Teamlab
|
6
|
+
attr_reader :config
|
7
|
+
|
8
|
+
def self.configure(&block)
|
9
|
+
@config ||= Config.new
|
10
|
+
yield @config if block_given?
|
11
|
+
@config.api_additive = 'authentication'
|
12
|
+
@config.token = Teamlab::Request.post('', {:userName => @config.username, :password => @config.password}).body['response']['token']
|
13
|
+
@config.headers = { 'authorization' => @config.token}
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.config
|
17
|
+
@config ||= Config.new
|
18
|
+
end
|
19
|
+
|
20
|
+
class Config
|
21
|
+
include ActiveSupport::Configurable
|
22
|
+
|
23
|
+
config_accessor :server, :api_path, :api_additive, :username, :password, :token, :headers
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
default_configuration
|
27
|
+
end
|
28
|
+
|
29
|
+
def default_configuration
|
30
|
+
self.server = 'https://teamlab.com'
|
31
|
+
self.api_path = '/api/2.0/'
|
32
|
+
self.api_additive = ''
|
33
|
+
self.username = 'user'
|
34
|
+
self.password = 'password'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Teamlab
|
2
|
+
class Calendar
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@request = Teamlab::Request
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_default_access
|
9
|
+
@request.get(%w(sharing))
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_calendar(id)
|
13
|
+
@request.get([id.to_s])
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_subscription_list
|
17
|
+
@request.get(%w(subscriptions))
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_icalc_link(calendar_id)
|
21
|
+
@request.get([calendar_id.to_s, 'icalurl'])
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_access_parameters(calendar_id)
|
25
|
+
@request.get([calendar_id.to_s, 'sharing'])
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_icalc_feed(calendar_id, signature)
|
29
|
+
@request.get([calendar_id.to_s, 'ical', signature.to_s])
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_calendar_events(start_date, end_date)
|
33
|
+
@request.get(['eventdays', start_date.to_s, end_date.to_s])
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_calendars_and_subscriptions(start_date, end_date)
|
37
|
+
@request.get(['calendars', start_date.to_s, end_date.to_s])
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_calendar(name, options = {})
|
41
|
+
@request.post('', {name: name}.merge(options))
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_calendar_by_ical_link(ical_url, options = {})
|
45
|
+
@request.post(%w(calendarurl), {iCalUrl: ical_url}.merge(options))
|
46
|
+
end
|
47
|
+
|
48
|
+
#============== TODO: OPTIONAL VARIABLES
|
49
|
+
|
50
|
+
def add_event(calendar_id, name, options = {})
|
51
|
+
@request.post([calendar_id.to_s], {name: name}.merge(options))
|
52
|
+
end
|
53
|
+
|
54
|
+
def import_ical(calendar_id, *files)
|
55
|
+
@request.post([calendar_id.to_s, 'import'], files: files.flatten)
|
56
|
+
end
|
57
|
+
|
58
|
+
#============== TODO: OPTIONAL VARIABLES
|
59
|
+
|
60
|
+
def update_calendar(calendar_id, name, options = {})
|
61
|
+
@request.put([calendar_id.to_s], {name: name}.merge(options))
|
62
|
+
end
|
63
|
+
|
64
|
+
#============== TODO: OPTIONAL VARIABLES
|
65
|
+
|
66
|
+
def update_calendar_user_view(calendar_id, options = {})
|
67
|
+
@request.put([calendar_id.to_s, 'view'], options)
|
68
|
+
end
|
69
|
+
|
70
|
+
def manage_subscriptions(states)
|
71
|
+
@request.put(%w(subscriptions manage), states: states)
|
72
|
+
end
|
73
|
+
|
74
|
+
#============== TODO: OPTIONAL VARIABLES
|
75
|
+
|
76
|
+
def update_event(calendar_id, event_id, name, options = {})
|
77
|
+
@request.put([calendar_id.to_s, event_id.to_s], {name: name}.merge(options))
|
78
|
+
end
|
79
|
+
|
80
|
+
def delete_calendar(calendar_id)
|
81
|
+
@request.delete([calendar_id.to_s])
|
82
|
+
end
|
83
|
+
|
84
|
+
def delete_event_series(event_id)
|
85
|
+
@request.delete(['events', event_id.to_s])
|
86
|
+
end
|
87
|
+
|
88
|
+
#============== TODO: OPTIONAL VARIABLES
|
89
|
+
|
90
|
+
def remove_event(event_id, options = {})
|
91
|
+
@request.delete(['events', event_id.to_s, 'custom'], options)
|
92
|
+
end
|
93
|
+
|
94
|
+
def unsubscribe_from_event(event_id)
|
95
|
+
@request.delete(['events', event_id.to_s, 'unsubscribe'])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,248 @@
|
|
1
|
+
module Teamlab
|
2
|
+
class Community
|
3
|
+
def initialize
|
4
|
+
@request = Teamlab::Request
|
5
|
+
end
|
6
|
+
|
7
|
+
def get_all_posts
|
8
|
+
@request.get(%w(blog))
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_blog_tags
|
12
|
+
@request.get(%w(blog tag))
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_my_posts
|
16
|
+
@request.get(%w(blog @self))
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_post(post_id)
|
20
|
+
@request.get(['blog', post_id.to_s])
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_posts_by_tag(tag)
|
24
|
+
@request.get(['blog', 'tag', tag.to_s])
|
25
|
+
end
|
26
|
+
|
27
|
+
def search_posts(query)
|
28
|
+
@request.get(['blog', '@search', query.to_s])
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_user_posts(username)
|
32
|
+
@request.get(['blog', 'user', username.to_s])
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_comments(post_id)
|
36
|
+
@request.get(['blog', post_id.to_s, 'comment'])
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_post(title, content, options = {})
|
40
|
+
@request.post(%w(blog), {title: title, content: content}.merge(options))
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_comment(post_id, content, options = {})
|
44
|
+
@request.post(['blog', post_id.to_s, 'comment'], {content: content}.merge(options))
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_post(post_id, title, content, options = {})
|
48
|
+
@request.put(['blog', post_id.to_s], {title: title, content: content}.merge(options))
|
49
|
+
end
|
50
|
+
|
51
|
+
def delete_post(post_id)
|
52
|
+
@request.delete(['blog', post_id.to_s])
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_all_bookmarks
|
56
|
+
@request.get(%w(bookmark))
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_all_bookmark_tags
|
60
|
+
@request.get(%w(bookmark tag))
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_bookmark(id)
|
64
|
+
@request.get(['bookmark', id.to_s])
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_bookmarks_added_by_me
|
68
|
+
@request.get(%w(bookmark @self))
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_my_favourite_bookmarks
|
72
|
+
@request.get(%w(bookmark @favs))
|
73
|
+
end
|
74
|
+
|
75
|
+
%w(day week month year).each do |e|
|
76
|
+
define_method("get_top_of_#{e}_bookmarks") { @request.get(['bookmark', 'top', e.to_s]) }
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_bookmarks_by_tag(tag)
|
80
|
+
@request.get(['bookmark', 'tag', tag.to_s])
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_recently_added_bookmarks
|
84
|
+
@request.get(%w(bookmark top recent))
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_bookmark_comments(bookmark_id)
|
88
|
+
@request.get(['bookmark', bookmark_id.to_s, 'comment'])
|
89
|
+
end
|
90
|
+
|
91
|
+
def search_bookmarks(queue)
|
92
|
+
@request.get(['bookmark', '@search', queue.to_s])
|
93
|
+
end
|
94
|
+
|
95
|
+
def add_bookmark(url, title, options = {})
|
96
|
+
@request.post(%w(bookmark), {url: url, title: title}.merge(options))
|
97
|
+
end
|
98
|
+
|
99
|
+
def add_comment_to_bookmark(bookmark_id, content, options = {})
|
100
|
+
@request.post(['bookmark', bookmark_id.to_s, 'comment'], {content: content}.merge(options))
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_all_events
|
104
|
+
@request.get(%w(event))
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_my_events
|
108
|
+
@request.get(%w(event @self))
|
109
|
+
end
|
110
|
+
|
111
|
+
def get_event(id)
|
112
|
+
@request.get(['event', id.to_s])
|
113
|
+
end
|
114
|
+
|
115
|
+
def search_events(query)
|
116
|
+
@request.get(['event', '@search', query])
|
117
|
+
end
|
118
|
+
|
119
|
+
def get_event_comments(event_id)
|
120
|
+
@request.get(['event', event_id.to_s, 'comment'])
|
121
|
+
end
|
122
|
+
|
123
|
+
def create_event(title, content, options = {})
|
124
|
+
@request.post(%w(event), {title: title, content: content}.merge(options))
|
125
|
+
end
|
126
|
+
|
127
|
+
def vote_for_event(event_id, *variants)
|
128
|
+
@request.post(['event', event_id.to_s, 'vote'], variants: variants.flatten)
|
129
|
+
end
|
130
|
+
|
131
|
+
def add_comment_to_event(event_id, content, options = {})
|
132
|
+
@request.post(['event', event_id.to_s, 'comment'], {content: content}.merge(options))
|
133
|
+
end
|
134
|
+
|
135
|
+
def update_event(event_id, title, content, options = {})
|
136
|
+
@request.put(['event', event_id.to_s], {title: title, content: content}.merge(options))
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_forums
|
140
|
+
@request.get(%w(forum))
|
141
|
+
end
|
142
|
+
|
143
|
+
def get_thread_topics(id)
|
144
|
+
@request.get(['forum', id.to_s])
|
145
|
+
end
|
146
|
+
|
147
|
+
def get_last_updated_topics
|
148
|
+
@request.get(%w(forum topic recent))
|
149
|
+
end
|
150
|
+
|
151
|
+
def get_posts(topic_id)
|
152
|
+
@request.get(['forum', 'topic', topic_id.to_s])
|
153
|
+
end
|
154
|
+
|
155
|
+
def search_topics(query)
|
156
|
+
@request.get(['forum', '@search', query.to_s])
|
157
|
+
end
|
158
|
+
|
159
|
+
#==================================== TODO: ERROR
|
160
|
+
|
161
|
+
def add_thread_to_category(category_id, category_name, thread_name, options = {})
|
162
|
+
@request.post(%w(forum), {categoryId: category_id, categoryName: category_name.to_s, threadName: thread_name}.merge(options))
|
163
|
+
end
|
164
|
+
|
165
|
+
def add_topic_to_thread(thread_id, subject, content, options = {})
|
166
|
+
@request.post(['forum', thread_id], {subject: subject, content: content}.merge(options))
|
167
|
+
end
|
168
|
+
|
169
|
+
def add_post_to_topic(topic_id, subject, content, options = {})
|
170
|
+
@request.post(['forum', 'topic', topic_id.to_s], {subject: subject, content: content}.merge(options))
|
171
|
+
end
|
172
|
+
|
173
|
+
def update_topic_in_thread(topic_id, options = {})
|
174
|
+
@request.put(['forum', 'topic', topic_id.to_s], options)
|
175
|
+
end
|
176
|
+
|
177
|
+
def update_post_in_topic(topic_id, post_id, options = {})
|
178
|
+
@request.put(['forum', 'topic', topic_id.to_s, post_id.to_s], options)
|
179
|
+
end
|
180
|
+
|
181
|
+
def delete_post_in_topic(topic_id, post_id)
|
182
|
+
@request.delete(['forum', 'topic', topic_id.to_s, post_id.to_s])
|
183
|
+
end
|
184
|
+
|
185
|
+
def get_wiki_pages
|
186
|
+
@request.get(%w(wiki))
|
187
|
+
end
|
188
|
+
|
189
|
+
def get_wiki_page(name, options = {})
|
190
|
+
@request.get(['wiki', name], options)
|
191
|
+
end
|
192
|
+
|
193
|
+
def get_wiki_file_info(name)
|
194
|
+
@request.get(['wiki', 'file', name.to_s])
|
195
|
+
end
|
196
|
+
|
197
|
+
def get_page_history(name)
|
198
|
+
@request.get(['wiki', name.to_s, 'story'])
|
199
|
+
end
|
200
|
+
|
201
|
+
def get_all_page_comments(page_name)
|
202
|
+
@request.get(['wiki', page_name.to_s, 'comment'])
|
203
|
+
end
|
204
|
+
|
205
|
+
def search_wiki_pages_by_name(name)
|
206
|
+
@request.get(['wiki', 'search', 'byname', name.to_s])
|
207
|
+
end
|
208
|
+
|
209
|
+
def search_wiki_pages_by_content(content)
|
210
|
+
@request.get(['wiki', 'search', 'bycontent', content.to_s])
|
211
|
+
end
|
212
|
+
|
213
|
+
def create_page(name, body)
|
214
|
+
@request.post(%w(wiki), {name: name.to_s, body: body.to_s})
|
215
|
+
end
|
216
|
+
|
217
|
+
#================================== TODO: UPLOAD FILES ================================
|
218
|
+
|
219
|
+
def upload_files(*files)
|
220
|
+
@request.post(%w(wiki file), files)
|
221
|
+
end
|
222
|
+
|
223
|
+
def create_wiki_page_comment(page_name, content, options = {})
|
224
|
+
@request.post(['wiki', page_name.to_s, 'comment'], {content: content.to_s}.merge(options))
|
225
|
+
end
|
226
|
+
|
227
|
+
def update_wiki_page(name, body)
|
228
|
+
@request.put(['wiki', name.to_s], {body: body.to_s})
|
229
|
+
end
|
230
|
+
|
231
|
+
def update_wiki_page_comment(comment_id, body)
|
232
|
+
@request.put(['wiki', 'comment', comment_id.to_s], body: body)
|
233
|
+
end
|
234
|
+
|
235
|
+
def delete_wiki_page(name)
|
236
|
+
@request.delete(['wiki', name.to_s])
|
237
|
+
end
|
238
|
+
|
239
|
+
def delete_wiki_file(name)
|
240
|
+
@request.delete(['wiki', 'file', name.to_s])
|
241
|
+
end
|
242
|
+
|
243
|
+
def delete_wiki_page_comment(id)
|
244
|
+
@request.delete(['wiki', 'comment', id.to_s])
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|