onlyoffice_api 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onlyoffice_api/onlyoffice_api_instance.rb +65 -0
- data/lib/onlyoffice_api.rb +1 -0
- data/lib/teamlab/config.rb +5 -2
- data/lib/teamlab/modules/calendar.rb +2 -2
- data/lib/teamlab/modules/community.rb +2 -2
- data/lib/teamlab/modules/crm/crm_common.rb +19 -1
- data/lib/teamlab/modules/crm/crm_contacts.rb +31 -0
- data/lib/teamlab/modules/crm/crm_invoices.rb +14 -0
- data/lib/teamlab/modules/crm/crm_opportunities.rb +7 -0
- data/lib/teamlab/modules/crm/crm_tags.rb +9 -0
- data/lib/teamlab/modules/crm.rb +2 -2
- data/lib/teamlab/modules/feed.rb +2 -2
- data/lib/teamlab/modules/files.rb +2 -2
- data/lib/teamlab/modules/group.rb +2 -2
- data/lib/teamlab/modules/mail.rb +2 -2
- data/lib/teamlab/modules/mailserver.rb +2 -2
- data/lib/teamlab/modules/people/people_reassign.rb +4 -1
- data/lib/teamlab/modules/people/people_remove.rb +27 -0
- data/lib/teamlab/modules/people.rb +30 -6
- data/lib/teamlab/modules/portals.rb +8 -2
- data/lib/teamlab/modules/project.rb +2 -2
- data/lib/teamlab/modules/projects/projects_comments.rb +16 -0
- data/lib/teamlab/modules/projects/projects_discussions.rb +14 -0
- data/lib/teamlab/modules/projects/projects_milestones.rb +37 -0
- data/lib/teamlab/modules/projects/projects_projects.rb +7 -12
- data/lib/teamlab/modules/projects/projects_reports.rb +7 -0
- data/lib/teamlab/modules/projects/projects_settings.rb +11 -0
- data/lib/teamlab/modules/settings.rb +2 -2
- data/lib/teamlab/request.rb +25 -8
- data/lib/teamlab/responce/custom_exceptions.rb +6 -0
- data/lib/teamlab/response.rb +56 -5
- data/lib/teamlab/version.rb +1 -1
- metadata +40 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f8c8455b783aef58695e2f11ac059804435a6be117b76b453cdebd0a996e41a
|
4
|
+
data.tar.gz: 46cf0de4e5b2a8a8ad1215c7f86f50d182b5b4bcc1f364054c50015a0b522123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d88170f761bb8384014573a865dc1e5d2614054bf8e7f4e032f36b043160763ad2d6226cf4151cd145a7b8cfc42a1313fd6a7670e8fa532298cad3c49c32ac00
|
7
|
+
data.tar.gz: ffa186f53c8b0077ca1af6e04495c6a83992a02f02cc861a8a6f26335fc4f022f2a1ecc3a9555a2a5a0ea5537dd6fd710dbeebfa96d92ebf3e3e1281f0a5f6c9
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../teamlab/config'
|
4
|
+
|
5
|
+
module Teamlab
|
6
|
+
# Class for multiuser instance
|
7
|
+
class OnlyofficeApiInstance
|
8
|
+
def initialize(params = {})
|
9
|
+
@config = Config.new(params)
|
10
|
+
auth_response = Teamlab::Request.new(@config, 'authentication').post('', userName: @config.username, password: @config.password).body
|
11
|
+
raise "Cannot get response token for #{auth_response}" if auth_response['response'].nil? || auth_response['response']['token'].nil?
|
12
|
+
|
13
|
+
@config.token = auth_response['response']['token']
|
14
|
+
@config.headers = { 'authorization' => @config.token }
|
15
|
+
end
|
16
|
+
|
17
|
+
def people
|
18
|
+
@people ||= Teamlab::People.new(@config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def group
|
22
|
+
@group ||= Teamlab::Group.new(@config)
|
23
|
+
end
|
24
|
+
|
25
|
+
def settings
|
26
|
+
@settings ||= Teamlab::Settings.new(@config)
|
27
|
+
end
|
28
|
+
|
29
|
+
def files
|
30
|
+
@files ||= Teamlab::Files.new(@config)
|
31
|
+
end
|
32
|
+
|
33
|
+
def project
|
34
|
+
@project ||= Teamlab::Project.new(@config)
|
35
|
+
end
|
36
|
+
|
37
|
+
def portal
|
38
|
+
@portal ||= Teamlab::Portal.new(@config)
|
39
|
+
end
|
40
|
+
|
41
|
+
def crm
|
42
|
+
@crm ||= Teamlab::Crm.new(@config)
|
43
|
+
end
|
44
|
+
|
45
|
+
def community
|
46
|
+
@community ||= Teamlab::Community.new(@config)
|
47
|
+
end
|
48
|
+
|
49
|
+
def calendar
|
50
|
+
@calendar ||= Teamlab::Calendar.new(@config)
|
51
|
+
end
|
52
|
+
|
53
|
+
def mail
|
54
|
+
@mail ||= Teamlab::Mail.new(@config)
|
55
|
+
end
|
56
|
+
|
57
|
+
def mailserver
|
58
|
+
@mailserver ||= Teamlab::MailServer.new(@config)
|
59
|
+
end
|
60
|
+
|
61
|
+
def feed
|
62
|
+
@feed ||= Teamlab::Feed.new(@config)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/onlyoffice_api.rb
CHANGED
data/lib/teamlab/config.rb
CHANGED
@@ -8,7 +8,7 @@ module Teamlab
|
|
8
8
|
def self.configure(&block)
|
9
9
|
@config ||= Config.new
|
10
10
|
yield @config if block
|
11
|
-
auth_response = Teamlab::Request.new('authentication').post('', userName: @config.username, password: @config.password).body
|
11
|
+
auth_response = Teamlab::Request.new(nil, 'authentication').post('', userName: @config.username, password: @config.password).body
|
12
12
|
raise "Cannot get response token for #{auth_response}" if auth_response['response'].nil? || auth_response['response']['token'].nil?
|
13
13
|
|
14
14
|
@config.token = auth_response['response']['token']
|
@@ -24,8 +24,11 @@ module Teamlab
|
|
24
24
|
# @return [Net::HTTP::Proxy] connection proxy
|
25
25
|
attr_accessor :proxy
|
26
26
|
|
27
|
-
def initialize
|
27
|
+
def initialize(params = {})
|
28
28
|
default_configuration
|
29
|
+
@server = params[:server]
|
30
|
+
@username = params[:username]
|
31
|
+
@password = params[:password]
|
29
32
|
end
|
30
33
|
|
31
34
|
def default_configuration
|
@@ -23,7 +23,7 @@ module Teamlab
|
|
23
23
|
@request.get(%w[currency rates], {})
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def create_currency_rate(from = 'EUR', to = 'USD', rate = '1.0')
|
27
27
|
@request.post(%w[currency rates], fromCurrency: from, toCurrency: to, rate: rate)
|
28
28
|
end
|
29
29
|
|
@@ -31,6 +31,14 @@ module Teamlab
|
|
31
31
|
@request.get(['currency', 'rates', id.to_s], {})
|
32
32
|
end
|
33
33
|
|
34
|
+
# Get currency rate by currencies
|
35
|
+
# @param from_currency [String] rate from currency
|
36
|
+
# @param to_currency [String] rate to currency
|
37
|
+
# @return [Hash] currency rate data
|
38
|
+
def get_currency_rate_by_currency(from_currency, to_currency)
|
39
|
+
@request.get(['currency', 'rates', from_currency.to_s, to_currency.to_s])
|
40
|
+
end
|
41
|
+
|
34
42
|
def delete_currency_rate_by_id(id)
|
35
43
|
@request.delete(['currency', 'rates', id.to_s], {})
|
36
44
|
end
|
@@ -38,5 +46,15 @@ module Teamlab
|
|
38
46
|
def set_is_portal_configured(options = {})
|
39
47
|
@request.put(%w[settings], options)
|
40
48
|
end
|
49
|
+
|
50
|
+
# Update currency rate object
|
51
|
+
# @param id [String] id of rate currency
|
52
|
+
# @param from [String] rate from currency
|
53
|
+
# @param to [String] rate to currency
|
54
|
+
# @param rate [String] currency rate
|
55
|
+
# @return [Hash] currency and rate data
|
56
|
+
def update_currency_rate(id, from, to, rate)
|
57
|
+
@request.put(['currency', 'rates', id.to_s], fromCurrency: from, toCurrency: to, rate: rate)
|
58
|
+
end
|
41
59
|
end
|
42
60
|
end
|
@@ -139,6 +139,13 @@ module Teamlab
|
|
139
139
|
@request.get(['contact', 'company', company_id.to_s, 'person'])
|
140
140
|
end
|
141
141
|
|
142
|
+
# Returns the detailed information about the contacts Email, Phone, Web Site/Social Networks and Address information with the ID
|
143
|
+
# @param contact_id [String] Contact ID
|
144
|
+
# @return [Hash] Contact information
|
145
|
+
def get_contact_information(contact_id)
|
146
|
+
@request.get(['contact', contact_id.to_s, 'data'])
|
147
|
+
end
|
148
|
+
|
142
149
|
def get_contact_information_by_type(contact_id, info_type)
|
143
150
|
@request.get(['contact', contact_id.to_s, 'data', info_type.to_s])
|
144
151
|
end
|
@@ -192,6 +199,13 @@ module Teamlab
|
|
192
199
|
@request.put(['contact', contact_id.to_s, 'access'], options)
|
193
200
|
end
|
194
201
|
|
202
|
+
# Returns access rights to the contact with the ID specified in the request
|
203
|
+
# @param contact_id [String] Contact ID
|
204
|
+
# @return [Array] List of contacts
|
205
|
+
def get_contact_access_rights(contact_id)
|
206
|
+
@request.get(['contact', contact_id.to_s, 'access'])
|
207
|
+
end
|
208
|
+
|
195
209
|
def update_company(company_id, company_name, options = {})
|
196
210
|
@request.put(['contact', 'company', company_id.to_s], { companyName: company_name.to_s }.merge(options))
|
197
211
|
end
|
@@ -239,5 +253,22 @@ module Teamlab
|
|
239
253
|
def remove_contact_from_project(contact_id, project_id)
|
240
254
|
@request.delete(['contact', contact_id.to_s, 'project', project_id.to_s])
|
241
255
|
end
|
256
|
+
|
257
|
+
# Adds the address information to the contact with the selected ID
|
258
|
+
# @param contact_id [String] Contact ID
|
259
|
+
# @param address [Hash] Contact address parameters: street, city, state, zip, country, isPrimary
|
260
|
+
# @return [Hash] Contact information
|
261
|
+
def add_address_info(contact_id, address = {})
|
262
|
+
@request.post(['contact', contact_id.to_s, 'addressdata'], { address: address })
|
263
|
+
end
|
264
|
+
|
265
|
+
# Updates the address information with the parameters specified in the request for the contact with the selected ID
|
266
|
+
# @param contact_id [String] Contact ID
|
267
|
+
# @param info_id [String] Contact information record ID
|
268
|
+
# @param address [Hash] Contact address parameters: street, city, state, zip, country, isPrimary
|
269
|
+
# @return [Hash] Contact information
|
270
|
+
def update_address_info(contact_id, info_id, address = {})
|
271
|
+
@request.put(['contact', contact_id.to_s, 'addressdata', info_id.to_s], { address: address })
|
272
|
+
end
|
242
273
|
end
|
243
274
|
end
|
@@ -117,5 +117,19 @@ module Teamlab
|
|
117
117
|
def get_invoice_item_by_id(invoice_item_id)
|
118
118
|
@request.get(['invoiceitem', invoice_item_id])
|
119
119
|
end
|
120
|
+
|
121
|
+
# Returns the existence of an invoice with the number specified in the request
|
122
|
+
# @param number [String] Invoice number
|
123
|
+
# @return [Boolean] Invoice existence
|
124
|
+
def check_invoice_existence_by_number(number)
|
125
|
+
@request.get(%w[invoice bynumber exist], number: number)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Returns the detailed information about an invoice with the number specified in the request
|
129
|
+
# @param number [String] Invoice number
|
130
|
+
# @return [Hash] Invoice data
|
131
|
+
def get_invoice_by_number(number)
|
132
|
+
@request.get(%w[invoice bynumber], number: number)
|
133
|
+
end
|
120
134
|
end
|
121
135
|
end
|
@@ -23,6 +23,13 @@ module Teamlab
|
|
23
23
|
@request.get(['opportunity', opportunity_id.to_s, 'contact'])
|
24
24
|
end
|
25
25
|
|
26
|
+
# Returns a list of all the opportunities for the contact with the ID specified in the request
|
27
|
+
# @param contact_id [String, Integer] Contact ID
|
28
|
+
# @return [Array] List of opportunities
|
29
|
+
def get_contact_opportunities(contact_id)
|
30
|
+
@request.get(['opportunity', 'bycontact', contact_id.to_s])
|
31
|
+
end
|
32
|
+
|
26
33
|
def create_opportunity(stage_id, title, responsible_id, options = {})
|
27
34
|
options[:bidCurrencyAbbr] ||= 'USD'
|
28
35
|
@request.post(%w[opportunity], { stageId: stage_id, title: title, responsibleid: responsible_id }.merge(options))
|
@@ -50,5 +50,14 @@ module Teamlab
|
|
50
50
|
def add_contact_tag_to_group(entity_type, entity_id, tag)
|
51
51
|
@request.post([entity_type.to_s, entity_id.to_s, 'tag', 'group'], tagName: tag)
|
52
52
|
end
|
53
|
+
|
54
|
+
# Deletes the selected tag from the entity (company or person) specified in the request and from all the related contacts
|
55
|
+
# @param entity_type [String, Symbol] Entity type
|
56
|
+
# @param entity_id [String] Entity ID
|
57
|
+
# @param tag [String] Tag name
|
58
|
+
# @return [String] Tag name
|
59
|
+
def delete_contact_tag_of_group(entity_type, entity_id, tag)
|
60
|
+
@request.delete([entity_type.to_s, entity_id, 'tag', 'group'], tagName: tag)
|
61
|
+
end
|
53
62
|
end
|
54
63
|
end
|
data/lib/teamlab/modules/crm.rb
CHANGED
data/lib/teamlab/modules/feed.rb
CHANGED
data/lib/teamlab/modules/mail.rb
CHANGED
@@ -25,8 +25,8 @@ module Teamlab
|
|
25
25
|
include MailSettings
|
26
26
|
include MailTags
|
27
27
|
|
28
|
-
def initialize
|
29
|
-
@request = Teamlab::Request.new('mail')
|
28
|
+
def initialize(config = nil)
|
29
|
+
@request = Teamlab::Request.new(config, 'mail')
|
30
30
|
end
|
31
31
|
|
32
32
|
# @return [Teamlab::Response] Returns all Mail running operations (only complex)
|
@@ -7,18 +7,21 @@ module Teamlab
|
|
7
7
|
# @param from_user_id [String] guid of user from whom reassign
|
8
8
|
# @param to_user_id [String] guid of user to whom reassign
|
9
9
|
# @param delete_profile [True, False] Delete profile when reassignment will be finished
|
10
|
+
# @return [Hash] reassign progress data
|
10
11
|
def start_reassign_user_data(from_user_id, to_user_id, delete_profile = true)
|
11
12
|
@request.post(%w[reassign start], fromUserId: from_user_id, toUserId: to_user_id, deleteProfile: delete_profile)
|
12
13
|
end
|
13
14
|
|
14
15
|
# Returns the progress of the started reassign process
|
15
16
|
# @param from_user_id [String] User ID (guid) whose data is reassigned
|
16
|
-
|
17
|
+
# @return [Hash] reassign progress data
|
18
|
+
def reassign_progress(from_user_id)
|
17
19
|
@request.get(%w[reassign progress], userId: from_user_id)
|
18
20
|
end
|
19
21
|
|
20
22
|
# Terminate reassign process
|
21
23
|
# @param user_id [String] User ID (guid) whose data is reassigned
|
24
|
+
# @return [Void]
|
22
25
|
def terminate_reassign(user_id)
|
23
26
|
@request.put(%w[reassign terminate], userId: user_id)
|
24
27
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Teamlab
|
4
|
+
# Module for people removing process
|
5
|
+
module PeopleRemove
|
6
|
+
# Start a remove process
|
7
|
+
# @param userId [String] guid of user to remove
|
8
|
+
# @return [Hash] remove progress data
|
9
|
+
def start_remove(user_id)
|
10
|
+
@request.post(%w[remove start], userId: user_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns the progress of the started remove process
|
14
|
+
# @param userId [String] guid of user to remove
|
15
|
+
# @return [Hash] remove progress data
|
16
|
+
def remove_progress(user_id)
|
17
|
+
@request.get(%w[remove progress], userId: user_id)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Terminate remove process
|
21
|
+
# @param userId [String] guid of user to remove
|
22
|
+
# @return [Void]
|
23
|
+
def terminate_remove(user_id)
|
24
|
+
@request.put(%w[remove terminate], userId: user_id)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'people/people_reassign'
|
4
|
+
require_relative 'people/people_remove'
|
4
5
|
module Teamlab
|
5
6
|
class People
|
6
7
|
include PeopleReassign
|
8
|
+
include PeopleRemove
|
7
9
|
|
8
|
-
def initialize
|
9
|
-
@request = Teamlab::Request.new('people')
|
10
|
+
def initialize(config = nil)
|
11
|
+
@request = Teamlab::Request.new(config, 'people')
|
10
12
|
end
|
11
13
|
|
12
14
|
def get_people
|
@@ -45,10 +47,6 @@ module Teamlab
|
|
45
47
|
@request.post(nil, { isVisitor: is_visitor, email: email, firstname: firstname, lastname: lastname }.merge(options))
|
46
48
|
end
|
47
49
|
|
48
|
-
def active(options = {})
|
49
|
-
@request.post(['active'], options) # TODO: need some fixing
|
50
|
-
end
|
51
|
-
|
52
50
|
def update_contacts(user_id, contacts = {})
|
53
51
|
@request.post([user_id, 'contacts'], contacts)
|
54
52
|
end
|
@@ -100,5 +98,31 @@ module Teamlab
|
|
100
98
|
def unlink_account(provider)
|
101
99
|
@request.delete([%w[thirdparty unlinkaccount]], provider: provider)
|
102
100
|
end
|
101
|
+
|
102
|
+
# Return the detailed information about the profile of the user with the email specified in the request
|
103
|
+
# @param email [String] User email
|
104
|
+
# @return [Hash] result user search by email
|
105
|
+
def get_user_by_email(email)
|
106
|
+
@request.get(['email'], email: email)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Get user photos
|
110
|
+
# @param userid [String] User ID
|
111
|
+
# @return [Hash] result user photos
|
112
|
+
def get_user_photoes(user_id)
|
113
|
+
@request.get([user_id, 'photo'])
|
114
|
+
end
|
115
|
+
|
116
|
+
# Send instructions for delete user own profile
|
117
|
+
# @return [Void] send `Deletion of your profile` letter
|
118
|
+
def send_delete_instruction
|
119
|
+
@request.put(%w[self delete])
|
120
|
+
end
|
121
|
+
|
122
|
+
# Join to affiliate programme
|
123
|
+
# @return [String] link to affiliate programme
|
124
|
+
def join_to_affiliate_programme
|
125
|
+
@request.put(%w[self joinaffiliate])
|
126
|
+
end
|
103
127
|
end
|
104
128
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Teamlab
|
4
4
|
class Portal
|
5
|
-
def initialize
|
6
|
-
@request = Teamlab::Request.new('portal')
|
5
|
+
def initialize(config = nil)
|
6
|
+
@request = Teamlab::Request.new(config, 'portal')
|
7
7
|
end
|
8
8
|
|
9
9
|
def invite_user_url
|
@@ -13,5 +13,11 @@ module Teamlab
|
|
13
13
|
def invite_visitor_url
|
14
14
|
@request.get(%w[users invite visitor])
|
15
15
|
end
|
16
|
+
|
17
|
+
# Deletes the current portal immediately
|
18
|
+
# WARNING: Do not test this method in specs in this project
|
19
|
+
def delete_portal
|
20
|
+
@request.delete(%w[deleteportalimmediately])
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
@@ -30,5 +30,21 @@ module Teamlab
|
|
30
30
|
def delete_comment(comment_id)
|
31
31
|
@request.delete(['comment', comment_id.to_s])
|
32
32
|
end
|
33
|
+
|
34
|
+
# Adds a project comment with the parameters specified in the request
|
35
|
+
# @param entity_id [String] Entity ID
|
36
|
+
# @param content [String] Comment text
|
37
|
+
# @param type [String, Symbol] Comment type (message or task)
|
38
|
+
# @return [Hash] Comment information
|
39
|
+
def add_project_comment(entity_id, content, type, options = {})
|
40
|
+
@request.post(%w[comment], { entityid: entity_id, content: content, type: type.to_s }.merge(options))
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get a preview of a project comment with the ID specified in the request
|
44
|
+
# @param htmltext [String] Comment text in the HTML format
|
45
|
+
# @return [Hash] Comment information
|
46
|
+
def get_a_comment_preview(htmltext, options = {})
|
47
|
+
@request.post(%w[comment preview], { htmltext: htmltext }.merge(options))
|
48
|
+
end
|
33
49
|
end
|
34
50
|
end
|
@@ -39,8 +39,22 @@ module Teamlab
|
|
39
39
|
@request.put(['message', message_id.to_s, 'subscribe'])
|
40
40
|
end
|
41
41
|
|
42
|
+
# Returns a list of all the subscribers of the discussion with the selected message
|
43
|
+
# @param message_id [Integer, String] Message ID
|
44
|
+
# @return [Array] List of subscibers
|
45
|
+
def discussion_subscribers(message_id)
|
46
|
+
@request.get(['message', message_id.to_s, 'subscribes'])
|
47
|
+
end
|
48
|
+
|
42
49
|
def delete_message(message_id)
|
43
50
|
@request.delete(['message', message_id.to_s])
|
44
51
|
end
|
52
|
+
|
53
|
+
# Returns a preview of the discussion message
|
54
|
+
# @param [String] Message text in the HTML format
|
55
|
+
# @return [Hash] Message preview
|
56
|
+
def preview_of_discussion_message(htmltext)
|
57
|
+
@request.post(%w[message discussion preview], htmltext: htmltext)
|
58
|
+
end
|
45
59
|
end
|
46
60
|
end
|
@@ -31,6 +31,36 @@ module Teamlab
|
|
31
31
|
@request.get(['milestone', year.to_s, month.to_s, day.to_s])
|
32
32
|
end
|
33
33
|
|
34
|
+
# Returns a list of all the milestones within a project with the ID specified in the request
|
35
|
+
# @param project_id [Symbol, String] Project ID
|
36
|
+
# @return [Array] List of milestones
|
37
|
+
def milestones_by_project_id(project_id)
|
38
|
+
@request.get([project_id.to_s, 'milestone'])
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns a list of all the milestones within a project with the ID and status specified in the request
|
42
|
+
# @param project_id [Symbol, String] Project ID
|
43
|
+
# @param status [Symbol, String] Milestone status
|
44
|
+
# @return [Array] List of milestones
|
45
|
+
def milestones_by_project_id_and_status(project_id, status)
|
46
|
+
@request.get([project_id.to_s, 'milestone', status.to_s])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Adds a new milestone using the parameters (project ID, milestone title, deadline, etc) specified in the request
|
50
|
+
# @param project_id [Symbol, String] Project ID
|
51
|
+
# @param title [String] Milestone title
|
52
|
+
# @param deadline [String] Milestone deadline
|
53
|
+
# @param responsible_id [String] Milestone responsible
|
54
|
+
# @param options [Hash] options to create a Milestone with
|
55
|
+
# @option isKey [Boolean] Specifies if this is a key milestone or not
|
56
|
+
# @option isNotify [Boolean] Reminds me 48 hours before the milestone due date
|
57
|
+
# @option description [String] Milestone description
|
58
|
+
# @option notifyResponsible [Boolean] Notifies the responsible about the milestone actions or not
|
59
|
+
# @return [Hash] Added milestone
|
60
|
+
def add_milestone(project_id, title, deadline, responsible_id, options = {})
|
61
|
+
@request.post([project_id.to_s, 'milestone'], { title: title, deadline: deadline, responsible: responsible_id }.merge(options))
|
62
|
+
end
|
63
|
+
|
34
64
|
def update_milestone(id, title, deadline, options = {})
|
35
65
|
@request.put(['milestone', id.to_s], { title: title, deadline: deadline }.merge(options))
|
36
66
|
end
|
@@ -42,5 +72,12 @@ module Teamlab
|
|
42
72
|
def delete_milestone(id)
|
43
73
|
@request.delete(['milestone', id.to_s])
|
44
74
|
end
|
75
|
+
|
76
|
+
# Deletes the milestones with the IDs specified in the request
|
77
|
+
# @param ids [Array] Milestone IDs
|
78
|
+
# @return [Array] Deleted milestones
|
79
|
+
def delete_milestones(ids)
|
80
|
+
@request.delete(['milestone'], { ids: ids })
|
81
|
+
end
|
45
82
|
end
|
46
83
|
end
|
@@ -35,10 +35,6 @@ module Teamlab
|
|
35
35
|
@request.get([project_id.to_s, 'files'])
|
36
36
|
end
|
37
37
|
|
38
|
-
def get_milestones(project_id)
|
39
|
-
@request.get([project_id.to_s, 'milestone'])
|
40
|
-
end
|
41
|
-
|
42
38
|
def search_all_projects(query)
|
43
39
|
@request.get(['@search', query.to_s])
|
44
40
|
end
|
@@ -47,18 +43,10 @@ module Teamlab
|
|
47
43
|
@request.get([project_id.to_s, '@search', query.to_s])
|
48
44
|
end
|
49
45
|
|
50
|
-
def get_milestones_with_status(project_id, status)
|
51
|
-
@request.get([project_id.to_s, 'milestone', status.to_s])
|
52
|
-
end
|
53
|
-
|
54
46
|
def create_project(title, description, responsible_id, tags, private, options = {})
|
55
47
|
@request.post('', { title: title, description: description, responsibleid: responsible_id, tags: tags, private: private }.merge(options))
|
56
48
|
end
|
57
49
|
|
58
|
-
def add_milestone(project_id, title, deadline, responsible_id, options = {})
|
59
|
-
@request.post([project_id.to_s, 'milestone'], { title: title, deadline: deadline, responsible: responsible_id }.merge(options))
|
60
|
-
end
|
61
|
-
|
62
50
|
def update_project(id, title, responsible_id, options = {})
|
63
51
|
@request.put([id.to_s], { title: title, responsibleId: responsible_id }.merge(options))
|
64
52
|
end
|
@@ -78,5 +66,12 @@ module Teamlab
|
|
78
66
|
def delete_project(id)
|
79
67
|
@request.delete([id.to_s])
|
80
68
|
end
|
69
|
+
|
70
|
+
# Deletes the projects with the IDs specified in the request from the portal
|
71
|
+
# @param ids [Array] List of project IDs
|
72
|
+
# @return [Array] Deleted projects
|
73
|
+
def delete_projects(ids)
|
74
|
+
@request.delete('', { projectids: ids })
|
75
|
+
end
|
81
76
|
end
|
82
77
|
end
|
@@ -11,6 +11,13 @@ module Teamlab
|
|
11
11
|
@request.put(['report', report_id.to_s], { name: name }.merge(options))
|
12
12
|
end
|
13
13
|
|
14
|
+
# Returns a project report template with the ID specified in the request
|
15
|
+
# @param report_id [Symbol, String] Report template ID
|
16
|
+
# @return [Hash] Project report template
|
17
|
+
def report_template(report_id)
|
18
|
+
@request.get(['report', report_id.to_s])
|
19
|
+
end
|
20
|
+
|
14
21
|
def delete_report_template(report_id)
|
15
22
|
@request.delete(['report', report_id.to_s])
|
16
23
|
end
|
@@ -7,5 +7,16 @@ module Teamlab
|
|
7
7
|
def projects_settings
|
8
8
|
@request.get(%w[settings])
|
9
9
|
end
|
10
|
+
|
11
|
+
# Updates the project settings with the parameters specified in the request
|
12
|
+
# @param options [Hash] options to change Projects module settings
|
13
|
+
# @option everebodyCanCreate [Boolean] Specifies if all the portal users can create projects or not
|
14
|
+
# @option hideEntitiesInPausedProjects [Boolean] Specifies if the entities will be hidden in the paused projects or not
|
15
|
+
# @option startModule [String] Module type: Projects, Tasks, Discussions, TimeTracking
|
16
|
+
# @option folderId [String] Folder ID
|
17
|
+
# @return [Hash] Updated settings
|
18
|
+
def update_projects_settings(options = {})
|
19
|
+
@request.put(%w[settings], options)
|
20
|
+
end
|
10
21
|
end
|
11
22
|
end
|
@@ -5,8 +5,8 @@ module Teamlab
|
|
5
5
|
# @return [String] id of global admin of portal
|
6
6
|
GLOBAL_ADMIN_ID = '00000000-0000-0000-0000-000000000000'
|
7
7
|
|
8
|
-
def initialize
|
9
|
-
@request = Teamlab::Request.new('settings')
|
8
|
+
def initialize(config = nil)
|
9
|
+
@request = Teamlab::Request.new(config, 'settings')
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_settings
|
data/lib/teamlab/request.rb
CHANGED
@@ -9,7 +9,8 @@ module Teamlab
|
|
9
9
|
class Request
|
10
10
|
include HTTParty
|
11
11
|
|
12
|
-
def initialize(api_additive)
|
12
|
+
def initialize(config, api_additive)
|
13
|
+
@config = config
|
13
14
|
@api_additive = api_additive.to_s
|
14
15
|
end
|
15
16
|
|
@@ -49,8 +50,24 @@ module Teamlab
|
|
49
50
|
response
|
50
51
|
end
|
51
52
|
|
53
|
+
def server
|
54
|
+
@config&.server || Teamlab.config.server
|
55
|
+
end
|
56
|
+
|
57
|
+
def api_path
|
58
|
+
@config&.api_path || Teamlab.config.api_path
|
59
|
+
end
|
60
|
+
|
61
|
+
def headers
|
62
|
+
@config&.headers || Teamlab.config.headers
|
63
|
+
end
|
64
|
+
|
65
|
+
def proxy
|
66
|
+
@config&.proxy || Teamlab.config.proxy
|
67
|
+
end
|
68
|
+
|
52
69
|
def generate_request_url(command)
|
53
|
-
|
70
|
+
server + api_path + @api_additive + command
|
54
71
|
end
|
55
72
|
|
56
73
|
def parse_args(args, type)
|
@@ -58,7 +75,7 @@ module Teamlab
|
|
58
75
|
opts = {}
|
59
76
|
opts[:body] = args.last.instance_of?(Hash) ? args.pop : {}
|
60
77
|
opts[:body].delete_if { |_key, value| value == [] }
|
61
|
-
opts[:headers] =
|
78
|
+
opts[:headers] = headers
|
62
79
|
opts = init_proxy(opts)
|
63
80
|
opts[:query] = opts.delete(:body) if type == :get
|
64
81
|
[command, opts]
|
@@ -67,12 +84,12 @@ module Teamlab
|
|
67
84
|
# @param opts [Hash] options to init
|
68
85
|
# @return [Hash] options
|
69
86
|
def init_proxy(opts)
|
70
|
-
return opts unless
|
87
|
+
return opts unless proxy
|
71
88
|
|
72
|
-
opts[:http_proxyaddr] ||=
|
73
|
-
opts[:http_proxyport] ||=
|
74
|
-
opts[:http_proxyuser] ||=
|
75
|
-
opts[:http_proxypass] ||=
|
89
|
+
opts[:http_proxyaddr] ||= proxy.proxy_address
|
90
|
+
opts[:http_proxyport] ||= proxy.proxy_port
|
91
|
+
opts[:http_proxyuser] ||= proxy.proxy_user
|
92
|
+
opts[:http_proxypass] ||= proxy.proxy_pass
|
76
93
|
opts
|
77
94
|
end
|
78
95
|
end
|
data/lib/teamlab/response.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'responce/custom_exceptions'
|
4
|
+
|
3
5
|
module Teamlab
|
4
6
|
class Response
|
5
7
|
attr_reader :body, :error, :code, :success
|
@@ -9,7 +11,7 @@ module Teamlab
|
|
9
11
|
@success = @code < 400
|
10
12
|
err_msg = generate_err_msg(http_response) if @code >= 400
|
11
13
|
if @success
|
12
|
-
|
14
|
+
handle_success_responce(http_response)
|
13
15
|
else
|
14
16
|
raise TimeoutError, 'Portal is warming up' if http_response.parsed_response.include?('portal is being warmed')
|
15
17
|
raise "Error #{@code}\n#{err_msg}" if @code >= 400
|
@@ -21,10 +23,10 @@ module Teamlab
|
|
21
23
|
|
22
24
|
def generate_err_msg(http_response)
|
23
25
|
"API request failed\n\noriginal request:\n"\
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
"#{http_response.request.http_method} #{http_response.request.path}\nbody: "\
|
27
|
+
"#{JSON.pretty_generate(http_response.request.options[:body])}"\
|
28
|
+
"\n\nresponse:\n"\
|
29
|
+
"#{prettify_response(http_response.parsed_response)}"
|
28
30
|
end
|
29
31
|
|
30
32
|
def prettify_response(msg)
|
@@ -37,5 +39,54 @@ module Teamlab
|
|
37
39
|
def data
|
38
40
|
@body['response']
|
39
41
|
end
|
42
|
+
|
43
|
+
# Check if responce is succeed, has nil error and has hash body
|
44
|
+
# @param [Symbol] current api method
|
45
|
+
# @return [Boolean] result of responce check
|
46
|
+
def correct?(command)
|
47
|
+
result = @success && @error.nil? && @body.is_a?(Hash)
|
48
|
+
raise("Response should be always successful for #{command}") unless @success
|
49
|
+
raise("Response should not contain errors for #{command}") unless @error.nil?
|
50
|
+
raise("Response should be Hash for #{command}") unless @body.is_a?(Hash)
|
51
|
+
|
52
|
+
result
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# Sometime in strange situation, like maybe nginx errors
|
58
|
+
# API requests return not JSON, but html or other data
|
59
|
+
# @param [Teamlab::Responce] responce to check
|
60
|
+
# @return [Nil] is body responce correct and raise exception in any other situation
|
61
|
+
def check_responce_body(responce)
|
62
|
+
return if stream_data_request?(responce)
|
63
|
+
|
64
|
+
JSON.parse(responce.body)
|
65
|
+
rescue JSON::ParserError => e
|
66
|
+
request_info = "#{responce.request.http_method} #{responce.request.uri}"
|
67
|
+
raise NoJsonInResponce, "Request `#{request_info}` responce body is not a json\n "\
|
68
|
+
"Parsing error: \n#{e}\n"
|
69
|
+
end
|
70
|
+
|
71
|
+
# Handle success responce
|
72
|
+
# @param [Teamlab::Responce] responce to handle
|
73
|
+
# @return [nil] if everything is fine or exception
|
74
|
+
def handle_success_responce(responce)
|
75
|
+
check_responce_body(responce)
|
76
|
+
@body = responce.to_hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# Check if request for stream data
|
80
|
+
# Those request has no body, but data stream in responce
|
81
|
+
# @param [Teamlab::Responce] responce to check
|
82
|
+
# @return [Boolean] result of check
|
83
|
+
def stream_data_request?(responce)
|
84
|
+
calendar_ical_request_regexp = %r{.*/calendar/\d*/ical/\S*}
|
85
|
+
uri = responce.request.uri.to_s
|
86
|
+
|
87
|
+
return true if calendar_ical_request_regexp.match?(uri)
|
88
|
+
|
89
|
+
false
|
90
|
+
end
|
40
91
|
end
|
41
92
|
end
|
data/lib/teamlab/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onlyoffice_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ONLYOFFICE
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|
@@ -27,20 +27,6 @@ dependencies:
|
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0.16'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: codecov
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
requirements:
|
34
|
-
- - "~>"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '0'
|
37
|
-
type: :development
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0'
|
44
30
|
- !ruby/object:Gem::Dependency
|
45
31
|
name: faker
|
46
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,6 +83,20 @@ dependencies:
|
|
97
83
|
- - "~>"
|
98
84
|
- !ruby/object:Gem::Version
|
99
85
|
version: '3'
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: rspec-retry
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
100
|
- !ruby/object:Gem::Dependency
|
101
101
|
name: rubocop
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,6 +153,20 @@ dependencies:
|
|
153
153
|
- - "~>"
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: '2'
|
156
|
+
- !ruby/object:Gem::Dependency
|
157
|
+
name: simplecov-cobertura
|
158
|
+
requirement: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - "~>"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '2'
|
163
|
+
type: :development
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - "~>"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '2'
|
156
170
|
- !ruby/object:Gem::Dependency
|
157
171
|
name: yard
|
158
172
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,6 +191,7 @@ extensions: []
|
|
177
191
|
extra_rdoc_files: []
|
178
192
|
files:
|
179
193
|
- lib/onlyoffice_api.rb
|
194
|
+
- lib/onlyoffice_api/onlyoffice_api_instance.rb
|
180
195
|
- lib/teamlab/config.rb
|
181
196
|
- lib/teamlab/modules/calendar.rb
|
182
197
|
- lib/teamlab/modules/community.rb
|
@@ -218,6 +233,7 @@ files:
|
|
218
233
|
- lib/teamlab/modules/mailserver/mailboxes.rb
|
219
234
|
- lib/teamlab/modules/people.rb
|
220
235
|
- lib/teamlab/modules/people/people_reassign.rb
|
236
|
+
- lib/teamlab/modules/people/people_remove.rb
|
221
237
|
- lib/teamlab/modules/portals.rb
|
222
238
|
- lib/teamlab/modules/project.rb
|
223
239
|
- lib/teamlab/modules/projects/projects_comments.rb
|
@@ -236,17 +252,19 @@ files:
|
|
236
252
|
- lib/teamlab/modules/settings.rb
|
237
253
|
- lib/teamlab/name.rb
|
238
254
|
- lib/teamlab/request.rb
|
255
|
+
- lib/teamlab/responce/custom_exceptions.rb
|
239
256
|
- lib/teamlab/response.rb
|
240
257
|
- lib/teamlab/version.rb
|
241
|
-
homepage: https://github.com/ONLYOFFICE/
|
258
|
+
homepage: https://github.com/ONLYOFFICE/onlyoffice_api_gem
|
242
259
|
licenses:
|
243
260
|
- AGPL-3.0
|
244
261
|
metadata:
|
245
|
-
bug_tracker_uri: https://github.com/ONLYOFFICE/
|
246
|
-
changelog_uri: https://github.com/ONLYOFFICE/
|
262
|
+
bug_tracker_uri: https://github.com/ONLYOFFICE/onlyoffice_api_gem/issues
|
263
|
+
changelog_uri: https://github.com/ONLYOFFICE/onlyoffice_api_gem/blob/master/CHANGELOG.md
|
247
264
|
documentation_uri: https://www.rubydoc.info/gems/onlyoffice_api
|
248
|
-
homepage_uri: https://github.com/ONLYOFFICE/
|
249
|
-
source_code_uri: https://github.com/ONLYOFFICE/
|
265
|
+
homepage_uri: https://github.com/ONLYOFFICE/onlyoffice_api_gem
|
266
|
+
source_code_uri: https://github.com/ONLYOFFICE/onlyoffice_api_gem
|
267
|
+
rubygems_mfa_required: 'true'
|
250
268
|
post_install_message:
|
251
269
|
rdoc_options: []
|
252
270
|
require_paths:
|
@@ -262,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
280
|
- !ruby/object:Gem::Version
|
263
281
|
version: '0'
|
264
282
|
requirements: []
|
265
|
-
rubygems_version: 3.
|
283
|
+
rubygems_version: 3.3.4
|
266
284
|
signing_key:
|
267
285
|
specification_version: 4
|
268
286
|
summary: Ruby gem for OnlyOffice. Formerly known as `teamlab`.
|