onlyoffice_api 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/lib/onlyoffice_api.rb +65 -0
  3. data/lib/teamlab/config.rb +39 -0
  4. data/lib/teamlab/modules/calendar.rb +111 -0
  5. data/lib/teamlab/modules/community.rb +20 -0
  6. data/lib/teamlab/modules/community/community_blogs.rb +54 -0
  7. data/lib/teamlab/modules/community/community_bookmarks.rb +60 -0
  8. data/lib/teamlab/modules/community/community_events.rb +50 -0
  9. data/lib/teamlab/modules/community/community_forums.rb +70 -0
  10. data/lib/teamlab/modules/community/community_wiki.rb +66 -0
  11. data/lib/teamlab/modules/crm.rb +32 -0
  12. data/lib/teamlab/modules/crm/crm_cases.rb +72 -0
  13. data/lib/teamlab/modules/crm/crm_common.rb +42 -0
  14. data/lib/teamlab/modules/crm/crm_contacts.rb +243 -0
  15. data/lib/teamlab/modules/crm/crm_files.rb +44 -0
  16. data/lib/teamlab/modules/crm/crm_history.rb +42 -0
  17. data/lib/teamlab/modules/crm/crm_invoices.rb +123 -0
  18. data/lib/teamlab/modules/crm/crm_opportunities.rb +93 -0
  19. data/lib/teamlab/modules/crm/crm_organisation.rb +14 -0
  20. data/lib/teamlab/modules/crm/crm_tags.rb +54 -0
  21. data/lib/teamlab/modules/crm/crm_tasks.rb +62 -0
  22. data/lib/teamlab/modules/crm/crm_user_fields.rb +34 -0
  23. data/lib/teamlab/modules/feed.rb +23 -0
  24. data/lib/teamlab/modules/files.rb +256 -0
  25. data/lib/teamlab/modules/group.rb +53 -0
  26. data/lib/teamlab/modules/group/group_helper.rb +15 -0
  27. data/lib/teamlab/modules/mail.rb +32 -0
  28. data/lib/teamlab/modules/mail/mail_accounts.rb +55 -0
  29. data/lib/teamlab/modules/mail/mail_alerts.rb +14 -0
  30. data/lib/teamlab/modules/mail/mail_contacts.rb +14 -0
  31. data/lib/teamlab/modules/mail/mail_conversations.rb +54 -0
  32. data/lib/teamlab/modules/mail/mail_folders.rb +18 -0
  33. data/lib/teamlab/modules/mail/mail_helpcenter.rb +10 -0
  34. data/lib/teamlab/modules/mail/mail_images.rb +18 -0
  35. data/lib/teamlab/modules/mail/mail_messages.rb +74 -0
  36. data/lib/teamlab/modules/mail/mail_settings.rb +17 -0
  37. data/lib/teamlab/modules/mail/mail_signature.rb +14 -0
  38. data/lib/teamlab/modules/mail/mail_tags.rb +30 -0
  39. data/lib/teamlab/modules/people.rb +104 -0
  40. data/lib/teamlab/modules/people/people_reassign.rb +26 -0
  41. data/lib/teamlab/modules/portals.rb +17 -0
  42. data/lib/teamlab/modules/project.rb +37 -0
  43. data/lib/teamlab/modules/projects/projects_comments.rb +34 -0
  44. data/lib/teamlab/modules/projects/projects_contacts.rb +18 -0
  45. data/lib/teamlab/modules/projects/projects_discussions.rb +46 -0
  46. data/lib/teamlab/modules/projects/projects_files.rb +34 -0
  47. data/lib/teamlab/modules/projects/projects_milestones.rb +46 -0
  48. data/lib/teamlab/modules/projects/projects_projects.rb +82 -0
  49. data/lib/teamlab/modules/projects/projects_reports.rb +18 -0
  50. data/lib/teamlab/modules/projects/projects_settings.rb +11 -0
  51. data/lib/teamlab/modules/projects/projects_tags.rb +18 -0
  52. data/lib/teamlab/modules/projects/projects_tasks.rb +94 -0
  53. data/lib/teamlab/modules/projects/projects_team.rb +30 -0
  54. data/lib/teamlab/modules/projects/projects_templates.rb +26 -0
  55. data/lib/teamlab/modules/projects/projects_time.rb +34 -0
  56. data/lib/teamlab/modules/settings.rb +100 -0
  57. data/lib/teamlab/name.rb +5 -0
  58. data/lib/teamlab/request.rb +79 -0
  59. data/lib/teamlab/response.rb +41 -0
  60. data/lib/teamlab/version.rb +5 -0
  61. metadata +140 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1830c70d5adb88be136ed8754fbab4237f09215af5044e0c7fc19b595ee9b7a2
4
+ data.tar.gz: 58be0866eede5603be83fd7fcb2e6dc0ea91240c168ef7d2d64640e83f80688b
5
+ SHA512:
6
+ metadata.gz: 0ccb2919484583fee863be395d0cfa34149e4c8264cb2abd1d665dfcac939a8b6992a11586792693129efd4de9d082749a1048bfbefe656390e004d4079bdb6d
7
+ data.tar.gz: 5069dc9a84c740ee1888c3950cb93bc4d10ea8643d3a176ae91bce70855f9b80950500b31b34632f9b02baac393bfee563a26d5e7af6df7820afc5dcf51678ae
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'teamlab/version'
4
+ require_relative 'teamlab/config'
5
+ require_relative 'teamlab/request'
6
+ require_relative 'teamlab/response'
7
+ require_relative 'teamlab/modules/people'
8
+ require_relative 'teamlab/modules/group'
9
+ require_relative 'teamlab/modules/settings'
10
+ require_relative 'teamlab/modules/files'
11
+ require_relative 'teamlab/modules/project'
12
+ require_relative 'teamlab/modules/portals'
13
+ require_relative 'teamlab/modules/crm'
14
+ require_relative 'teamlab/modules/community'
15
+ require_relative 'teamlab/modules/calendar'
16
+ require_relative 'teamlab/modules/mail'
17
+ require_relative 'teamlab/modules/feed'
18
+
19
+ module Teamlab
20
+ def self.people
21
+ @people ||= Teamlab::People.new
22
+ end
23
+
24
+ def self.group
25
+ @group ||= Teamlab::Group.new
26
+ end
27
+
28
+ def self.settings
29
+ @settings ||= Teamlab::Settings.new
30
+ end
31
+
32
+ def self.files
33
+ @files ||= Teamlab::Files.new
34
+ end
35
+
36
+ def self.project
37
+ @project ||= Teamlab::Project.new
38
+ end
39
+
40
+ def self.portal
41
+ @portal ||= Teamlab::Portal.new
42
+ end
43
+
44
+ def self.crm
45
+ @crm ||= Teamlab::Crm.new
46
+ end
47
+
48
+ def self.community
49
+ @community ||= Teamlab::Community.new
50
+ end
51
+
52
+ def self.calendar
53
+ @calendar ||= Teamlab::Calendar.new
54
+ end
55
+
56
+ def self.mail
57
+ @mail ||= Teamlab::Mail.new
58
+ end
59
+
60
+ def self.feed
61
+ @feed ||= Teamlab::Feed.new
62
+ end
63
+ end
64
+
65
+ OnlyOfficeApi = Teamlab
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
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
+ auth_response = Teamlab::Request.new('authentication').post('', userName: @config.username, password: @config.password).body
12
+ raise "Cannot get response token for #{auth_response}" if auth_response['response'].nil? || auth_response['response']['token'].nil?
13
+
14
+ @config.token = auth_response['response']['token']
15
+ @config.headers = { 'authorization' => @config.token }
16
+ end
17
+
18
+ def self.config
19
+ @config ||= Config.new
20
+ end
21
+
22
+ class Config
23
+ attr_accessor :server, :api_path, :api_additive, :username, :password, :token, :headers
24
+ # @return [Net::HTTP::Proxy] connection proxy
25
+ attr_accessor :proxy
26
+
27
+ def initialize
28
+ default_configuration
29
+ end
30
+
31
+ def default_configuration
32
+ @server = 'https://teamlab.com'
33
+ @api_path = '/api/2.0/'
34
+ @api_additive = ''
35
+ @username = 'user'
36
+ @password = 'password'
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ class Calendar
5
+ def initialize
6
+ @request = Teamlab::Request.new('calendar')
7
+ end
8
+
9
+ def get_default_access
10
+ @request.get(%w[sharing])
11
+ end
12
+
13
+ def get_calendar(id)
14
+ @request.get([id.to_s])
15
+ end
16
+
17
+ def get_subscription_list
18
+ @request.get(%w[subscriptions])
19
+ end
20
+
21
+ def get_icalc_link(calendar_id)
22
+ @request.get([calendar_id.to_s, 'icalurl'])
23
+ end
24
+
25
+ def get_access_parameters(calendar_id)
26
+ @request.get([calendar_id.to_s, 'sharing'])
27
+ end
28
+
29
+ def get_event_history_by_id(event_id)
30
+ @request.get(['events', event_id.to_s, 'historybyid'])
31
+ end
32
+
33
+ def get_event_history_by_uid(event_uid)
34
+ @request.get(['events', event_uid.to_s, 'historybyuid'])
35
+ end
36
+
37
+ def get_icalc_feed(calendar_id, signature)
38
+ @request.get([calendar_id.to_s, 'ical', signature.to_s])
39
+ end
40
+
41
+ def get_calendar_events(start_date, end_date)
42
+ @request.get(['eventdays', start_date.to_s, end_date.to_s])
43
+ end
44
+
45
+ def get_calendars_and_subscriptions(start_date, end_date)
46
+ @request.get(['calendars', start_date.to_s, end_date.to_s])
47
+ end
48
+
49
+ def create_calendar(name, time_zone, options = {})
50
+ @request.post('', { name: name, timeZone: time_zone }.merge(options))
51
+ end
52
+
53
+ def create_calendar_by_ical_link(ical_url, name, options = {})
54
+ @request.post(%w[calendarurl], { iCalUrl: ical_url, name: name }.merge(options))
55
+ end
56
+
57
+ def add_event(calendar_id, name, options = {})
58
+ @request.post([calendar_id.to_s, 'event'], { name: name }.merge(options))
59
+ end
60
+
61
+ def add_icsevent(calendar_id, ics, options = {})
62
+ @request.post(['icsevent'], { calendarId: calendar_id.to_s, ics: ics.to_s }.merge(options))
63
+ end
64
+
65
+ def import_ical(calendar_id, file)
66
+ @request.post([calendar_id.to_s, 'import'], somefile: File.new(file))
67
+ end
68
+
69
+ def import_events(calendar_id, ical)
70
+ @request.post(['importIcs'], calendarId: calendar_id.to_s, iCalString: ical.to_s)
71
+ end
72
+
73
+ def update_calendar(calendar_id, name, time_zone, options = {})
74
+ @request.put([calendar_id.to_s], { name: name, timeZone: time_zone }.merge(options))
75
+ end
76
+
77
+ def update_calendar_user_view(calendar_id, name, time_zone, options = {})
78
+ @request.put([calendar_id.to_s, 'view'], { name: name, timeZone: time_zone }.merge(options))
79
+ end
80
+
81
+ def manage_subscriptions(states)
82
+ @request.put(%w[subscriptions manage], states: states)
83
+ end
84
+
85
+ def update_event(calendar_id, event_id, name, options = {})
86
+ @request.put([calendar_id.to_s, event_id.to_s], { name: name }.merge(options))
87
+ end
88
+
89
+ def update_icsevent(calendar_id, event_id, ics, options = {})
90
+ @request.put(['icsevent'], { calendarId: calendar_id.to_s, eventId: event_id.to_s, ics: ics.to_s }.merge(options))
91
+ end
92
+
93
+ def delete_calendar(calendar_id)
94
+ @request.delete([calendar_id.to_s])
95
+ end
96
+
97
+ def delete_event_series(event_id)
98
+ @request.delete(['events', event_id.to_s])
99
+ end
100
+
101
+ def delete_event(event_id, options = {})
102
+ @request.delete(['events', event_id.to_s, 'custom'], options)
103
+ end
104
+
105
+ alias remove_event delete_event
106
+
107
+ def unsubscribe_from_event(event_id)
108
+ @request.delete(['events', event_id.to_s, 'unsubscribe'])
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'community/community_blogs'
4
+ require_relative 'community/community_bookmarks'
5
+ require_relative 'community/community_events'
6
+ require_relative 'community/community_forums'
7
+ require_relative 'community/community_wiki'
8
+ module Teamlab
9
+ class Community
10
+ include CommunityBlogs
11
+ include CommunityBookmarks
12
+ include CommunityEvents
13
+ include CommunityForums
14
+ include CommunityWiki
15
+
16
+ def initialize
17
+ @request = Teamlab::Request.new('community')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with community blogs
5
+ module CommunityBlogs
6
+ def get_all_posts
7
+ @request.get(%w[blog])
8
+ end
9
+
10
+ def get_blog_tags
11
+ @request.get(%w[blog tag])
12
+ end
13
+
14
+ def get_my_posts
15
+ @request.get(%w[blog @self])
16
+ end
17
+
18
+ def get_post(post_id)
19
+ @request.get(['blog', post_id.to_s])
20
+ end
21
+
22
+ def get_posts_by_tag(tag)
23
+ @request.get(['blog', 'tag', tag.to_s])
24
+ end
25
+
26
+ def search_posts(query)
27
+ @request.get(['blog', '@search', query.to_s])
28
+ end
29
+
30
+ def get_user_posts(username)
31
+ @request.get(['blog', 'user', username.to_s])
32
+ end
33
+
34
+ def get_comments(post_id)
35
+ @request.get(['blog', post_id.to_s, 'comment'])
36
+ end
37
+
38
+ def create_post(title, content, options = {})
39
+ @request.post(%w[blog], { title: title, content: content }.merge(options))
40
+ end
41
+
42
+ def add_comment(post_id, content, options = {})
43
+ @request.post(['blog', post_id.to_s, 'comment'], { content: content }.merge(options))
44
+ end
45
+
46
+ def update_post(post_id, title, content, options = {})
47
+ @request.put(['blog', post_id.to_s], { title: title, content: content }.merge(options))
48
+ end
49
+
50
+ def delete_post(post_id)
51
+ @request.delete(['blog', post_id.to_s])
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with community bookmarks
5
+ module CommunityBookmarks
6
+ def get_all_bookmarks
7
+ @request.get(%w[bookmark])
8
+ end
9
+
10
+ def get_all_bookmark_tags
11
+ @request.get(%w[bookmark tag])
12
+ end
13
+
14
+ def get_bookmark(id)
15
+ @request.get(['bookmark', id.to_s])
16
+ end
17
+
18
+ def get_bookmarks_added_by_me
19
+ @request.get(%w[bookmark @self])
20
+ end
21
+
22
+ def get_my_favourite_bookmarks
23
+ @request.get(%w[bookmark @favs])
24
+ end
25
+
26
+ %w[day week month year].each do |e|
27
+ define_method("get_top_of_#{e}_bookmarks") { @request.get(['bookmark', 'top', e.to_s]) }
28
+ end
29
+
30
+ def get_bookmarks_by_tag(tag)
31
+ @request.get(['bookmark', 'tag', tag.to_s])
32
+ end
33
+
34
+ def get_recently_added_bookmarks
35
+ @request.get(%w[bookmark top recent])
36
+ end
37
+
38
+ def get_bookmark_comments(bookmark_id)
39
+ @request.get(['bookmark', bookmark_id.to_s, 'comment'])
40
+ end
41
+
42
+ def search_bookmarks(queue)
43
+ @request.get(['bookmark', '@search', queue.to_s])
44
+ end
45
+
46
+ def add_bookmark(url, title, options = {})
47
+ @request.post(%w[bookmark], { url: url, title: title }.merge(options))
48
+ end
49
+
50
+ def add_comment_to_bookmark(bookmark_id, content, options = {})
51
+ @request.post(['bookmark', bookmark_id.to_s, 'comment'], { content: content }.merge(options))
52
+ end
53
+
54
+ # @param bookmark_id [Intger] bookmark to delete
55
+ # @return [Teamlab::Response] result of delete
56
+ def delete_bookmark(bookmark_id)
57
+ @request.delete(['bookmark', bookmark_id.to_s])
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with community events
5
+ module CommunityEvents
6
+ def get_all_events
7
+ @request.get(%w[event])
8
+ end
9
+
10
+ def get_my_events
11
+ @request.get(%w[event @self])
12
+ end
13
+
14
+ def get_event(id)
15
+ @request.get(['event', id.to_s])
16
+ end
17
+
18
+ def search_events(query)
19
+ @request.get(['event', '@search', query])
20
+ end
21
+
22
+ def get_event_comments(event_id)
23
+ @request.get(['event', event_id.to_s, 'comment'])
24
+ end
25
+
26
+ def create_event(title, content, options = {})
27
+ @request.post(%w[event], { title: title, content: content }.merge(options))
28
+ end
29
+
30
+ def vote_for_event(event_id, *variants)
31
+ @request.post(['event', event_id.to_s, 'vote'], variants: variants.flatten)
32
+ end
33
+
34
+ def add_comment_to_event(event_id, content, options = {})
35
+ @request.post(['event', event_id.to_s, 'comment'], { content: content }.merge(options))
36
+ end
37
+
38
+ def update_event(event_id, options = {})
39
+ @request.put(['event', event_id.to_s], title: options[:title],
40
+ content: options[:content],
41
+ type: options[:type])
42
+ end
43
+
44
+ # Deletes the selected event
45
+ # @param event_id [Integer] id of event
46
+ def delete_event(event_id)
47
+ @request.delete(['event', event_id.to_s])
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with community forums
5
+ module CommunityForums
6
+ def get_forums
7
+ @request.get(%w[forum])
8
+ end
9
+
10
+ def get_thread_topics(id)
11
+ @request.get(['forum', id.to_s])
12
+ end
13
+
14
+ def get_last_updated_topics
15
+ @request.get(%w[forum topic recent])
16
+ end
17
+
18
+ def get_posts(topic_id)
19
+ @request.get(['forum', 'topic', topic_id.to_s])
20
+ end
21
+
22
+ def search_topics(query)
23
+ @request.get(['forum', '@search', query.to_s])
24
+ end
25
+
26
+ def add_thread_to_category(category_id, category_name, thread_name, description)
27
+ @request.post(%w[forum], categoryId: category_id, categoryName: category_name.to_s, threadName: thread_name, threadDescription: description)
28
+ end
29
+
30
+ def add_topic_to_thread(thread_id, subject, content, options = {})
31
+ @request.post(['forum', thread_id], { subject: subject, content: content }.merge(options))
32
+ end
33
+
34
+ def add_post_to_topic(topic_id, subject, content, options = {})
35
+ @request.post(['forum', 'topic', topic_id.to_s], { subject: subject, content: content }.merge(options))
36
+ end
37
+
38
+ def update_topic_in_thread(topic_id, subject, options = {})
39
+ @request.put(['forum', 'topic', topic_id.to_s], { subject: subject }.merge(options))
40
+ end
41
+
42
+ def update_post_in_topic(topic_id, post_id, options = {})
43
+ @request.put(['forum', 'topic', topic_id.to_s, post_id.to_s], options)
44
+ end
45
+
46
+ # @param post_id [Integer] post to delete
47
+ # @return [Teamlab::Response] result of delete
48
+ def delete_forum_post(post_id)
49
+ @request.delete(['forum', 'post', post_id.to_s])
50
+ end
51
+
52
+ # @param topic_id [Integer] topic to delete
53
+ # @return [Teamlab::Response] result of delete
54
+ def delete_forum_topic(topic_id)
55
+ @request.delete(['forum', 'topic', topic_id.to_s])
56
+ end
57
+
58
+ # @param thread_id [Integer] thread to delete
59
+ # @return [Teamlab::Response] result of delete
60
+ def delete_thread(thread_id)
61
+ @request.delete(['forum', 'thread', thread_id.to_s])
62
+ end
63
+
64
+ # @param category_id [Integer] category to delete
65
+ # @return [Teamlab::Response] result of delete
66
+ def delete_category(category_id)
67
+ @request.delete(['forum', 'category', category_id.to_s])
68
+ end
69
+ end
70
+ end