faxage 1.1.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +71 -0
- data/lib/faxage.rb +3 -0
- data/lib/faxage/receive_fax.rb +60 -24
- data/lib/faxage/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a03e5a557de75e3e23b481552f7dac9d652496ca6a013978c51580f3b88c50d
|
4
|
+
data.tar.gz: ce9c8db7811d2c0f587aef771d6a425d4b465f5822f2da339059197524819a52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 051ae752d2f1e6a3a8d17df6e3b7c8cefda75c242a846e7619f704cc46ce7637e0483d3ba5c6ed83c5c483b6b5cc73f2d4b7873c420b827ec310b7d23882f7a7
|
7
|
+
data.tar.gz: 14eaa675be8861717f7bf9596703adba1a2b8549e1c0e731f9db6980e26bcf661e7cbc8d7dc914f8c1e10b0c201f9255745d535cb868575fb873c11e6f85bb9e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -56,6 +56,51 @@ Click the link for ‘Q: What types of files can I send?’ on the above URL to
|
|
56
56
|
| HP Printer Control Language | PCL |
|
57
57
|
| Plain Text | TXT |
|
58
58
|
|
59
|
+
#### Error Types
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
class LoginError < StandardError
|
63
|
+
# "One or more of username, company, password is incorrect or your account is disabled for some reason."
|
64
|
+
end
|
65
|
+
|
66
|
+
class FaxageInternalError < StandardError
|
67
|
+
# "Internal FAXAGE error."
|
68
|
+
end
|
69
|
+
|
70
|
+
class UnknownOperationError < StandardError
|
71
|
+
# "Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}"
|
72
|
+
end
|
73
|
+
|
74
|
+
class NoResponseError < StandardError
|
75
|
+
# "An empty response was returned from Faxage."
|
76
|
+
end
|
77
|
+
|
78
|
+
class InvalidJobIdError < StandardError
|
79
|
+
# "Internal FAXAGE error – the job was not properly inserted into our database."
|
80
|
+
end
|
81
|
+
|
82
|
+
class InvalidFaxNoError < StandardError
|
83
|
+
# "The faxno variable does not contain a 10-digit numeric only string."
|
84
|
+
end
|
85
|
+
|
86
|
+
class NoFilesError < StandardError
|
87
|
+
# "No valid files were found in faxfilenames[] and/or faxfiledata[]."
|
88
|
+
end
|
89
|
+
|
90
|
+
class BlockedNumberError < StandardError
|
91
|
+
# "The number you tried to fax to was blocked (outside of continental US, Canada and Hawaii or a 555, 911, or other invalid/blocked type of number)."
|
92
|
+
end
|
93
|
+
|
94
|
+
class NoIncomingFaxesError < StandardError
|
95
|
+
# "There are no incoming faxes to list for you."
|
96
|
+
end
|
97
|
+
|
98
|
+
class FaxIdNotFoundError < StandardError
|
99
|
+
# The faxid passed in is invalid or is an ID that does not belong to your company.
|
100
|
+
end
|
101
|
+
```
|
102
|
+
|
103
|
+
|
59
104
|
#### Sending a fax
|
60
105
|
|
61
106
|
##### sendfax
|
@@ -122,6 +167,32 @@ Faxage::ReceiveFax.new(
|
|
122
167
|
).listfax()
|
123
168
|
```
|
124
169
|
|
170
|
+
##### getfax
|
171
|
+
This operation is used to download a received fax image.
|
172
|
+
```ruby
|
173
|
+
Faxage::ReceiveFax.new(
|
174
|
+
username: # Assigned FAXAGE username
|
175
|
+
company: # Assigned FAXAGE company credential
|
176
|
+
password: # Assigned FAXAGE password
|
177
|
+
).getfax(recvid:) # The numeric ID of the fax to get, retrieved from the listfax operation (the recvid in listfax)
|
178
|
+
|
179
|
+
# The actual data returned will be the binary contents of the fax itself.
|
180
|
+
|
181
|
+
# A practical example of uploading the file to AWS S3 in a Rails application could look like:
|
182
|
+
|
183
|
+
get_fax = Faxage::ReceiveFax.new(
|
184
|
+
username: # Assigned FAXAGE username
|
185
|
+
company: # Assigned FAXAGE company credential
|
186
|
+
password: # Assigned FAXAGE password
|
187
|
+
).getfax(recvid:)
|
188
|
+
|
189
|
+
creds = Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
|
190
|
+
s3_resource = Aws::S3::Resource.new(region: ENV['AWS_S3_REGION'], credentials: creds)
|
191
|
+
obj = s3_resource.bucket(ENV['AWS_BUCKET_NAME']).object("path-to-your-file-on-S3/your-file-name.pdf")
|
192
|
+
obj.put(body: get_fax)
|
193
|
+
|
194
|
+
```
|
195
|
+
|
125
196
|
#### Information Gathering Operations
|
126
197
|
|
127
198
|
These operations relate to gathering information that helps with managing and/or
|
data/lib/faxage.rb
CHANGED
data/lib/faxage/receive_fax.rb
CHANGED
@@ -15,6 +15,40 @@ module Faxage
|
|
15
15
|
@password = password
|
16
16
|
end
|
17
17
|
|
18
|
+
def getfax(recvid:, **options)
|
19
|
+
# This operation is used to download a received fax image.
|
20
|
+
|
21
|
+
subdirectory = "/httpsfax.php"
|
22
|
+
|
23
|
+
body = {
|
24
|
+
operation: "getfax",
|
25
|
+
username: username,
|
26
|
+
company: company,
|
27
|
+
password: password,
|
28
|
+
faxid: recvid
|
29
|
+
}.merge!(options.each { |k, v| options[k] = 1 if v } )
|
30
|
+
|
31
|
+
response = self.class.post(subdirectory,
|
32
|
+
body: body
|
33
|
+
)
|
34
|
+
|
35
|
+
if response.parsed_response.nil?
|
36
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
37
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
38
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
39
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
40
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
41
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
42
|
+
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}")
|
43
|
+
elsif response.parsed_response.include?("ERR12: FAX ID")
|
44
|
+
raise FaxIdNotFoundError.new("The faxid passed in is invalid or is an ID that does not belong to your company. #{response.parsed_response}")
|
45
|
+
elsif response.parsed_response.include?("ERR13: File could not be opened")
|
46
|
+
raise FaxageInternalError.new("Internal FAXAGE error. #{response.parsed_response}.")
|
47
|
+
else
|
48
|
+
return response.parsed_response
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
18
52
|
def listfax(**options)
|
19
53
|
# This operation is used to gather a list of incoming faxes for your account.
|
20
54
|
|
@@ -25,7 +59,7 @@ module Faxage
|
|
25
59
|
username: username,
|
26
60
|
company: company,
|
27
61
|
password: password
|
28
|
-
}.merge!(options)
|
62
|
+
}.merge!(options.each { |k, v| options[k] = 1 if v } )
|
29
63
|
|
30
64
|
response = self.class.post(subdirectory,
|
31
65
|
body: body
|
@@ -52,51 +86,53 @@ module Faxage
|
|
52
86
|
individual_fax = Hash.new
|
53
87
|
received_fax.split("\t").each_with_index do |item, index|
|
54
88
|
if options[:starttime].nil?
|
55
|
-
|
56
|
-
when 0
|
89
|
+
if index == 0
|
57
90
|
individual_fax[:recvid] = item
|
58
|
-
|
91
|
+
elsif index == 1
|
59
92
|
individual_fax[:revdate] = item
|
60
|
-
|
93
|
+
elsif index == 2
|
61
94
|
individual_fax[:cid] = item
|
62
|
-
|
95
|
+
elsif index == 3
|
63
96
|
individual_fax[:dnis] = item
|
64
|
-
|
97
|
+
elsif index == 4 && !options[:filename].nil?
|
65
98
|
individual_fax[:filename] = item
|
66
|
-
|
99
|
+
elsif index == 4 && options[:filename].nil? && !options[:pagecount].nil?
|
67
100
|
individual_fax[:pagecount] = item
|
68
|
-
|
101
|
+
elsif index == 4 && options[:filename].nil? && options[:pagecount].nil? && !options[:showtsid].nil?
|
69
102
|
individual_fax[:tsid] = item
|
70
|
-
|
103
|
+
elsif index == 5 && !options[:filename].nil? && !options[:pagecount].nil?
|
71
104
|
individual_fax[:pagecount] = item
|
72
|
-
|
105
|
+
elsif index == 5 && !options[:filename].nil? && options[:pagecount].nil? && !options[:showtsid].nil?
|
106
|
+
individual_fax[:tsid] = item
|
107
|
+
elsif index == 5 && options[:filename].nil? && !options[:pagecount].nil? && !options[:showtsid].nil?
|
73
108
|
individual_fax[:tsid] = item
|
74
|
-
|
109
|
+
elsif index == 6 && !options[:filename].nil? && !options[:pagecount].nil? && !options[:showtsid].nil?
|
75
110
|
individual_fax[:tsid] = item
|
76
111
|
end
|
77
112
|
else
|
78
|
-
|
79
|
-
when 0
|
113
|
+
if index == 0
|
80
114
|
individual_fax[:recvid] = item
|
81
|
-
|
115
|
+
elsif index == 1
|
82
116
|
individual_fax[:revdate] = item
|
83
|
-
|
117
|
+
elsif index == 2
|
84
118
|
individual_fax[:starttime] = item
|
85
|
-
|
119
|
+
elsif index == 3
|
86
120
|
individual_fax[:cid] = item
|
87
|
-
|
121
|
+
elsif index == 4
|
88
122
|
individual_fax[:dnis] = item
|
89
|
-
|
123
|
+
elsif index == 5 && !options[:filename].nil?
|
90
124
|
individual_fax[:filename] = item
|
91
|
-
|
125
|
+
elsif index == 5 && options[:filename].nil? && !options[:pagecount].nil?
|
92
126
|
individual_fax[:pagecount] = item
|
93
|
-
|
127
|
+
elsif index == 5 && options[:filename].nil? && options[:pagecount].nil? && !options[:showtsid].nil?
|
94
128
|
individual_fax[:tsid] = item
|
95
|
-
|
129
|
+
elsif index == 6 && !options[:filename].nil? && !options[:pagecount].nil?
|
96
130
|
individual_fax[:pagecount] = item
|
97
|
-
|
131
|
+
elsif index == 6 && !options[:filename].nil? && options[:pagecount].nil? && !options[:showtsid].nil?
|
132
|
+
individual_fax[:tsid] = item
|
133
|
+
elsif index == 6 && options[:filename].nil? && !options[:pagecount].nil? && !options[:showtsid].nil?
|
98
134
|
individual_fax[:tsid] = item
|
99
|
-
|
135
|
+
elsif index == 7 && !options[:filename].nil? && !options[:pagecount].nil? && !options[:showtsid].nil?
|
100
136
|
individual_fax[:tsid] = item
|
101
137
|
end
|
102
138
|
end
|
data/lib/faxage/version.rb
CHANGED