sr_fax 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b08b8fbb2726537e1c481371db271bd81a630689
4
- data.tar.gz: 12939f123b696d6bc753e275cd18cf7821184f78
3
+ metadata.gz: e48956c74b31f3de3cb0045346c13e853f2ff63b
4
+ data.tar.gz: 279682183600050e3feac2d51d6ad1edbd5f6904
5
5
  SHA512:
6
- metadata.gz: b3ba7b257586a528df2983a692ba24fc77cbc115125882fa478c55917ac979674a25c3a220426dceccdabbb638d06f78a9debda3b4fab077d76274f6be5197ec
7
- data.tar.gz: 03a576e0bc5b91855ff6737ae4dc1ac547673863d167d79e29f564a2f15639d4c5fc7cddbd17c7f08301cd8e53ae932a0bf0150d6f1be71d5e75e3b80bfb2f2f
6
+ metadata.gz: e604ffac24efd5b2740e7a0bf18d26abbe208a6cb59fa4f6362bd861fafe1efa3aa4499474a016b8b68e9b6d3cec637e4c1db197d3db22ee034e09fbbbb7230f
7
+ data.tar.gz: 52e0d48ec3caf51f3a07380684ecd25e7373b8099df7f28325f14d389f8b17fa1c81529a177ac5a2bd240fd2059ccfd7b80e521855f08eec2ae06298637801d5
data/README.md CHANGED
@@ -29,6 +29,7 @@ require 'srfax'
29
29
  SrFax.setup do |config|
30
30
  config.defaults[:access_id] = '1234'
31
31
  config.defaults[:access_pwd] = 'password'
32
+ config.connection_defaults[:timeout] = 180
32
33
  end
33
34
 
34
35
  SrFax.view_inbox
@@ -50,12 +51,6 @@ The SrFax module currently supports the following functions
50
51
  - View account usage
51
52
  - Download faxes from the inbox or outbox
52
53
 
53
- Not yet implemented:
54
- - Sending faxes
55
- - Delete pending faxes (to be sent)
56
- - Stop fax
57
- - Multifax status
58
-
59
54
  ## Development
60
55
 
61
56
  After checking out the repo, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -34,6 +34,12 @@ module SrFax
34
34
  sResponseFormat: 'JSON' # XML or JSON
35
35
  }
36
36
 
37
+ mattr_accessor :connection_defaults
38
+ # Default values to use with the RestClient connection
39
+ @@connection_defaults = {
40
+ timeout: 180
41
+ }
42
+
37
43
  mattr_accessor :logger
38
44
  # Logger object for use in standalone modeo or with Rails
39
45
  @@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
@@ -299,9 +305,37 @@ module SrFax
299
305
  # @return [Hash] The hash payload value including a proper status. Will never return nil.
300
306
  def execute(postVariables)
301
307
  logger.debug postVariables.merge(defaults)
302
- res = RestClient.post BASE_URL, postVariables.merge(defaults).to_json, :content_type => :json, :accept => :json
308
+ # redirect where necessary
309
+ res = RestClient::Request.execute(:method => :post, :url => BASE_URL,
310
+ :payload => postVariables.merge(defaults).to_json,
311
+ :timeout => connection_defaults[:timeout], :open_timeout => connection_defaults[:timeout],
312
+ :headers => {:accept => :json}) { |response, request, result, &block|
313
+ if [301, 302, 307].include? response.code
314
+ response.follow_redirection(request, result, &block)
315
+ elsif [200].include? response.code
316
+ # default behaviour for OK requests
317
+ response.return!(request, result, &block)
318
+ else
319
+ # suppress the throw's by RestClient
320
+ response = Oj.dump({"Status"=>"Failure", "Result"=>"#{response}"}, mode: :compat)
321
+ end
322
+ }
323
+
324
+ # res = RestClient.post(BASE_URL, postVariables.merge(defaults).to_json,
325
+ # :content_type => :json, :accept => :json,
326
+ # :timeout => connection_defaults[:timeout], :open_timeout => connection_defaults[:timeout] ){ |response, request, result, &block|
327
+ # if [301, 302, 307].include? response.code
328
+ # response.follow_redirection(request, result, &block)
329
+ # elsif [200].include? response.code
330
+ # # default behaviour
331
+ # response.return!(request, result, &block)
332
+ # else
333
+ # # suppress the throw's by RestClient
334
+ # response = {"Status"=>"Failure", "Result"=>"#{response}"}.to_json
335
+ # end
336
+ # }
303
337
  return_data = nil
304
- return_data = JSON.parse(res) if res
338
+ return_data = !res.nil? ? JSON.parse(res) : nil
305
339
 
306
340
  if return_data.nil? || return_data.fetch("Status", "Failure") != "Success"
307
341
  logger.debug "Execution of SR Fax command not successful"
@@ -1,4 +1,4 @@
1
1
  module SrFax
2
2
  # Version # for SrFax
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "pry", "~> 0.8"
25
25
  spec.add_development_dependency "yard", "~> 0.8"
26
26
  spec.add_dependency 'logger', '~> 1'
27
+ spec.add_dependency 'oj', '~> 2.11'
27
28
  spec.add_dependency 'activesupport', '~> 4.2'
28
29
  spec.add_dependency 'rest-client', '~> 1.7'
29
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sr_fax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Klink
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-05-13 00:00:00.000000000 Z
12
+ date: 2015-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: oj
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '2.11'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '2.11'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: activesupport
86
100
  requirement: !ruby/object:Gem::Requirement