filebound_client 0.2.0 → 0.3.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 +4 -4
- data/.rubocop.yml +3 -1
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +2 -2
- data/README.md +32 -1
- data/lib/filebound_client/endpoints.rb +5 -10
- data/lib/filebound_client/endpoints/projects.rb +1 -1
- data/lib/filebound_client/endpoints/routed_items.rb +59 -0
- data/lib/filebound_client/endpoints/routes.rb +67 -0
- data/lib/filebound_client/endpoints/users.rb +80 -0
- data/lib/filebound_client/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b857083501fad5a2cc689c18a3869939ba514679259f68809ac94ececc66cc4
|
4
|
+
data.tar.gz: 6217a7f015e0811a60e8231f7809401eac6d847830fb7122881c09e690c27c1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33ff1b9695aa36f1525be4b849edb22595d96f57019412518b53c22ea9ba409fba6170a2401a0de8199b57d2641359975ba9c6bbb94b0060af3bc0e9db88bc7e
|
7
|
+
data.tar.gz: 855fced0bf0da18243c51ab1c5379726ce67f0b690ab9148148af1b631b27438e0858d3f7992d5afe8a3d561de6fc8d0a26304f9b076cd7e613d05908a41e904
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
|
4
4
|
Changes to this gem will be noted here.
|
5
5
|
|
6
|
+
## [0.3.0] - 2019-01-22
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
|
10
|
+
- Upgraded httpi to 2.4.4.
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- User resource endpoint.
|
14
|
+
- Route resource endpoint.
|
15
|
+
- RoutedItem resource endpoint.
|
16
|
+
|
6
17
|
## [0.2.0] - 2018-08-07
|
7
18
|
### Changed
|
8
19
|
- Replaced ruby-ntlm dependency with httpi. httpi gem is actively being developed while ruby-ntlm hasn't had a new
|
data/Gemfile.lock
CHANGED
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
ast (2.4.0)
|
12
12
|
diff-lcs (1.3)
|
13
|
-
httpi (2.4.
|
13
|
+
httpi (2.4.4)
|
14
14
|
rack
|
15
15
|
socksify
|
16
16
|
jaro_winkler (1.5.1)
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
parser (2.5.1.2)
|
19
19
|
ast (~> 2.4.0)
|
20
20
|
powerpack (0.1.2)
|
21
|
-
rack (2.0.
|
21
|
+
rack (2.0.6)
|
22
22
|
rainbow (3.0.0)
|
23
23
|
rake (12.3.1)
|
24
24
|
rspec (3.7.0)
|
data/README.md
CHANGED
@@ -125,7 +125,7 @@ puts f[:notes]
|
|
125
125
|
```ruby
|
126
126
|
data = Base64.encode64(File.read('somefile.pdf'))
|
127
127
|
d = c.document_new
|
128
|
-
d[:allowSaveBinaryData] =
|
128
|
+
d[:allowSaveBinaryData] = true
|
129
129
|
d[:binaryData] = data
|
130
130
|
d[:extension] = 'pdf'
|
131
131
|
d[:fileId] = 123
|
@@ -154,6 +154,37 @@ d = c.document(document_id)
|
|
154
154
|
puts d[:name]
|
155
155
|
```
|
156
156
|
|
157
|
+
### Create document and assign it to a workflow and user
|
158
|
+
|
159
|
+
Here is a more detail example of a more complex API interaction.
|
160
|
+
This example shows how you can create a file, a document in the file and then
|
161
|
+
assign that document to a workflow and then a user. Obviously this a quick example
|
162
|
+
and still requires null checks and exception handling.
|
163
|
+
|
164
|
+
First create your [file](#create-a-file).
|
165
|
+
Then create your [document](#create-document-with-attached-binary-file-data).
|
166
|
+
Then build out the routed item and update it:
|
167
|
+
|
168
|
+
```ruby
|
169
|
+
user = c.users(filter: 'name_someuser').first
|
170
|
+
project = c.projects(filter: 'name_someproject').first
|
171
|
+
route = c.project_routes(project[:id], filter: 'name_someroute', hiddenRoutes: true).first
|
172
|
+
routed_item = c.route_document_to_workflow(route[:id], d[:id], 'test note')
|
173
|
+
routed_item[:userId] = user[:id]
|
174
|
+
routed_item[:userName] = user[:name]
|
175
|
+
routed_item_id = c.routed_item_update(routed_item)
|
176
|
+
```
|
177
|
+
|
178
|
+
### Send an additional filter in the querystring
|
179
|
+
|
180
|
+
The FileBound API also gives you the ability to send an additional filter on certain calls to further filter
|
181
|
+
a GET result by any of the fields in the resource. See below for an example:
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
u = c.users(filter: 'name_someusername')
|
185
|
+
puts u[:displayName]
|
186
|
+
```
|
187
|
+
|
157
188
|
## Development
|
158
189
|
|
159
190
|
After checking out the repo, run `bin/setup` to install dependencies. Setup your Filebound connection information
|
@@ -1,13 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'filebound_client/endpoints/files'
|
3
|
-
require 'filebound_client/endpoints/documents'
|
4
|
-
require 'filebound_client/endpoints/version'
|
5
|
-
require 'filebound_client/endpoints/assignments'
|
6
|
-
require 'filebound_client/endpoints/dividers'
|
7
|
-
require 'filebound_client/endpoints/document_binary_data'
|
8
|
-
require 'filebound_client/endpoints/eform_data'
|
9
|
-
require 'filebound_client/endpoints/separators'
|
10
|
-
require 'filebound_client/endpoints/query'
|
1
|
+
Dir[File.join(__dir__, '/endpoints/*.rb')].each { |file| require file }
|
11
2
|
|
12
3
|
module FileboundClient
|
13
4
|
# Module for resource endpoints
|
@@ -45,8 +36,12 @@ module FileboundClient
|
|
45
36
|
include FileboundClient::Endpoints::Dividers
|
46
37
|
include FileboundClient::Endpoints::DocumentBinaryData
|
47
38
|
include FileboundClient::Endpoints::EFormData
|
39
|
+
include FileboundClient::Endpoints::EFormDetail
|
48
40
|
include FileboundClient::Endpoints::Separators
|
49
41
|
include FileboundClient::Endpoints::Query
|
42
|
+
include FileboundClient::Endpoints::Users
|
43
|
+
include FileboundClient::Endpoints::Routes
|
44
|
+
include FileboundClient::Endpoints::RoutedItems
|
50
45
|
end
|
51
46
|
end
|
52
47
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
@@ -92,7 +92,7 @@ module FileboundClient
|
|
92
92
|
# c = FileboundClient::Client.connect(host: url, username: 'username', password: 'password', use_ntlm: true,
|
93
93
|
# ntlm_user: 'ntlm_user', ntlm_password: 'ntlm_password',
|
94
94
|
# ntlm_domain: 'ntlm_domain')
|
95
|
-
# c.project_add(ProjectId:
|
95
|
+
# c.project_add(ProjectId: nil, Name: 'Test API Project', ProjectType: 'HR')
|
96
96
|
def project_add(project)
|
97
97
|
raise Client::FileboundClientException.new('Id is required', 0) if project[:projectId].greater_than_zero?
|
98
98
|
put('/projects', nil, project)
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module FileboundClient
|
2
|
+
module Endpoints
|
3
|
+
# Module for RoutedItems resource endpoint
|
4
|
+
module RoutedItems
|
5
|
+
def self.included(klass)
|
6
|
+
klass.instance_eval do
|
7
|
+
allow_new :routeditem
|
8
|
+
allow_all :routeditems
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Edits a routed item. The routed_item.id must be not nil and > 0.
|
13
|
+
# @param [Hash] routed_item the routed item to edit
|
14
|
+
# @return [nil]
|
15
|
+
# @example Update an existing routed item
|
16
|
+
# c = FileboundClient::Client.connect(host: url, username: 'username', password: 'password', use_ntlm: true,
|
17
|
+
# ntlm_user: 'ntlm_user', ntlm_password: 'ntlm_password',
|
18
|
+
# ntlm_domain: 'ntlm_domain')
|
19
|
+
# c.routed_item_update(routed_item)
|
20
|
+
def routed_item_update(routed_item)
|
21
|
+
raise Client::FileboundClientException.new('Id is required', 0) unless routed_item[:id].greater_than_zero?
|
22
|
+
post("/routeditems/#{routed_item[:id]}", nil, routed_item)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Completes the current step for the routed item. The routed_item.id must be not nil and > 0.
|
26
|
+
# @param [int] routed_item_id the routed item key to update
|
27
|
+
# @param [int] step_number the step number to route to
|
28
|
+
# @param [string] step_caption the step caption for the step
|
29
|
+
# @param [string] comment optional comment for the step
|
30
|
+
# @param [DateTime] due_date optional due date for the routed item
|
31
|
+
# @param [long] user_id optional; if reassigning this the user id to reassign to
|
32
|
+
# @param [string] checklist_data optional comma-seperated checklist values
|
33
|
+
# @param [long] route_step_id optional RouteStep key
|
34
|
+
# @param [long] route_step_task_id options RouteStepTask key
|
35
|
+
# @return [Array] array of RouteTask for the specified route step
|
36
|
+
# @example Complete the current route step
|
37
|
+
# c = FileboundClient::Client.connect(host: url, username: 'username', password: 'password', use_ntlm: true,
|
38
|
+
# ntlm_user: 'ntlm_user', ntlm_password: 'ntlm_password',
|
39
|
+
# ntlm_domain: 'ntlm_domain')
|
40
|
+
# c.routed_item_complete_step(routed_item)
|
41
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/ParameterLists, Metrics/PerceivedComplexity
|
42
|
+
def routed_item_complete_step(routed_item_id, step_number:, step_caption:, comment:, due_date:, user_id:,
|
43
|
+
checklist_data:, route_step_id:, route_step_task_id:)
|
44
|
+
raise Client::FileboundClientException.new('Id is required', 0) unless routed_item_id.greater_than_zero?
|
45
|
+
params = {}
|
46
|
+
params[:stepNumber] = step_number if step_number
|
47
|
+
params[:stepCaption] = step_caption if step_caption
|
48
|
+
params[:comment] = comment if comment
|
49
|
+
params[:dueDate] = due_date if due_date
|
50
|
+
params[:userId] = user_id if user_id
|
51
|
+
params[:checklistData] = checklist_data if checklist_data
|
52
|
+
params[:routeStepId] = route_step_id if route_step_id
|
53
|
+
params[:routeStepTaskId] = route_step_task_id if route_step_task_id
|
54
|
+
put("/routeditems/#{routed_item_id}/complete", params, nil)
|
55
|
+
end
|
56
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/ParameterLists, Metrics/PerceivedComplexity
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module FileboundClient
|
2
|
+
module Endpoints
|
3
|
+
# Module for Routes resource endpoint
|
4
|
+
module Routes
|
5
|
+
def self.included(klass)
|
6
|
+
klass.instance_eval do
|
7
|
+
allow_new :route
|
8
|
+
allow_all :routes
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Retrieves xml for a route
|
13
|
+
# @param [int] route_id the route key
|
14
|
+
# @param [Hash] query_params additional query params to send in the request
|
15
|
+
# @return [string] string of xml representing route
|
16
|
+
def route_xml(route_id, query_params = nil)
|
17
|
+
get("/routes/#{route_id}/xml", query_params)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Routes a document to the start of a workflow
|
21
|
+
# @param [long] route_id the route key
|
22
|
+
# @param [int] document_id the document key to route
|
23
|
+
# @param [string] notes optional notes to from the user who started the document down the route
|
24
|
+
# @return [RoutedItem] a hash of the RoutedItem resource that was added
|
25
|
+
def route_document_to_workflow(route_id, document_id, notes)
|
26
|
+
params = { documentId: document_id }
|
27
|
+
params[:notes] = notes if notes
|
28
|
+
put("/routes/#{route_id}", params, nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Routes a document to a specified step
|
32
|
+
# @param [long] routed_item_id the RoutedItem key
|
33
|
+
# @param [int] step_number the step number to route to
|
34
|
+
# @param [string] comment optional comment for the step
|
35
|
+
# @param [DateTime] due_date optional due date for the routed item
|
36
|
+
# @param [long] user_id optional; if reassigning this the user id to reassign to
|
37
|
+
# @param [string] checklist_data optional comma-seperated checklist values
|
38
|
+
# @param [long] route_step_id optional RouteStep key
|
39
|
+
# @param [long] route_step_task_id options RouteStepTask key
|
40
|
+
# @return [nil]
|
41
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/ParameterLists
|
42
|
+
def route_document_to_step(routed_item_id, step_number, comment:, due_date:, user_id:, checklist_data:,
|
43
|
+
route_step_id:, route_step_task_id:)
|
44
|
+
params = { id: routed_item_id, stepNumber: step_number }
|
45
|
+
params[:comment] = comment if comment
|
46
|
+
params[:dueDate] = due_date if due_date
|
47
|
+
params[:userId] = user_id if user_id
|
48
|
+
params[:checklistData] = checklist_data if checklist_data
|
49
|
+
params[:routeStepId] = route_step_id if route_step_id
|
50
|
+
params[:routeStepTaskId] = route_step_task_id if route_step_task_id
|
51
|
+
put('/routes', params, nil)
|
52
|
+
end
|
53
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/ParameterLists
|
54
|
+
|
55
|
+
# Routes a document to a user
|
56
|
+
# @param [long] document_id document key to route
|
57
|
+
# @param [long] user_id user key to route to
|
58
|
+
# @param [bool] route_back whether to route the document back when completed
|
59
|
+
# @param [DateTime] due_date due date for the document
|
60
|
+
# @return [nil]
|
61
|
+
def route_document_to_user(document_id, user_id, route_back, due_date)
|
62
|
+
params = { documentId: document_id, userId: user_id, routeBack: route_back, dueDate: due_date }
|
63
|
+
put('/routes', params, nil)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module FileboundClient
|
2
|
+
module Endpoints
|
3
|
+
# Module for Users resource endpoint
|
4
|
+
module Users
|
5
|
+
# This will call macros to create resource methods on the fly
|
6
|
+
def self.included(klass)
|
7
|
+
klass.instance_eval do
|
8
|
+
allow_new :user
|
9
|
+
allow_all :users
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieves a single user by its key
|
14
|
+
# @param [int] user_id the user key
|
15
|
+
# @param [Hash] query_params additional query params to send in the request
|
16
|
+
# @return [User] user object
|
17
|
+
def user(user_id, query_params = nil)
|
18
|
+
get("/users/#{user_id}", query_params)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Retrieves routed items for a user
|
22
|
+
# @param [int] user_id the user key
|
23
|
+
# @param [Hash] query_params additional query params to send in the request
|
24
|
+
# @return [Array] array of routed items
|
25
|
+
def user_routeditems(user_id, query_params = nil)
|
26
|
+
get_user_children(user_id, __method__, query_params)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Retrieves groups for a user
|
30
|
+
# @param [int] user_id the user key
|
31
|
+
# @param [Hash] query_params additional query params to send in the request
|
32
|
+
# @return [Array] array of groups
|
33
|
+
def user_groups(user_id, query_params = nil)
|
34
|
+
get_user_children(user_id, __method__, query_params)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Retrieves assignments for a user
|
38
|
+
# @param [int] user_id the user key
|
39
|
+
# @param [Hash] query_params additional query params to send in the request
|
40
|
+
# @return [Array] array of assignments
|
41
|
+
def user_assignments(user_id, query_params = nil)
|
42
|
+
get_user_children(user_id, __method__, query_params)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Edits a user. The user.Id must be not nil and > 0.
|
46
|
+
# @param [Hash] user the user to edit
|
47
|
+
# @param [string] groups a comma-delimited string of group ids to add the user to
|
48
|
+
# @return [int] the user id updated
|
49
|
+
# @example Update an existing user
|
50
|
+
# c = FileboundClient::Client.connect(host: url, username: 'username', password: 'password', use_ntlm: true,
|
51
|
+
# ntlm_user: 'ntlm_user', ntlm_password: 'ntlm_password',
|
52
|
+
# ntlm_domain: 'ntlm_domain')
|
53
|
+
# c.user_update(id: 165, displayName: 'Test User', email: 'someone@somewhere.com', name: 'username')
|
54
|
+
def user_update(user, groups)
|
55
|
+
raise Client::FileboundClientException.new('Id is required', 0) unless user[:dd].greater_than_zero?
|
56
|
+
put('/users', nil, user: user, groups: groups)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Adds a user. The user.id must be nil or 0.
|
60
|
+
# @param [user] user the user to add
|
61
|
+
# @param [string] groups a comma-delimited string of group ids to add the user to
|
62
|
+
# @return [int] the id of the newly created user
|
63
|
+
# @example Add a user
|
64
|
+
# c = FileboundClient::Client.connect(host: url, username: 'username', password: 'password', use_ntlm: true,
|
65
|
+
# ntlm_user: 'ntlm_user', ntlm_password: 'ntlm_password',
|
66
|
+
# ntlm_domain: 'ntlm_domain')
|
67
|
+
# c.user_add(id: nil, displayName: 'Test User', email: 'someone@somewhere.com', name: 'username')
|
68
|
+
def user_add(user, groups)
|
69
|
+
raise Client::FileboundClientException.new('Id is required', 0) if user[:userId].greater_than_zero?
|
70
|
+
put('/users', nil, user, user: user, groups: groups)
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def get_user_children(user_id, child_name, query_params = nil)
|
76
|
+
get("/users/#{user_id}/#{child_name.to_s.split('_')[1]}", query_params)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filebound_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Richardson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,7 +122,10 @@ files:
|
|
122
122
|
- lib/filebound_client/endpoints/files.rb
|
123
123
|
- lib/filebound_client/endpoints/projects.rb
|
124
124
|
- lib/filebound_client/endpoints/query.rb
|
125
|
+
- lib/filebound_client/endpoints/routed_items.rb
|
126
|
+
- lib/filebound_client/endpoints/routes.rb
|
125
127
|
- lib/filebound_client/endpoints/separators.rb
|
128
|
+
- lib/filebound_client/endpoints/users.rb
|
126
129
|
- lib/filebound_client/endpoints/version.rb
|
127
130
|
- lib/filebound_client/version.rb
|
128
131
|
- test.txt
|