faxage 0.1.3 → 1.0.0
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 +121 -1
- data/faxage.gemspec +1 -0
- data/lib/faxage.rb +4 -0
- data/lib/faxage/information_gathering.rb +8 -7
- data/lib/faxage/receive_fax.rb +49 -0
- data/lib/faxage/send_fax.rb +13 -5
- data/lib/faxage/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ddc13458c6a5240635be1aa1f7c8e7aec3e794121f399fb7b985aa426c72c44
|
4
|
+
data.tar.gz: 226ad755e313625fa171771ea213e3d2a7b1333f702c01ff14763939274cebb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad8704196cd2d4f200d4258d21546436287057a5318164899e376b139bdd987c1bdbb1e8cbc792630683c2a4442483ae02ecbfdd3cae4f83f2de7be018792190
|
7
|
+
data.tar.gz: 233e11214f064bc0b6901a595af546462fc6b9d4c546caa080792c5b7007ce8c420c35531bf488cf9c3ff06805b6662153bf44889c05a8461bfe62107ae32b89
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -57,7 +57,13 @@ Click the link for ‘Q: What types of files can I send?’ on the above URL to
|
|
57
57
|
| Plain Text | TXT |
|
58
58
|
|
59
59
|
#### Sending a fax
|
60
|
+
|
61
|
+
##### sendfax
|
62
|
+
|
63
|
+
This operation is used to send a fax.
|
64
|
+
|
60
65
|
```ruby
|
66
|
+
|
61
67
|
Faxage::SendFax.new(
|
62
68
|
username: # Assigned FAXAGE username
|
63
69
|
company: # Assigned FAXAGE company credential
|
@@ -77,8 +83,45 @@ Faxage::SendFax.new(
|
|
77
83
|
# regular/production URL.
|
78
84
|
# For example, if you send a fax using the sendfax operation with
|
79
85
|
# the debugging URL, the fax will still get sent as normal.
|
80
|
-
).
|
86
|
+
).sendfax()
|
87
|
+
|
88
|
+
# Practical example of faxing a template from your Rails app:
|
89
|
+
# html = ActionController::Base.new().render_to_string(template: 'path-to-your-template')
|
90
|
+
# encoded_file_data = Base64.encode64(html)
|
91
|
+
|
92
|
+
Faxage::SendFax.new(
|
93
|
+
username: "your-username", # string
|
94
|
+
company: "your-faxage-company-id", # string
|
95
|
+
password: "your-faxage-password", # string
|
96
|
+
recipname: "ABC company", #string
|
97
|
+
faxno: "5555555555", # string (no hyphens, parenthesis, or spaces)
|
98
|
+
faxfilenames: ['my-file.html'],
|
99
|
+
faxfiledata: [encoded_file_data],
|
100
|
+
debug: false
|
101
|
+
).sendfax()
|
102
|
+
|
103
|
+
# Expected response:
|
104
|
+
|
105
|
+
# {
|
106
|
+
# job_id: 543211
|
107
|
+
# }
|
108
|
+
|
109
|
+
|
110
|
+
```
|
111
|
+
|
112
|
+
#### Receiving a fax
|
113
|
+
|
114
|
+
##### listfax
|
115
|
+
This operation is used to gather a list of incoming faxes for your account.
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
Faxage::ReceiveFax.new(
|
119
|
+
username: # Assigned FAXAGE username
|
120
|
+
company: # Assigned FAXAGE company credential
|
121
|
+
password: # Assigned FAXAGE password
|
122
|
+
).listfax()
|
81
123
|
```
|
124
|
+
|
82
125
|
#### Information Gathering Operations
|
83
126
|
|
84
127
|
These operations relate to gathering information that helps with managing and/or
|
@@ -101,6 +144,83 @@ Faxage::InformationGathering.new(
|
|
101
144
|
# }
|
102
145
|
```
|
103
146
|
|
147
|
+
##### pendcount
|
148
|
+
This operation allows you to see how many outgoing faxes are currently pending to be sent on your FAXAGE account.
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
Faxage::InformationGathering.new(
|
152
|
+
username: # Assigned FAXAGE username
|
153
|
+
company: # Assigned FAXAGE company credential
|
154
|
+
password: # Assigned FAXAGE password
|
155
|
+
).pendcount
|
156
|
+
|
157
|
+
# Example response:
|
158
|
+
# {
|
159
|
+
# pending_count: 10
|
160
|
+
# }
|
161
|
+
```
|
162
|
+
|
163
|
+
##### qstatus
|
164
|
+
This operation allows you to gather details about how your outgoing pending faxes are currently queued. When you have more than one line on your FAXAGE account, the system automatically load-levels outgoing faxes across however many lines you have. Using this operation, you can see all of your pending outgoing faxes and which line(s) they are queued on, in order to analyze how your outgoing traffic is being distributed for sending by FAXAGE.
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
Faxage::InformationGathering.new(
|
168
|
+
username: # Assigned FAXAGE username
|
169
|
+
company: # Assigned FAXAGE company credential
|
170
|
+
password: # Assigned FAXAGE password
|
171
|
+
).qstatus
|
172
|
+
```
|
173
|
+
|
174
|
+
##### incomingcalls
|
175
|
+
This operation allows you to see how many incoming calls are currently in progress to your account and how many maximum total simultaneous calls your account is currently configured to allow without sending a busy signal.
|
176
|
+
|
177
|
+
```ruby
|
178
|
+
Faxage::InformationGathering.new(
|
179
|
+
username: # Assigned FAXAGE username
|
180
|
+
company: # Assigned FAXAGE company credential
|
181
|
+
password: # Assigned FAXAGE password
|
182
|
+
).incomingcalls
|
183
|
+
|
184
|
+
# Example response:
|
185
|
+
# {
|
186
|
+
# incoming_count: 0,
|
187
|
+
# allocated_count: 1
|
188
|
+
# }
|
189
|
+
```
|
190
|
+
|
191
|
+
##### busycalls
|
192
|
+
This operation allows you to see incoming calls that have experienced a busy signal because more calls were in progress at the time the call came than your account was configured to support.
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
Faxage::InformationGathering.new(
|
196
|
+
username: # Assigned FAXAGE username
|
197
|
+
company: # Assigned FAXAGE company credential
|
198
|
+
password: # Assigned FAXAGE password
|
199
|
+
).busycalls
|
200
|
+
```
|
201
|
+
|
202
|
+
##### portstatus
|
203
|
+
This operation allows you to see the status of port requests you have in progress or that have been completed with FAXAGE.
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
Faxage::InformationGathering.new(
|
207
|
+
username: # Assigned FAXAGE username
|
208
|
+
company: # Assigned FAXAGE company credential
|
209
|
+
password: # Assigned FAXAGE password
|
210
|
+
).portstatus
|
211
|
+
```
|
212
|
+
|
213
|
+
##### auditlog
|
214
|
+
This operation allows you to retrieve audit logs for your FAXAGE account. The FAXAGE auditing system is a comprehensive system that keeps a trail of all activities within your account. See the FAXAGE Internet Fax Auditing Documentation for details as to the structure of audit logs and what data is contained within each type of auditable operation.
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
Faxage::InformationGathering.new(
|
218
|
+
username: # Assigned FAXAGE username
|
219
|
+
company: # Assigned FAXAGE company credential
|
220
|
+
password: # Assigned FAXAGE password
|
221
|
+
).auditlog
|
222
|
+
```
|
223
|
+
|
104
224
|
## Development
|
105
225
|
|
106
226
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/faxage.gemspec
CHANGED
data/lib/faxage.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "faxage/version"
|
2
2
|
require "faxage/send_fax"
|
3
|
+
require "faxage/receive_fax"
|
3
4
|
require "faxage/information_gathering"
|
4
5
|
|
5
6
|
class LoginError < StandardError
|
@@ -24,4 +25,7 @@ class NoFilesError < StandardError
|
|
24
25
|
end
|
25
26
|
|
26
27
|
class BlockedNumberError < StandardError
|
28
|
+
end
|
29
|
+
|
30
|
+
class NoIncomingFaxesError < StandardError
|
27
31
|
end
|
@@ -8,6 +8,7 @@ module Faxage
|
|
8
8
|
attr_reader :username, # Assigned FAXAGE username
|
9
9
|
:company, # Assigned FAXAGE company credential
|
10
10
|
:password # Assigned FAXAGE password
|
11
|
+
|
11
12
|
def initialize(username:, company:, password:)
|
12
13
|
@username = username
|
13
14
|
@company = company
|
@@ -37,7 +38,7 @@ module Faxage
|
|
37
38
|
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
38
39
|
raise FaxageInternalError.new("Internal FAXAGE error.")
|
39
40
|
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
40
|
-
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
41
|
+
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}")
|
41
42
|
else
|
42
43
|
parsed_response = response.parsed_response.gsub("\n", "").split("~")
|
43
44
|
data = {
|
@@ -72,7 +73,7 @@ module Faxage
|
|
72
73
|
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
73
74
|
raise FaxageInternalError.new("Internal FAXAGE error.")
|
74
75
|
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
75
|
-
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
76
|
+
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}")
|
76
77
|
else
|
77
78
|
parsed_response = response.parsed_response.gsub("\n", "").to_i
|
78
79
|
data = {
|
@@ -109,7 +110,7 @@ module Faxage
|
|
109
110
|
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
110
111
|
raise FaxageInternalError.new("Internal FAXAGE error.")
|
111
112
|
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
112
|
-
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
113
|
+
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}")
|
113
114
|
else
|
114
115
|
# TODO - parse response
|
115
116
|
|
@@ -154,7 +155,7 @@ module Faxage
|
|
154
155
|
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
155
156
|
raise FaxageInternalError.new("Internal FAXAGE error.")
|
156
157
|
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
157
|
-
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
158
|
+
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}")
|
158
159
|
else
|
159
160
|
parsed_response = response.parsed_response.gsub("\n", "").split("~")
|
160
161
|
data = {
|
@@ -190,7 +191,7 @@ module Faxage
|
|
190
191
|
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
191
192
|
raise FaxageInternalError.new("Internal FAXAGE error.")
|
192
193
|
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
193
|
-
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
194
|
+
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}")
|
194
195
|
else
|
195
196
|
# TODO - parse response
|
196
197
|
|
@@ -229,7 +230,7 @@ module Faxage
|
|
229
230
|
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
230
231
|
raise FaxageInternalError.new("Internal FAXAGE error.")
|
231
232
|
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
232
|
-
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
233
|
+
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}")
|
233
234
|
else
|
234
235
|
# TODO - parse response
|
235
236
|
|
@@ -279,7 +280,7 @@ module Faxage
|
|
279
280
|
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
280
281
|
raise FaxageInternalError.new("Internal FAXAGE error.")
|
281
282
|
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
282
|
-
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
283
|
+
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}")
|
283
284
|
else
|
284
285
|
# TODO - parse response
|
285
286
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Faxage
|
4
|
+
class ReceiveFax
|
5
|
+
include HTTParty
|
6
|
+
base_uri "https://api.faxage.com"
|
7
|
+
|
8
|
+
attr_reader :username, # Assigned FAXAGE username
|
9
|
+
:company, # Assigned FAXAGE company credential
|
10
|
+
:password, # Assigned FAXAGE password
|
11
|
+
|
12
|
+
def initialize(username:, company:, password:)
|
13
|
+
@username = username
|
14
|
+
@company = company
|
15
|
+
@password = password
|
16
|
+
end
|
17
|
+
|
18
|
+
def listfax(**options)
|
19
|
+
# This operation is used to gather a list of incoming faxes for your account.
|
20
|
+
|
21
|
+
subdirectory = "/httpsfax.php"
|
22
|
+
|
23
|
+
body = {
|
24
|
+
operation: "listfax",
|
25
|
+
username: username,
|
26
|
+
company: company,
|
27
|
+
password: password
|
28
|
+
}.merge!(options)
|
29
|
+
|
30
|
+
response = self.class.post(subdirectory,
|
31
|
+
body: body
|
32
|
+
)
|
33
|
+
|
34
|
+
if response.parsed_response.nil?
|
35
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
36
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
37
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
38
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
39
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
40
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
41
|
+
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}")
|
42
|
+
elsif response.parsed_response.include?("ERR11: No incoming faxes available")
|
43
|
+
raise NoIncomingFaxesError.new("There are no incoming faxes to list for you.")
|
44
|
+
else
|
45
|
+
return response.parsed_response
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/faxage/send_fax.rb
CHANGED
@@ -35,7 +35,7 @@ module Faxage
|
|
35
35
|
@debug = debug
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def sendfax(**options)
|
39
39
|
if debug
|
40
40
|
subdirectory = "/httpsfax-debug.php"
|
41
41
|
else
|
@@ -70,14 +70,22 @@ module Faxage
|
|
70
70
|
elsif response.parsed_response.include?("ERR05")
|
71
71
|
raise BlockedNumberError.new("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).")
|
72
72
|
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
73
|
-
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
73
|
+
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}")
|
74
74
|
elsif response.parsed_response.include?("ERR15: Invalid Job ID")
|
75
75
|
raise InvalidJobIdError.new("Internal FAXAGE error – the job was not properly inserted into our database.")
|
76
76
|
else
|
77
|
+
debug_output = response.parsed_response
|
77
78
|
job_id = response.parsed_response.scan(JOB_ID_REGEX)[0].strip.to_i
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
if debug
|
80
|
+
data = {
|
81
|
+
job_id: job_id,
|
82
|
+
debug: debug_output
|
83
|
+
}
|
84
|
+
else
|
85
|
+
data = {
|
86
|
+
job_id: job_id
|
87
|
+
}
|
88
|
+
end
|
81
89
|
return data
|
82
90
|
end
|
83
91
|
end
|
data/lib/faxage/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faxage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Dias
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- faxage.gemspec
|
92
92
|
- lib/faxage.rb
|
93
93
|
- lib/faxage/information_gathering.rb
|
94
|
+
- lib/faxage/receive_fax.rb
|
94
95
|
- lib/faxage/send_fax.rb
|
95
96
|
- lib/faxage/version.rb
|
96
97
|
homepage: https://github.com/diasks2/faxage
|