inforouter 0.1.0 → 0.2.0
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 +8 -8
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/.travis.yml +5 -0
- data/Gemfile +0 -3
- data/README.md +102 -2
- data/Rakefile +20 -1
- data/inforouter.gemspec +12 -8
- data/lib/config/locales/en.yml +34 -0
- data/lib/inforouter.rb +26 -7
- data/lib/inforouter/access_list.rb +25 -27
- data/lib/inforouter/access_list_domain_members_item.rb +11 -0
- data/lib/inforouter/access_list_user_group_item.rb +17 -0
- data/lib/inforouter/access_list_user_item.rb +17 -0
- data/lib/inforouter/client.rb +19 -16
- data/lib/inforouter/configuration.rb +10 -4
- data/lib/inforouter/document.rb +64 -0
- data/lib/inforouter/errors.rb +2 -0
- data/lib/inforouter/errors/api_error.rb +17 -0
- data/lib/inforouter/errors/inforouter_error.rb +77 -1
- data/lib/inforouter/errors/missing_config_error.rb +1 -1
- data/lib/inforouter/errors/missing_config_option_error.rb +1 -1
- data/lib/inforouter/errors/soap_error.rb +2 -1
- data/lib/inforouter/errors/unexpected_soap_response_error.rb +18 -0
- data/lib/inforouter/folder.rb +139 -0
- data/lib/inforouter/record.rb +13 -0
- data/lib/inforouter/responses.rb +14 -0
- data/lib/inforouter/responses/base.rb +78 -0
- data/lib/inforouter/responses/create_folder.rb +10 -0
- data/lib/inforouter/responses/delete_folder.rb +10 -0
- data/lib/inforouter/responses/document.rb +48 -0
- data/lib/inforouter/responses/document_exists.rb +10 -0
- data/lib/inforouter/responses/folder.rb +33 -0
- data/lib/inforouter/responses/folder_exists.rb +10 -0
- data/lib/inforouter/responses/generic.rb +28 -0
- data/lib/inforouter/responses/set_access_list.rb +10 -0
- data/lib/inforouter/responses/set_folder_rules.rb +10 -0
- data/lib/inforouter/responses/update_folder_properties.rb +10 -0
- data/lib/inforouter/responses/update_property_set_definition.rb +10 -0
- data/lib/inforouter/responses/update_property_set_row.rb +10 -0
- data/lib/inforouter/responses/users.rb +38 -0
- data/lib/inforouter/rights.rb +18 -0
- data/lib/inforouter/rule_item.rb +25 -0
- data/lib/inforouter/rules.rb +51 -0
- data/lib/inforouter/user.rb +39 -0
- data/lib/inforouter/users.rb +25 -0
- data/lib/inforouter/version.rb +1 -1
- data/test/helper.rb +3 -0
- data/test/test_client.rb +4 -0
- data/test/test_configuration.rb +31 -0
- data/test/test_setup.rb +18 -0
- metadata +96 -6
- data/.rspec +0 -2
- data/lib/inforouter/folder_rule.rb +0 -50
- data/spec/spec_helper.rb +0 -29
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Create Folder API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=CreateFolder
|
6
|
+
class CreateFolder < Generic
|
7
|
+
response_key :create_folder
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Delete Folder API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=DeleteFolder
|
6
|
+
class DeleteFolder < Generic
|
7
|
+
response_key :delete_folder
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Get Document API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=GetDocument
|
6
|
+
|
7
|
+
class Document < Base
|
8
|
+
response_success 'get_document_response/get_document_result/response/@success'
|
9
|
+
error_message 'get_document_response/get_document_result/response/@error'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Parse an infoRouter response.
|
13
|
+
#
|
14
|
+
# @param savon_response [Savon::Response] SOAP response.
|
15
|
+
#
|
16
|
+
# @return [Inforouter::Document]
|
17
|
+
def parse(savon_response)
|
18
|
+
response = new(savon_response)
|
19
|
+
document = response.match('get_document_response/get_document_result/response/document')
|
20
|
+
Inforouter::Document.new(
|
21
|
+
:document_id => document[:@document_id].to_i,
|
22
|
+
:name => document[:@name].strip,
|
23
|
+
:path => document[:@path].strip,
|
24
|
+
:description => document[:@description].strip,
|
25
|
+
:update_instructions => document[:@update_instructions].strip,
|
26
|
+
:creation_date => parse_datetime(document[:@creation_date]),
|
27
|
+
:modification_date => parse_datetime(document[:@modification_date]),
|
28
|
+
:checkout_date => parse_datetime(document[:@checkout_date]),
|
29
|
+
:checkout_by => document[:@checkout_by].strip,
|
30
|
+
:checkout_by_user_name => document[:@checkout_by_user_name].strip,
|
31
|
+
:size => document[:@size].to_i,
|
32
|
+
:type => document[:@type].strip,
|
33
|
+
:percent_complete => document[:@percent_complete].to_i,
|
34
|
+
:importance => document[:@importance].strip,
|
35
|
+
:retention_date => parse_datetime(document[:@retention_date]),
|
36
|
+
:disposition_date => parse_datetime(document[:@disposition_date]),
|
37
|
+
:expiration_date => parse_datetime(document[:@expiration_date]),
|
38
|
+
:register_date => parse_datetime(document[:@register_date]),
|
39
|
+
:registered_by => document[:@registered_by].strip,
|
40
|
+
:doc_type_id => document[:@doc_type_id].to_i,
|
41
|
+
:doc_type_name => document[:@doc_type_name].strip,
|
42
|
+
:version_number => document[:@version_number].to_i,
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Document Exists API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=DocumentExists
|
6
|
+
class DocumentExists < Generic
|
7
|
+
response_key :document_exists
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Get Folder API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=GetFolder
|
6
|
+
class Folder < Base
|
7
|
+
response_success 'get_folder_response/get_folder_result/response/@success'
|
8
|
+
error_message 'get_folder_response/get_folder_result/response/@error'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# Parse an infoRouter response.
|
12
|
+
#
|
13
|
+
# @param savon_response [Savon::Response] SOAP response.
|
14
|
+
#
|
15
|
+
# @return [Inforouter::Folder]
|
16
|
+
def parse(savon_response)
|
17
|
+
response = new(savon_response)
|
18
|
+
folder = response.match('get_folder_response/get_folder_result/response/folder')
|
19
|
+
Inforouter::Folder.new(
|
20
|
+
:folder_id => folder[:@folder_id].to_i,
|
21
|
+
:parent_id => folder[:@parent_id].to_i,
|
22
|
+
:name => folder[:@name].strip,
|
23
|
+
:path => folder[:@path].strip,
|
24
|
+
:description => folder[:@description].strip,
|
25
|
+
:creation_date => parse_datetime(folder[:@creation_date]),
|
26
|
+
:owner_name => folder[:@owner_name].strip,
|
27
|
+
:domain_id => folder[:@domain_id].to_i
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Folder Exists API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=FolderExists
|
6
|
+
class FolderExists < Generic
|
7
|
+
response_key :folder_exists
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# A generic response to an infoRouter API call.
|
4
|
+
class Generic < Base
|
5
|
+
# Response key.
|
6
|
+
class_attribute :key
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# Set the response key.
|
10
|
+
#
|
11
|
+
# @param key [String]
|
12
|
+
def response_key(key)
|
13
|
+
self.key = key
|
14
|
+
response_success "#{key}_response/#{key}_result/response/@success"
|
15
|
+
error_message "#{key}_response/#{key}_result/response/@error"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Parse an infoRouter response.
|
19
|
+
#
|
20
|
+
# @param savon_response [Savon::Response]
|
21
|
+
def parse(savon_response)
|
22
|
+
response = new(savon_response)
|
23
|
+
response.raw["#{key}_response".to_sym]["#{key}_result".to_sym][:response]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Set Access List API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=SetAccessList
|
6
|
+
class SetAccessList < Generic
|
7
|
+
response_key :set_access_list
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Set Folder Rules API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=SetFolderRules
|
6
|
+
class SetFolderRules < Generic
|
7
|
+
response_key :set_folder_rules
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Update Folder Properties API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=UpdateFolderProperties
|
6
|
+
class UpdateFolderProperties < Generic
|
7
|
+
response_key :update_folder_properties
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Update Property Set Definition API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=UpdatePropertySetDefinition
|
6
|
+
class UpdatePropertySetDefinition < Generic
|
7
|
+
response_key :update_property_set_definition
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Update Property Set Row API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=UpdatePropertySetRow
|
6
|
+
class UpdatePropertySetRow < Generic
|
7
|
+
response_key :update_property_set_row
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
module Responses #:nodoc:
|
3
|
+
# Response to an infoRouter Get All Users API call.
|
4
|
+
#
|
5
|
+
# See http://www.inforouter.com/web-services-80/default.aspx?op=GetAllUsers
|
6
|
+
class Users < Base
|
7
|
+
response_success 'get_all_users_response/get_all_users_result/response/@success'
|
8
|
+
error_message 'get_all_users_response/get_all_users_result/response/@error'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# Parse an infoRouter response.
|
12
|
+
#
|
13
|
+
# @param savon_response [Savon::Response] SOAP response.
|
14
|
+
#
|
15
|
+
# @return [Array]
|
16
|
+
def parse(savon_response)
|
17
|
+
response = new(savon_response)
|
18
|
+
users = response.match('get_all_users_response/get_all_users_result/response/users/user')
|
19
|
+
users.map do |user|
|
20
|
+
Inforouter::User.new(
|
21
|
+
:user_id => user[:@user_id].to_i,
|
22
|
+
:domain => user[:@domain].strip,
|
23
|
+
:user_name => user[:@user_name].strip,
|
24
|
+
:first_name => user[:@first_name].strip,
|
25
|
+
:last_name => user[:@last_name].strip,
|
26
|
+
:last_logon => DateTime.strptime(user[:@last_logon_date], '%Y-%m-%d %H:%M:%S'),
|
27
|
+
:last_password_change => DateTime.strptime(user[:@last_password_change_date], '%Y-%m-%d %H:%M:%S'),
|
28
|
+
:authentication_authority => user[:@authentication_authority].strip,
|
29
|
+
:read_only => user[:@read_only_user] == 'TRUE',
|
30
|
+
:email => user[:@email].strip,
|
31
|
+
:enabled => user[:@enabled] == 'TRUE'
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Inforouter
|
2
|
+
class RuleItem < Record
|
3
|
+
# Rule item name.
|
4
|
+
attr_accessor :name
|
5
|
+
# Rule item value.
|
6
|
+
attr_accessor :value
|
7
|
+
|
8
|
+
# @return [Hash]
|
9
|
+
def to_hash
|
10
|
+
{
|
11
|
+
:Name => name,
|
12
|
+
:Value => value
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
def value
|
18
|
+
if !!@value == @value
|
19
|
+
@value ? 'allows' : 'disallows'
|
20
|
+
else
|
21
|
+
@value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Inforouter
|
2
|
+
class Rules
|
3
|
+
# Array of <tt>Inforouter::RuleItem</tt>s.
|
4
|
+
attr_accessor :rules
|
5
|
+
|
6
|
+
def initialize(params = {})
|
7
|
+
params = {
|
8
|
+
:allowable_file_types => '',
|
9
|
+
:checkins => false,
|
10
|
+
:checkouts => false,
|
11
|
+
:document_deletes => false,
|
12
|
+
:folder_deletes => false,
|
13
|
+
:new_documents => false,
|
14
|
+
:new_folders => false,
|
15
|
+
:classified_documents => false
|
16
|
+
}.merge(params)
|
17
|
+
@rules = []
|
18
|
+
params.each do |key, value|
|
19
|
+
@rules << Inforouter::RuleItem.new(
|
20
|
+
:name => key.to_s.camelize,
|
21
|
+
:value => value
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# The Rules XML fragment should be as described below.
|
27
|
+
# The Rule item that is not specified in the xml structure will not be
|
28
|
+
# updated.
|
29
|
+
# For the AllowableFileTypes set value attribute to comman delimited file
|
30
|
+
# extensions or set value to "*" for allowing all file types.
|
31
|
+
#
|
32
|
+
# <Rules>
|
33
|
+
# <Rule Name="AllowableFileTypes" Value="BMP,DOC,JPG,XLS" />
|
34
|
+
# <Rule Name="Checkins" Value="disallows" />
|
35
|
+
# <Rule Name="Checkouts" Value="disallows" />
|
36
|
+
# <Rule Name="DocumentDeletes" Value="disallows" />
|
37
|
+
# <Rule Name="FolderDeletes" Value="disallows" />
|
38
|
+
# <Rule Name="NewDocuments" Value="disallows" />
|
39
|
+
# <Rule Name="NewFolders" Value="disallows" />
|
40
|
+
# <Rule Name="ClassifiedDocuments" Value="allows" />
|
41
|
+
# </Rules>
|
42
|
+
def to_xml
|
43
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
44
|
+
xml.Rules do
|
45
|
+
rules.each { |rule| xml.Rules(rule.to_hash) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
builder.doc.root.to_xml
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
# A <tt>User</tt> defines an infoRouter user.
|
3
|
+
class User < Record
|
4
|
+
# User ID.
|
5
|
+
attr_accessor :user_id
|
6
|
+
# User domain.
|
7
|
+
attr_accessor :domain
|
8
|
+
# User username.
|
9
|
+
attr_accessor :user_name
|
10
|
+
# User first name.
|
11
|
+
attr_accessor :first_name
|
12
|
+
# User last name.
|
13
|
+
attr_accessor :last_name
|
14
|
+
# User email.
|
15
|
+
attr_accessor :email
|
16
|
+
# User last login date
|
17
|
+
attr_accessor :last_logon
|
18
|
+
# User last password change
|
19
|
+
attr_accessor :last_password_change
|
20
|
+
# User authentication authority.
|
21
|
+
attr_accessor :authentication_authority
|
22
|
+
# User read only.
|
23
|
+
attr_accessor :read_only
|
24
|
+
# User enabled.
|
25
|
+
attr_accessor :enabled
|
26
|
+
|
27
|
+
def read_only?
|
28
|
+
@read_only
|
29
|
+
end
|
30
|
+
|
31
|
+
def enabled?
|
32
|
+
@enabled
|
33
|
+
end
|
34
|
+
|
35
|
+
def name
|
36
|
+
[@first_name, @last_name].join(' ').strip
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Inforouter #:nodoc:
|
2
|
+
class Users
|
3
|
+
class << self
|
4
|
+
# All users.
|
5
|
+
#
|
6
|
+
# @return [Hash]
|
7
|
+
def all
|
8
|
+
@users ||= begin
|
9
|
+
response = Inforouter.client.request :get_all_users
|
10
|
+
users = Inforouter::Responses::Users.parse response
|
11
|
+
Hash[users.map { |user| [user.user_name, user] }]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Lookup a user by user name.
|
16
|
+
#
|
17
|
+
# @param user_name [String]
|
18
|
+
#
|
19
|
+
# @return [Inforouter::User]
|
20
|
+
def [](user_name)
|
21
|
+
all[user_name]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/inforouter/version.rb
CHANGED
data/test/helper.rb
ADDED
data/test/test_client.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestConfiguration < TestSetup
|
4
|
+
def setup
|
5
|
+
Inforouter.setup!
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_missing_configuration
|
9
|
+
assert_raise Inforouter::Errors::MissingConfig do
|
10
|
+
Inforouter.client.request :dummy, :body => {}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_missing_host
|
15
|
+
Inforouter.configure do |config|
|
16
|
+
config.username = 'inforouter_username'
|
17
|
+
end
|
18
|
+
assert_raise Inforouter::Errors::MissingConfigOption do
|
19
|
+
Inforouter.client.request :dummy, :body => {}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_missing_username
|
24
|
+
Inforouter.configure do |config|
|
25
|
+
config.host = 'inforouter_host'
|
26
|
+
end
|
27
|
+
assert_raise Inforouter::Errors::MissingConfigOption do
|
28
|
+
Inforouter.client.request :dummy, :body => {}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|