faxage 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +21 -0
- data/README.md +120 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/faxage.gemspec +30 -0
- data/lib/faxage.rb +3 -0
- data/lib/faxage/information_gathering.rb +308 -0
- data/lib/faxage/send_fax.rb +60 -0
- data/lib/faxage/version.rb +3 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9bf0a54daaaf950f2b5ad56aeafc9e81b6097cdba4a76ca7db165b07ae91e40d
|
4
|
+
data.tar.gz: bb3ee8132869fbf8216e190c837390926ab87457418d69cb8051b43a4bde056f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ce41be4d2b5e2d70f32d511c4084e07b2ba5d8deeafb4ba65e6c5161a33c1bdb5d4c51876879c097ff913baaa3e2c8eea4f27cec3ba3c9edbb09d0f9496e0fd
|
7
|
+
data.tar.gz: 26bb746a3c90321dc3316c7eb51d6fb9b2a36d82ae1516210df56e55ca7dc95bb7614f0c434aaa906b20397cf12dde32c24c36438451fbb11b04eba945ebbb82
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at diasks2@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
faxage (0.1.0)
|
5
|
+
httparty
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
httparty (0.18.0)
|
12
|
+
mime-types (~> 3.0)
|
13
|
+
multi_xml (>= 0.5.2)
|
14
|
+
mime-types (3.3.1)
|
15
|
+
mime-types-data (~> 3.2015)
|
16
|
+
mime-types-data (3.2019.1009)
|
17
|
+
multi_xml (0.6.0)
|
18
|
+
rake (13.0.1)
|
19
|
+
rspec (3.9.0)
|
20
|
+
rspec-core (~> 3.9.0)
|
21
|
+
rspec-expectations (~> 3.9.0)
|
22
|
+
rspec-mocks (~> 3.9.0)
|
23
|
+
rspec-core (3.9.1)
|
24
|
+
rspec-support (~> 3.9.1)
|
25
|
+
rspec-expectations (3.9.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.9.0)
|
28
|
+
rspec-mocks (3.9.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-support (3.9.2)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (~> 1.17)
|
38
|
+
faxage!
|
39
|
+
rake (>= 12.3.3)
|
40
|
+
rspec (>= 3.4)
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
1.17.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Kevin Dias
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# Faxage
|
2
|
+
|
3
|
+
Faxage is a Ruby wrapper for the [faxage.com](https://www.faxage.com/internet-fax-api.php) API.
|
4
|
+
|
5
|
+
The Faxage API can be used to send and receive faxes, gather sent fax images and transmittal pages, provision DIDs, enable and disable (busy out) DIDs, access CDRs, get realtime status, can be polled or can push sent and received fax notifications, check local number portability, manage users, retrieve system audit logs and more.
|
6
|
+
|
7
|
+
The author of this gem is not affliated with Faxage. The Faxage API docs can be found [here](https://www.faxage.com/docdl.php?docid=6).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'faxage'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install faxage
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
#### Supported File Types
|
28
|
+
|
29
|
+
As of this writing, the following file types are supported for sending, others may become
|
30
|
+
available over time, so please check with us if the type of content you wish to send is not
|
31
|
+
listed here. An automatically updated list (based on what FAXAGE is configured to
|
32
|
+
support) is available at the following URL: http://www.faxage.com/learn_faxage_send_faxes_email_website_api.php
|
33
|
+
|
34
|
+
Click the link for ‘Q: What types of files can I send?’ on the above URL to get the list.
|
35
|
+
|
36
|
+
| Description | Extension(s) |
|
37
|
+
|--------------------------------------|--------------|
|
38
|
+
| Adobe PDF | PDF |
|
39
|
+
| Adobe PostScript | PS |
|
40
|
+
| Microsoft Word | DOC or DOCX |
|
41
|
+
| Microsoft Word Template | DOT |
|
42
|
+
| Microsoft Works | WPS |
|
43
|
+
| WordPerfect | WPD |
|
44
|
+
| OpenOffice / LibreOffice Document | ODT |
|
45
|
+
| Rich Text | RTF |
|
46
|
+
| Microsoft Excel | XLS or XLSX |
|
47
|
+
| Microsoft Powerpoint | PPT or PPTX |
|
48
|
+
| OpenOffice / LibreOffice Spreadsheet | ODS |
|
49
|
+
| Comma-separated CSV | CSV |
|
50
|
+
| HTML | HTM, HTML |
|
51
|
+
| Bitmap Image | BMP |
|
52
|
+
| GIF Image | GIF |
|
53
|
+
| JPEG Image | JPG, JPEG |
|
54
|
+
| TIFF Image | TIF, TIFF |
|
55
|
+
| PNG Image | PNG |
|
56
|
+
| HP Printer Control Language | PCL |
|
57
|
+
| Plain Text | TXT |
|
58
|
+
|
59
|
+
#### Sending a fax
|
60
|
+
```ruby
|
61
|
+
Faxage::SendFax.new(
|
62
|
+
username: # Assigned FAXAGE username
|
63
|
+
company: # Assigned FAXAGE company credential
|
64
|
+
password: # Assigned FAXAGE password
|
65
|
+
recipname: # Recipient Name – 32 characters max
|
66
|
+
faxno: # Fax Number – 10 digits, numeric only
|
67
|
+
faxfilenames: # Array of file names. These must end in a
|
68
|
+
# supported extension – see the table above for a list
|
69
|
+
faxfiledata: # Corresponding array of base64-encoded strings that are the
|
70
|
+
# contents/data of the file in faxfilenames. E.g.: if faxfilenames[0] is
|
71
|
+
# test.doc, then faxfiledata[0] should be the base64-encoded contents
|
72
|
+
# of test.doc
|
73
|
+
debug: # A debugging URL is also provided that is equivalent to
|
74
|
+
# the httpsfax.php URL, except that
|
75
|
+
# it also returns the contents of your POST:
|
76
|
+
# Note that the debugging URL is still live and identical to the
|
77
|
+
# regular/production URL.
|
78
|
+
# For example, if you send a fax using the sendfax operation with
|
79
|
+
# the debugging URL, the fax will still get sent as normal.
|
80
|
+
).send_fax()
|
81
|
+
```
|
82
|
+
#### Information Gathering Operations
|
83
|
+
|
84
|
+
These operations relate to gathering information that helps with managing and/or
|
85
|
+
monitoring your overall FAXAGE account.
|
86
|
+
|
87
|
+
##### handlecount
|
88
|
+
This operation allows you to see how many incoming faxes are stored within FAXAGE and, of those, how many you have marked as handled using the handled operation.
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
Faxage::InformationGathering.new(
|
92
|
+
username: # Assigned FAXAGE username
|
93
|
+
company: # Assigned FAXAGE company credential
|
94
|
+
password: # Assigned FAXAGE password
|
95
|
+
).handlecount
|
96
|
+
|
97
|
+
# Example response:
|
98
|
+
# {
|
99
|
+
# total_count: 10,
|
100
|
+
# handled_count: 5
|
101
|
+
# }
|
102
|
+
```
|
103
|
+
|
104
|
+
## Development
|
105
|
+
|
106
|
+
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.
|
107
|
+
|
108
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
109
|
+
|
110
|
+
## Contributing
|
111
|
+
|
112
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/diasks2/faxage. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
113
|
+
|
114
|
+
## License
|
115
|
+
|
116
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
117
|
+
|
118
|
+
## Code of Conduct
|
119
|
+
|
120
|
+
Everyone interacting in the Faxage project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/diasks2/faxage/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "faxage"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/faxage.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "faxage/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "faxage"
|
8
|
+
spec.version = Faxage::VERSION
|
9
|
+
spec.authors = ["Kevin Dias"]
|
10
|
+
spec.email = ["diasks2@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Faxage is a Ruby wrapper for the faxage.com API}
|
13
|
+
spec.description = %q{The Faxage API can be used to send and receive faxes, gather sent fax images and transmittal pages, provision DIDs, enable and disable (busy out) DIDs, access CDRs, get realtime status, can be polled or can push sent and received fax notifications, check local number portability, manage users, retrieve system audit logs and more.}
|
14
|
+
spec.homepage = "https://github.com/diasks2/faxage"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
27
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
28
|
+
spec.add_development_dependency "rspec", ">= 3.4"
|
29
|
+
spec.add_runtime_dependency "httparty"
|
30
|
+
end
|
data/lib/faxage.rb
ADDED
@@ -0,0 +1,308 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Faxage
|
4
|
+
class LoginError < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class FaxageInternalError < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
class UnknownOperationError < StandardError
|
11
|
+
end
|
12
|
+
|
13
|
+
class NoResponseError < StandardError
|
14
|
+
end
|
15
|
+
|
16
|
+
class InformationGathering
|
17
|
+
include HTTParty
|
18
|
+
base_uri "https://api.faxage.com"
|
19
|
+
|
20
|
+
attr_reader :username, # Assigned FAXAGE username
|
21
|
+
:company, # Assigned FAXAGE company credential
|
22
|
+
:password # Assigned FAXAGE password
|
23
|
+
def initialize(username:, company:, password:)
|
24
|
+
@username = username
|
25
|
+
@company = company
|
26
|
+
@password = password
|
27
|
+
end
|
28
|
+
|
29
|
+
def handlecount
|
30
|
+
# This operation allows you to see how many incoming faxes are stored within FAXAGE
|
31
|
+
# and, of those, how many you have marked as handled using the handled operation.
|
32
|
+
subdirectory = "/httpsfax.php"
|
33
|
+
|
34
|
+
body = {
|
35
|
+
operation: "handlecount",
|
36
|
+
username: username,
|
37
|
+
company: company,
|
38
|
+
password: password
|
39
|
+
}
|
40
|
+
|
41
|
+
response = self.class.post(subdirectory,
|
42
|
+
body: body
|
43
|
+
)
|
44
|
+
|
45
|
+
if response.parsed_response.nil?
|
46
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
47
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
48
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
49
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
50
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
51
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
52
|
+
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
53
|
+
else
|
54
|
+
parsed_response = response.parsed_response.gsub("\n", "").split("~")
|
55
|
+
data = {
|
56
|
+
total_count: parsed_response[0].to_i,
|
57
|
+
handled_count: parsed_response[1].to_i
|
58
|
+
}
|
59
|
+
return data
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def pendcount
|
64
|
+
# This operation allows you to see how many outgoing faxes are currently pending to be
|
65
|
+
# sent on your FAXAGE account.
|
66
|
+
|
67
|
+
subdirectory = "/httpsfax.php"
|
68
|
+
|
69
|
+
body = {
|
70
|
+
operation: "pendcount",
|
71
|
+
username: username,
|
72
|
+
company: company,
|
73
|
+
password: password
|
74
|
+
}
|
75
|
+
|
76
|
+
response = self.class.post(subdirectory,
|
77
|
+
body: body
|
78
|
+
)
|
79
|
+
|
80
|
+
if response.parsed_response.nil?
|
81
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
82
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
83
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
84
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
85
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
86
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
87
|
+
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
88
|
+
else
|
89
|
+
parsed_response = response.parsed_response.gsub("\n", "").to_i
|
90
|
+
data = {
|
91
|
+
pending_count: parsed_response
|
92
|
+
}
|
93
|
+
return data
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def qstatus
|
98
|
+
# This operation allows you to gather details about how your outgoing pending faxes are
|
99
|
+
# currently queued. When you have more than one line on your FAXAGE account, the
|
100
|
+
# system automatically load-levels outgoing faxes across however many lines you have.
|
101
|
+
# Using this operation, you can see all of your pending outgoing faxes and which line(s)
|
102
|
+
# they are queued on, in order to analyze how your outgoing traffic is being distributed for
|
103
|
+
# sending by FAXAGE.
|
104
|
+
subdirectory = "/httpsfax.php"
|
105
|
+
|
106
|
+
body = {
|
107
|
+
operation: "qstatus",
|
108
|
+
username: username,
|
109
|
+
company: company,
|
110
|
+
password: password
|
111
|
+
}
|
112
|
+
|
113
|
+
response = self.class.post(subdirectory,
|
114
|
+
body: body
|
115
|
+
)
|
116
|
+
|
117
|
+
if response.parsed_response.nil?
|
118
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
119
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
120
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
121
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
122
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
123
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
124
|
+
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
125
|
+
else
|
126
|
+
# TODO - parse response
|
127
|
+
|
128
|
+
# New-line separated records, as follows:
|
129
|
+
# <jobid><tab><callerID><tab><destination><tab><lineid
|
130
|
+
# ><tab><pagecount>
|
131
|
+
# See qstatus record definition below.
|
132
|
+
|
133
|
+
# CallerID – The caller ID you have requested when making the sendfax request, or your
|
134
|
+
# account’s default if you do not set separate caller ID’s for outgoing faxes
|
135
|
+
# Destination – The destination fax number for this outgoing fax
|
136
|
+
# LineID – Unique numeric ‘line’ ID. If you see more than one fax with the same LineID,
|
137
|
+
# that means FAXAGE has queued those faxes to the same line to be sent and one will
|
138
|
+
# have to wait for the other to finish before it will dial
|
139
|
+
# Pagecount – The number of pages associated with a given fax
|
140
|
+
return response.parsed_response
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def incomingcalls
|
145
|
+
# This operation allows you to see how many incoming calls are currently in progress to
|
146
|
+
# your account and how many maximum total simultaneous calls your account is currently
|
147
|
+
# configured to allow without sending a busy signal.
|
148
|
+
|
149
|
+
subdirectory = "/httpsfax.php"
|
150
|
+
|
151
|
+
body = {
|
152
|
+
operation: "incomingcalls",
|
153
|
+
username: username,
|
154
|
+
company: company,
|
155
|
+
password: password
|
156
|
+
}
|
157
|
+
|
158
|
+
response = self.class.post(subdirectory,
|
159
|
+
body: body
|
160
|
+
)
|
161
|
+
|
162
|
+
if response.parsed_response.nil?
|
163
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
164
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
165
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
166
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
167
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
168
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
169
|
+
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
170
|
+
else
|
171
|
+
parsed_response = response.parsed_response.gsub("\n", "").split("~")
|
172
|
+
data = {
|
173
|
+
incoming_count: parsed_response[0].to_i,
|
174
|
+
allocated_count: parsed_response[1].to_i
|
175
|
+
}
|
176
|
+
return data
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def busycalls
|
181
|
+
# This operation allows you to see incoming calls that have experienced a busy signal
|
182
|
+
# because more calls were in progress at the time the call came than your account was
|
183
|
+
# configured to support.
|
184
|
+
|
185
|
+
subdirectory = "/httpsfax.php"
|
186
|
+
|
187
|
+
body = {
|
188
|
+
operation: "busycalls",
|
189
|
+
username: username,
|
190
|
+
company: company,
|
191
|
+
password: password
|
192
|
+
}
|
193
|
+
|
194
|
+
response = self.class.post(subdirectory,
|
195
|
+
body: body
|
196
|
+
)
|
197
|
+
|
198
|
+
if response.parsed_response.nil?
|
199
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
200
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
201
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
202
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
203
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
204
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
205
|
+
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
206
|
+
else
|
207
|
+
# TODO - parse response
|
208
|
+
|
209
|
+
# New-line separated records, formatted as follows:
|
210
|
+
# <number-called><tab><number-calling><tab><time>
|
211
|
+
# Where:
|
212
|
+
# Number-called – Your number that was called
|
213
|
+
# Number-calling – The Caller ID for the caller
|
214
|
+
# Time – YYYY-MM-DD HH:MM:SS format
|
215
|
+
|
216
|
+
return response.parsed_response
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def portstatus
|
221
|
+
# This operation allows you to see the status of port requests you have in progress or that
|
222
|
+
# have been completed with FAXAGE.
|
223
|
+
|
224
|
+
subdirectory = "/httpsfax.php"
|
225
|
+
|
226
|
+
body = {
|
227
|
+
operation: "portstatus",
|
228
|
+
username: username,
|
229
|
+
company: company,
|
230
|
+
password: password
|
231
|
+
}
|
232
|
+
|
233
|
+
response = self.class.post(subdirectory,
|
234
|
+
body: body
|
235
|
+
)
|
236
|
+
|
237
|
+
if response.parsed_response.nil?
|
238
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
239
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
240
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
241
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
242
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
243
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
244
|
+
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
245
|
+
else
|
246
|
+
# TODO - parse response
|
247
|
+
|
248
|
+
# New-line separated records, formatted as follows:
|
249
|
+
# <number><tab><request-date><tab><duedate><tab><completedate><tab><status><tab><comment><tab><complete>
|
250
|
+
# Where:
|
251
|
+
# Number – The number you are porting
|
252
|
+
# Request-date – YYYY-MM-DD date of request
|
253
|
+
# Due-date – YYYY-MM-DD expected completion date
|
254
|
+
# Complete-date – YYYY-MM-DD date actually
|
255
|
+
# completed 0000-00-00 for requests in progress
|
256
|
+
# Status – One of ‘Initial’, ‘SOA PEND’, ‘Reject’,
|
257
|
+
# ‘Completed’ or ‘Canceled’. SOA PEND means the
|
258
|
+
# carrier has accepted for completion on the Due-date
|
259
|
+
# Comment – Free-form comment about the current
|
260
|
+
# status. FAXAGE staff enters these as ports are worked
|
261
|
+
# Complete – Yes or No
|
262
|
+
|
263
|
+
return response.parsed_response
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def auditlog(**options)
|
268
|
+
# This operation allows you to retrieve audit logs for your FAXAGE account. The
|
269
|
+
# FAXAGE auditing system is a comprehensive system that keeps a trail of all activities
|
270
|
+
# within your account. See the FAXAGE Internet Fax Auditing Documentation for details
|
271
|
+
# as to the structure of audit logs and what data is contained within each type of auditable
|
272
|
+
# operation.
|
273
|
+
|
274
|
+
subdirectory = "/httpsfax.php"
|
275
|
+
|
276
|
+
body = {
|
277
|
+
operation: "auditlog",
|
278
|
+
username: username,
|
279
|
+
company: company,
|
280
|
+
password: password
|
281
|
+
}.merge!(options)
|
282
|
+
|
283
|
+
response = self.class.post(subdirectory,
|
284
|
+
body: body
|
285
|
+
)
|
286
|
+
|
287
|
+
if response.parsed_response.nil?
|
288
|
+
raise NoResponseError.new("An empty response was returned from Faxage.")
|
289
|
+
elsif response.parsed_response.include?("ERR02: Login incorrect")
|
290
|
+
raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
|
291
|
+
elsif response.parsed_response.include?("ERR01: Database connection failed")
|
292
|
+
raise FaxageInternalError.new("Internal FAXAGE error.")
|
293
|
+
elsif response.parsed_response.include?("ERR08: Unknown operation")
|
294
|
+
raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
|
295
|
+
else
|
296
|
+
# TODO - parse response
|
297
|
+
|
298
|
+
# <audit-id><tab><timestamp><tab><login><tab><ipaddress><tab><interface><tab><web
|
299
|
+
# sessid><tab><auditop><tab><opstat><tab><requestdetail><tab><response-detail>
|
300
|
+
# Each of the above fields is defined in detail in the
|
301
|
+
# Internet Fax Auditing Documentation as previously
|
302
|
+
# noted
|
303
|
+
|
304
|
+
return response.parsed_response
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Faxage
|
4
|
+
class SendFax
|
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
|
+
:recipname, # Recipient Name – 32 characters max
|
12
|
+
:faxno, # Fax Number – 10 digits, numeric only
|
13
|
+
:faxfilenames, # Array of file names. These must end in a
|
14
|
+
# supported extension – see the table in the README for a list
|
15
|
+
:faxfiledata, # Corresponding array of base64-encoded strings that are the
|
16
|
+
# contents/data of the file in faxfilenames. E.g.: if faxfilenames[0] is
|
17
|
+
# test.doc, then faxfiledata[0] should be the base64-encoded contents
|
18
|
+
# of test.doc
|
19
|
+
:debug # A debugging URL is also provided that is equivalent to
|
20
|
+
# the httpsfax.php URL, except that
|
21
|
+
# it also returns the contents of your POST:
|
22
|
+
# Note that the debugging URL is still live and identical to the
|
23
|
+
# regular/production URL.
|
24
|
+
# For example, if you send a fax using the sendfax operation with
|
25
|
+
# the debugging URL, the fax will still get sent as normal.
|
26
|
+
def initialize(username:, company:, password:, recipname:, faxno:, faxfilenames:, faxfiledata:, debug:)
|
27
|
+
@username = username
|
28
|
+
@company = company
|
29
|
+
@password = password
|
30
|
+
@recipname = recipname
|
31
|
+
@faxno = faxno
|
32
|
+
@faxfilenames = faxfilenames
|
33
|
+
@faxfiledata = faxfiledata
|
34
|
+
@debug = debug
|
35
|
+
end
|
36
|
+
|
37
|
+
def send_fax(**options)
|
38
|
+
if debug
|
39
|
+
subdirectory = "/httpsfax-debug.php"
|
40
|
+
else
|
41
|
+
subdirectory = "/httpsfax.php"
|
42
|
+
end
|
43
|
+
|
44
|
+
body = {
|
45
|
+
operation: "sendfax",
|
46
|
+
username: username,
|
47
|
+
company: company,
|
48
|
+
password: password,
|
49
|
+
recipname: recipname,
|
50
|
+
faxno: faxno,
|
51
|
+
faxfilenames: faxfilenames,
|
52
|
+
faxfiledata: faxfiledata
|
53
|
+
}.merge!(options)
|
54
|
+
|
55
|
+
self.class.post(subdirectory,
|
56
|
+
body: body
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: faxage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Dias
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 12.3.3
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 12.3.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: The Faxage API can be used to send and receive faxes, gather sent fax
|
70
|
+
images and transmittal pages, provision DIDs, enable and disable (busy out) DIDs,
|
71
|
+
access CDRs, get realtime status, can be polled or can push sent and received fax
|
72
|
+
notifications, check local number portability, manage users, retrieve system audit
|
73
|
+
logs and more.
|
74
|
+
email:
|
75
|
+
- diasks2@gmail.com
|
76
|
+
executables: []
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- ".gitignore"
|
81
|
+
- ".rspec"
|
82
|
+
- ".travis.yml"
|
83
|
+
- CODE_OF_CONDUCT.md
|
84
|
+
- Gemfile
|
85
|
+
- Gemfile.lock
|
86
|
+
- LICENSE.txt
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- bin/console
|
90
|
+
- bin/setup
|
91
|
+
- faxage.gemspec
|
92
|
+
- lib/faxage.rb
|
93
|
+
- lib/faxage/information_gathering.rb
|
94
|
+
- lib/faxage/send_fax.rb
|
95
|
+
- lib/faxage/version.rb
|
96
|
+
homepage: https://github.com/diasks2/faxage
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.7.6
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Faxage is a Ruby wrapper for the faxage.com API
|
120
|
+
test_files: []
|