onlyoffice_api 0.11.0 → 0.12.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.rb +1 -0
- data/lib/onlyoffice_api/onlyoffice_api_instance.rb +65 -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.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.rb +2 -2
- data/lib/teamlab/modules/portals.rb +2 -2
- data/lib/teamlab/modules/project.rb +2 -2
- data/lib/teamlab/modules/settings.rb +2 -2
- data/lib/teamlab/request.rb +25 -8
- data/lib/teamlab/response.rb +4 -4
- data/lib/teamlab/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdbcfc630b8186f0ce844c741c43a3a80873823d5cd826a4499490c1b07600df
|
4
|
+
data.tar.gz: 51be328e7d6d9a061baf729481d22b498fd84502d4f74d5e898c6820e9cd9516
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beddc9c36885235acef44a1b2d2306c18c7d57dd91e94a267d219937e3deadcce2462292409f62dab2a220a5c86629651b997eb30fb996d8766b6c406ec5d960
|
7
|
+
data.tar.gz: 944ac964b667783207b6e95541456f1168c2f216f6041e8e97202c4ea99bcde87fa86345878f6b1a654fd4024bbda735900c9f9064b0cc5dcf0e2e1f1505a6e2
|
data/lib/onlyoffice_api.rb
CHANGED
@@ -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/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
|
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)
|
@@ -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
@@ -23,10 +23,10 @@ module Teamlab
|
|
23
23
|
|
24
24
|
def generate_err_msg(http_response)
|
25
25
|
"API request failed\n\noriginal request:\n"\
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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)}"
|
30
30
|
end
|
31
31
|
|
32
32
|
def prettify_response(msg)
|
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: 0.12.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: 2021-
|
14
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|
@@ -177,6 +177,7 @@ extensions: []
|
|
177
177
|
extra_rdoc_files: []
|
178
178
|
files:
|
179
179
|
- lib/onlyoffice_api.rb
|
180
|
+
- lib/onlyoffice_api/onlyoffice_api_instance.rb
|
180
181
|
- lib/teamlab/config.rb
|
181
182
|
- lib/teamlab/modules/calendar.rb
|
182
183
|
- lib/teamlab/modules/community.rb
|
@@ -263,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
264
|
- !ruby/object:Gem::Version
|
264
265
|
version: '0'
|
265
266
|
requirements: []
|
266
|
-
rubygems_version: 3.
|
267
|
+
rubygems_version: 3.2.21
|
267
268
|
signing_key:
|
268
269
|
specification_version: 4
|
269
270
|
summary: Ruby gem for OnlyOffice. Formerly known as `teamlab`.
|