doxie 2.0.0 → 3.0.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 +5 -5
- data/README.md +53 -24
- data/lib/doxie.rb +1 -0
- data/lib/doxie/client.rb +17 -9
- data/lib/doxie/models.rb +12 -0
- data/lib/doxie/version.rb +1 -1
- data/spec/doxie_spec.rb +33 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 86ca65be716261fc75507c33432181058e8c567be9e9c8f34e88b884222822be
|
4
|
+
data.tar.gz: 2686549b36f731522f3f7c11c505f9c57dbb2ff5e1d8cac461b2827d2a535b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87d150d0d5fc9cf79c06e3aa6726d92c3a1eaf83c8208043f4dd512f79f32af37512402a83919a095769ec63ba80722df70f83b225a00eb6ffe32cf60bb3fae7
|
7
|
+
data.tar.gz: b3b46c8ceb2128959117a7ca2502da83cf77ff3afece80acd563d95f849dd58ba6f42b31bef641770edd6cd80ef23578ab048cbbda5fe521f77c119ba8792f2b
|
data/README.md
CHANGED
@@ -2,7 +2,15 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/doxie) [](https://travis-ci.org/cbetta/doxie)
|
4
4
|
|
5
|
-
A
|
5
|
+
A client library for the API available on WiFi-enabled [Doxie scanners](http://getdoxie.com). The specification of the API is available in their [developer documentation](/docs).
|
6
|
+
|
7
|
+
## Scanners Supported
|
8
|
+
|
9
|
+
This library supports the following scanners:
|
10
|
+
|
11
|
+
* Doxie Go Wifi (DX250)
|
12
|
+
* Doxie Go SE (DX255)
|
13
|
+
* Doxie Q (DX300)
|
6
14
|
|
7
15
|
## Installation
|
8
16
|
|
@@ -15,9 +23,9 @@ gem 'doxie-scanner' # optional if your Doxie is not on a fixed IP
|
|
15
23
|
|
16
24
|
## Usage
|
17
25
|
|
18
|
-
### Finding your Doxie
|
26
|
+
### Optional: Finding your Doxie's IP
|
19
27
|
|
20
|
-
This requires the [`
|
28
|
+
This optional step requires the [`doxie-scanner`](https://github.com/cbetta/doxie-scanner) gem. This gem has a bigger dependency than the `doxie` gem, which is why it has been intentionally separated into a seperate library.
|
21
29
|
|
22
30
|
```rb
|
23
31
|
require 'doxie/scanner'
|
@@ -29,14 +37,29 @@ Doxie::Scanner.ips
|
|
29
37
|
|
30
38
|
### Client
|
31
39
|
|
32
|
-
The client accepts an `ip` and `password`. You can omit the `password` if your Doxie has non set.
|
40
|
+
The client accepts an `ip` address, a scanner model number (defaults to `Doxie::GO`) and an optional `password`. You can omit the `password` if your Doxie has non set.
|
33
41
|
|
34
42
|
```rb
|
35
43
|
require 'doxie'
|
36
|
-
client = Doxie::Client.new(
|
44
|
+
client = Doxie::Client.new(
|
45
|
+
ip: '192.168.1.2',
|
46
|
+
model: Doxie::Q, # of Doxie::GO, or Doxie::GO_SE
|
47
|
+
password: 'test'
|
48
|
+
)
|
37
49
|
```
|
38
50
|
|
39
|
-
|
51
|
+
Alternatively, you can use the [`doxie-scanner`](https://github.com/cbetta/doxie-scanner) gem to automatically connect to any scanner found.
|
52
|
+
|
53
|
+
```rb
|
54
|
+
require 'doxie'
|
55
|
+
require 'doxie/scanner'
|
56
|
+
|
57
|
+
client = Doxie::Client.new(
|
58
|
+
Doxie::Scanner.devices.first
|
59
|
+
)
|
60
|
+
```
|
61
|
+
|
62
|
+
### `GET /hello.json`
|
40
63
|
|
41
64
|
Returns status information for the scanner, firmware, network mode, and password
|
42
65
|
configuration. Accessing this command does not require a password if one has been
|
@@ -57,22 +80,22 @@ client.hello
|
|
57
80
|
}
|
58
81
|
```
|
59
82
|
|
60
|
-
*
|
61
|
-
*
|
83
|
+
* `model`: DX250 for the Doxie Go WiFi.
|
84
|
+
* `name`: The name of the scanner, which defaults to the form "Doxie_XXXXXX".
|
62
85
|
The name of a scanner can be changed by using the Doxie desktop app.
|
63
|
-
*
|
64
|
-
*
|
86
|
+
* `firmwareWiFi`: The Wi-Fi firmware version.
|
87
|
+
* `hasPassword`: Indicates whether a password has been set to authenticate API
|
65
88
|
access. Passwords can be set and removed by using the Doxie desktop app.
|
66
|
-
*
|
89
|
+
* `MAC`: The MAC address of the scanner as shown on the scanner's bottom
|
67
90
|
label.
|
68
|
-
*
|
91
|
+
* `mode`: "AP" if the scanner is creating its own network or "Client" if the
|
69
92
|
scanner is joining an existing network.
|
70
|
-
*
|
93
|
+
* `network`: If the scanner is in "Client" mode, this is the name of the
|
71
94
|
network it has joined.
|
72
|
-
*
|
95
|
+
* `ip`: If the scanner is in "Client" mode, this is the IP of the scanner on
|
73
96
|
the network it has joined.
|
74
97
|
|
75
|
-
### GET /hello_extra.json
|
98
|
+
### `GET /hello_extra.json`
|
76
99
|
|
77
100
|
Returns additional status values. These values are accessed separately from
|
78
101
|
those in `/hello.json` because there can be a delay of several seconds in
|
@@ -87,12 +110,14 @@ client.hello_extra
|
|
87
110
|
}
|
88
111
|
```
|
89
112
|
|
90
|
-
*
|
91
|
-
*
|
113
|
+
* `firmware`: The scanner firmware version.
|
114
|
+
* `connectedToExternalPower`: Indicates whether the scanner is connected to
|
92
115
|
its AC adapter versus running on battery power. This value is not cached, so
|
93
116
|
it immediately reflects any state changes.
|
94
117
|
|
95
|
-
|
118
|
+
This method is only available for the original Doxie Go WiFi model.
|
119
|
+
|
120
|
+
### `GET /restart.json`
|
96
121
|
|
97
122
|
Restarts the scanner's Wi-Fi system. The scanner's status light blinks blue
|
98
123
|
during the restart.
|
@@ -102,7 +127,7 @@ client.restart
|
|
102
127
|
=> true
|
103
128
|
```
|
104
129
|
|
105
|
-
### GET /scans.json
|
130
|
+
### `GET /scans.json`
|
106
131
|
|
107
132
|
Returns an array of all scans currently in the scanner’s memory. After scanning
|
108
133
|
a document, the scan will available via the API several second later.
|
@@ -123,7 +148,7 @@ result, even if there are other scans on the scanner, due to the scanner's
|
|
123
148
|
memory being in use. Consider retrying if a successful HTTP status code is
|
124
149
|
returned along with a blank body.
|
125
150
|
|
126
|
-
### GET /scans/recent.json
|
151
|
+
### `GET /scans/recent.json`
|
127
152
|
|
128
153
|
Returns the path to the last scan if available. Monitoring this value for
|
129
154
|
changes provides a simple way to detect new scans without having to fetch the
|
@@ -136,7 +161,7 @@ client.recent_scans
|
|
136
161
|
}
|
137
162
|
```
|
138
163
|
|
139
|
-
### GET /scans/DOXIE/JPEG/IMG_XXXX.JPG
|
164
|
+
### `GET /scans/DOXIE/JPEG/IMG_XXXX.JPG`
|
140
165
|
|
141
166
|
There are 2 ways to get a scan off your Doxie. The first is to get the raw binary content and then do something with it yourself.
|
142
167
|
|
@@ -152,7 +177,7 @@ client.scan "/DOXIE/JPEG/IMG_0001.JPG", 'test.jpg'
|
|
152
177
|
=> true
|
153
178
|
```
|
154
179
|
|
155
|
-
### GET /thumbnails/DOXIE/JPEG/IMG_XXXX.JPG
|
180
|
+
### `GET /thumbnails/DOXIE/JPEG/IMG_XXXX.JPG`
|
156
181
|
|
157
182
|
There are 2 ways to get a thumbnail off your Doxie. The first is to get the raw binary content and then do something with it yourself.
|
158
183
|
|
@@ -174,7 +199,7 @@ scans are not generated until after the scan has been made available in
|
|
174
199
|
if the thumbnail has not yet been generated. Retrying after a delay is
|
175
200
|
recommended to handle such cases.
|
176
201
|
|
177
|
-
### DELETE /scans/DOXIE/JPEG/IMG_XXXX.JPG
|
202
|
+
### `DELETE /scans/DOXIE/JPEG/IMG_XXXX.JPG`
|
178
203
|
|
179
204
|
Deletes the scan at the specified path.
|
180
205
|
|
@@ -188,7 +213,9 @@ obtained and released. Deleting may fail if the lock cannot be obtained
|
|
188
213
|
(e.g., the scanner is busy), so consider retrying on failure conditions. When
|
189
214
|
deleting multiple scans, use `/scans/delete.json` for best performance.
|
190
215
|
|
191
|
-
|
216
|
+
This will raise an error if the file is no longer present (`Doxie::Client::Error<Net::HTTPForbidden>`)
|
217
|
+
|
218
|
+
### `POST /scans/delete.json`
|
192
219
|
|
193
220
|
Deletes multiple scans in a single operation. This is much faster than deleting
|
194
221
|
each scan individually.
|
@@ -198,6 +225,8 @@ client.delete_scans ["/DOXIE/JPEG/IMG_0001.JPG", "/DOXIE/JPEG/IMG_0002.JPG"]
|
|
198
225
|
=> true
|
199
226
|
```
|
200
227
|
|
228
|
+
This will raise an error if the files are no longer present (`Doxie::Client::Error<Net::HTTPForbidden>`)
|
229
|
+
|
201
230
|
## Contributing
|
202
231
|
|
203
232
|
1. **Fork** the repo on GitHub
|
data/lib/doxie.rb
CHANGED
data/lib/doxie/client.rb
CHANGED
@@ -5,17 +5,19 @@ module Doxie
|
|
5
5
|
# The client for connecting to a Doxie scanner.
|
6
6
|
#
|
7
7
|
# Use the IP and password to connect as follows:
|
8
|
-
# Doxie::Client.new(ip: '192.168.1.2', password: 'test')
|
8
|
+
# Doxie::Client.new(ip: '192.168.1.2', model: Doxie::Q, password: 'test')
|
9
9
|
class Client
|
10
10
|
class Error < StandardError; end
|
11
11
|
|
12
12
|
USERNAME = 'doxie'.freeze
|
13
13
|
|
14
|
-
attr_accessor :ip, :password
|
14
|
+
attr_accessor :ip, :password, :model, :port
|
15
15
|
|
16
16
|
def initialize(options)
|
17
17
|
@ip = options[:ip] || ''
|
18
18
|
@password = options[:password] || ''
|
19
|
+
@model = options[:model] || Doxie::API_V1
|
20
|
+
@port = @model == Doxie::API_V1 ? 8080 : 80
|
19
21
|
end
|
20
22
|
|
21
23
|
def hello
|
@@ -23,19 +25,25 @@ module Doxie
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def hello_extra
|
28
|
+
raise Error.new('Method does not exist for this model') if model == Doxie::API_V2
|
26
29
|
get('/hello_extra.json')
|
27
30
|
end
|
28
31
|
|
29
32
|
def restart
|
30
|
-
get('/restart.json')
|
33
|
+
get('/restart.json') || true
|
31
34
|
end
|
32
35
|
|
33
36
|
def scans
|
34
37
|
get('/scans.json')
|
38
|
+
rescue Doxie::Client::Error => error
|
39
|
+
# a 404 is thrown on the Doxie Q and
|
40
|
+
# Doxie GO SE when there are no scans
|
41
|
+
raise error if model == Doxie::DX250
|
42
|
+
[]
|
35
43
|
end
|
36
44
|
|
37
45
|
def recent_scans
|
38
|
-
get('/scans/recent.json')
|
46
|
+
get('/scans/recent.json') || []
|
39
47
|
end
|
40
48
|
|
41
49
|
def scan(scan_name, file_name = nil)
|
@@ -47,11 +55,11 @@ module Doxie
|
|
47
55
|
end
|
48
56
|
|
49
57
|
def delete_scan(scan_name)
|
50
|
-
delete("/scans#{scan_name}")
|
58
|
+
delete("/scans#{scan_name}") || true
|
51
59
|
end
|
52
60
|
|
53
61
|
def delete_scans(scan_names)
|
54
|
-
post('/scans/delete.json', scan_names)
|
62
|
+
post('/scans/delete.json', scan_names) || true
|
55
63
|
end
|
56
64
|
|
57
65
|
private
|
@@ -76,11 +84,11 @@ module Doxie
|
|
76
84
|
end
|
77
85
|
|
78
86
|
def uri_for(path)
|
79
|
-
URI("
|
87
|
+
URI("http://#{ip}:#{port}#{path}")
|
80
88
|
end
|
81
89
|
|
82
90
|
def request(uri, message)
|
83
|
-
message.basic_auth USERNAME, password if password
|
91
|
+
message.basic_auth USERNAME, password if password && password.length > 0
|
84
92
|
http = Net::HTTP.new(uri.host, uri.port)
|
85
93
|
http.request(message)
|
86
94
|
end
|
@@ -88,7 +96,7 @@ module Doxie
|
|
88
96
|
def parse(response)
|
89
97
|
case response
|
90
98
|
when Net::HTTPNoContent
|
91
|
-
|
99
|
+
nil
|
92
100
|
when Net::HTTPSuccess
|
93
101
|
parse_json(response)
|
94
102
|
else
|
data/lib/doxie/models.rb
ADDED
data/lib/doxie/version.rb
CHANGED
data/spec/doxie_spec.rb
CHANGED
@@ -18,9 +18,22 @@ describe 'Doxie::Client' do
|
|
18
18
|
@json_response_body = json_response_body('{"key":"value"}')
|
19
19
|
@ip = '192.168.1.1'
|
20
20
|
@base_url = "http://#{@ip}:8080"
|
21
|
+
@base_url_v2 = "http://#{@ip}:80"
|
21
22
|
@client = Doxie::Client.new(ip: @ip)
|
22
23
|
end
|
23
24
|
|
25
|
+
describe 'Doxie Models' do
|
26
|
+
it 'should assign the right values to each model' do
|
27
|
+
assert_equal Doxie::GO, Doxie::API_V1
|
28
|
+
assert_equal Doxie::DX250, Doxie::API_V1
|
29
|
+
|
30
|
+
assert_equal Doxie::Q, Doxie::API_V2
|
31
|
+
assert_equal Doxie::GO_SE, Doxie::API_V2
|
32
|
+
assert_equal Doxie::DX255, Doxie::API_V2
|
33
|
+
assert_equal Doxie::DX300, Doxie::API_V2
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
24
37
|
describe 'get /hello.json' do
|
25
38
|
it 'should return the result' do
|
26
39
|
stub_request(:get, "#{@base_url}/hello.json")
|
@@ -35,6 +48,12 @@ describe 'Doxie::Client' do
|
|
35
48
|
.to_return(@json_response_body)
|
36
49
|
@client.hello_extra.must_equal(@json_response_object)
|
37
50
|
end
|
51
|
+
|
52
|
+
it 'should error for API V2 models, as the method does not exist' do
|
53
|
+
@client = Doxie::Client.new(ip: @ip, model: Doxie::API_V2)
|
54
|
+
error = -> { @client.hello_extra }.must_raise(Doxie::Client::Error)
|
55
|
+
error.message.must_match "Method does not exist for this model"
|
56
|
+
end
|
38
57
|
end
|
39
58
|
|
40
59
|
describe 'get /restart.json' do
|
@@ -51,6 +70,13 @@ describe 'Doxie::Client' do
|
|
51
70
|
.to_return(@json_response_body)
|
52
71
|
@client.scans.must_equal(@json_response_object)
|
53
72
|
end
|
73
|
+
|
74
|
+
it 'should return an empty array when there are no scans on a V2 model' do
|
75
|
+
@client = Doxie::Client.new(ip: @ip, model: Doxie::API_V2)
|
76
|
+
stub_request(:get, "#{@base_url_v2}/scans.json")
|
77
|
+
.to_return(status: 404)
|
78
|
+
@client.scans.must_equal([])
|
79
|
+
end
|
54
80
|
end
|
55
81
|
|
56
82
|
describe 'get /scans/recent.json' do
|
@@ -59,6 +85,13 @@ describe 'Doxie::Client' do
|
|
59
85
|
.to_return(@json_response_body)
|
60
86
|
@client.recent_scans.must_equal(@json_response_object)
|
61
87
|
end
|
88
|
+
|
89
|
+
it 'should return an empty array when there are no scans on a V2 model' do
|
90
|
+
@client = Doxie::Client.new(ip: @ip, model: Doxie::API_V2)
|
91
|
+
stub_request(:get, "#{@base_url_v2}/scans/recent.json")
|
92
|
+
.to_return(status: 204)
|
93
|
+
@client.recent_scans.must_equal([])
|
94
|
+
end
|
62
95
|
end
|
63
96
|
|
64
97
|
describe 'get /scans/DOXIE/JPEG/IMG_0001.JPG' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doxie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cristiano Betta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- doxie.gemspec
|
78
78
|
- lib/doxie.rb
|
79
79
|
- lib/doxie/client.rb
|
80
|
+
- lib/doxie/models.rb
|
80
81
|
- lib/doxie/version.rb
|
81
82
|
- spec/doxie_spec.rb
|
82
83
|
homepage: https://github.com/cbetta/doxie
|
@@ -98,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
99
|
- !ruby/object:Gem::Version
|
99
100
|
version: '0'
|
100
101
|
requirements: []
|
101
|
-
|
102
|
-
rubygems_version: 2.6.13
|
102
|
+
rubygems_version: 3.0.2
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: Doxie API Wrapper for getting scans off your Doxie scanner
|