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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4da6935cc3d256a7b5b39d6b02f7a4a038e908cd8a7949c34f89e124da984a9a
4
- data.tar.gz: f7baefc1910689ff41da8deaab16c70a8776a1cd40878876993ab072cfbd2c20
3
+ metadata.gz: bdbcfc630b8186f0ce844c741c43a3a80873823d5cd826a4499490c1b07600df
4
+ data.tar.gz: 51be328e7d6d9a061baf729481d22b498fd84502d4f74d5e898c6820e9cd9516
5
5
  SHA512:
6
- metadata.gz: a3e475df99ffaaef22bb7d140d3e18968f735a666142cf6722909402e43c54d5bb26a3efc3db6964434d8499afef36fa449549d248c477c29c9e9d77464b641c
7
- data.tar.gz: 036ac1d16df32299bf439f5e04c4e5b4dd5f31d1bbb27d8dca654d98c6a1c3b1c59b176aa650d63b3ab97f8daf050e4a7bbba2fa19964a30f3023129177e39d4
6
+ metadata.gz: beddc9c36885235acef44a1b2d2306c18c7d57dd91e94a267d219937e3deadcce2462292409f62dab2a220a5c86629651b997eb30fb996d8766b6c406ec5d960
7
+ data.tar.gz: 944ac964b667783207b6e95541456f1168c2f216f6041e8e97202c4ea99bcde87fa86345878f6b1a654fd4024bbda735900c9f9064b0cc5dcf0e2e1f1505a6e2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'onlyoffice_api/onlyoffice_api_instance'
3
4
  require_relative 'teamlab/version'
4
5
  require_relative 'teamlab/config'
5
6
  require_relative 'teamlab/request'
@@ -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
@@ -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
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Teamlab
4
4
  class Calendar
5
- def initialize
6
- @request = Teamlab::Request.new('calendar')
5
+ def initialize(config = nil)
6
+ @request = Teamlab::Request.new(config, 'calendar')
7
7
  end
8
8
 
9
9
  def get_default_access
@@ -13,8 +13,8 @@ module Teamlab
13
13
  include CommunityForums
14
14
  include CommunityWiki
15
15
 
16
- def initialize
17
- @request = Teamlab::Request.new('community')
16
+ def initialize(config = nil)
17
+ @request = Teamlab::Request.new(config, 'community')
18
18
  end
19
19
  end
20
20
  end
@@ -25,8 +25,8 @@ module Teamlab
25
25
  include CrmTasks
26
26
  include CrmUserFields
27
27
 
28
- def initialize
29
- @request = Teamlab::Request.new('crm')
28
+ def initialize(config = nil)
29
+ @request = Teamlab::Request.new(config, 'crm')
30
30
  end
31
31
  end
32
32
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Teamlab
4
4
  class Feed
5
- def initialize
6
- @request = Teamlab::Request.new('feed')
5
+ def initialize(config = nil)
6
+ @request = Teamlab::Request.new(config, 'feed')
7
7
  end
8
8
 
9
9
  # TODO: find out how it should work api.onlyoffice.com missing documentation
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Teamlab
4
4
  class Files
5
- def initialize
6
- @request = Teamlab::Request.new('files')
5
+ def initialize(config = nil)
6
+ @request = Teamlab::Request.new(config, 'files')
7
7
  end
8
8
 
9
9
  # region File Creation
@@ -6,8 +6,8 @@ module Teamlab
6
6
  class Group
7
7
  include GroupHelper
8
8
 
9
- def initialize
10
- @request = Teamlab::Request.new('group')
9
+ def initialize(config = nil)
10
+ @request = Teamlab::Request.new(config, 'group')
11
11
  end
12
12
 
13
13
  def get_groups
@@ -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)
@@ -11,8 +11,8 @@ module Teamlab
11
11
  include MailserverDomains
12
12
  include MailserverMailboxes
13
13
 
14
- def initialize
15
- @request = Teamlab::Request.new('mailserver')
14
+ def initialize(config = nil)
15
+ @request = Teamlab::Request.new(config, 'mailserver')
16
16
  end
17
17
  end
18
18
  end
@@ -5,8 +5,8 @@ module Teamlab
5
5
  class People
6
6
  include PeopleReassign
7
7
 
8
- def initialize
9
- @request = Teamlab::Request.new('people')
8
+ def initialize(config = nil)
9
+ @request = Teamlab::Request.new(config, 'people')
10
10
  end
11
11
 
12
12
  def get_people
@@ -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
@@ -30,8 +30,8 @@ module Teamlab
30
30
  include ProjectsTemplates
31
31
  include ProjectsTime
32
32
 
33
- def initialize
34
- @request = Teamlab::Request.new('project')
33
+ def initialize(config = nil)
34
+ @request = Teamlab::Request.new(config, 'project')
35
35
  end
36
36
  end
37
37
  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
@@ -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
- Teamlab.config.server + Teamlab.config.api_path + @api_additive + command
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] = Teamlab.config.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 Teamlab.config.proxy
87
+ return opts unless proxy
71
88
 
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
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
@@ -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
- "#{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)}"
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teamlab
4
- VERSION = '0.11.0'
4
+ VERSION = '0.12.0'
5
5
  end
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.11.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-06-22 00:00:00.000000000 Z
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.1.6
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`.