onlyoffice_api 0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/onlyoffice_api.rb +65 -0
- data/lib/teamlab/config.rb +39 -0
- data/lib/teamlab/modules/calendar.rb +111 -0
- data/lib/teamlab/modules/community.rb +20 -0
- data/lib/teamlab/modules/community/community_blogs.rb +54 -0
- data/lib/teamlab/modules/community/community_bookmarks.rb +60 -0
- data/lib/teamlab/modules/community/community_events.rb +50 -0
- data/lib/teamlab/modules/community/community_forums.rb +70 -0
- data/lib/teamlab/modules/community/community_wiki.rb +66 -0
- data/lib/teamlab/modules/crm.rb +32 -0
- data/lib/teamlab/modules/crm/crm_cases.rb +72 -0
- data/lib/teamlab/modules/crm/crm_common.rb +42 -0
- data/lib/teamlab/modules/crm/crm_contacts.rb +243 -0
- data/lib/teamlab/modules/crm/crm_files.rb +44 -0
- data/lib/teamlab/modules/crm/crm_history.rb +42 -0
- data/lib/teamlab/modules/crm/crm_invoices.rb +123 -0
- data/lib/teamlab/modules/crm/crm_opportunities.rb +93 -0
- data/lib/teamlab/modules/crm/crm_organisation.rb +14 -0
- data/lib/teamlab/modules/crm/crm_tags.rb +54 -0
- data/lib/teamlab/modules/crm/crm_tasks.rb +62 -0
- data/lib/teamlab/modules/crm/crm_user_fields.rb +34 -0
- data/lib/teamlab/modules/feed.rb +23 -0
- data/lib/teamlab/modules/files.rb +256 -0
- data/lib/teamlab/modules/group.rb +53 -0
- data/lib/teamlab/modules/group/group_helper.rb +15 -0
- data/lib/teamlab/modules/mail.rb +32 -0
- data/lib/teamlab/modules/mail/mail_accounts.rb +55 -0
- data/lib/teamlab/modules/mail/mail_alerts.rb +14 -0
- data/lib/teamlab/modules/mail/mail_contacts.rb +14 -0
- data/lib/teamlab/modules/mail/mail_conversations.rb +54 -0
- data/lib/teamlab/modules/mail/mail_folders.rb +18 -0
- data/lib/teamlab/modules/mail/mail_helpcenter.rb +10 -0
- data/lib/teamlab/modules/mail/mail_images.rb +18 -0
- data/lib/teamlab/modules/mail/mail_messages.rb +74 -0
- data/lib/teamlab/modules/mail/mail_settings.rb +17 -0
- data/lib/teamlab/modules/mail/mail_signature.rb +14 -0
- data/lib/teamlab/modules/mail/mail_tags.rb +30 -0
- data/lib/teamlab/modules/people.rb +104 -0
- data/lib/teamlab/modules/people/people_reassign.rb +26 -0
- data/lib/teamlab/modules/portals.rb +17 -0
- data/lib/teamlab/modules/project.rb +37 -0
- data/lib/teamlab/modules/projects/projects_comments.rb +34 -0
- data/lib/teamlab/modules/projects/projects_contacts.rb +18 -0
- data/lib/teamlab/modules/projects/projects_discussions.rb +46 -0
- data/lib/teamlab/modules/projects/projects_files.rb +34 -0
- data/lib/teamlab/modules/projects/projects_milestones.rb +46 -0
- data/lib/teamlab/modules/projects/projects_projects.rb +82 -0
- data/lib/teamlab/modules/projects/projects_reports.rb +18 -0
- data/lib/teamlab/modules/projects/projects_settings.rb +11 -0
- data/lib/teamlab/modules/projects/projects_tags.rb +18 -0
- data/lib/teamlab/modules/projects/projects_tasks.rb +94 -0
- data/lib/teamlab/modules/projects/projects_team.rb +30 -0
- data/lib/teamlab/modules/projects/projects_templates.rb +26 -0
- data/lib/teamlab/modules/projects/projects_time.rb +34 -0
- data/lib/teamlab/modules/settings.rb +100 -0
- data/lib/teamlab/name.rb +5 -0
- data/lib/teamlab/request.rb +79 -0
- data/lib/teamlab/response.rb +41 -0
- data/lib/teamlab/version.rb +5 -0
- metadata +140 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Teamlab
|
4
|
+
# Module for projects time methods
|
5
|
+
module ProjectsTime
|
6
|
+
def get_time_spent_by_filter(options = {})
|
7
|
+
@request.get(%w[time filter], options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_total_time_spent_by_filter(options = {})
|
11
|
+
@request.get(%w[time filter total], options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_time_spent(task_id)
|
15
|
+
@request.get(['task', task_id.to_s, 'time'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_task_time(task_id, date, person_id, project_id, options = {})
|
19
|
+
@request.post(['task', task_id.to_s, 'time'], { date: date, personId: person_id, projectId: project_id }.merge(options))
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_task_time(time_id, date, person_id, options = {})
|
23
|
+
@request.put(['time', time_id.to_s], { date: date, personId: person_id }.merge(options))
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_time_status_of_payment(time_ids, status)
|
27
|
+
@request.put(%w[time times status], timeids: time_ids, status: status)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete_time_spents(*time_ids)
|
31
|
+
@request.delete(%w[time times remove], timeIds: time_ids.flatten)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Teamlab
|
4
|
+
class Settings
|
5
|
+
# @return [String] id of global admin of portal
|
6
|
+
GLOBAL_ADMIN_ID = '00000000-0000-0000-0000-000000000000'
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@request = Teamlab::Request.new('settings')
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_settings
|
13
|
+
@request.get
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_sso_settings
|
17
|
+
@request.get(%w[ssov2])
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_ldap_settings
|
21
|
+
@request.get(%w[LDAP])
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_logo
|
25
|
+
@request.get(%w[logo])
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_usage_quota
|
29
|
+
@request.get(%w[quota])
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_version
|
33
|
+
@request.get(%w[version])
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_version_build
|
37
|
+
@request.get(%w[version build])
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_security(ids = [])
|
41
|
+
@request.get(%w[security], ids: ids)
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_ip_restrictions
|
45
|
+
@request.get(%w[iprestrictions])
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_white_label_sizes
|
49
|
+
@request.get(%w[whitelabel sizes])
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_admin_security(product_id, user_id)
|
53
|
+
@request.get(%w[security administrator], productid: product_id, userid: user_id)
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_product_admin(product_id)
|
57
|
+
@request.get(['security', 'administrator', product_id.to_s])
|
58
|
+
end
|
59
|
+
|
60
|
+
def sms_settings(enable)
|
61
|
+
@request.put(%w[sms], enable: enable)
|
62
|
+
end
|
63
|
+
|
64
|
+
def update_tips(show)
|
65
|
+
@request.put(%w[tips], show: show)
|
66
|
+
end
|
67
|
+
|
68
|
+
def set_version(version_id)
|
69
|
+
@request.put(%w[version], versionId: version_id)
|
70
|
+
end
|
71
|
+
|
72
|
+
def set_security(id, options = {})
|
73
|
+
@request.put(%w[security], { id: id }.merge(options))
|
74
|
+
end
|
75
|
+
|
76
|
+
def save_ip_restrictions(ips)
|
77
|
+
@request.put(%w[iprestrictions], ips: ips)
|
78
|
+
end
|
79
|
+
|
80
|
+
def set_access(id, enabled = true)
|
81
|
+
@request.put(%w[security access], items: [{ key: id, value: enabled }])
|
82
|
+
end
|
83
|
+
|
84
|
+
def set_product_admin(product_id, user_id, administrator = true)
|
85
|
+
@request.put(%w[security administrator], productid: product_id, userid: user_id, administrator: administrator)
|
86
|
+
end
|
87
|
+
|
88
|
+
def update_ip_restrictions(enable)
|
89
|
+
@request.put(%w[iprestrictions settings], enable: enable)
|
90
|
+
end
|
91
|
+
|
92
|
+
def update_timezone_and_language(timezone, language)
|
93
|
+
@request.put(%w[timeandlanguage], lng: language, timeZoneId: timezone)
|
94
|
+
end
|
95
|
+
|
96
|
+
def update_default_portal_page(portal_page_id)
|
97
|
+
@request.put(%w[defaultpage], defaultProductID: portal_page_id)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/lib/teamlab/name.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'json'
|
5
|
+
require 'httparty'
|
6
|
+
require_relative 'response'
|
7
|
+
|
8
|
+
module Teamlab
|
9
|
+
class Request
|
10
|
+
include HTTParty
|
11
|
+
|
12
|
+
def initialize(api_additive)
|
13
|
+
@api_additive = api_additive.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
def post(*args)
|
17
|
+
request(:post, args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(*args)
|
21
|
+
request(:get, args)
|
22
|
+
end
|
23
|
+
|
24
|
+
def put(*args)
|
25
|
+
request(:put, args)
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete(*args)
|
29
|
+
request(:delete, args)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def request(type, args)
|
35
|
+
command, opts = parse_args(args, type)
|
36
|
+
url = generate_request_url(command)
|
37
|
+
attempts = 0
|
38
|
+
begin
|
39
|
+
response = Teamlab::Response.new(HTTParty.send(type, url, opts))
|
40
|
+
rescue Timeout::Error => e
|
41
|
+
attempts += 1
|
42
|
+
retry if attempts < 3
|
43
|
+
raise "Can't #{type} to #{url} because of TimeoutError: #{e}"
|
44
|
+
rescue StandardError => e
|
45
|
+
raise e
|
46
|
+
end
|
47
|
+
raise("Error #{response.code}: #{response.error}") unless response.success
|
48
|
+
|
49
|
+
response
|
50
|
+
end
|
51
|
+
|
52
|
+
def generate_request_url(command)
|
53
|
+
Teamlab.config.server + Teamlab.config.api_path + @api_additive + command
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_args(args, type)
|
57
|
+
command = args.first.instance_of?(Array) ? '/' + args.shift.join('/') : args.shift.to_s
|
58
|
+
opts = {}
|
59
|
+
opts[:body] = args.last.instance_of?(Hash) ? args.pop : {}
|
60
|
+
opts[:body].delete_if { |_key, value| value == [] }
|
61
|
+
opts[:headers] = Teamlab.config.headers
|
62
|
+
opts = init_proxy(opts)
|
63
|
+
opts[:query] = opts.delete(:body) if type == :get
|
64
|
+
[command, opts]
|
65
|
+
end
|
66
|
+
|
67
|
+
# @param opts [Hash] options to init
|
68
|
+
# @return [Hash] options
|
69
|
+
def init_proxy(opts)
|
70
|
+
return opts unless Teamlab.config.proxy
|
71
|
+
|
72
|
+
opts[:http_proxyaddr] ||= Teamlab.config.proxy.proxy_address
|
73
|
+
opts[:http_proxyport] ||= Teamlab.config.proxy.proxy_port
|
74
|
+
opts[:http_proxyuser] ||= Teamlab.config.proxy.proxy_user
|
75
|
+
opts[:http_proxypass] ||= Teamlab.config.proxy.proxy_pass
|
76
|
+
opts
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Teamlab
|
4
|
+
class Response
|
5
|
+
attr_reader :body, :error, :code, :success
|
6
|
+
|
7
|
+
def initialize(http_response)
|
8
|
+
@code = http_response.code
|
9
|
+
@success = @code < 400
|
10
|
+
err_msg = generate_err_msg(http_response) if @code >= 400
|
11
|
+
if @success
|
12
|
+
@body = http_response.to_hash
|
13
|
+
else
|
14
|
+
raise TimeoutError, 'Portal is warming up' if http_response.parsed_response.include?('portal is being warmed')
|
15
|
+
raise "Error #{@code}\n#{err_msg}" if @code >= 400
|
16
|
+
|
17
|
+
@body = http_response.respond_to?(:parsed_response) && http_response.parsed_response.key?('result') ? http_response.parsed_response['result'] : http_response.to_hash
|
18
|
+
@error = @body['error']['message'] if @body.key?('error') && @body['error'].key?('message')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate_err_msg(http_response)
|
23
|
+
"API request failed\n\noriginal request:\n"\
|
24
|
+
"#{http_response.request.http_method} #{http_response.request.path}\nbody: "\
|
25
|
+
"#{JSON.pretty_generate(http_response.request.options[:body])}"\
|
26
|
+
"\n\nresponse:\n"\
|
27
|
+
"#{prettify_response(http_response.parsed_response)}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def prettify_response(msg)
|
31
|
+
JSON.pretty_generate(msg)
|
32
|
+
rescue Encoding::UndefinedConversionError
|
33
|
+
msg.force_encoding(Encoding::UTF_8)
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Hash] data of response
|
37
|
+
def data
|
38
|
+
@body['response']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: onlyoffice_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.7'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ONLYOFFICE
|
8
|
+
- Pavel Lobashov
|
9
|
+
- rzagudaev
|
10
|
+
- DaftTrick
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2020-04-30 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: httparty
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.16'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.16'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '13.0'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '13.0'
|
44
|
+
description: Ruby Framework to interact with OnlyOffice API 2.0
|
45
|
+
email:
|
46
|
+
- rzagudaev@gmail.com
|
47
|
+
- shockwavenn@gmail.com
|
48
|
+
- nazarov90@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/onlyoffice_api.rb
|
54
|
+
- lib/teamlab/config.rb
|
55
|
+
- lib/teamlab/modules/calendar.rb
|
56
|
+
- lib/teamlab/modules/community.rb
|
57
|
+
- lib/teamlab/modules/community/community_blogs.rb
|
58
|
+
- lib/teamlab/modules/community/community_bookmarks.rb
|
59
|
+
- lib/teamlab/modules/community/community_events.rb
|
60
|
+
- lib/teamlab/modules/community/community_forums.rb
|
61
|
+
- lib/teamlab/modules/community/community_wiki.rb
|
62
|
+
- lib/teamlab/modules/crm.rb
|
63
|
+
- lib/teamlab/modules/crm/crm_cases.rb
|
64
|
+
- lib/teamlab/modules/crm/crm_common.rb
|
65
|
+
- lib/teamlab/modules/crm/crm_contacts.rb
|
66
|
+
- lib/teamlab/modules/crm/crm_files.rb
|
67
|
+
- lib/teamlab/modules/crm/crm_history.rb
|
68
|
+
- lib/teamlab/modules/crm/crm_invoices.rb
|
69
|
+
- lib/teamlab/modules/crm/crm_opportunities.rb
|
70
|
+
- lib/teamlab/modules/crm/crm_organisation.rb
|
71
|
+
- lib/teamlab/modules/crm/crm_tags.rb
|
72
|
+
- lib/teamlab/modules/crm/crm_tasks.rb
|
73
|
+
- lib/teamlab/modules/crm/crm_user_fields.rb
|
74
|
+
- lib/teamlab/modules/feed.rb
|
75
|
+
- lib/teamlab/modules/files.rb
|
76
|
+
- lib/teamlab/modules/group.rb
|
77
|
+
- lib/teamlab/modules/group/group_helper.rb
|
78
|
+
- lib/teamlab/modules/mail.rb
|
79
|
+
- lib/teamlab/modules/mail/mail_accounts.rb
|
80
|
+
- lib/teamlab/modules/mail/mail_alerts.rb
|
81
|
+
- lib/teamlab/modules/mail/mail_contacts.rb
|
82
|
+
- lib/teamlab/modules/mail/mail_conversations.rb
|
83
|
+
- lib/teamlab/modules/mail/mail_folders.rb
|
84
|
+
- lib/teamlab/modules/mail/mail_helpcenter.rb
|
85
|
+
- lib/teamlab/modules/mail/mail_images.rb
|
86
|
+
- lib/teamlab/modules/mail/mail_messages.rb
|
87
|
+
- lib/teamlab/modules/mail/mail_settings.rb
|
88
|
+
- lib/teamlab/modules/mail/mail_signature.rb
|
89
|
+
- lib/teamlab/modules/mail/mail_tags.rb
|
90
|
+
- lib/teamlab/modules/people.rb
|
91
|
+
- lib/teamlab/modules/people/people_reassign.rb
|
92
|
+
- lib/teamlab/modules/portals.rb
|
93
|
+
- lib/teamlab/modules/project.rb
|
94
|
+
- lib/teamlab/modules/projects/projects_comments.rb
|
95
|
+
- lib/teamlab/modules/projects/projects_contacts.rb
|
96
|
+
- lib/teamlab/modules/projects/projects_discussions.rb
|
97
|
+
- lib/teamlab/modules/projects/projects_files.rb
|
98
|
+
- lib/teamlab/modules/projects/projects_milestones.rb
|
99
|
+
- lib/teamlab/modules/projects/projects_projects.rb
|
100
|
+
- lib/teamlab/modules/projects/projects_reports.rb
|
101
|
+
- lib/teamlab/modules/projects/projects_settings.rb
|
102
|
+
- lib/teamlab/modules/projects/projects_tags.rb
|
103
|
+
- lib/teamlab/modules/projects/projects_tasks.rb
|
104
|
+
- lib/teamlab/modules/projects/projects_team.rb
|
105
|
+
- lib/teamlab/modules/projects/projects_templates.rb
|
106
|
+
- lib/teamlab/modules/projects/projects_time.rb
|
107
|
+
- lib/teamlab/modules/settings.rb
|
108
|
+
- lib/teamlab/name.rb
|
109
|
+
- lib/teamlab/request.rb
|
110
|
+
- lib/teamlab/response.rb
|
111
|
+
- lib/teamlab/version.rb
|
112
|
+
homepage: https://github.com/ONLYOFFICE/onlyoffice_api
|
113
|
+
licenses:
|
114
|
+
- AGPL-3.0
|
115
|
+
metadata:
|
116
|
+
bug_tracker_uri: https://github.com/ONLYOFFICE/onlyoffice_api/issues
|
117
|
+
changelog_uri: https://github.com/ONLYOFFICE/onlyoffice_api/blob/master/CHANGELOG.md
|
118
|
+
documentation_uri: https://www.rubydoc.info/gems/onlyoffice_api
|
119
|
+
homepage_uri: https://github.com/ONLYOFFICE/onlyoffice_api
|
120
|
+
source_code_uri: https://github.com/ONLYOFFICE/onlyoffice_api
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubygems_version: 3.1.2
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Ruby gem for OnlyOffice. Formerly known as `teamlab`.
|
140
|
+
test_files: []
|