interfax 1.0.1 → 1.1.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/README.md +15 -5
- data/lib/interfax/client.rb +16 -2
- data/lib/interfax/image.rb +8 -0
- data/lib/interfax/inbound.rb +2 -2
- data/lib/interfax/outbound.rb +2 -2
- data/lib/interfax/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55720a871ff442165ff9c12c3c1c8b51bd4cab07
|
4
|
+
data.tar.gz: c36611237b5d777b2526e96261cad0519d679a22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf3283be3e11cdacc296af03433775a172ac14cc28fbec679359677e1fb0416ab9ef587400823d8e72ba07731af15abb98bbc5a1954511878352df59734ee3d5
|
7
|
+
data.tar.gz: f7a4fac0ac9322ad16f579f2f4c8957d89b218187132797273340922b0c67a7ac5450906945a93503f60a4123b227e39c7c48dda53a9fc87c84058ea2a8bb31e
|
data/README.md
CHANGED
@@ -39,7 +39,7 @@ The client follows the [12-factor](http://12factor.net/config) apps principle an
|
|
39
39
|
# Initialize using parameters
|
40
40
|
interfax = InterFAX::Client.new(username: '...', password: '...')
|
41
41
|
|
42
|
-
#
|
42
|
+
# Alternative: Initialize using environment variables
|
43
43
|
# * INTERFAX_USERNAME
|
44
44
|
# * INTERFAX_PASSWORD
|
45
45
|
interfax = InterFAX::Client.new
|
@@ -248,14 +248,14 @@ interfax.inbound.find(123456)
|
|
248
248
|
|
249
249
|
`interfax.inbound.image(fax_id)`
|
250
250
|
|
251
|
-
Retrieves a single fax's image.
|
251
|
+
Retrieves a single fax's image. This can be a PDF or a TIFF file.
|
252
252
|
|
253
253
|
```ruby
|
254
254
|
image = interfax.inbound.image(123456)
|
255
255
|
=> #<InterFAX::Image>
|
256
256
|
image.data
|
257
257
|
=> # "....binary data...."
|
258
|
-
image.save(
|
258
|
+
image.save("path/to/fax.#{image.extension}")
|
259
259
|
=> # saves image to file
|
260
260
|
```
|
261
261
|
|
@@ -513,8 +513,18 @@ document.id # Extracts the ID from the URI (the API does not return the ID)
|
|
513
513
|
1. **Fork** the repo on GitHub
|
514
514
|
2. **Clone** the project to your own machine
|
515
515
|
3. **Commit** changes to your own branch
|
516
|
-
4. **
|
517
|
-
5.
|
516
|
+
4. **Test** the changes you have made
|
517
|
+
5. **Push** your work back up to your fork
|
518
|
+
6. Submit a **Pull request** so that we can review your changes
|
519
|
+
|
520
|
+
### Testing
|
521
|
+
|
522
|
+
Before submitting a contribution please ensure all tests pass.
|
523
|
+
|
524
|
+
```sh
|
525
|
+
bundle install # install dependencies
|
526
|
+
rake spec # run all tests
|
527
|
+
```
|
518
528
|
|
519
529
|
## License
|
520
530
|
|
data/lib/interfax/client.rb
CHANGED
@@ -104,6 +104,8 @@ module InterFAX
|
|
104
104
|
when Net::HTTPSuccess
|
105
105
|
if response['location']
|
106
106
|
response['location']
|
107
|
+
elsif tiff?(response) || pdf?(response)
|
108
|
+
return [response.body, response['Content-Type']]
|
107
109
|
elsif json?(response)
|
108
110
|
begin
|
109
111
|
JSON.parse(response.body)
|
@@ -128,11 +130,23 @@ module InterFAX
|
|
128
130
|
end
|
129
131
|
end
|
130
132
|
|
133
|
+
def pdf?(response)
|
134
|
+
type?(response, 'application/pdf')
|
135
|
+
end
|
136
|
+
|
137
|
+
def tiff?(response)
|
138
|
+
type?(response, 'image/tiff')
|
139
|
+
end
|
140
|
+
|
131
141
|
def json?(response)
|
142
|
+
type?(response, 'text/json')
|
143
|
+
end
|
144
|
+
|
145
|
+
def type?(response, mime_type)
|
132
146
|
content_type = response['Content-Type']
|
133
|
-
|
147
|
+
correct_header = content_type && content_type.split(';').first == mime_type
|
134
148
|
has_body = response.body && response.body.length > 0
|
135
|
-
|
149
|
+
correct_header && has_body
|
136
150
|
end
|
137
151
|
end
|
138
152
|
end
|
data/lib/interfax/image.rb
CHANGED
data/lib/interfax/inbound.rb
CHANGED
@@ -18,8 +18,8 @@ class InterFAX::Inbound
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def image fax_id
|
21
|
-
data = @client.get("/inbound/faxes/#{fax_id}/image")
|
22
|
-
InterFAX::Image.new(data: data, client: @client)
|
21
|
+
data, mimeType = @client.get("/inbound/faxes/#{fax_id}/image")
|
22
|
+
InterFAX::Image.new(data: data, client: @client, mimeType: mimeType)
|
23
23
|
end
|
24
24
|
|
25
25
|
def mark fax_id, options = {}
|
data/lib/interfax/outbound.rb
CHANGED
@@ -38,8 +38,8 @@ class InterFAX::Outbound
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def image fax_id
|
41
|
-
data = @client.get("/outbound/faxes/#{fax_id}/image")
|
42
|
-
InterFAX::Image.new(data: data, client: @client)
|
41
|
+
data, mimeType = @client.get("/outbound/faxes/#{fax_id}/image")
|
42
|
+
InterFAX::Image.new(data: data, client: @client, mimeType: mimeType)
|
43
43
|
end
|
44
44
|
|
45
45
|
def cancel fax_id
|
data/lib/interfax/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interfax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InterFAX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mimemagic
|