srfax 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 923cf0d5cd313366bbbafaa0aabcc7efd4106b27
4
+ data.tar.gz: d3b8c94e74e0428b8eeef199c3befe2a310bee2e
5
+ SHA512:
6
+ metadata.gz: e9c12fb72f4f99b467915269bdfbc59880c391d8a86a2f564e2cff5d79082b691277aaf0f02708d700ae5c37fff12b92b840ce8765ad2760953318b4d9a1473d
7
+ data.tar.gz: bdb9233921b832aa404d878232a882a25c062e27ab109fd24f1e44bdde624c03fcc4e29ff905a2a7a0be5edac1f2ae09a72aaee14b3c0cc962227d2fc52a0b8c
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ gemfiles/*.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in srfax.gemspec.
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Sean Esson
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.
@@ -0,0 +1,69 @@
1
+ Srfax
2
+
3
+ This is the 'unofficial' SRFax (http://www.srfax.com) API wrapper for ruby. The API documentation for SRFax can be found at https://www.srfax.com/srf/media/SRFax-REST-API-Documentation.pdf
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sr_fax'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself using:
18
+
19
+ $ gem install sr_fax
20
+
21
+ ## Usage
22
+
23
+ To get started, simply open the console view and require the SrFax module. Once you have completed that, enter your account credentials using the SrFax setup block, and then begin to execute calls. All status' returned are simply formatted hashes from the SrFax service.
24
+
25
+ ```ruby
26
+
27
+ require 'srfax'
28
+
29
+ SrFax.setup do |config|
30
+ config.defaults[:access_id] = '1234'
31
+ config.defaults[:access_pwd] = 'password'
32
+ config.connection_defaults[:timeout] = 180
33
+ end
34
+
35
+ SrFax.view_inbox
36
+ SrFax.view_outbox
37
+ SrFax.update_fax_status(descriptor, direction)
38
+ SrFax.get_fax(descriptor, direction, {:sMarkasViewed => 'Y'}
39
+ ```
40
+
41
+ As an example, here is a sample queue fax call to send a fax
42
+
43
+ ```ruby
44
+ SrFax.queue_fax "yourname@yourdomain.com", "SINGLE", "18888888888", {sFileName_1: "file1.txt", sFileContent_1: Base64.encode64("Sample Fax")}
45
+ ```
46
+
47
+ The SrFax module currently supports the following functions
48
+ - Sending and receiving faxes
49
+ - Updating flags on the inbox or outbox faxes
50
+ - Deleting faxes from either the inbox or outbox
51
+ - View account usage
52
+ - Download faxes from the inbox or outbox
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/console` for an interactive prompt that will allow you to experiment.
57
+
58
+ 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( https://github.com/TechCanuck/srfax/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create a new Pull Request
67
+
68
+ Licensing: **MIT**
69
+ Remember: **'Great opportunities to help others seldom come, but small ones surround us daily' -- Sally Koch**
@@ -0,0 +1,31 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
+ require 'srfax/version'
5
+
6
+ begin
7
+ Bundler.setup(:default, :development)
8
+ rescue Bundler::BundlerError => e
9
+ $stderr.puts e.message
10
+ $stderr.puts "Run `bundle install` to install missing gems"
11
+ exit e.status_code
12
+ end
13
+ require 'rake'
14
+
15
+ require 'rake/testtask'
16
+ Rake::TestTask.new(:test) do |test|
17
+ test.libs << 'lib' << 'test'
18
+ test.test_files = Dir.glob("test/**/*_test.rb")
19
+ test.verbose = true
20
+ end
21
+
22
+ task :build do
23
+ system "gem build srfax.gemspec"
24
+ end
25
+
26
+ task :release => :build do
27
+ system "gem push srfax-#{SrFax::VERSION}.gem"
28
+ system "rm srfax-#{SrFax::VERSION}.gem"
29
+ end
30
+
31
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'srfax'
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,326 @@
1
+ require 'restclient'
2
+ require 'active_support'
3
+ require 'active_support/core_ext/hash'
4
+ require 'json'
5
+ require 'srfax/version'
6
+
7
+ # This class serves as the integration component between the application and the SRFax cloud service.
8
+ # API DOX available @ https://www.srfax.com/srf/media/SRFax-REST-API-Documentation.pdf.
9
+ #
10
+ # This module currently Implements the following POST commands from the API:
11
+ # Get_Usage – Retrieves the account usage.
12
+ # Update_Viewed_Status – Mark a inbound or outbound fax as read or unread.
13
+ # Queue_Fax - Schedules a fax to be sent with or without cover page.
14
+ # Get_Fax_Inbox - Returns a list of faxes received for a specified period of time.
15
+ # Get_Fax_Outbox - Returns a list of faxes sent for a specified period of time.
16
+ # Retrieve_Fax – Returns a specified sent or received fax file in PDF or TIFF format.
17
+ # Delete_Fax - Deletes specified received or sent faxes.
18
+ # Get_FaxStatus – Determines the status of a fax that has been scheduled for delivery.
19
+ # Get_MultiFaxStatus – Determines the status of a multiple faxes that have been
20
+ # scheduled for delivery.
21
+ # Stop_Fax - Removes a scheduled fax from the queue.
22
+ # Unimplemented methods:
23
+ # Delete_Pending_Fax - THIS DOESN'T EXIST - but is documented to exist.
24
+ module SrFax
25
+ # Base URL for accessing SRFax API
26
+ BASE_URL = 'https://www.srfax.com/SRF_SecWebSvc.php'.freeze
27
+
28
+ mattr_accessor :defaults
29
+ # Default values hash to use with all #execute commands
30
+ @@defaults = {
31
+ access_id: '1234',
32
+ access_pwd: 'password',
33
+ sFaxFormat: 'PDF', # Default format, PDF or TIF
34
+ sCallerID: '5555555555', # MUST be 10 digits
35
+ sResponseFormat: 'JSON' # XML or JSON
36
+ }
37
+
38
+ mattr_accessor :connection_defaults
39
+ # Default values to use with the RestClient connection
40
+ @@connection_defaults = {
41
+ timeout: 180
42
+ }
43
+
44
+ mattr_accessor :logger
45
+ # Logger object for use in standalone mode or with Rails
46
+ if defined?(Rails)
47
+ @@logger = Rails.logger
48
+ else
49
+ @@logger = Logger.new(STDOUT)
50
+ @@logger.level = Logger::INFO
51
+ end
52
+
53
+ class << self
54
+ # Allow configuring Srfax with a block, these will be the methods default values for passing to
55
+ # each function and will be overridden by any methods locally posted variables (ex: :action)
56
+ #
57
+ # @yield Accepts a block of valid configuration options to set or override default values
58
+ #
59
+ # Example:
60
+ # Srfax.setup do |config|
61
+ # config.defaults[:access_id] = '1234'
62
+ # config.defaults[:access_pwd] = 'password'
63
+ # config.defaults[:sCallerID] = '5555555555'
64
+ # end
65
+ def setup
66
+ yield self
67
+ end
68
+
69
+ # Views the remote inbox. By default this call does NOT update the viewed
70
+ # or read status of the fax unless specified in options.
71
+ #
72
+ # @param status [String] Specify the status of the message you are listing (UNREAD, ALL, READ)
73
+ # @param options [Hash] An optional hash paramter to ovveride any default values (ie., Account ID)
74
+ # @option options [String] :sPeriod Specify the period to query. Accepts 'ALL' or 'RANGE'
75
+ # @option options [String] :sStatDate Used with :sPeriod and denotes the period to start at. Format is 'YYYYMMDD'
76
+ # @option options [String] :sEndDate Used with :sPeriod and denotes the period to endd at. Format is 'YYYYMMDD'
77
+ # @option options [String] :sIncludeSubUsers Include subuser accounts ('Y' or 'N')
78
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
79
+ #
80
+ # Example Payload for Return:
81
+ # {"Status"=>"Success", "Result"=>[{"FileName"=>"20150430124505-6104-19_1|20360095", "ReceiveStatus"=>"Ok",
82
+ # "Date"=>"Apr 30/15 02:45 PM", "EpochTime"=>1430423105, "CallerID"=>"5555555555", "RemoteID"=>"", "Pages"=>"1",
83
+ # "Size"=>"5000", "ViewedStatus"=>"N"} ]}
84
+ def view_inbox(status = 'UNREAD', options = {})
85
+ logger.debug 'Checking fax inbox from cloud service'
86
+ postVariables = {
87
+ action: 'Get_Fax_Inbox',
88
+ sViewedStatus: status.upcase
89
+ }.merge!(options)
90
+ res = execute(postVariables)
91
+
92
+ if res[:Status] != 'Failure'
93
+ faxcount = res['Result'].count
94
+ faxcount > 0 ? logger.debug("Found #{faxcount} new fax(es)") : logger.debug('No faxes found matching that criteria')
95
+ end
96
+
97
+ res
98
+ end
99
+
100
+ # Uses post Get_Usage to fetch the current account usage statistics (for all associated accounts)
101
+ #
102
+ # @param options [Hash] An optional hash paramter to ovveride any default values (ie., Account ID)
103
+ # @option options [String] :sPeriod Specify the period to query. Accepts 'ALL' or 'RANGE'
104
+ # @option options [String] :sStatDate Used with :sPeriod and denotes the period to start at. Format is 'YYYYMMDD'
105
+ # @option options [String] :sEndDate Used with :sPeriod and denotes the period to endd at. Format is 'YYYYMMDD'
106
+ # @option options [String] :sIncludeSubUsers Include subuser accounts ('Y' or 'N')
107
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
108
+ #
109
+ # Example Payload for Return:
110
+ # {"Status"=>"Success", "Result"=>[{"UserID"=>1234, "Period"=>"ALL",
111
+ # "ClientName"=>nil, "SubUserID"=>0, "BillingNumber"=>"8888888888", "NumberOfFaxes"=>5, "NumberOfPages"=>8}]}
112
+ def view_usage(_options = {})
113
+ logger.debug 'Viewing fax usage from cloud service'
114
+ postVariables = { action: 'Get_Fax_Usage' }
115
+ res = execute(postVariables)
116
+ res
117
+ end
118
+
119
+ # Uses post Get_Fax_Outbox to retrieve the usage for the account (and all subaccounts)
120
+ #
121
+ # @param options [Hash] An optional hash paramter to ovveride any default values (ie., Account ID)
122
+ # @option options [String] :sPeriod Specify the period to query. Accepts 'ALL' or 'RANGE'
123
+ # @option options [String] :sStatDate Used with :sPeriod and denotes the period to start at. Format is 'YYYYMMDD'
124
+ # @option options [String] :sEndDate Used with :sPeriod and denotes the period to endd at. Format is 'YYYYMMDD'
125
+ # @option options [String] :sIncludeSubUsers Include subuser accounts ('Y' or 'N')
126
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
127
+ def view_outbox(_options = {})
128
+ logger.debug 'Viewing fax outbox from cloud service'
129
+ postVariables = { action: 'Get_Fax_Outbox' }
130
+ res = execute(postVariables)
131
+
132
+ if res[:Status] != 'Failure'
133
+ faxcount = res['Result'].count
134
+ faxcount > 0 ? logger.debug("Found #{faxcount} new fax(es)") : logger.debug('No faxes found matching that criteria')
135
+ end
136
+
137
+ res
138
+ end
139
+
140
+ # Uses POST Retrieve_Fax to retrieve a specified fax from the server. Returns it in the default
141
+ # specified format (PDF or TIFF)
142
+ #
143
+ # @param descriptor [String] Specify the status of the message you are listing (UNREAD, ALL, READ)
144
+ # @param direction [String] Either 'IN' or 'OUT' to specify the inbox or outbox
145
+ # @param options [Hash] An optional hash paramter to ovveride any default values (ie., Account ID)
146
+ # @option options [String] :sMarkasViewed Update the fax status to viewed (or unviewed). Accepts 'Y' or 'N'
147
+ # @option options [String] :sFaxFormat Update the format to retrieve the file in ('PDF' or 'TIFF')
148
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
149
+ def get_fax(descriptor, direction, options = {})
150
+ logger.debug "Retrieving fax from cloud service in the direction of '#{direction}', Descriptor: '#{descriptor}'"
151
+ faxname, faxid = descriptor.split('|')
152
+ if faxname.nil? || faxid.nil?
153
+ logger.debug "Valid descriptor not provided to get_fax function call. Descriptor: '#{descriptor}'"
154
+ return nil
155
+ end
156
+
157
+ logger.debug 'Retrieving fax from cloud service'
158
+ postVariables = {
159
+ action: 'Retrieve_Fax',
160
+ sFaxFileName: descriptor,
161
+ sFaxDetailsID: faxid,
162
+ sDirection: direction.upcase,
163
+ sMarkasViewed: 'N'
164
+ }.merge!(options)
165
+ res = execute(postVariables)
166
+ res
167
+ end
168
+
169
+ # Update the status (read/unread) for a particular fax
170
+ #
171
+ # @param descriptor [String] Specify the status of the message you are listing (UNREAD, ALL, READ)
172
+ # @param direction [String] Either 'IN' or 'OUT' to specify the inbox or outbox
173
+ # @param options [Hash] An optional hash paramter to ovveride any default values (ie., Account ID)
174
+ # @option options [String] :sMarkasViewed Update the fax status to viewed (or unviewed). Accepts 'Y' or 'N'. Defaults to Y
175
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
176
+ def update_fax_status(descriptor, direction, options = {})
177
+ logger.debug "Updating a fax in the cloud service in the direction of '#{direction}', Descriptor: '#{descriptor}'"
178
+ faxname, faxid = descriptor.split('|')
179
+ if faxname.nil? || faxid.nil?
180
+ logger.debug "Valid descriptor not provided to get_fax function call. Descriptor: '#{descriptor}'"
181
+ return nil
182
+ end
183
+
184
+ postVariables = {
185
+ action: 'Update_Viewed_Status',
186
+ sFaxFileName: descriptor,
187
+ sFaxDetailsID: faxid,
188
+ sDirection: direction.upcase,
189
+ sMarkasViewed: 'Y'
190
+ }.merge!(options)
191
+ res = execute(postVariables)
192
+ res
193
+ end
194
+
195
+ # Schedules a fax to be sent with or without cover page
196
+ #
197
+ # @param faxids [String, Array] Get the state of 'id' as given by the #queue_fax call
198
+ # @param options [Hash] An optional hash paramter to ovveride any default values (ie., Account ID)
199
+ # @option options [String] :sResponseFormat The output response format for
200
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
201
+ def get_fax_status(faxids, options = {})
202
+ logger.debug "Gathering fax status information for id(s): '#{faxids}'"
203
+
204
+ if faxids.is_a? String
205
+ action = 'Get_FaxStatus'
206
+ elsif faxids.is_a? Array
207
+ action = 'Get_MultiFaxStatus'
208
+ faxids = faxids.join('|')
209
+ else
210
+ logger.warn "Error wth fax ids parameter id(s): '#{faxid}'"
211
+ return { Status: 'Failure' }
212
+ end
213
+
214
+ postVariables = {
215
+ action: action,
216
+ sFaxDetailsID: faxids
217
+ }.merge!(options)
218
+ res = execute(postVariables)
219
+ res
220
+ end
221
+
222
+ # Determines the state of a fax that has been scheduled for delivery. Use queue fax to schedule a fax
223
+ # for delivery. Note: no validation is done on the fields prior to sending.
224
+ #
225
+ # @param senderEmail [String] Email address of the sender
226
+ # @param receiverNumber [String, Array] Single 11 digit fax number or up to 50 x 11 fax numbers
227
+ # @param faxType [String] 'SINGLE' or 'BROADCAST'
228
+ # @param options [Hash] An optional hash paramter to ovveride any default values (ie., Account ID)
229
+ # @option options [String] :sResponseFormat The output response format for
230
+ # @option options [String] :sAccountCode Internal reference number (Max of 20 Characters)
231
+ # @option options [String] :sRetries Number of times the system is to retry a number if busy or an error is encountered – number from 0 to 6.
232
+ # @option options [String] :sCoverPage If you want to use one of the cover pages on file, specify the cover page you wish to use “Basic”, “Standard” , “Company” or “Personal”. If a cover page is not provided then all cover page variable will be ignored. NOTE: If the default cover page on the account is set to “Attachments ONLY” the cover page will NOT be created irrespective of this variable.
233
+ # @option options [String] :sFaxFromHeader From: On the Fax Header Line (max 30 Char)
234
+ # @option options [String] :sCPFromName Sender’s name on the Cover Page
235
+ # @option options [String] :sCPToName Recipient’s name on the Cover Page
236
+ # @option options [String] :sCPOrganization Organization on the Cover Page
237
+ # @option options [String] :sCPSubject Subject line on the Cover Page**
238
+ # @option options [String] :sCPComments Comments placed in the body of the Cover Page
239
+ # @option options [String] :sFileName_x (See supported file types @ https://www.srfax.com/faqs)
240
+ # @option options [String] :sFileContent_x Base64 encoding of file contents.
241
+ # @option options [String] :sNotifyURL Provide an absolute URL (beginning with http:// or https://) and the SRFax system will POST back the fax status record when the fax completes. See the ‘NOTIFY URL POST’ section below for details of what is posted.
242
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
243
+ #
244
+ # Example code (this will send a fax with 'Sample Fax' as the fileContent field):
245
+ # SrFax.queue_fax "yourname@yourdomain.com", "18888888888", "SINGLE", {sFileName_1: "file1.txt", sFileContent_1: Base64.encode64("Sample Fax")}
246
+ def queue_fax(senderEmail, receiverNumber, faxType, options = {})
247
+ logger.debug 'Attempting to queue fax'
248
+ receiverNumber = receiverNumber.join('|') if receiverNumber.is_a? Array
249
+
250
+ postVariables = {
251
+ action: 'Queue_Fax',
252
+ sSenderEmail: senderEmail,
253
+ sFaxType: faxType,
254
+ sToFaxNumber: receiverNumber
255
+ }.merge!(options)
256
+ res = execute(postVariables)
257
+ res
258
+ end
259
+
260
+ # Attempt to stop a fax from being delivered. See the result payload for possible conditions in fax status
261
+ #
262
+ # @param faxid [String] Stop fax with 'id' as given by the #queue_fax call.
263
+ # @param options [Hash] An optional hash paramter to ovveride any default values (ie., Account ID).
264
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
265
+ def stop_fax(faxid, options = {})
266
+ logger.debug "Sending stop fax command for id: '#{faxid}'"
267
+
268
+ postVariables = {
269
+ action: 'Stop_Fax',
270
+ sFaxDetailsID: faxid
271
+ }.merge!(options)
272
+ res = execute(postVariables)
273
+ res
274
+ end
275
+
276
+ # Delete a particular fax from the SRFax cloud service
277
+ #
278
+ # @param descriptor [String] THe descriptor provided by SRFax which identifies a unique fax
279
+ # @param direction [String] Either 'IN' or 'OUT' to specify the inbox or outbox
280
+ # @return [Hash] A hash containing the return value (Success/Failure) and the payload where applicable
281
+ #
282
+ # Example Payload for Return:
283
+ # {"Status"=>"Success", "Result"=>[{"FileName"=>"20150430124505-6104-19_1|20360095", "ReceiveStatus"=>"Ok",
284
+ # "Date"=>"Apr 30/15 02:45 PM", "EpochTime"=>1430423105, "CallerID"=>"5555555555", "RemoteID"=>"", "Pages"=>"1",
285
+ # "Size"=>"5000", "ViewedStatus"=>"N"} ]}
286
+ def delete_fax(descriptor, direction)
287
+ logger.debug "Deleting a fax in the cloud service in the direction of '#{direction}', Descriptor: '#{descriptor}'"
288
+ faxname, faxid = descriptor.split('|')
289
+ if faxname.nil? || faxid.nil?
290
+ logger.debug "Valid descriptor not provided to get_fax function call. Descriptor: '#{descriptor}'"
291
+ return nil
292
+ end
293
+
294
+ postVariables = {
295
+ action: 'Delete_Fax',
296
+ sFaxFileName_x: descriptor,
297
+ sFaxDetailsID_x: faxid,
298
+ sDirection: direction.upcase
299
+ }
300
+ res = execute(postVariables)
301
+ res
302
+ end
303
+
304
+ private
305
+
306
+ # Actually execute the RESTful post command to the #BASE_URL
307
+ #
308
+ # @param postVariables [String] The list of variables to apply in the POST body when executing the request.
309
+ # @return [Hash] The hash payload value including a proper status. Will never return nil.
310
+ def execute(postVariables)
311
+ logger.debug postVariables.merge(defaults)
312
+ # Redirect where necessary.
313
+ res = RestClient.post(BASE_URL, postVariables.merge(defaults), { accept: :json })
314
+ unless res.code == 200
315
+ return { 'Status' => 'Failed', 'Result' => res.body }.with_indifferent_access
316
+ end
317
+
318
+ return_data = JSON.parse(res.body).with_indifferent_access
319
+
320
+ if return_data['Status'] == 'Failed'
321
+ logger.debug 'Execution of SR Fax command not successful'
322
+ end
323
+ return_data
324
+ end
325
+ end
326
+ end
@@ -0,0 +1,3 @@
1
+ module SrFax
2
+ VERSION = '0.5.2'.freeze
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'srfax/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'srfax'
8
+ spec.version = SrFax::VERSION
9
+ spec.authors = ['Jeff Klink', 'Sean Esson', 'Brady Bouchard']
10
+ spec.email = ['techcanuck@gmail.com']
11
+
12
+ spec.summary = 'SR Fax Module provides and easy way to access SR fax online services to send, receive or query faxes'
13
+ spec.description = "This is the 'unofficial' SRFax (http://www.srfax.com) API wrapper for ruby. The API documentation for SRFax can be found at https://www.srfax.com/srf/media/SRFax-REST-API-Documentation.pdf"
14
+ spec.homepage = 'https://github.com/bouchard/srfax'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'minitest'
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'rake', '~> 11.0'
25
+ spec.add_development_dependency 'pry', '~> 0.8'
26
+ spec.add_development_dependency 'yard', '~> 0.8'
27
+ spec.add_dependency 'logger', '~> 1'
28
+ spec.add_dependency 'activesupport', '~> 4.2'
29
+ spec.add_dependency 'rest-client', '~> 2.0'
30
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: srfax
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.2
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Klink
8
+ - Sean Esson
9
+ - Brady Bouchard
10
+ autorequire:
11
+ bindir: exe
12
+ cert_chain: []
13
+ date: 2016-07-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: minitest
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.6'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.6'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '11.0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '11.0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: pry
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '0.8'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '0.8'
71
+ - !ruby/object:Gem::Dependency
72
+ name: yard
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '0.8'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '0.8'
85
+ - !ruby/object:Gem::Dependency
86
+ name: logger
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '1'
92
+ type: :runtime
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '1'
99
+ - !ruby/object:Gem::Dependency
100
+ name: activesupport
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '4.2'
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '4.2'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rest-client
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '2.0'
120
+ type: :runtime
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '2.0'
127
+ description: This is the 'unofficial' SRFax (http://www.srfax.com) API wrapper for
128
+ ruby. The API documentation for SRFax can be found at https://www.srfax.com/srf/media/SRFax-REST-API-Documentation.pdf
129
+ email:
130
+ - techcanuck@gmail.com
131
+ executables: []
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - ".gitignore"
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/console
141
+ - bin/setup
142
+ - lib/srfax.rb
143
+ - lib/srfax/version.rb
144
+ - srfax.gemspec
145
+ homepage: https://github.com/bouchard/srfax
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.5.1
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: SR Fax Module provides and easy way to access SR fax online services to send,
169
+ receive or query faxes
170
+ test_files: []
171
+ has_rdoc: