filebound_client 0.1.1 → 0.2.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: ff7cb48474b62921efc99c473e43a5176fa9656f4d93909aa1583ff367e13f32
4
- data.tar.gz: ce0a1ca7de55a7945a2fceee13bdec8081d76cd8d834e18927c96db426a173f2
3
+ metadata.gz: 5430818e9e9bb023e023b877145a3ad2d49e34faa526095eeca9d539570d0424
4
+ data.tar.gz: c96ef4679daf8250c0917de85c671c68e3e831605f2e7018e3b7200f58af0839
5
5
  SHA512:
6
- metadata.gz: 00a8e448b5442b217e9eb89c849846fa34b1124fe82a90e459a428e194e83bf566ac702217209cc242e5c235ba745115bcb784c7e0c76536f9a0a65346fe3889
7
- data.tar.gz: 425e0c2a93b085e06c55ab42b0716501dad591bb8552bd1946fee2ab76e566e56839d1331c48b8605f56fc4cced25f336a0851f3077f9f038d1ca033b38f939c
6
+ metadata.gz: '09da2bf6aa663fd2be1f91883406fca201ed71de8958762fe3ea90575d925d58651c4d8848a02c9ea9a7c228797efb0cc6c55676bf42ab00b06b7e16deb5fc95'
7
+ data.tar.gz: 7da1a67a86028ce37f3373dfd4839db06288a30bad281a6e3a77b99210bb78db8ae5dcb1d86671c6ad43f5ca04c593a689049e5801f6476b87df65e024842cfd
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+
5
+ ---
6
+
7
+ **Describe the bug**
8
+ A clear and concise description of what the bug is.
9
+
10
+ **To Reproduce**
11
+ Steps to reproduce the behavior:
12
+ 1. Go to '...'
13
+ 2. Click on '....'
14
+ 3. Scroll down to '....'
15
+ 4. See error
16
+
17
+ **Expected behavior**
18
+ A clear and concise description of what you expected to happen.
19
+
20
+ **Screenshots**
21
+ If applicable, add screenshots to help explain your problem.
22
+
23
+ **Desktop (please complete the following information):**
24
+ - OS: [e.g. iOS]
25
+ - Browser [e.g. chrome, safari]
26
+ - Version [e.g. 22]
27
+
28
+ **Smartphone (please complete the following information):**
29
+ - Device: [e.g. iPhone6]
30
+ - OS: [e.g. iOS8.1]
31
+ - Browser [e.g. stock browser, safari]
32
+ - Version [e.g. 22]
33
+
34
+ **Additional context**
35
+ Add any other context about the problem here.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+
5
+ ---
6
+
7
+ **Is your feature request related to a problem? Please describe.**
8
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9
+
10
+ **Describe the solution you'd like**
11
+ A clear and concise description of what you want to happen.
12
+
13
+ **Describe alternatives you've considered**
14
+ A clear and concise description of any alternative solutions or features you've considered.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,23 @@
1
+ **IMPORTANT: Please do not create a Pull Request without creating an issue first.**
2
+
3
+ *Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.*
4
+
5
+ Please provide enough information so that others can review your pull request:
6
+
7
+ Explain the **details** for making this change. What existing problem does the pull request solve?
8
+
9
+ **Test plan (required)**
10
+
11
+ Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
12
+
13
+ Write your test code using RSpec.
14
+
15
+ This gem requires a connection to a test Filebound server to run specs. We expect all specs to pass when we run them against our local test Filebound server. Travis CI won't run the specs because we don't have access to a Filebound server within the Travis servers but we need to be able to run the specs locally where we do have access to a Filebound test server. It would be helpful if you let us know what version of the Filebound API you were using to run your specs against as well just in case there are compatibility issues.
16
+
17
+ **Code formatting**
18
+
19
+ Lint you code through Rubocop and fix any issues that come up before submitting the PR.
20
+
21
+ **Closing issues**
22
+
23
+ Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such).
@@ -1,5 +1,19 @@
1
- sudo: false
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=787a2f89b15c637323c7340d65ec17e898ac44480706b4b4122ea040c2a88f1d
2
4
  language: ruby
3
5
  rvm:
4
6
  - 2.5.1
5
- before_install: gem install bundler -v 1.16.2
7
+ before_install:
8
+ - gem install bundler
9
+ - bundle --version
10
+ install:
11
+ - bundle install
12
+ before_script:
13
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
+ - chmod +x ./cc-test-reporter
15
+ - ./cc-test-reporter before-build
16
+ script: skip
17
+ after_script:
18
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
19
+
@@ -3,6 +3,14 @@
3
3
 
4
4
  Changes to this gem will be noted here.
5
5
 
6
+ ## [0.2.0] - 2018-08-07
7
+ ### Changed
8
+ - Replaced ruby-ntlm dependency with httpi. httpi gem is actively being developed while ruby-ntlm hasn't had a new
9
+ release in over a year.
10
+
11
+ ### Added
12
+ - Query resource endpoint.
13
+
6
14
  ## [0.1.1] - 2018-08-01
7
15
  ### Fixed
8
16
  - Fixed error in summary in the gemspec file.
@@ -16,43 +16,75 @@ this code to [dev@heiskell.com](mailto:dev@heiskell.com).
16
16
 
17
17
  ### Reporting Bugs
18
18
 
19
- Coming soon...
19
+ Thank you for reporting those pesky bugs!
20
+
21
+ In order for us to effectively reproduce and therefore fix the bug we need a "good" bug report submitted by you.
22
+ All bug reports can be submitted by going to the Issues tab in GitHub and clicking "New Issue".
20
23
 
21
24
  #### Submitting A Good Bug Report
22
25
 
23
- Coming soon...
26
+ So what is meant by a good bug report? Well first of all please use GitHub's built in issue tracking by going to
27
+ the issues tab and clicking "New Issue". Then please use [this document](.github/ISSUE_TEMPLATE/bug_report.md) as the template for submitting the report.
28
+ Following this template should hopefully give us enough information to reproduce and fix the issue you have discovered.
29
+ Thank you!
24
30
 
25
31
  ### Suggesting Enhancements
26
32
 
27
- Coming soon...
33
+ We always welcome enhancement suggestions! Making this software better is a high priority so thank you for any suggestions you may have! Given that we do have some guidelines to follow when making enhancement suggestions.
28
34
 
29
35
  #### Submitting a Good Enhancement Suggestion
30
36
 
31
- Coming soon...
37
+ Submitting a good enhancement suggestion is key to making this software do what it is intended to do with minimal technical debt and to properly test the functionality.
38
+
39
+ Enhancement suggestions can be submitted through GitHub using the built-in issue tracking. All issues opened for enhancements should be tagged as such to differentiate them from bug reports. Please use [this document](.github/ISSUE_TEMPLATE/feature_request.md) as the template for submitting an enhancement suggestion.
32
40
 
33
41
  ### Pull Requests
34
42
 
35
- Coming soon...
43
+ If you would like to contribute to the project, great! Thank you for taking the time to work on this project! Given that it is important to let us know some information about the code and what feature or problem you are submitting the request for. Please use [this document](.github/PULL_REQUEST_TEMPLATE.md) as a template for submitting your PR and again, thank you!
36
44
 
37
45
  ## Styleguides
38
46
 
39
- Coming soon...
47
+ Please follow these style guides when submitting code to this project. It helps for readability and productivity if everyone is on the same page with how code and commits are supposed to be formatted.
40
48
 
41
49
  ### Commit Messages
42
50
 
43
- Coming soon...
51
+ We use this git commit style guide suggested by Tim Pope - https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
52
+
53
+ ```
54
+ Capitalized, short (50 chars or less) summary
55
+
56
+ More detailed explanatory text, if necessary. Wrap it to about 72
57
+ characters or so. In some contexts, the first line is treated as the
58
+ subject of an email and the rest of the text as the body. The blank
59
+ line separating the summary from the body is critical (unless you omit
60
+ the body entirely); tools like rebase can get confused if you run the
61
+ two together.
62
+
63
+ Write your commit message in the imperative: "Fix bug" and not "Fixed bug"
64
+ or "Fixes bug." This convention matches up with commit messages generated
65
+ by commands like git merge and git revert.
66
+
67
+ Further paragraphs come after blank lines.
68
+
69
+ - Bullet points are okay, too
70
+
71
+ - Typically a hyphen or asterisk is used for the bullet, followed by a
72
+ single space, with blank lines in between, but conventions vary here
73
+
74
+ - Use a hanging indent
75
+ ```
44
76
 
45
77
  ### Ruby Styleguide
46
78
 
47
- Coming soon...
79
+ Please lint all code through Rubocop using the .rubocop.yml file in the root of this repository before submitting a PR.
48
80
 
49
81
  ### Specs Styleguide
50
82
 
51
- Coming soon...
83
+ Please lint your spec code through Rubocop using .rubocop.yml as well.
52
84
 
53
85
  ### Documentation Styleguide
54
86
 
55
- Coming soon...
87
+ We use YARD for document generation so please use the conventions stated at https://yardoc.org. Make sure all public interfaces are documented and parameters and return values are in that documentation.
56
88
 
57
89
 
58
90
 
@@ -1,19 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- filebound_client (0.1.1)
5
- ruby-ntlm (~> 0.0.4)
4
+ filebound_client (0.2.0)
5
+ httpi (~> 2.4.0)
6
+ rubyntlm (~> 0.6.0)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  ast (2.4.0)
11
12
  diff-lcs (1.3)
13
+ httpi (2.4.3)
14
+ rack
15
+ socksify
12
16
  jaro_winkler (1.5.1)
13
17
  parallel (1.12.1)
14
18
  parser (2.5.1.2)
15
19
  ast (~> 2.4.0)
16
20
  powerpack (0.1.2)
21
+ rack (2.0.5)
17
22
  rainbow (3.0.0)
18
23
  rake (12.3.1)
19
24
  rspec (3.7.0)
@@ -37,8 +42,9 @@ GEM
37
42
  rainbow (>= 2.2.2, < 4.0)
38
43
  ruby-progressbar (~> 1.7)
39
44
  unicode-display_width (~> 1.0, >= 1.0.1)
40
- ruby-ntlm (0.0.4)
41
45
  ruby-progressbar (1.9.0)
46
+ rubyntlm (0.6.2)
47
+ socksify (1.7.1)
42
48
  unicode-display_width (1.4.0)
43
49
  yard (0.9.15)
44
50
 
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This gem provides a easy way for you to access the Filebound API.
4
4
 
5
+ [![Build Status](https://travis-ci.org/JDHeiskell/filebound_client.svg?branch=master)](https://travis-ci.org/JDHeiskell/filebound_client)
6
+
5
7
  ## Dependencies
6
8
 
7
9
  ### Development
@@ -13,8 +15,9 @@ This gem provides a easy way for you to access the Filebound API.
13
15
 
14
16
  ### Runtime
15
17
  * Ruby
16
- * ruby-ntlm - this gem provides the ability to send NTLM headers in requests for when your Filebound server is running
17
- on an IIS web site with Windows Authentication enabled.
18
+ * httpi - this gem provides the ability to send NTLM headers in requests for when your Filebound server is running
19
+ on an IIS web site with Windows Authentication enabled.
20
+ * rubyntlm - this gem is required by the httpi gem to support NTLM headers
18
21
 
19
22
  ## Installation
20
23
 
@@ -25,5 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'rake', '~> 12.3.0'
26
26
  spec.add_development_dependency 'yard', '~> 0.9.0'
27
27
 
28
- spec.add_runtime_dependency 'ruby-ntlm', '~> 0.0.4'
28
+ spec.add_runtime_dependency 'httpi', '~> 2.4.0'
29
+ spec.add_runtime_dependency 'rubyntlm', '~> 0.6.0'
29
30
  end
@@ -94,7 +94,7 @@ module FileboundClient
94
94
  def perform(action, url, params)
95
95
  response = connection.send(action, url, params)
96
96
  # rubocop:disable Metrics/LineLength
97
- raise FileboundClientException.new("#{action.upcase} request failed: #{response.code}", response.code) unless response.code == '200'
97
+ raise FileboundClientException.new("#{action.upcase} request failed: #{response.code}", response.code) unless response.code == 200
98
98
  # rubocop:enable Metrics/LineLength
99
99
  response.body
100
100
  end
@@ -1,6 +1,6 @@
1
- require 'ntlm/http'
2
1
  require 'filebound_client/config'
3
2
  require 'json'
3
+ require 'httpi'
4
4
 
5
5
  module FileboundClient
6
6
  # Encapsulates low level logic to talk to Filebound server
@@ -30,6 +30,7 @@ module FileboundClient
30
30
  # rubocop:disable Metrics/LineLength
31
31
  c.ntlm_auth = { user: config[:ntlm_user], password: config[:ntlm_password], domain: config[:ntlm_domain] } if config[:use_ntlm]
32
32
  # rubocop:enable Metrics/LineLength
33
+ HTTPI.adapter = :net_http
33
34
  end
34
35
  end
35
36
 
@@ -102,8 +103,8 @@ module FileboundClient
102
103
  # @param [Hash] params the params Hash that will be sent in the request (keys: query, headers, body)
103
104
  # @return [Net::HTTPResponse] the response from the GET request
104
105
  def get(url, params)
105
- request = Net::HTTP::Get.new(resource_url(url, query_params(params[:query])))
106
- execute_request(request, params)
106
+ request = HTTPI::Request.new(resource_url(url, query_params(params[:query])))
107
+ execute_request(:get, request, params)
107
108
  end
108
109
 
109
110
  # Sends a PUT request to the supplied resource using the supplied params hash
@@ -111,9 +112,9 @@ module FileboundClient
111
112
  # @param [Hash] params the params Hash that will be sent in the request (keys: query, headers, body)
112
113
  # @return [Net::HTTPResponse] the response from the PUT request
113
114
  def put(url, params)
114
- request = Net::HTTP::Put.new(resource_url(url, query_params(params[:query])))
115
+ request = HTTPI::Request.new(resource_url(url, query_params(params[:query])))
115
116
  request.body = params[:body].to_json
116
- execute_request(request, params)
117
+ execute_request(:put, request, params)
117
118
  end
118
119
 
119
120
  # Sends a POST request to the supplied resource using the supplied params hash
@@ -121,9 +122,9 @@ module FileboundClient
121
122
  # @param [Hash] params the params Hash that will be sent in the request (keys: query, headers, body)
122
123
  # @return [Net::HTTPResponse] the response from the POST request
123
124
  def post(url, params)
124
- request = Net::HTTP::Post.new(resource_url(url, query_params(params[:query])))
125
+ request = HTTPI::Request.new(resource_url(url, query_params(params[:query])))
125
126
  request.body = params[:body].to_json
126
- execute_request(request, params)
127
+ execute_request(:post, request, params)
127
128
  end
128
129
 
129
130
  # Sends a DELETE request to the supplied resource using the supplied params hash
@@ -131,8 +132,8 @@ module FileboundClient
131
132
  # @param [Hash] params the params Hash that will be sent in the request (keys: query, headers, body)
132
133
  # @return [Net::HTTPResponse] the response from the DELETE request
133
134
  def delete(url, params)
134
- request = Net::HTTP::Delete.new(resource_url(url, query_params(params[:query])))
135
- execute_request(request, params)
135
+ request = HTTPI::Request.new(resource_url(url, query_params(params[:query])))
136
+ execute_request(:delete, request, params)
136
137
  end
137
138
 
138
139
  # Sends a POST request to the Filebound API's login endpoint to request a new security token
@@ -140,7 +141,7 @@ module FileboundClient
140
141
  def login
141
142
  response = post('/login', body: { username: configuration.username, password: configuration.password },
142
143
  headers: { 'Content-Type' => 'application/json' })
143
- if response.is_a?(Net::HTTPSuccess)
144
+ if response.code == 200
144
145
  @token = JSON.parse(response.body, symbolize_names: true)
145
146
  true
146
147
  else
@@ -151,9 +152,9 @@ module FileboundClient
151
152
  private
152
153
 
153
154
  def resource_url(url, query)
154
- return "#{api_base_uri}/#{url.reverse.chomp('/').reverse}" unless query
155
+ return "http://#{host}#{api_base_uri}/#{url.reverse.chomp('/').reverse}" unless query
155
156
  query_string = query.map { |k, v| "#{k}=#{v}" }.join('&')
156
- "#{api_base_uri}/#{url.reverse.chomp('/').reverse}?#{query_string}"
157
+ "http://#{host}#{api_base_uri}/#{url.reverse.chomp('/').reverse}?#{query_string}"
157
158
  end
158
159
 
159
160
  def query_params(params)
@@ -167,17 +168,16 @@ module FileboundClient
167
168
  def set_headers(request, headers)
168
169
  if headers.respond_to?(:to_hash)
169
170
  headers.each do |k, v|
170
- request[k.to_s] = v.to_s
171
+ request.headers[k.to_s] = v.to_s
171
172
  end
172
173
  end
173
174
  request
174
175
  end
175
176
 
176
- def execute_request(request, params)
177
- http = Net::HTTP.new(configuration.host)
177
+ def execute_request(method, request, params)
178
178
  request = set_headers(request, params[:headers])
179
- request.ntlm_auth(ntlm_user, ntlm_domain, ntlm_password) if configuration.ntlm_auth
180
- http.request(request)
179
+ request.auth.ntlm(ntlm_user, ntlm_password, ntlm_domain) if configuration.ntlm_auth
180
+ HTTPI.request(method, request)
181
181
  end
182
182
  end
183
183
  end
@@ -7,6 +7,7 @@ require 'filebound_client/endpoints/dividers'
7
7
  require 'filebound_client/endpoints/document_binary_data'
8
8
  require 'filebound_client/endpoints/eform_data'
9
9
  require 'filebound_client/endpoints/separators'
10
+ require 'filebound_client/endpoints/query'
10
11
 
11
12
  module FileboundClient
12
13
  # Module for resource endpoints
@@ -45,6 +46,7 @@ module FileboundClient
45
46
  include FileboundClient::Endpoints::DocumentBinaryData
46
47
  include FileboundClient::Endpoints::EFormData
47
48
  include FileboundClient::Endpoints::Separators
49
+ include FileboundClient::Endpoints::Query
48
50
  end
49
51
  end
50
52
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
@@ -0,0 +1,17 @@
1
+ module FileboundClient
2
+ module Endpoints
3
+ # Module for Query resource endpoint
4
+ module Query
5
+ # Runs a query against the API using the project, files and documents query supplied.
6
+ # See https://applications.filebound.com/v3/documentation/endpoints#Custom+Query for more detail.
7
+ # @param [String] projects_query the comma-delimited projects query, pass 'all' for no filter (ex: name_Invoices)
8
+ # @param [String] files_query the comma-delimited files query, pass 'all' for no filter (ex: status_1)
9
+ # @param [String] documents_query the comma-delimited documents query, pass 'all' for no filter (ex: divider_HR)
10
+ # @example Get project named Invoices with Files that have a status of 1 and documents with a divider named HR
11
+ # query('name_Invoices','status_1','divider_HR')
12
+ def query(projects_query, files_query, documents_query, query_params = nil)
13
+ get("/query/#{projects_query}/#{files_query}/#{documents_query}", query_params)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
1
  module FileboundClient
2
2
  # Current version of gem
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  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.1.1
4
+ version: 0.2.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: 2018-08-01 00:00:00.000000000 Z
11
+ date: 2018-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,19 +53,33 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.9.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: ruby-ntlm
56
+ name: httpi
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.0.4
61
+ version: 2.4.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.0.4
68
+ version: 2.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubyntlm
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.0
69
83
  description:
70
84
  email:
71
85
  - brichardson@heiskell.com
@@ -73,6 +87,9 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
90
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
91
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
92
+ - ".github/PULL_REQUEST_TEMPLATE.md"
76
93
  - ".gitignore"
77
94
  - ".rspec"
78
95
  - ".rubocop.yml"
@@ -104,6 +121,7 @@ files:
104
121
  - lib/filebound_client/endpoints/eform_detail.rb
105
122
  - lib/filebound_client/endpoints/files.rb
106
123
  - lib/filebound_client/endpoints/projects.rb
124
+ - lib/filebound_client/endpoints/query.rb
107
125
  - lib/filebound_client/endpoints/separators.rb
108
126
  - lib/filebound_client/endpoints/version.rb
109
127
  - lib/filebound_client/version.rb